Bug 1498898 - Don't draw container-only widgets, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Thu, 25 Oct 2018 12:54:35 +0000
changeset 491362 0a63507e990c0dbf2fb668880cee8097d4205511
parent 491361 3c935139d3d84dde6579d5302fdd5d06a96d0f74
child 491363 821f982805ab2fbc2e77e0673eedf3d2a163fe45
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjhorak
bugs1498898
milestone65.0a1
Bug 1498898 - Don't draw container-only widgets, r=jhorak 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[];