Bug 1478519 - Introduce a utility method calling some notification method for nsIPresShell. r?karlt draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 27 Jul 2018 14:36:57 +0900
changeset 823380 d854fb147dfd2d43850388fee9d6152d58691b65
parent 823333 8f2f847b2f9dc5643eeb9935d603a3b30686f972
child 823381 fbdd9f989f066809380db5e84db370d162b24fa5
child 823382 ac8578c8716fc56ac739b92bc3f443caf991f333
push id117654
push userhikezoe@mozilla.com
push dateFri, 27 Jul 2018 05:38:59 +0000
reviewerskarlt
bugs1478519
milestone63.0a1
Bug 1478519 - Introduce a utility method calling some notification method for nsIPresShell. r?karlt MozReview-Commit-ID: 1uO3uZeuU4N
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1828,61 +1828,56 @@ nsBaseWidget::NotifyWindowDestroyed()
   nsCOMPtr<nsIXULWindow> window = mWidgetListener->GetXULWindow();
   nsCOMPtr<nsIBaseWindow> xulWindow(do_QueryInterface(window));
   if (xulWindow) {
     xulWindow->Destroy();
   }
 }
 
 void
-nsBaseWidget::NotifySizeMoveDone()
-{
-  if (!mWidgetListener || mWidgetListener->GetXULWindow())
-    return;
-
-  nsIPresShell* presShell = mWidgetListener->GetPresShell();
-  if (presShell) {
-    presShell->WindowSizeMoveDone();
-  }
-}
-
-void
 nsBaseWidget::NotifyWindowMoved(int32_t aX, int32_t aY)
 {
   if (mWidgetListener) {
     mWidgetListener->WindowMoved(this, aX, aY);
   }
 
   if (mIMEHasFocus && IMENotificationRequestsRef().WantPositionChanged()) {
     NotifyIME(IMENotification(IMEMessage::NOTIFY_IME_OF_POSITION_CHANGE));
   }
 }
 
 void
-nsBaseWidget::NotifySysColorChanged()
+nsBaseWidget::NotifyPresShell(NotificationFunc aNotificationFunc)
 {
-  if (!mWidgetListener || mWidgetListener->GetXULWindow())
+  if (!mWidgetListener || mWidgetListener->GetXULWindow()) {
     return;
+  }
 
   nsIPresShell* presShell = mWidgetListener->GetPresShell();
   if (presShell) {
-    presShell->SysColorChanged();
+    (presShell->*aNotificationFunc)();
   }
 }
 
 void
+nsBaseWidget::NotifySizeMoveDone()
+{
+  NotifyPresShell(&nsIPresShell::WindowSizeMoveDone);
+}
+
+void
+nsBaseWidget::NotifySysColorChanged()
+{
+  NotifyPresShell(&nsIPresShell::SysColorChanged);
+}
+
+void
 nsBaseWidget::NotifyThemeChanged()
 {
-  if (!mWidgetListener || mWidgetListener->GetXULWindow())
-    return;
-
-  nsIPresShell* presShell = mWidgetListener->GetPresShell();
-  if (presShell) {
-    presShell->ThemeChanged();
-  }
+  NotifyPresShell(&nsIPresShell::ThemeChanged);
 }
 
 void
 nsBaseWidget::NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
                                    UIStateChangeType aShowFocusRings)
 {
   if (nsIDocument* doc = GetDocument()) {
     nsPIDOMWindowOuter* win = doc->GetWindow();
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -314,16 +314,19 @@ public:
                               const nsTArray<ScrollableLayerGuid>& aTargets) const override;
 
   void UpdateZoomConstraints(const uint32_t& aPresShellId,
                              const FrameMetrics::ViewID& aViewId,
                              const mozilla::Maybe<ZoomConstraints>& aConstraints) override;
 
   bool AsyncPanZoomEnabled() const override;
 
+  typedef void (nsIPresShell::*NotificationFunc)(void);
+  void NotifyPresShell(NotificationFunc aNotificationFunc);
+
   void NotifyWindowDestroyed();
   void NotifySizeMoveDone();
   void NotifyWindowMoved(int32_t aX, int32_t aY);
 
   // Register plugin windows for remote updates from the compositor
   virtual void RegisterPluginWindowForRemoteUpdates() override;
   virtual void UnregisterPluginWindowForRemoteUpdates() override;