Title: [164977] trunk/Source/WebCore
Revision
164977
Author
calva...@igalia.com
Date
2014-03-03 00:36:56 -0800 (Mon, 03 Mar 2014)

Log Message

[GTK] Multimedia controls captions icon needs its own metaphor
https://bugs.webkit.org/show_bug.cgi?id=129091

Reviewed by Martin Robinson.

As we got the new icon created, we used it with a fallback to the
old icon to keep run-time compatibility.

No new tests, current ones suffice.

* platform/gtk/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::paintMediaToggleClosedCaptionsButton):
Replicated RenderThemeGtk::paintMediaButton to check for the
necessary icon first and do the fallback to the old and stock
icons.
* platform/gtk/RenderThemeGtk2.cpp:
(WebCore::getStockIconForWidgetType): Added ASSERT for non-empty
icon name.
(WebCore::getStockSymbolicIconForWidgetType): Check for non empty
icon name before calling getStockIconForWidgetType. Fixed coding
style.
* platform/gtk/RenderThemeGtk3.cpp:
(WebCore::getStockIconForWidgetType): Added ASSERT for non-empty
icon name.
(WebCore::getStockSymbolicIconForWidgetType): Check for non empty
icon name before calling getStockIconForWidgetType. Fixed coding
style.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164976 => 164977)


--- trunk/Source/WebCore/ChangeLog	2014-03-03 08:24:55 UTC (rev 164976)
+++ trunk/Source/WebCore/ChangeLog	2014-03-03 08:36:56 UTC (rev 164977)
@@ -1,3 +1,33 @@
+2014-03-03  Xabier Rodriguez Calvar  <calva...@igalia.com>
+
+        [GTK] Multimedia controls captions icon needs its own metaphor
+        https://bugs.webkit.org/show_bug.cgi?id=129091
+
+        Reviewed by Martin Robinson.
+
+        As we got the new icon created, we used it with a fallback to the
+        old icon to keep run-time compatibility.
+
+        No new tests, current ones suffice.
+
+        * platform/gtk/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::paintMediaToggleClosedCaptionsButton):
+        Replicated RenderThemeGtk::paintMediaButton to check for the
+        necessary icon first and do the fallback to the old and stock
+        icons.
+        * platform/gtk/RenderThemeGtk2.cpp:
+        (WebCore::getStockIconForWidgetType): Added ASSERT for non-empty
+        icon name.
+        (WebCore::getStockSymbolicIconForWidgetType): Check for non empty
+        icon name before calling getStockIconForWidgetType. Fixed coding
+        style.
+        * platform/gtk/RenderThemeGtk3.cpp:
+        (WebCore::getStockIconForWidgetType): Added ASSERT for non-empty
+        icon name.
+        (WebCore::getStockSymbolicIconForWidgetType): Check for non empty
+        icon name before calling getStockIconForWidgetType. Fixed coding
+        style.
+
 2014-03-02  Benjamin Poulain  <benja...@webkit.org>
 
         Add a fallback path for compiling the remaining attribute checkers

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp (164976 => 164977)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2014-03-03 08:24:55 UTC (rev 164976)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2014-03-03 08:36:56 UTC (rev 164977)
@@ -62,7 +62,7 @@
 // This would be a static method, except that forward declaring GType is tricky, since its
 // definition depends on including glib.h, negating the benefit of using a forward declaration.
 extern GRefPtr<GdkPixbuf> getStockIconForWidgetType(GType, const char* iconName, gint direction, gint state, gint iconSize);
-extern GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char *fallbackStockIconName, gint direction, gint state, gint iconSize);
+extern GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char* fallbackStockIconName, gint direction, gint state, gint iconSize);
 
 #if ENABLE(VIDEO)
 static HTMLMediaElement* getMediaElementFromRenderObject(RenderObject* o)
@@ -566,7 +566,15 @@
 #if ENABLE(VIDEO_TRACK)
 bool RenderThemeGtk::paintMediaToggleClosedCaptionsButton(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    return paintMediaButton(renderObject, paintInfo.context, rect, "user-invisible-symbolic", GTK_STOCK_JUSTIFY_FILL);
+    IntRect iconRect(rect.x() + (rect.width() - m_mediaIconSize) / 2, rect.y() + (rect.height() - m_mediaIconSize) / 2,
+        m_mediaIconSize, m_mediaIconSize);
+    GRefPtr<GdkPixbuf> icon = getStockSymbolicIconForWidgetType(GTK_TYPE_CONTAINER, "media-view-subtitles-symbolic", nullptr,
+        gtkTextDirection(renderObject->style().direction()), gtkIconState(this, renderObject), iconRect.width());
+    if (!icon)
+        icon = getStockSymbolicIconForWidgetType(GTK_TYPE_CONTAINER, "user-invisible-symbolic", GTK_STOCK_JUSTIFY_FILL,
+            gtkTextDirection(renderObject->style().direction()), gtkIconState(this, renderObject), iconRect.width());
+    paintGdkPixbuf(paintInfo.context, icon.get(), iconRect);
+    return true;
 }
 #endif
 

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp (164976 => 164977)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp	2014-03-03 08:24:55 UTC (rev 164976)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp	2014-03-03 08:36:56 UTC (rev 164977)
@@ -654,6 +654,7 @@
 GRefPtr<GdkPixbuf> getStockIconForWidgetType(GType widgetType, const char* iconName, gint direction, gint state, gint iconSize)
 {
     ASSERT(widgetType == GTK_TYPE_CONTAINER || widgetType == GTK_TYPE_ENTRY);
+    ASSERT(iconName);
 
     RenderThemeGtk* theme = static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get());
     GtkWidget* widget = widgetType == GTK_TYPE_CONTAINER ? GTK_WIDGET(theme->gtkContainer()) : theme->gtkEntry();
@@ -666,8 +667,11 @@
                                               static_cast<GtkIconSize>(iconSize), 0, 0));
 }
 
-GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char *fallbackStockIconName, gint direction, gint state, gint iconSize)
+GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char* fallbackStockIconName, gint direction, gint state, gint iconSize)
 {
+    if (!fallbackStockIconName)
+        return nullptr;
+
     return getStockIconForWidgetType(widgetType, fallbackStockIconName, direction, state, iconSize);
 }
 

Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp (164976 => 164977)


--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp	2014-03-03 08:24:55 UTC (rev 164976)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp	2014-03-03 08:36:56 UTC (rev 164977)
@@ -878,6 +878,8 @@
 
 GRefPtr<GdkPixbuf> getStockIconForWidgetType(GType widgetType, const char* iconName, gint direction, gint state, gint iconSize)
 {
+    ASSERT(iconName);
+
     GtkStyleContext* context = getStyleContext(widgetType);
     GtkIconSet* iconSet = gtk_style_context_lookup_icon_set(context, iconName);
 
@@ -898,7 +900,7 @@
     return adoptGRef(icon);
 }
 
-GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char *fallbackStockIconName, gint direction, gint state, gint iconSize)
+GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char* fallbackStockIconName, gint direction, gint state, gint iconSize)
 {
     GtkStyleContext* context = getStyleContext(widgetType);
 
@@ -922,8 +924,11 @@
 
     gtk_style_context_restore(context);
 
-    if (!icon)
+    if (!icon) {
+        if (!fallbackStockIconName)
+            return nullptr;
         return getStockIconForWidgetType(widgetType, fallbackStockIconName, direction, state, iconSize);
+    }
 
     return adoptGRef(icon);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to