Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ash / wm / custom_frame_view_ash.cc
index 50e9e23..8df509c 100644 (file)
@@ -105,7 +105,7 @@ class CustomFrameViewAshWindowStateDelegate
     window_state_ = NULL;
   }
   // Overridden from ash::wm::WindowStateObserver:
-  virtual void OnWindowShowTypeChanged(
+  virtual void OnPostWindowShowTypeChange(
       ash::wm::WindowState* window_state,
       ash::wm::WindowShowType old_type) OVERRIDE {
     if (!window_state->IsFullscreen() &&
@@ -357,6 +357,10 @@ CustomFrameViewAsh::OverlayView::~OverlayView() {
 }
 
 void CustomFrameViewAsh::OverlayView::Layout() {
+  // Layout |header_view_| because layout affects the result of
+  // GetPreferredOnScreenHeight().
+  header_view_->Layout();
+
   int onscreen_height = header_view_->GetPreferredOnScreenHeight();
   if (onscreen_height == 0) {
     header_view_->SetVisible(false);
@@ -394,7 +398,7 @@ CustomFrameViewAsh::CustomFrameViewAsh(views::Widget* frame)
   if (!window_state->HasDelegate()) {
     window_state->SetDelegate(scoped_ptr<wm::WindowStateDelegate>(
         new CustomFrameViewAshWindowStateDelegate(
-            window_state, this)).Pass());
+            window_state, this)));
   }
 }
 
@@ -468,11 +472,16 @@ gfx::Size CustomFrameViewAsh::GetMaximumSize() {
 }
 
 void CustomFrameViewAsh::SchedulePaintInRect(const gfx::Rect& r) {
-  // The HeaderView is not a child of CustomFrameViewAsh. Redirect the paint to
-  // HeaderView instead.
-  gfx::RectF to_paint(r);
-  views::View::ConvertRectToTarget(this, header_view_, &to_paint);
-  header_view_->SchedulePaintInRect(gfx::ToEnclosingRect(to_paint));
+  // We may end up here before |header_view_| has been added to the Widget.
+  if (header_view_->GetWidget()) {
+    // The HeaderView is not a child of CustomFrameViewAsh. Redirect the paint
+    // to HeaderView instead.
+    gfx::RectF to_paint(r);
+    views::View::ConvertRectToTarget(this, header_view_, &to_paint);
+    header_view_->SchedulePaintInRect(gfx::ToEnclosingRect(to_paint));
+  } else {
+    views::NonClientFrameView::SchedulePaintInRect(r);
+  }
 }
 
 bool CustomFrameViewAsh::HitTestRect(const gfx::Rect& rect) const {