Bug 841308 - Make WillPaintWindow be called for cocoa popups. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 26 Feb 2013 10:18:48 +1300
changeset 122928 919c98296dbf5a37101be779c984f451ebbb63db
parent 122927 71a93fff73115a2b6ce16286f3c99e29b7d46739
child 122929 c44f37baa96470725fd443921cec0a06d923eabc
push id23565
push usermwoodrow@mozilla.com
push dateMon, 25 Feb 2013 21:18:59 +0000
treeherdermozilla-inbound@c44f37baa964 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs841308
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 841308 - Make WillPaintWindow be called for cocoa popups. r=roc
view/src/nsView.cpp
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -305,16 +305,18 @@ void nsView::SetDimensions(const nsRect&
 
 void nsView::NotifyEffectiveVisibilityChanged(bool aEffectivelyVisible)
 {
   if (!aEffectivelyVisible)
   {
     DropMouseGrabbing();
   }
 
+  SetForcedRepaint(true);
+
   if (nullptr != mWindow)
   {
     if (aEffectivelyVisible)
     {
       DoResetWidgetBounds(false, true);
       mWindow->Show(true);
     }
     else
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -480,16 +480,17 @@ public:
 
   virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint)
   { return SynthesizeNativeMouseEvent(aPoint, NSMouseMoved, 0); }
 
   // Mac specific methods
   
   virtual bool      DispatchWindowEvent(nsGUIEvent& event);
 
+  void WillPaintWindow();
   bool PaintWindow(nsIntRegion aRegion, bool aIsAlternate);
 
 #ifdef ACCESSIBILITY
   already_AddRefed<mozilla::a11y::Accessible> GetDocumentAccessible();
 #endif
 
   virtual void CreateCompositor();
   virtual gfxASurface* GetThebesSurface();
@@ -553,16 +554,18 @@ protected:
   virtual already_AddRefed<nsIWidget>
   AllocateChildPopupWidget()
   {
     static NS_DEFINE_IID(kCPopUpCID, NS_POPUP_CID);
     nsCOMPtr<nsIWidget> widget = do_CreateInstance(kCPopUpCID);
     return widget.forget();
   }
 
+  nsIWidget* GetWidgetForListenerEvents();
+
 protected:
 
   NSView<mozView>*      mView;      // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG]
   nsRefPtr<mozilla::widget::TextInputHandler> mTextInputHandler;
   InputContext          mInputContext;
 
   NSView<mozView>*      mParentView;
   nsIWidget*            mParentWidget;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1489,29 +1489,45 @@ NS_IMETHODIMP nsChildView::DispatchEvent
 
 bool nsChildView::DispatchWindowEvent(nsGUIEvent &event)
 {
   nsEventStatus status;
   DispatchEvent(&event, status);
   return ConvertStatus(status);
 }
 
-bool nsChildView::PaintWindow(nsIntRegion aRegion, bool aIsAlternate)
-{
-  nsCOMPtr<nsIWidget> widget = this;
-
+nsIWidget*
+nsChildView::GetWidgetForListenerEvents()
+{
   // If there is no listener, use the parent popup's listener if that exists.
   if (!mWidgetListener && mParentWidget) {
     nsWindowType type;
     mParentWidget->GetWindowType(type);
     if (type == eWindowType_popup) {
-      widget = mParentWidget;
+      return mParentWidget;
     }
   }
 
+  return this;
+}
+
+void nsChildView::WillPaintWindow()
+{
+  nsCOMPtr<nsIWidget> widget = GetWidgetForListenerEvents();
+
+  nsIWidgetListener* listener = widget->GetWidgetListener();
+  if (listener) {
+    listener->WillPaintWindow(widget);
+  }
+}
+
+bool nsChildView::PaintWindow(nsIntRegion aRegion, bool aIsAlternate)
+{
+  nsCOMPtr<nsIWidget> widget = GetWidgetForListenerEvents();
+
   nsIWidgetListener* listener = widget->GetWidgetListener();
   if (!listener)
     return false;
 
   bool returnValue = false;
   bool oldDispatchPaint = mIsDispatchPaint;
   mIsDispatchPaint = true;
   uint32_t flags = 0;
@@ -2688,20 +2704,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
       }
       NS_ADDREF(mGeckoChild);
       [widgetArray addObject:[NSNumber numberWithUnsignedInteger:(NSUInteger)mGeckoChild]];
       [self performSelector:@selector(releaseWidgets:)
                  withObject:widgetArray
                  afterDelay:0];
     }
 
-    nsIWidgetListener* listener = mGeckoChild->GetWidgetListener();
-    if (listener) {
-      listener->WillPaintWindow(mGeckoChild);
-    }
+    mGeckoChild->WillPaintWindow();
   }
   [super viewWillDraw];
 }
 
 // Allows us to turn off setting up the clip region
 // before each drawRect. We already clip within gecko.
 - (BOOL)wantsDefaultClipping
 {