Bug 1498898 - Don't draw container-only widgets. r=jhorak, a=RyanVM
authorMartin Stransky <stransky@redhat.com>
Thu, 25 Oct 2018 12:54:35 +0000
changeset 498220 2bb12341b0fd
parent 498219 b5f86619d085
child 498221 9f3e14f67500
push id10076
push userryanvm@gmail.com
push dateWed, 31 Oct 2018 15:37:36 +0000
treeherdermozilla-beta@f9da620994ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak, RyanVM
bugs1498898
milestone64.0
Bug 1498898 - Don't draw container-only widgets. r=jhorak, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D9379
widget/gtk/nsNativeThemeGTK.cpp
widget/gtk/nsNativeThemeGTK.h
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1137,30 +1137,45 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
   gint scale = GetMonitorScaleFactor(aFrame);
   aExtra->top *= scale;
   aExtra->right *= scale;
   aExtra->bottom *= scale;
   aExtra->left *= scale;
   return true;
 }
 
+bool
+nsNativeThemeGTK::IsWidgetVisible(WidgetType aWidgetType)
+{
+  switch (aWidgetType) {
+  case StyleAppearance::MozWindowButtonBox:
+    return false;
+  default:
+    break;
+  }
+  return true;
+}
+
 NS_IMETHODIMP
 nsNativeThemeGTK::DrawWidgetBackground(gfxContext* aContext,
                                        nsIFrame* aFrame,
                                        StyleAppearance aWidgetType,
                                        const nsRect& aRect,
                                        const nsRect& aDirtyRect)
 {
   GtkWidgetState state;
   WidgetNodeType gtkWidgetType;
   GtkTextDirection direction = GetTextDirection(aFrame);
   gint flags;
-  if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state,
-                            &flags))
+
+  if (!IsWidgetVisible(aWidgetType) ||
+      !GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state,
+                            &flags)) {
     return NS_OK;
+  }
 
   gfxContext* ctx = aContext;
   nsPresContext *presContext = aFrame->PresContext();
 
   gfxRect rect = presContext->AppUnitsToGfxUnits(aRect);
   gfxRect dirtyRect = presContext->AppUnitsToGfxUnits(aDirtyRect);
   gint scaleFactor = GetMonitorScaleFactor(aFrame);
 
--- a/widget/gtk/nsNativeThemeGTK.h
+++ b/widget/gtk/nsNativeThemeGTK.h
@@ -87,16 +87,17 @@ protected:
 private:
   GtkTextDirection GetTextDirection(nsIFrame* aFrame);
   gint GetTabMarginPixels(nsIFrame* aFrame);
   bool GetGtkWidgetAndState(WidgetType aWidgetType, nsIFrame* aFrame,
                             WidgetNodeType& aGtkWidgetType,
                             GtkWidgetState* aState, gint* aWidgetFlags);
   bool GetExtraSizeForWidget(nsIFrame* aFrame, WidgetType aWidgetType,
                                nsIntMargin* aExtra);
+  bool IsWidgetVisible(WidgetType aWidgetType);
 
   void RefreshWidgetWindow(nsIFrame* aFrame);
   WidgetNodeType NativeThemeToGtkTheme(WidgetType aWidgetType, nsIFrame* aFrame);
 
   uint8_t mDisabledWidgetTypes[(static_cast<size_t>(mozilla::StyleAppearance::Count) + 7) / 8];
   uint8_t mSafeWidgetStates[static_cast<size_t>(mozilla::StyleAppearance::Count) * 4]; // 32 bits per widget
   static const char* sDisabledEngines[];