Bug 1266914 - Use the border subnode for GtkFrame to fetch border colours. r=karlt draft
authorAndrew Comminos <andrew@comminos.com>
Mon, 25 Jul 2016 10:32:12 -0400
changeset 393348 31a41c2c5df64a04bed5425b42c679ca4cef8739
parent 393304 fef429fba4c64c5b9c0c823a6ab713edbbcd4220
child 526570 0907cabd0a61317a28110bb3ac0d2d750679ad6c
push id24296
push userbmo:andrew@comminos.com
push dateWed, 27 Jul 2016 19:20:36 +0000
reviewerskarlt
bugs1266914
milestone50.0a1
Bug 1266914 - Use the border subnode for GtkFrame to fetch border colours. r=karlt MozReview-Commit-ID: 4muOcOStA7A
widget/gtk/WidgetStyleCache.cpp
widget/gtk/gtkdrawing.h
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/WidgetStyleCache.cpp
+++ b/widget/gtk/WidgetStyleCache.cpp
@@ -442,16 +442,18 @@ GetCssNodeStyleInternal(WidgetNodeType a
     case MOZ_GTK_SCROLLED_WINDOW:
       // TODO - create from CSS node
       return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW,
                                      GTK_STYLE_CLASS_FRAME);
     case MOZ_GTK_TEXT_VIEW:
       // TODO - create from CSS node
       return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW,
                                      GTK_STYLE_CLASS_VIEW);
+    case MOZ_GTK_FRAME_BORDER:
+      return CreateChildCSSNode("border", MOZ_GTK_FRAME);
     default:
       // TODO - create style from style path
       GtkWidget* widget = GetWidget(aNodeType);
       return gtk_widget_get_style_context(widget);
   }
 
   MOZ_ASSERT(style, "missing style context for node type");
   sStyleStorage[aNodeType] = style;
@@ -508,16 +510,18 @@ GetWidgetStyleInternal(WidgetNodeType aN
       return GetWidgetStyleWithClass(MOZ_GTK_SPINBUTTON,
                                      GTK_STYLE_CLASS_ENTRY);
     case MOZ_GTK_SCROLLED_WINDOW:
       return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW,
                                      GTK_STYLE_CLASS_FRAME);
     case MOZ_GTK_TEXT_VIEW:
       return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW,
                                      GTK_STYLE_CLASS_VIEW);
+    case MOZ_GTK_FRAME_BORDER:
+      return GetWidgetStyleInternal(MOZ_GTK_FRAME);
     default:
       GtkWidget* widget = GetWidget(aNodeType);
       MOZ_ASSERT(widget);
       return gtk_widget_get_style_context(widget);
   }
 }
 
 void
--- a/widget/gtk/gtkdrawing.h
+++ b/widget/gtk/gtkdrawing.h
@@ -154,16 +154,18 @@ typedef enum {
   /* Paints the background of a GtkHandleBox. */
   MOZ_GTK_TOOLBAR,
   /* Paints a toolbar separator */
   MOZ_GTK_TOOLBAR_SEPARATOR,
   /* Paints a GtkToolTip */
   MOZ_GTK_TOOLTIP,
   /* Paints a GtkFrame (e.g. a status bar panel). */
   MOZ_GTK_FRAME,
+  /* Paints the border of a GtkFrame */
+  MOZ_GTK_FRAME_BORDER,
   /* Paints a resize grip for a GtkWindow */
   MOZ_GTK_RESIZER,
   /* Paints a GtkProgressBar. */
   MOZ_GTK_PROGRESSBAR,
   /* Paints a trough (track) of a GtkProgressBar */
   MOZ_GTK_PROGRESS_TROUGH,
   /* Paints a progress chunk of a GtkProgressBar. */
   MOZ_GTK_PROGRESS_CHUNK,
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1344,22 +1344,21 @@ nsLookAndFeel::Init()
 
     // Get odd row background color
     gtk_style_context_save(style);
     gtk_style_context_add_region(style, GTK_STYLE_REGION_ROW, GTK_REGION_ODD);
     gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
     sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color);
     gtk_style_context_restore(style);
 
-    GtkWidget *frame = gtk_frame_new(nullptr);
-    gtk_container_add(GTK_CONTAINER(parent), frame);
-    style = gtk_widget_get_style_context(frame);
+    gtk_widget_path_free(path);
+
+    style = ClaimStyleContext(MOZ_GTK_FRAME_BORDER);
     GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder);
-
-    gtk_widget_path_free(path);
+    ReleaseStyleContext(style);
 
     // GtkInfoBar
     // TODO - Use WidgetCache for it?
     GtkWidget* infoBar = gtk_info_bar_new();
     GtkWidget* infoBarContent = gtk_info_bar_get_content_area(GTK_INFO_BAR(infoBar));
     GtkWidget* infoBarLabel = gtk_label_new(nullptr);
     gtk_container_add(GTK_CONTAINER(parent), infoBar);
     gtk_container_add(GTK_CONTAINER(infoBarContent), infoBarLabel);