Commit 161fa414 authored by sky's avatar sky Committed by Commit bot

Fixes bug where client area would not get set correctly

The client area is updated when the bounds change, further to
correctly calculate the client area the NonClientView has to have been
created. Prior to this fix if the window was sized during
InitNativeWidget() and never changed after that, then the client area
was not correctly set because during InitNativeWidget() the
NonClientView has not been created.

The fix is to add a NativeWidgetPrivate function that Widget calls
after it has created the NonClientView.

BUG=none
TEST=none
R=erg@chromium.org

Review URL: https://codereview.chromium.org/1565243002

Cr-Commit-Position: refs/heads/master@{#368141}
parent c9a27cb8
......@@ -309,6 +309,14 @@ void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) {
native_widget_delegate_->OnNativeWidgetCreated(false);
}
void NativeWidgetMus::OnWidgetInitDone() {
// The client area is calculated from the NonClientView. During
// InitNativeWidget() the NonClientView has not been created. When this
// function is called the NonClientView has been created, so that we can
// correctly calculate the client area and push it to the mus::Window.
UpdateClientArea();
}
bool NativeWidgetMus::ShouldUseNativeFrame() const {
// NOTIMPLEMENTED();
return false;
......
......@@ -84,6 +84,7 @@ class VIEWS_MUS_EXPORT NativeWidgetMus : public internal::NativeWidgetPrivate,
// internal::NativeWidgetPrivate:
NonClientFrameView* CreateNonClientFrameView() override;
void InitNativeWidget(const Widget::InitParams& params) override;
void OnWidgetInitDone() override;
bool ShouldUseNativeFrame() const override;
bool ShouldWindowContentsBeTransparent() const override;
void FrameTypeChanged() override;
......
......@@ -182,6 +182,8 @@ void NativeWidgetAndroid::InitNativeWidget(const Widget::InitParams& params) {
// the necessary parts that exists in desktop_native_widget_aura.
}
void NativeWidgetAndroid::OnWidgetInitDone() {}
NonClientFrameView* NativeWidgetAndroid::CreateNonClientFrameView() {
NOTIMPLEMENTED();
return nullptr;
......
......@@ -59,6 +59,7 @@ class VIEWS_EXPORT NativeWidgetAndroid
// Overridden from internal::NativeWidgetPrivate:
void InitNativeWidget(const Widget::InitParams& params) override;
void OnWidgetInitDone() override;
NonClientFrameView* CreateNonClientFrameView() override;
bool ShouldUseNativeFrame() const override;
bool ShouldWindowContentsBeTransparent() const override;
......
......@@ -546,6 +546,8 @@ void DesktopNativeWidgetAura::InitNativeWidget(
GetWidget()->GetRootView()));
}
void DesktopNativeWidgetAura::OnWidgetInitDone() {}
NonClientFrameView* DesktopNativeWidgetAura::CreateNonClientFrameView() {
return ShouldUseNativeFrame() ? new NativeFrameView(GetWidget()) : NULL;
}
......
......@@ -91,6 +91,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
protected:
// Overridden from internal::NativeWidgetPrivate:
void InitNativeWidget(const Widget::InitParams& params) override;
void OnWidgetInitDone() override;
NonClientFrameView* CreateNonClientFrameView() override;
bool ShouldUseNativeFrame() const override;
bool ShouldWindowContentsBeTransparent() const override;
......
......@@ -181,6 +181,8 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
GetWidget()->GetRootView()));
}
void NativeWidgetAura::OnWidgetInitDone() {}
NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() {
return NULL;
}
......
......@@ -50,6 +50,7 @@ class VIEWS_EXPORT NativeWidgetAura
// Overridden from internal::NativeWidgetPrivate:
void InitNativeWidget(const Widget::InitParams& params) override;
void OnWidgetInitDone() override;
NonClientFrameView* CreateNonClientFrameView() override;
bool ShouldUseNativeFrame() const override;
bool ShouldWindowContentsBeTransparent() const override;
......
......@@ -49,6 +49,7 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
// internal::NativeWidgetPrivate:
void InitNativeWidget(const Widget::InitParams& params) override;
void OnWidgetInitDone() override;
NonClientFrameView* CreateNonClientFrameView() override;
bool ShouldUseNativeFrame() const override;
bool ShouldWindowContentsBeTransparent() const override;
......
......@@ -139,6 +139,8 @@ void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) {
bridge_->CreateLayer(params.layer_type, translucent);
}
void NativeWidgetMac::OnWidgetInitDone() {}
NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() {
return new NativeFrameView(GetWidget());
}
......
......@@ -74,6 +74,10 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
// Initializes the NativeWidget.
virtual void InitNativeWidget(const Widget::InitParams& params) = 0;
// Called at the end of Widget::Init(), after Widget has completed
// initialization.
virtual void OnWidgetInitDone() = 0;
// Returns a NonClientFrameView for the widget's NonClientView, or NULL if
// the NativeWidget wants no special NonClientFrameView.
virtual NonClientFrameView* CreateNonClientFrameView() = 0;
......
......@@ -397,6 +397,7 @@ void Widget::Init(const InitParams& in_params) {
// the correct NativeTheme (on Linux). See http://crbug.com/384492
observer_manager_.Add(GetNativeTheme());
native_widget_initialized_ = true;
native_widget_->OnWidgetInitDone();
}
// Unconverted methods (see header) --------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment