win: Implement setContentSize API.
This commit is contained in:
parent
0b202a2df1
commit
8ae66cab9d
2 changed files with 24 additions and 14 deletions
|
@ -203,6 +203,7 @@ NativeWindowWin::NativeWindowWin(content::WebContents* web_contents,
|
|||
: NativeWindow(web_contents, options),
|
||||
window_(new views::Widget),
|
||||
web_view_(new views::WebView(NULL)),
|
||||
use_content_size_(false),
|
||||
resizable_(true) {
|
||||
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
||||
params.delegate = this;
|
||||
|
@ -216,18 +217,12 @@ NativeWindowWin::NativeWindowWin(content::WebContents* web_contents,
|
|||
options->GetInteger(switches::kWidth, &width);
|
||||
options->GetInteger(switches::kHeight, &height);
|
||||
|
||||
bool use_content_size = false;
|
||||
options->GetBoolean(switches::kUseContentSize, &use_content_size);
|
||||
if (has_frame_ && use_content_size) {
|
||||
gfx::Size window = window_->GetWindowBoundsInScreen().size();
|
||||
gfx::Size client = window_->GetClientAreaBoundsInScreen().size();
|
||||
width += window.width() - client.width();
|
||||
height += window.height() - client.height();
|
||||
}
|
||||
|
||||
gfx::Size size(width, height);
|
||||
window_->CenterWindow(size);
|
||||
options->GetBoolean(switches::kUseContentSize, &use_content_size_);
|
||||
if (has_frame_ && use_content_size_)
|
||||
ClientAreaSizeToWindowSize(&size);
|
||||
|
||||
window_->CenterWindow(size);
|
||||
window_->UpdateWindowIcon();
|
||||
|
||||
web_view_->SetWebContents(web_contents);
|
||||
|
@ -305,7 +300,9 @@ gfx::Size NativeWindowWin::GetSize() {
|
|||
}
|
||||
|
||||
void NativeWindowWin::SetContentSize(const gfx::Size& size) {
|
||||
// FIXME
|
||||
gfx::Size resized(size);
|
||||
ClientAreaSizeToWindowSize(&resized);
|
||||
SetSize(resized);
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowWin::GetContentSize() {
|
||||
|
@ -393,10 +390,12 @@ void NativeWindowWin::SetMenu(ui::MenuModel* menu_model) {
|
|||
RegisterAccelerators();
|
||||
|
||||
// Resize the window so SetMenu won't change client area size.
|
||||
if (use_content_size_) {
|
||||
gfx::Size size = GetSize();
|
||||
size.set_height(size.height() + GetSystemMetrics(SM_CYMENU));
|
||||
SetSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindowWin::UpdateDraggableRegions(
|
||||
const std::vector<DraggableRegion>& regions) {
|
||||
|
@ -514,6 +513,13 @@ views::NonClientFrameView* NativeWindowWin::CreateNonClientFrameView(
|
|||
return new NativeWindowFramelessView(widget, this);
|
||||
}
|
||||
|
||||
void NativeWindowWin::ClientAreaSizeToWindowSize(gfx::Size* size) {
|
||||
gfx::Size window = window_->GetWindowBoundsInScreen().size();
|
||||
gfx::Size client = window_->GetClientAreaBoundsInScreen().size();
|
||||
size->set_width(size->width() + window.width() - client.width());
|
||||
size->set_height(size->height() + window.height() - client.height());
|
||||
}
|
||||
|
||||
void NativeWindowWin::OnViewWasResized() {
|
||||
// Set the window shape of the RWHV.
|
||||
gfx::Size sz = web_view_->size();
|
||||
|
|
|
@ -115,6 +115,8 @@ class NativeWindowWin : public NativeWindow,
|
|||
typedef struct { int position; ui::MenuModel* model; } MenuItem;
|
||||
typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;
|
||||
|
||||
void ClientAreaSizeToWindowSize(gfx::Size* size);
|
||||
|
||||
void OnViewWasResized();
|
||||
|
||||
// Register accelerators supported by the menu model.
|
||||
|
@ -131,6 +133,8 @@ class NativeWindowWin : public NativeWindow,
|
|||
|
||||
scoped_ptr<SkRegion> draggable_region_;
|
||||
|
||||
bool use_content_size_;
|
||||
|
||||
bool resizable_;
|
||||
string16 title_;
|
||||
gfx::Size minimum_size_;
|
||||
|
|
Loading…
Reference in a new issue