Bug 1478519 - Introduce a utility method calling some notification method for nsIPresShell. r?karlt
MozReview-Commit-ID: 1uO3uZeuU4N
--- 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;