<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[173109] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/173109">173109</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-08-29 00:39:13 -0700 (Fri, 29 Aug 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Merge RenderThemeGtk3.cpp into RenderThemeGtk.cpp and ScrollbarThemeGtk3.cpp intoScrollbarThemeGtk.cpp
https://bugs.webkit.org/show_bug.cgi?id=136336
Reviewed by Philippe Normand.
There's no reason to have two files now that there's no GTK+2
support. Also fix coding style issues and compile warnings.
* PlatformGTK.cmake:
* platform/gtk/RenderThemeGtk.cpp:
* platform/gtk/RenderThemeGtk.h:
* platform/gtk/RenderThemeGtk3.cpp: Removed.
* platform/gtk/ScrollbarThemeGtk.cpp:
* platform/gtk/ScrollbarThemeGtk3.cpp: Removed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkRenderThemeGtkcpp">trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkRenderThemeGtkh">trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkScrollbarThemeGtkcpp">trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgtkRenderThemeGtk3cpp">trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkScrollbarThemeGtk3cpp">trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173108 => 173109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-08-29 03:56:17 UTC (rev 173108)
+++ trunk/Source/WebCore/ChangeLog        2014-08-29 07:39:13 UTC (rev 173109)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-08-28 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Merge RenderThemeGtk3.cpp into RenderThemeGtk.cpp and ScrollbarThemeGtk3.cpp intoScrollbarThemeGtk.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=136336
+
+ Reviewed by Philippe Normand.
+
+ There's no reason to have two files now that there's no GTK+2
+ support. Also fix coding style issues and compile warnings.
+
+ * PlatformGTK.cmake:
+ * platform/gtk/RenderThemeGtk.cpp:
+ * platform/gtk/RenderThemeGtk.h:
+ * platform/gtk/RenderThemeGtk3.cpp: Removed.
+ * platform/gtk/ScrollbarThemeGtk.cpp:
+ * platform/gtk/ScrollbarThemeGtk3.cpp: Removed.
+
</ins><span class="cx"> 2014-08-28 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> DebuggerCallFrame::scope() should return a DebuggerScope.
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (173108 => 173109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2014-08-29 03:56:17 UTC (rev 173108)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2014-08-29 07:39:13 UTC (rev 173109)
</span><span class="lines">@@ -239,9 +239,7 @@
</span><span class="cx"> platform/gtk/PlatformWheelEventGtk.cpp
</span><span class="cx"> platform/gtk/RedirectedXCompositeWindow.cpp
</span><span class="cx"> platform/gtk/RenderThemeGtk.cpp
</span><del>- platform/gtk/RenderThemeGtk3.cpp
</del><span class="cx"> platform/gtk/ScrollbarThemeGtk.cpp
</span><del>- platform/gtk/ScrollbarThemeGtk3.cpp
</del><span class="cx"> platform/gtk/SharedBufferGtk.cpp
</span><span class="cx"> platform/gtk/SharedTimerGtk.cpp
</span><span class="cx"> platform/gtk/SoundGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkRenderThemeGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp (173108 => 173109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp        2014-08-29 03:56:17 UTC (rev 173108)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp        2014-08-29 07:39:13 UTC (rev 173109)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include "LocalizedStrings.h"
</span><span class="cx"> #include "MediaControlElements.h"
</span><span class="cx"> #include "NamedNodeMap.h"
</span><ins>+#include "Page.h"
</ins><span class="cx"> #include "PaintInfo.h"
</span><span class="cx"> #include "PlatformContextCairo.h"
</span><span class="cx"> #include "RenderBox.h"
</span><span class="lines">@@ -50,6 +51,7 @@
</span><span class="cx"> #include <gdk/gdk.h>
</span><span class="cx"> #include <glib.h>
</span><span class="cx"> #include <gtk/gtk.h>
</span><ins>+#include <wtf/NeverDestroyed.h>
</ins><span class="cx"> #include <wtf/gobject/GRefPtr.h>
</span><span class="cx"> #include <wtf/gobject/GUniquePtr.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="lines">@@ -89,7 +91,7 @@
</span><span class="cx">
</span><span class="cx"> // This will be a font selection string like "Sans 10" so we cannot use it as the family name.
</span><span class="cx"> GUniqueOutPtr<gchar> fontName;
</span><del>- g_object_get(settings, "gtk-font-name", &fontName.outPtr(), NULL);
</del><ins>+ g_object_get(settings, "gtk-font-name", &fontName.outPtr(), nullptr);
</ins><span class="cx">
</span><span class="cx"> PangoFontDescription* pangoDescription = pango_font_description_from_string(fontName.get());
</span><span class="cx"> if (!pangoDescription)
</span><span class="lines">@@ -126,11 +128,137 @@
</span><span class="cx">
</span><span class="cx"> #ifndef GTK_API_VERSION_2
</span><span class="cx">
</span><del>-// 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);
</del><ins>+// This is the default value defined by GTK+, where it was defined as MIN_ARROW_SIZE in gtkarrow.c.
+static const int minArrowSize = 15;
+// This is the default value defined by GTK+, where it was defined as MIN_ARROW_WIDTH in gtkspinbutton.c.
+static const int minSpinButtonArrowSize = 6;
</ins><span class="cx">
</span><ins>+typedef HashMap<GType, GRefPtr<GtkStyleContext>> StyleContextMap;
+static StyleContextMap& styleContextMap();
+
+static void gtkStyleChangedCallback(GObject*, GParamSpec*)
+{
+ for (const auto& styleContext : styleContextMap())
+ gtk_style_context_invalidate(styleContext.value.get());
+ Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
+}
+
+static StyleContextMap& styleContextMap()
+{
+ static NeverDestroyed<StyleContextMap> map;
+ static bool initialized = false;
+ if (!initialized) {
+ GtkSettings* settings = gtk_settings_get_default();
+ g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(gtkStyleChangedCallback), nullptr);
+ g_signal_connect(settings, "notify::gtk-color-scheme", G_CALLBACK(gtkStyleChangedCallback), nullptr);
+ initialized = true;
+ }
+ return map;
+}
+
+static GtkStyleContext* getStyleContext(GType widgetType)
+{
+ StyleContextMap::AddResult result = styleContextMap().add(widgetType, nullptr);
+ if (!result.isNewEntry)
+ return result.iterator->value.get();
+
+ GtkWidgetPath* path = gtk_widget_path_new();
+ gtk_widget_path_append_type(path, widgetType);
+
+ if (widgetType == GTK_TYPE_SCROLLBAR)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCROLLBAR);
+ else if (widgetType == GTK_TYPE_ENTRY)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_ENTRY);
+ else if (widgetType == GTK_TYPE_ARROW)
+ gtk_widget_path_iter_add_class(path, 0, "arrow");
+ else if (widgetType == GTK_TYPE_BUTTON) {
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON);
+ gtk_widget_path_iter_add_class(path, 1, "text-button");
+ } else if (widgetType == GTK_TYPE_SCALE)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCALE);
+ else if (widgetType == GTK_TYPE_SEPARATOR)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SEPARATOR);
+ else if (widgetType == GTK_TYPE_PROGRESS_BAR)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_PROGRESSBAR);
+ else if (widgetType == GTK_TYPE_SPIN_BUTTON)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SPINBUTTON);
+ else if (widgetType == GTK_TYPE_TREE_VIEW)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_VIEW);
+ else if (widgetType == GTK_TYPE_CHECK_BUTTON)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_CHECK);
+ else if (widgetType == GTK_TYPE_RADIO_BUTTON)
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_RADIO);
+
+ GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new());
+ gtk_style_context_set_path(context.get(), path);
+ gtk_widget_path_free(path);
+
+ result.iterator->value = context;
+ return context.get();
+}
+
+GtkStyleContext* RenderThemeGtk::gtkScrollbarStyle()
+{
+ return getStyleContext(GTK_TYPE_SCROLLBAR);
+}
+
+static 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);
+
+ gtk_style_context_save(context);
+
+ guint flags = 0;
+ if (state == GTK_STATE_PRELIGHT)
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ else if (state == GTK_STATE_INSENSITIVE)
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+ gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(direction));
+ GdkPixbuf* icon = gtk_icon_set_render_icon_pixbuf(iconSet, context, static_cast<GtkIconSize>(iconSize));
+
+ gtk_style_context_restore(context);
+
+ return adoptGRef(icon);
+}
+
+static GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char* fallbackStockIconName, gint direction, gint state, gint iconSize)
+{
+ GtkStyleContext* context = getStyleContext(widgetType);
+
+ gtk_style_context_save(context);
+
+ guint flags = 0;
+ if (state == GTK_STATE_PRELIGHT)
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ else if (state == GTK_STATE_INSENSITIVE)
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+ gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(direction));
+ GtkIconInfo* info = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), symbolicIconName, iconSize,
+ static_cast<GtkIconLookupFlags>(GTK_ICON_LOOKUP_FORCE_SVG | GTK_ICON_LOOKUP_FORCE_SIZE));
+ GdkPixbuf* icon = 0;
+ if (info) {
+ icon = gtk_icon_info_load_symbolic_for_context(info, context, 0, 0);
+ gtk_icon_info_free(info);
+ }
+
+ gtk_style_context_restore(context);
+
+ if (!icon) {
+ if (!fallbackStockIconName)
+ return nullptr;
+ return getStockIconForWidgetType(widgetType, fallbackStockIconName, direction, state, iconSize);
+ }
+
+ return adoptGRef(icon);
+}
+
</ins><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx"> static HTMLMediaElement* getMediaElementFromRenderObject(const RenderObject& o)
</span><span class="cx"> {
</span><span class="lines">@@ -144,6 +272,19 @@
</span><span class="cx"> return toHTMLMediaElement(mediaNode);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void RenderThemeGtk::initMediaColors()
+{
+ GdkRGBA color;
+ GtkStyleContext* containerContext = getStyleContext(GTK_TYPE_CONTAINER);
+
+ gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_NORMAL, &color);
+ m_panelColor = color;
+ gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_ACTIVE, &color);
+ m_sliderColor = color;
+ gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_SELECTED, &color);
+ m_sliderThumbColor = color;
+}
+
</ins><span class="cx"> void RenderThemeGtk::initMediaButtons()
</span><span class="cx"> {
</span><span class="cx"> static bool iconsInitialized = false;
</span><span class="lines">@@ -198,13 +339,16 @@
</span><span class="cx"> , m_mediaIconSize(16)
</span><span class="cx"> , m_mediaSliderHeight(14)
</span><span class="cx"> {
</span><del>- platformInit();
</del><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx"> initMediaColors();
</span><span class="cx"> initMediaButtons();
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+RenderThemeGtk::~RenderThemeGtk()
+{
+}
+
</ins><span class="cx"> static bool supportsFocus(ControlPart appearance)
</span><span class="cx"> {
</span><span class="cx"> switch (appearance) {
</span><span class="lines">@@ -249,10 +393,7 @@
</span><span class="cx"> return RenderTheme::baselinePosition(o);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// This is used in RenderThemeGtk3. Normally, it would be in
-// the RenderThemeGtk header (perhaps as a static method), but we want to avoid
-// having to include GTK+ headers only for the GtkTextDirection enum.
-GtkTextDirection gtkTextDirection(TextDirection direction)
</del><ins>+static GtkTextDirection gtkTextDirection(TextDirection direction)
</ins><span class="cx"> {
</span><span class="cx"> switch (direction) {
</span><span class="cx"> case RTL:
</span><span class="lines">@@ -276,6 +417,57 @@
</span><span class="cx"> return GTK_STATE_NORMAL;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void adjustRectForFocus(GtkStyleContext* context, FloatRect& rect)
+{
+ gint focusWidth, focusPad;
+ gtk_style_context_get_style(context, "focus-line-width", &focusWidth, "focus-padding", &focusPad, nullptr);
+ rect.inflate(focusWidth + focusPad);
+}
+
+void RenderThemeGtk::adjustRepaintRect(const RenderObject& renderObject, FloatRect& rect)
+{
+ GtkStyleContext* context = 0;
+ bool checkInteriorFocus = false;
+ ControlPart part = renderObject.style().appearance();
+ switch (part) {
+ case CheckboxPart:
+ case RadioPart:
+ context = getStyleContext(part == CheckboxPart ? GTK_TYPE_CHECK_BUTTON : GTK_TYPE_RADIO_BUTTON);
+
+ gint indicatorSpacing;
+ gtk_style_context_get_style(context, "indicator-spacing", &indicatorSpacing, nullptr);
+ rect.inflate(indicatorSpacing);
+
+ return;
+ case SliderVerticalPart:
+ case SliderHorizontalPart:
+ context = getStyleContext(GTK_TYPE_SCALE);
+ break;
+ case ButtonPart:
+ case MenulistButtonPart:
+ case MenulistPart:
+ context = getStyleContext(GTK_TYPE_BUTTON);
+ checkInteriorFocus = true;
+ break;
+ case TextFieldPart:
+ case TextAreaPart:
+ context = getStyleContext(GTK_TYPE_ENTRY);
+ checkInteriorFocus = true;
+ break;
+ default:
+ return;
+ }
+
+ ASSERT(context);
+ if (checkInteriorFocus) {
+ gboolean interiorFocus;
+ gtk_style_context_get_style(context, "interior-focus", &interiorFocus, nullptr);
+ if (interiorFocus)
+ return;
+ }
+ adjustRectForFocus(context, rect);
+}
+
</ins><span class="cx"> void RenderThemeGtk::adjustButtonStyle(StyleResolver&, RenderStyle& style, WebCore::Element&) const
</span><span class="cx"> {
</span><span class="cx"> // Some layout tests check explicitly that buttons ignore line-height.
</span><span class="lines">@@ -283,6 +475,187 @@
</span><span class="cx"> style.setLineHeight(RenderStyle::initialLineHeight());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void setToggleSize(GtkStyleContext* context, RenderStyle& style)
+{
+ // The width and height are both specified, so we shouldn't change them.
+ if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto())
+ return;
+
+ // Other ports hard-code this to 13 which is also the default value defined by GTK+.
+ // GTK+ users tend to demand the native look.
+ // It could be made a configuration option values other than 13 actually break site compatibility.
+ gint indicatorSize;
+ gtk_style_context_get_style(context, "indicator-size", &indicatorSize, nullptr);
+
+ if (style.width().isIntrinsicOrAuto())
+ style.setWidth(Length(indicatorSize, Fixed));
+
+ if (style.height().isAuto())
+ style.setHeight(Length(indicatorSize, Fixed));
+}
+
+static void paintToggle(const RenderThemeGtk* theme, GType widgetType, const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& fullRect)
+{
+ GtkStyleContext* context = getStyleContext(widgetType);
+ gtk_style_context_save(context);
+
+ // Some themes do not render large toggle buttons properly, so we simply
+ // shrink the rectangle back down to the default size and then center it
+ // in the full toggle button region. The reason for not simply forcing toggle
+ // buttons to be a smaller size is that we don't want to break site layouts.
+ gint indicatorSize;
+ gtk_style_context_get_style(context, "indicator-size", &indicatorSize, nullptr);
+ IntRect rect(fullRect);
+ if (rect.width() > indicatorSize) {
+ rect.inflateX(-(rect.width() - indicatorSize) / 2);
+ rect.setWidth(indicatorSize); // In case rect.width() was equal to indicatorSize + 1.
+ }
+
+ if (rect.height() > indicatorSize) {
+ rect.inflateY(-(rect.height() - indicatorSize) / 2);
+ rect.setHeight(indicatorSize); // In case rect.height() was equal to indicatorSize + 1.
+ }
+
+ gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
+ gtk_style_context_add_class(context, widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO);
+
+ guint flags = 0;
+ if (!theme->isEnabled(renderObject) || theme->isReadOnlyControl(renderObject))
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ else if (theme->isHovered(renderObject))
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ if (theme->isIndeterminate(renderObject))
+ flags |= GTK_STATE_FLAG_INCONSISTENT;
+ else if (theme->isChecked(renderObject))
+#if GTK_CHECK_VERSION(3, 13, 7)
+ flags |= GTK_STATE_FLAG_CHECKED;
+#else
+ flags |= GTK_STATE_FLAG_ACTIVE;
+#endif
+ if (theme->isPressed(renderObject))
+ flags |= GTK_STATE_FLAG_SELECTED;
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+
+ if (widgetType == GTK_TYPE_CHECK_BUTTON)
+ gtk_render_check(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+ else
+ gtk_render_option(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+
+ if (theme->isFocused(renderObject)) {
+ IntRect indicatorRect(rect);
+ gint indicatorSpacing;
+ gtk_style_context_get_style(context, "indicator-spacing", &indicatorSpacing, nullptr);
+ indicatorRect.inflate(indicatorSpacing);
+ gtk_render_focus(context, paintInfo.context->platformContext()->cr(), indicatorRect.x(), indicatorRect.y(),
+ indicatorRect.width(), indicatorRect.height());
+ }
+
+ gtk_style_context_restore(context);
+}
+
+void RenderThemeGtk::setCheckboxSize(RenderStyle& style) const
+{
+ setToggleSize(getStyleContext(GTK_TYPE_CHECK_BUTTON), style);
+}
+
+bool RenderThemeGtk::paintCheckbox(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ paintToggle(this, GTK_TYPE_CHECK_BUTTON, renderObject, paintInfo, rect);
+ return false;
+}
+
+void RenderThemeGtk::setRadioSize(RenderStyle& style) const
+{
+ setToggleSize(getStyleContext(GTK_TYPE_RADIO_BUTTON), style);
+}
+
+bool RenderThemeGtk::paintRadio(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ paintToggle(this, GTK_TYPE_RADIO_BUTTON, renderObject, paintInfo, rect);
+ return false;
+}
+
+static void renderButton(RenderTheme* theme, GtkStyleContext* context, const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ IntRect buttonRect(rect);
+
+ guint flags = 0;
+ if (!theme->isEnabled(renderObject) || theme->isReadOnlyControl(renderObject))
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ else if (theme->isHovered(renderObject))
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ if (theme->isPressed(renderObject))
+ flags |= GTK_STATE_FLAG_ACTIVE;
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+
+ if (theme->isDefault(renderObject)) {
+ GtkBorder* borderPtr = 0;
+ GtkBorder border = { 1, 1, 1, 1 };
+
+ gtk_style_context_get_style(context, "default-border", &borderPtr, nullptr);
+ if (borderPtr) {
+ border = *borderPtr;
+ gtk_border_free(borderPtr);
+ }
+
+ buttonRect.move(border.left, border.top);
+ buttonRect.setWidth(buttonRect.width() - (border.left + border.right));
+ buttonRect.setHeight(buttonRect.height() - (border.top + border.bottom));
+
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_DEFAULT);
+ }
+
+ gtk_render_background(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
+ gtk_render_frame(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
+
+ if (theme->isFocused(renderObject)) {
+ gint focusWidth, focusPad;
+ gboolean displaceFocus, interiorFocus;
+ gtk_style_context_get_style(
+ context,
+ "focus-line-width", &focusWidth,
+ "focus-padding", &focusPad,
+ "interior-focus", &interiorFocus,
+ "displace-focus", &displaceFocus,
+ nullptr);
+
+ if (interiorFocus) {
+ GtkBorder borderWidth;
+ gtk_style_context_get_border(context, static_cast<GtkStateFlags>(flags), &borderWidth);
+
+ buttonRect = IntRect(
+ buttonRect.x() + borderWidth.left + focusPad,
+ buttonRect.y() + borderWidth.top + focusPad,
+ buttonRect.width() - (2 * focusPad + borderWidth.left + borderWidth.right),
+ buttonRect.height() - (2 * focusPad + borderWidth.top + borderWidth.bottom));
+ } else
+ buttonRect.inflate(focusWidth + focusPad);
+
+ if (displaceFocus && theme->isPressed(renderObject)) {
+ gint childDisplacementX;
+ gint childDisplacementY;
+ gtk_style_context_get_style(context, "child-displacement-x", &childDisplacementX, "child-displacement-y", &childDisplacementY, nullptr);
+ buttonRect.move(childDisplacementX, childDisplacementY);
+ }
+
+ gtk_render_focus(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
+ }
+}
+bool RenderThemeGtk::paintButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_BUTTON);
+ gtk_style_context_save(context);
+
+ gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+
+ renderButton(this, context, renderObject, paintInfo, rect);
+
+ gtk_style_context_restore(context);
+
+ return false;
+}
+
</ins><span class="cx"> void RenderThemeGtk::adjustMenuListStyle(StyleResolver&, RenderStyle& style, Element&) const
</span><span class="cx"> {
</span><span class="cx"> // The tests check explicitly that select menu buttons ignore line height.
</span><span class="lines">@@ -297,11 +670,246 @@
</span><span class="cx"> adjustMenuListStyle(styleResolver, style, e);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void getComboBoxMetrics(RenderStyle& style, GtkBorder& border, int& focus, int& separator)
+{
+ // If this menu list button isn't drawn using the native theme, we
+ // don't add any extra padding beyond what WebCore already uses.
+ if (style.appearance() == NoControlPart)
+ return;
+
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_COMBO_BOX);
+ gtk_style_context_save(context);
+
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+ gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(style.direction())));
+
+ gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &border);
+
+ gboolean interiorFocus;
+ gint focusWidth, focusPad;
+ gtk_style_context_get_style(context, "interior-focus", &interiorFocus, "focus-line-width", &focusWidth, "focus-padding", &focusPad, nullptr);
+ focus = interiorFocus ? focusWidth + focusPad : 0;
+
+ gtk_style_context_restore(context);
+
+ context = getStyleContext(GTK_TYPE_SEPARATOR);
+ gtk_style_context_save(context);
+
+ GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(style.direction()));
+ gtk_style_context_set_direction(context, direction);
+ gtk_style_context_add_class(context, "separator");
+
+ gboolean wideSeparators;
+ gint separatorWidth;
+ gtk_style_context_get_style(context, "wide-separators", &wideSeparators, "separator-width", &separatorWidth, nullptr);
+
+ // GTK+ always uses border.left, regardless of text direction. See gtkseperator.c.
+ if (!wideSeparators)
+ separatorWidth = border.left;
+
+ separator = separatorWidth;
+
+ gtk_style_context_restore(context);
+}
+
+int RenderThemeGtk::popupInternalPaddingLeft(RenderStyle& style) const
+{
+ GtkBorder borderWidth = { 0, 0, 0, 0 };
+ int focusWidth = 0, separatorWidth = 0;
+ getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
+ int left = borderWidth.left + focusWidth;
+ if (style.direction() == RTL)
+ left += separatorWidth + minArrowSize;
+ return left;
+}
+
+int RenderThemeGtk::popupInternalPaddingRight(RenderStyle& style) const
+{
+ GtkBorder borderWidth = { 0, 0, 0, 0 };
+ int focusWidth = 0, separatorWidth = 0;
+ getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
+ int right = borderWidth.right + focusWidth;
+ if (style.direction() == LTR)
+ right += separatorWidth + minArrowSize;
+ return right;
+}
+
+int RenderThemeGtk::popupInternalPaddingTop(RenderStyle& style) const
+{
+ GtkBorder borderWidth = { 0, 0, 0, 0 };
+ int focusWidth = 0, separatorWidth = 0;
+ getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
+ return borderWidth.top + focusWidth;
+}
+
+int RenderThemeGtk::popupInternalPaddingBottom(RenderStyle& style) const
+{
+ GtkBorder borderWidth = { 0, 0, 0, 0 };
+ int focusWidth = 0, separatorWidth = 0;
+ getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
+ return borderWidth.bottom + focusWidth;
+}
+
+bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& r)
+{
+ // FIXME: adopt subpixel themes.
+ IntRect rect = IntRect(r);
+
+ cairo_t* cairoContext = paintInfo.context->platformContext()->cr();
+ GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()));
+
+ // Paint the button.
+ GtkStyleContext* buttonStyleContext = getStyleContext(GTK_TYPE_BUTTON);
+ gtk_style_context_save(buttonStyleContext);
+ gtk_style_context_set_direction(buttonStyleContext, direction);
+ gtk_style_context_add_class(buttonStyleContext, GTK_STYLE_CLASS_BUTTON);
+ renderButton(this, buttonStyleContext, renderObject, paintInfo, rect);
+
+ // Get the inner rectangle.
+ gint focusWidth, focusPad;
+ GtkBorder* innerBorderPtr = 0;
+ GtkBorder innerBorder = { 1, 1, 1, 1 };
+ gtk_style_context_get_style(buttonStyleContext, "inner-border", &innerBorderPtr, "focus-line-width", &focusWidth, "focus-padding", &focusPad, nullptr);
+ if (innerBorderPtr) {
+ innerBorder = *innerBorderPtr;
+ gtk_border_free(innerBorderPtr);
+ }
+
+ GtkBorder borderWidth;
+ GtkStateFlags state = gtk_style_context_get_state(buttonStyleContext);
+ gtk_style_context_get_border(buttonStyleContext, state, &borderWidth);
+
+ focusWidth += focusPad;
+ IntRect innerRect(
+ rect.x() + innerBorder.left + borderWidth.left + focusWidth,
+ rect.y() + innerBorder.top + borderWidth.top + focusWidth,
+ rect.width() - borderWidth.left - borderWidth.right - innerBorder.left - innerBorder.right - (2 * focusWidth),
+ rect.height() - borderWidth.top - borderWidth.bottom - innerBorder.top - innerBorder.bottom - (2 * focusWidth));
+
+ if (isPressed(renderObject)) {
+ gint childDisplacementX;
+ gint childDisplacementY;
+ gtk_style_context_get_style(buttonStyleContext, "child-displacement-x", &childDisplacementX, "child-displacement-y", &childDisplacementY, nullptr);
+ innerRect.move(childDisplacementX, childDisplacementY);
+ }
+ innerRect.setWidth(std::max(1, innerRect.width()));
+ innerRect.setHeight(std::max(1, innerRect.height()));
+
+ gtk_style_context_restore(buttonStyleContext);
+
+ // Paint the arrow.
+ GtkStyleContext* arrowStyleContext = getStyleContext(GTK_TYPE_ARROW);
+ gtk_style_context_save(arrowStyleContext);
+
+ gtk_style_context_set_direction(arrowStyleContext, direction);
+ gtk_style_context_add_class(arrowStyleContext, "arrow");
+ gtk_style_context_add_class(arrowStyleContext, GTK_STYLE_CLASS_BUTTON);
+
+ gfloat arrowScaling;
+ gtk_style_context_get_style(arrowStyleContext, "arrow-scaling", &arrowScaling, nullptr);
+
+ IntSize arrowSize(minArrowSize, innerRect.height());
+ FloatPoint arrowPosition(innerRect.location());
+ if (direction == GTK_TEXT_DIR_LTR)
+ arrowPosition.move(innerRect.width() - arrowSize.width(), 0);
+
+ // GTK+ actually fetches the xalign and valign values from the widget, but since we
+ // don't have a widget here, we are just using the default xalign and valign values of 0.5.
+ gint extent = std::min(arrowSize.width(), arrowSize.height()) * arrowScaling;
+ arrowPosition.move((arrowSize.width() - extent) / 2, (arrowSize.height() - extent) / 2);
+
+ gtk_style_context_set_state(arrowStyleContext, state);
+ gtk_render_arrow(arrowStyleContext, cairoContext, G_PI, arrowPosition.x(), arrowPosition.y(), extent);
+
+ gtk_style_context_restore(arrowStyleContext);
+
+ // Paint the separator if needed.
+ GtkStyleContext* separatorStyleContext = getStyleContext(GTK_TYPE_COMBO_BOX);
+ gtk_style_context_save(separatorStyleContext);
+
+ gtk_style_context_set_direction(separatorStyleContext, direction);
+ gtk_style_context_add_class(separatorStyleContext, "separator");
+
+ gboolean wideSeparators;
+ gint separatorWidth;
+ gtk_style_context_get_style(separatorStyleContext, "wide-separators", &wideSeparators, "separator-width", &separatorWidth, nullptr);
+ if (wideSeparators && !separatorWidth) {
+ gtk_style_context_restore(separatorStyleContext);
+ return false;
+ }
+
+ gtk_style_context_set_state(separatorStyleContext, state);
+ IntPoint separatorPosition(arrowPosition.x(), innerRect.y());
+ if (wideSeparators) {
+ if (direction == GTK_TEXT_DIR_LTR)
+ separatorPosition.move(-separatorWidth, 0);
+ else
+ separatorPosition.move(arrowSize.width(), 0);
+
+ gtk_render_frame(separatorStyleContext, cairoContext, separatorPosition.x(), separatorPosition.y(), separatorWidth, innerRect.height());
+ } else {
+ GtkBorder padding;
+ gtk_style_context_get_padding(separatorStyleContext, state, &padding);
+ GtkBorder border;
+ gtk_style_context_get_border(separatorStyleContext, state, &border);
+
+ if (direction == GTK_TEXT_DIR_LTR)
+ separatorPosition.move(-(padding.left + border.left), 0);
+ else
+ separatorPosition.move(arrowSize.width(), 0);
+
+ cairo_save(cairoContext);
+
+ // An extra clip prevents the separator bleeding outside of the specified rectangle because of subpixel positioning.
+ cairo_rectangle(cairoContext, separatorPosition.x(), separatorPosition.y(), border.left, innerRect.height());
+ cairo_clip(cairoContext);
+ gtk_render_line(separatorStyleContext, cairoContext, separatorPosition.x(), separatorPosition.y(), separatorPosition.x(), innerRect.maxY());
+ cairo_restore(cairoContext);
+ }
+
+ gtk_style_context_restore(separatorStyleContext);
+ return false;
+}
+
</ins><span class="cx"> bool RenderThemeGtk::paintMenuListButtonDecorations(const RenderObject& object, const PaintInfo& info, const FloatRect& rect)
</span><span class="cx"> {
</span><span class="cx"> return paintMenuList(object, info, rect);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool RenderThemeGtk::paintTextField(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
+{
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_ENTRY);
+ gtk_style_context_save(context);
+
+ gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_ENTRY);
+
+ guint flags = 0;
+ if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ else if (isFocused(renderObject))
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+
+ gtk_render_background(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+ gtk_render_frame(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+
+ if (isFocused(renderObject) && isEnabled(renderObject)) {
+ gboolean interiorFocus;
+ gint focusWidth, focusPad;
+ gtk_style_context_get_style(context, "interior-focus", &interiorFocus, "focus-line-width", &focusWidth, "focus-padding", &focusPad, nullptr);
+ if (!interiorFocus) {
+ IntRect focusRect(rect);
+ focusRect.inflate(focusWidth + focusPad);
+ gtk_render_focus(context, paintInfo.context->platformContext()->cr(), focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
+ }
+ }
+
+ gtk_style_context_restore(context);
+
+ return false;
+}
+
</ins><span class="cx"> bool RenderThemeGtk::paintTextArea(const RenderObject& o, const PaintInfo& i, const FloatRect& r)
</span><span class="cx"> {
</span><span class="cx"> return paintTextField(o, i, r);
</span><span class="lines">@@ -481,6 +1089,240 @@
</span><span class="cx"> style.setBoxShadow(nullptr);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void applySliderStyleContextClasses(GtkStyleContext* context, ControlPart part)
+{
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCALE);
+ if (part == SliderHorizontalPart || part == SliderThumbHorizontalPart)
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_HORIZONTAL);
+ else if (part == SliderVerticalPart || part == SliderThumbVerticalPart)
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_VERTICAL);
+}
+
+bool RenderThemeGtk::paintSliderTrack(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ ControlPart part = renderObject.style().appearance();
+ ASSERT_UNUSED(part, part == SliderHorizontalPart || part == SliderVerticalPart || part == MediaVolumeSliderPart);
+
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_SCALE);
+ gtk_style_context_save(context);
+
+ gtk_style_context_set_direction(context, gtkTextDirection(renderObject.style().direction()));
+ applySliderStyleContextClasses(context, part);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH);
+
+ if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
+ gtk_style_context_set_state(context, GTK_STATE_FLAG_INSENSITIVE);
+
+ gtk_render_background(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+ gtk_render_frame(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+
+ if (isFocused(renderObject)) {
+ gint focusWidth, focusPad;
+ gtk_style_context_get_style(context, "focus-line-width", &focusWidth, "focus-padding", &focusPad, nullptr);
+ IntRect focusRect(rect);
+ focusRect.inflate(focusWidth + focusPad);
+ gtk_render_focus(context, paintInfo.context->platformContext()->cr(), focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
+ }
+
+ gtk_style_context_restore(context);
+ return false;
+}
+
+bool RenderThemeGtk::paintSliderThumb(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ ControlPart part = renderObject.style().appearance();
+ ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
+
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_SCALE);
+ gtk_style_context_save(context);
+
+ gtk_style_context_set_direction(context, gtkTextDirection(renderObject.style().direction()));
+ applySliderStyleContextClasses(context, part);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_SLIDER);
+
+ guint flags = 0;
+ if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ else if (isHovered(renderObject))
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ if (isPressed(renderObject))
+ flags |= GTK_STATE_FLAG_ACTIVE;
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+
+ gtk_render_slider(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height(),
+ part == SliderThumbHorizontalPart ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
+
+ gtk_style_context_restore(context);
+
+ return false;
+}
+
+void RenderThemeGtk::adjustSliderThumbSize(RenderStyle& style, Element&) const
+{
+ ControlPart part = style.appearance();
+ if (part != SliderThumbHorizontalPart && part != SliderThumbVerticalPart)
+ return;
+
+ gint sliderWidth, sliderLength;
+ gtk_style_context_get_style(getStyleContext(GTK_TYPE_SCALE), "slider-width", &sliderWidth, "slider-length", &sliderLength, nullptr);
+ if (part == SliderThumbHorizontalPart) {
+ style.setWidth(Length(sliderLength, Fixed));
+ style.setHeight(Length(sliderWidth, Fixed));
+ return;
+ }
+ ASSERT(part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
+ style.setWidth(Length(sliderWidth, Fixed));
+ style.setHeight(Length(sliderLength, Fixed));
+}
+
+bool RenderThemeGtk::paintProgressBar(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ if (!renderObject.isProgress())
+ return true;
+
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_PROGRESS_BAR);
+ gtk_style_context_save(context);
+
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH);
+
+ gtk_render_background(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+ gtk_render_frame(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+
+ gtk_style_context_restore(context);
+
+ gtk_style_context_save(context);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR);
+
+
+ GtkBorder padding;
+ gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
+ IntRect progressRect(
+ rect.x() + padding.left,
+ rect.y() + padding.top,
+ rect.width() - (padding.left + padding.right),
+ rect.height() - (padding.top + padding.bottom));
+ progressRect = RenderThemeGtk::calculateProgressRect(renderObject, progressRect);
+
+ if (!progressRect.isEmpty())
+ gtk_render_activity(context, paintInfo.context->platformContext()->cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
+
+ gtk_style_context_restore(context);
+ return false;
+}
+
+static gint spinButtonArrowSize(GtkStyleContext* context)
+{
+ PangoFontDescription* fontDescription;
+ gtk_style_context_get(context, static_cast<GtkStateFlags>(0), "font", &fontDescription, nullptr);
+ gint fontSize = pango_font_description_get_size(fontDescription);
+ gint arrowSize = std::max(PANGO_PIXELS(fontSize), minSpinButtonArrowSize);
+ pango_font_description_free(fontDescription);
+
+ return arrowSize - arrowSize % 2; // Force even.
+}
+
+void RenderThemeGtk::adjustInnerSpinButtonStyle(StyleResolver&, RenderStyle& style, Element&) const
+{
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
+
+ GtkBorder padding;
+ gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
+
+ int width = spinButtonArrowSize(context) + padding.left + padding.right;
+ style.setWidth(Length(width, Fixed));
+ style.setMinWidth(Length(width, Fixed));
+}
+
+static void paintSpinArrowButton(RenderTheme* theme, GtkStyleContext* context, const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect, GtkArrowType arrowType)
+{
+ ASSERT(arrowType == GTK_ARROW_UP || arrowType == GTK_ARROW_DOWN);
+
+ gtk_style_context_save(context);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+
+ GtkTextDirection direction = gtk_style_context_get_direction(context);
+ guint state = static_cast<guint>(gtk_style_context_get_state(context));
+ if (!(state & GTK_STATE_FLAG_INSENSITIVE)) {
+ if (theme->isPressed(renderObject)) {
+ if ((arrowType == GTK_ARROW_UP && theme->isSpinUpButtonPartPressed(renderObject))
+ || (arrowType == GTK_ARROW_DOWN && !theme->isSpinUpButtonPartPressed(renderObject)))
+ state |= GTK_STATE_FLAG_ACTIVE;
+ } else if (theme->isHovered(renderObject)) {
+ if ((arrowType == GTK_ARROW_UP && theme->isSpinUpButtonPartHovered(renderObject))
+ || (arrowType == GTK_ARROW_DOWN && !theme->isSpinUpButtonPartHovered(renderObject)))
+ state |= GTK_STATE_FLAG_PRELIGHT;
+ }
+ }
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(state));
+
+ // Paint button.
+ IntRect buttonRect(rect);
+ guint junction = gtk_style_context_get_junction_sides(context);
+ if (arrowType == GTK_ARROW_UP)
+ junction |= GTK_JUNCTION_BOTTOM;
+ else {
+ junction |= GTK_JUNCTION_TOP;
+ buttonRect.move(0, rect.height() / 2);
+ }
+ buttonRect.setHeight(rect.height() / 2);
+ gtk_style_context_set_junction_sides(context, static_cast<GtkJunctionSides>(junction));
+
+ gtk_render_background(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
+ gtk_render_frame(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
+
+ // Paint arrow centered inside button.
+ // This code is based on gtkspinbutton.c code.
+ IntRect arrowRect;
+ gdouble angle;
+ if (arrowType == GTK_ARROW_UP) {
+ angle = 0;
+ arrowRect.setY(rect.y());
+ arrowRect.setHeight(rect.height() / 2 - 2);
+ } else {
+ angle = G_PI;
+ arrowRect.setY(rect.y() + buttonRect.y());
+ arrowRect.setHeight(rect.height() - arrowRect.y() - 2);
+ }
+ arrowRect.setWidth(rect.width() - 3);
+ if (direction == GTK_TEXT_DIR_LTR)
+ arrowRect.setX(rect.x() + 1);
+ else
+ arrowRect.setX(rect.x() + 2);
+
+ gint width = arrowRect.width() / 2;
+ width -= width % 2 - 1; // Force odd.
+ gint height = (width + 1) / 2;
+
+ arrowRect.move((arrowRect.width() - width) / 2, (arrowRect.height() - height) / 2);
+ gtk_render_arrow(context, paintInfo.context->platformContext()->cr(), angle, arrowRect.x(), arrowRect.y(), width);
+
+ gtk_style_context_restore(context);
+}
+
+bool RenderThemeGtk::paintInnerSpinButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
+ gtk_style_context_save(context);
+
+ GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()));
+ gtk_style_context_set_direction(context, direction);
+
+ guint flags = 0;
+ if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ else if (isFocused(renderObject))
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
+ gtk_style_context_remove_class(context, GTK_STYLE_CLASS_ENTRY);
+
+ paintSpinArrowButton(this, context, renderObject, paintInfo, rect, GTK_ARROW_UP);
+ paintSpinArrowButton(this, context, renderObject, paintInfo, rect, GTK_ARROW_DOWN);
+
+ gtk_style_context_restore(context);
+
+ return false;
+}
+
</ins><span class="cx"> double RenderThemeGtk::caretBlinkInterval() const
</span><span class="cx"> {
</span><span class="cx"> GtkSettings* settings = gtk_settings_get_default();
</span><span class="lines">@@ -488,7 +1330,7 @@
</span><span class="cx"> gboolean shouldBlink;
</span><span class="cx"> gint time;
</span><span class="cx">
</span><del>- g_object_get(settings, "gtk-cursor-blink", &shouldBlink, "gtk-cursor-blink-time", &time, NULL);
</del><ins>+ g_object_get(settings, "gtk-cursor-blink", &shouldBlink, "gtk-cursor-blink-time", &time, nullptr);
</ins><span class="cx">
</span><span class="cx"> if (!shouldBlink)
</span><span class="cx"> return 0;
</span><span class="lines">@@ -496,6 +1338,78 @@
</span><span class="cx"> return time / 2000.;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::platformInactiveSelectionBackgroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_ENTRY), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::platformActiveSelectionForegroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::platformInactiveSelectionForegroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::platformActiveListBoxSelectionBackgroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_TREE_VIEW), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::platformInactiveListBoxSelectionBackgroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_TREE_VIEW), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::platformActiveListBoxSelectionForegroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_color(getStyleContext(GTK_TYPE_TREE_VIEW), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::platformInactiveListBoxSelectionForegroundColor() const
+{
+ GdkRGBA gdkRGBAColor;
+ gtk_style_context_get_color(getStyleContext(GTK_TYPE_TREE_VIEW), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
+ return gdkRGBAColor;
+}
+
+Color RenderThemeGtk::systemColor(CSSValueID cssValueId) const
+{
+ GdkRGBA gdkRGBAColor;
+
+ switch (cssValueId) {
+ case CSSValueButtontext:
+ gtk_style_context_get_color(getStyleContext(GTK_TYPE_BUTTON), GTK_STATE_FLAG_ACTIVE, &gdkRGBAColor);
+ return gdkRGBAColor;
+ case CSSValueCaptiontext:
+ gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(0), &gdkRGBAColor);
+ return gdkRGBAColor;
+ default:
+ return RenderTheme::systemColor(cssValueId);
+ }
+}
+
</ins><span class="cx"> void RenderThemeGtk::platformColorsDidChange()
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="lines">@@ -519,9 +1433,10 @@
</span><span class="cx">
</span><span class="cx"> bool RenderThemeGtk::paintMediaButton(const RenderObject& renderObject, GraphicsContext* context, const IntRect& rect, const char* symbolicIconName, const char* fallbackStockIconName)
</span><span class="cx"> {
</span><del>- IntRect iconRect(rect.x() + (rect.width() - m_mediaIconSize) / 2,
- rect.y() + (rect.height() - m_mediaIconSize) / 2,
- m_mediaIconSize, m_mediaIconSize);
</del><ins>+ IntRect iconRect(
+ rect.x() + (rect.width() - m_mediaIconSize) / 2,
+ rect.y() + (rect.height() - m_mediaIconSize) / 2,
+ m_mediaIconSize, m_mediaIconSize);
</ins><span class="cx"> GRefPtr<GdkPixbuf> icon = getStockSymbolicIconForWidgetType(GTK_TYPE_CONTAINER, symbolicIconName, fallbackStockIconName,
</span><span class="cx"> gtkTextDirection(renderObject.style().direction()), gtkIconState(this, renderObject), iconRect.width());
</span><span class="cx"> paintGdkPixbuf(context, icon.get(), iconRect);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkRenderThemeGtkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h (173108 => 173109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h        2014-08-29 03:56:17 UTC (rev 173108)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk.h        2014-08-29 07:39:13 UTC (rev 173109)
</span><span class="lines">@@ -184,7 +184,6 @@
</span><span class="cx">
</span><span class="cx"> virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const override;
</span><span class="cx">
</span><del>- void platformInit();
</del><span class="cx"> static void setTextInputBorders(RenderStyle&);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkRenderThemeGtk3cpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp (173108 => 173109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp        2014-08-29 03:56:17 UTC (rev 173108)
+++ trunk/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp        2014-08-29 07:39:13 UTC (rev 173109)
</span><span class="lines">@@ -1,1016 +0,0 @@
</span><del>-/*
- * Copyright (C) 2007 Apple Inc.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Collabora Ltd.
- * Copyright (C) 2009 Kenneth Rohde Christiansen
- * Copyright (C) 2010 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "RenderThemeGtk.h"
-
-#ifndef GTK_API_VERSION_2
-
-#include "CSSValueKeywords.h"
-#include "GraphicsContext.h"
-#include "GtkVersioning.h"
-#include "HTMLNames.h"
-#include "MediaControlElements.h"
-#include "Page.h"
-#include "PaintInfo.h"
-#include "PlatformContextCairo.h"
-#include "RenderElement.h"
-#include "TextDirection.h"
-#include "UserAgentStyleSheets.h"
-#include <cmath>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <wtf/gobject/GRefPtr.h>
-
-namespace WebCore {
-
-// This is the default value defined by GTK+, where it was defined as MIN_ARROW_SIZE in gtkarrow.c.
-static const int minArrowSize = 15;
-// This is the default value defined by GTK+, where it was defined as MIN_ARROW_WIDTH in gtkspinbutton.c.
-static const int minSpinButtonArrowSize = 6;
-
-typedef HashMap<GType, GRefPtr<GtkStyleContext> > StyleContextMap;
-static StyleContextMap& styleContextMap();
-
-static void gtkStyleChangedCallback(GObject*, GParamSpec*)
-{
- StyleContextMap::const_iterator end = styleContextMap().end();
- for (StyleContextMap::const_iterator iter = styleContextMap().begin(); iter != end; ++iter)
- gtk_style_context_invalidate(iter->value.get());
-
- Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
-}
-
-static StyleContextMap& styleContextMap()
-{
- DEPRECATED_DEFINE_STATIC_LOCAL(StyleContextMap, map, ());
-
- static bool initialized = false;
- if (!initialized) {
- GtkSettings* settings = gtk_settings_get_default();
- g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(gtkStyleChangedCallback), 0);
- g_signal_connect(settings, "notify::gtk-color-scheme", G_CALLBACK(gtkStyleChangedCallback), 0);
- initialized = true;
- }
- return map;
-}
-
-static GtkStyleContext* getStyleContext(GType widgetType)
-{
- StyleContextMap::AddResult result = styleContextMap().add(widgetType, nullptr);
- if (!result.isNewEntry)
- return result.iterator->value.get();
-
- GtkWidgetPath* path = gtk_widget_path_new();
- gtk_widget_path_append_type(path, widgetType);
-
- if (widgetType == GTK_TYPE_SCROLLBAR)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCROLLBAR);
- else if (widgetType == GTK_TYPE_ENTRY)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_ENTRY);
- else if (widgetType == GTK_TYPE_ARROW)
- gtk_widget_path_iter_add_class(path, 0, "arrow");
- else if (widgetType == GTK_TYPE_BUTTON) {
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON);
- gtk_widget_path_iter_add_class(path, 1, "text-button");
- }
- else if (widgetType == GTK_TYPE_SCALE)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCALE);
- else if (widgetType == GTK_TYPE_SEPARATOR)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SEPARATOR);
- else if (widgetType == GTK_TYPE_PROGRESS_BAR)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_PROGRESSBAR);
- else if (widgetType == GTK_TYPE_SPIN_BUTTON)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SPINBUTTON);
- else if (widgetType == GTK_TYPE_TREE_VIEW)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_VIEW);
- else if (widgetType == GTK_TYPE_CHECK_BUTTON)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_CHECK);
- else if (widgetType == GTK_TYPE_RADIO_BUTTON)
- gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_RADIO);
-
- GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new());
- gtk_style_context_set_path(context.get(), path);
- gtk_widget_path_free(path);
-
- result.iterator->value = context;
- return context.get();
-}
-
-GtkStyleContext* RenderThemeGtk::gtkScrollbarStyle()
-{
- return getStyleContext(GTK_TYPE_SCROLLBAR);
-}
-
-// This is not a static method, because we want to avoid having GTK+ headers in RenderThemeGtk.h.
-extern GtkTextDirection gtkTextDirection(TextDirection);
-
-void RenderThemeGtk::platformInit()
-{
-}
-
-RenderThemeGtk::~RenderThemeGtk()
-{
-}
-
-#if ENABLE(VIDEO)
-void RenderThemeGtk::initMediaColors()
-{
- GdkRGBA color;
- GtkStyleContext* containerContext = getStyleContext(GTK_TYPE_CONTAINER);
-
- gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_NORMAL, &color);
- m_panelColor = color;
- gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_ACTIVE, &color);
- m_sliderColor = color;
- gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_SELECTED, &color);
- m_sliderThumbColor = color;
-}
-#endif
-
-static void adjustRectForFocus(GtkStyleContext* context, FloatRect& rect)
-{
- gint focusWidth, focusPad;
- gtk_style_context_get_style(context,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad, NULL);
- rect.inflate(focusWidth + focusPad);
-}
-
-void RenderThemeGtk::adjustRepaintRect(const RenderObject& renderObject, FloatRect& rect)
-{
- GtkStyleContext* context = 0;
- bool checkInteriorFocus = false;
- ControlPart part = renderObject.style().appearance();
- switch (part) {
- case CheckboxPart:
- case RadioPart:
- context = getStyleContext(part == CheckboxPart ? GTK_TYPE_CHECK_BUTTON : GTK_TYPE_RADIO_BUTTON);
-
- gint indicatorSpacing;
- gtk_style_context_get_style(context, "indicator-spacing", &indicatorSpacing, NULL);
- rect.inflate(indicatorSpacing);
-
- return;
- case SliderVerticalPart:
- case SliderHorizontalPart:
- context = getStyleContext(GTK_TYPE_SCALE);
- break;
- case ButtonPart:
- case MenulistButtonPart:
- case MenulistPart:
- context = getStyleContext(GTK_TYPE_BUTTON);
- checkInteriorFocus = true;
- break;
- case TextFieldPart:
- case TextAreaPart:
- context = getStyleContext(GTK_TYPE_ENTRY);
- checkInteriorFocus = true;
- break;
- default:
- return;
- }
-
- ASSERT(context);
- if (checkInteriorFocus) {
- gboolean interiorFocus;
- gtk_style_context_get_style(context, "interior-focus", &interiorFocus, NULL);
- if (interiorFocus)
- return;
- }
- adjustRectForFocus(context, rect);
-}
-
-static void setToggleSize(GtkStyleContext* context, RenderStyle& style)
-{
- // The width and height are both specified, so we shouldn't change them.
- if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto())
- return;
-
- // Other ports hard-code this to 13 which is also the default value defined by GTK+.
- // GTK+ users tend to demand the native look.
- // It could be made a configuration option values other than 13 actually break site compatibility.
- gint indicatorSize;
- gtk_style_context_get_style(context, "indicator-size", &indicatorSize, NULL);
-
- if (style.width().isIntrinsicOrAuto())
- style.setWidth(Length(indicatorSize, Fixed));
-
- if (style.height().isAuto())
- style.setHeight(Length(indicatorSize, Fixed));
-}
-
-static void paintToggle(const RenderThemeGtk* theme, GType widgetType, const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& fullRect)
-{
- GtkStyleContext* context = getStyleContext(widgetType);
- gtk_style_context_save(context);
-
- // Some themes do not render large toggle buttons properly, so we simply
- // shrink the rectangle back down to the default size and then center it
- // in the full toggle button region. The reason for not simply forcing toggle
- // buttons to be a smaller size is that we don't want to break site layouts.
- gint indicatorSize;
- gtk_style_context_get_style(context, "indicator-size", &indicatorSize, NULL);
- IntRect rect(fullRect);
- if (rect.width() > indicatorSize) {
- rect.inflateX(-(rect.width() - indicatorSize) / 2);
- rect.setWidth(indicatorSize); // In case rect.width() was equal to indicatorSize + 1.
- }
-
- if (rect.height() > indicatorSize) {
- rect.inflateY(-(rect.height() - indicatorSize) / 2);
- rect.setHeight(indicatorSize); // In case rect.height() was equal to indicatorSize + 1.
- }
-
- gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
- gtk_style_context_add_class(context, widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO);
-
- guint flags = 0;
- if (!theme->isEnabled(renderObject) || theme->isReadOnlyControl(renderObject))
- flags |= GTK_STATE_FLAG_INSENSITIVE;
- else if (theme->isHovered(renderObject))
- flags |= GTK_STATE_FLAG_PRELIGHT;
- if (theme->isIndeterminate(renderObject))
- flags |= GTK_STATE_FLAG_INCONSISTENT;
- else if (theme->isChecked(renderObject))
-#if GTK_CHECK_VERSION(3, 13, 7)
- flags |= GTK_STATE_FLAG_CHECKED;
-#else
- flags |= GTK_STATE_FLAG_ACTIVE;
-#endif
- if (theme->isPressed(renderObject))
- flags |= GTK_STATE_FLAG_SELECTED;
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
-
- if (widgetType == GTK_TYPE_CHECK_BUTTON)
- gtk_render_check(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
- else
- gtk_render_option(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
-
- if (theme->isFocused(renderObject)) {
- IntRect indicatorRect(rect);
- gint indicatorSpacing;
- gtk_style_context_get_style(context, "indicator-spacing", &indicatorSpacing, NULL);
- indicatorRect.inflate(indicatorSpacing);
- gtk_render_focus(context, paintInfo.context->platformContext()->cr(), indicatorRect.x(), indicatorRect.y(),
- indicatorRect.width(), indicatorRect.height());
- }
-
- gtk_style_context_restore(context);
-}
-
-void RenderThemeGtk::setCheckboxSize(RenderStyle& style) const
-{
- setToggleSize(getStyleContext(GTK_TYPE_CHECK_BUTTON), style);
-}
-
-bool RenderThemeGtk::paintCheckbox(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- paintToggle(this, GTK_TYPE_CHECK_BUTTON, renderObject, paintInfo, rect);
- return false;
-}
-
-void RenderThemeGtk::setRadioSize(RenderStyle& style) const
-{
- setToggleSize(getStyleContext(GTK_TYPE_RADIO_BUTTON), style);
-}
-
-bool RenderThemeGtk::paintRadio(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- paintToggle(this, GTK_TYPE_RADIO_BUTTON, renderObject, paintInfo, rect);
- return false;
-}
-
-static void renderButton(RenderTheme* theme, GtkStyleContext* context, const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- IntRect buttonRect(rect);
-
- guint flags = 0;
- if (!theme->isEnabled(renderObject) || theme->isReadOnlyControl(renderObject))
- flags |= GTK_STATE_FLAG_INSENSITIVE;
- else if (theme->isHovered(renderObject))
- flags |= GTK_STATE_FLAG_PRELIGHT;
- if (theme->isPressed(renderObject))
- flags |= GTK_STATE_FLAG_ACTIVE;
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
-
- if (theme->isDefault(renderObject)) {
- GtkBorder* borderPtr = 0;
- GtkBorder border = { 1, 1, 1, 1 };
-
- gtk_style_context_get_style(context, "default-border", &borderPtr, NULL);
- if (borderPtr) {
- border = *borderPtr;
- gtk_border_free(borderPtr);
- }
-
- buttonRect.move(border.left, border.top);
- buttonRect.setWidth(buttonRect.width() - (border.left + border.right));
- buttonRect.setHeight(buttonRect.height() - (border.top + border.bottom));
-
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_DEFAULT);
- }
-
- gtk_render_background(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
- gtk_render_frame(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
-
- if (theme->isFocused(renderObject)) {
- gint focusWidth, focusPad;
- gboolean displaceFocus, interiorFocus;
- gtk_style_context_get_style(context,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad,
- "interior-focus", &interiorFocus,
- "displace-focus", &displaceFocus,
- NULL);
-
- if (interiorFocus) {
- GtkBorder borderWidth;
- gtk_style_context_get_border(context, static_cast<GtkStateFlags>(flags), &borderWidth);
-
- buttonRect = IntRect(buttonRect.x() + borderWidth.left + focusPad, buttonRect.y() + borderWidth.top + focusPad,
- buttonRect.width() - (2 * focusPad + borderWidth.left + borderWidth.right),
- buttonRect.height() - (2 * focusPad + borderWidth.top + borderWidth.bottom));
- } else
- buttonRect.inflate(focusWidth + focusPad);
-
- if (displaceFocus && theme->isPressed(renderObject)) {
- gint childDisplacementX;
- gint childDisplacementY;
- gtk_style_context_get_style(context,
- "child-displacement-x", &childDisplacementX,
- "child-displacement-y", &childDisplacementY,
- NULL);
- buttonRect.move(childDisplacementX, childDisplacementY);
- }
-
- gtk_render_focus(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
- }
-}
-bool RenderThemeGtk::paintButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- GtkStyleContext* context = getStyleContext(GTK_TYPE_BUTTON);
- gtk_style_context_save(context);
-
- gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
-
- renderButton(this, context, renderObject, paintInfo, rect);
-
- gtk_style_context_restore(context);
-
- return false;
-}
-
-static void getComboBoxMetrics(RenderStyle& style, GtkBorder& border, int& focus, int& separator)
-{
- // If this menu list button isn't drawn using the native theme, we
- // don't add any extra padding beyond what WebCore already uses.
- if (style.appearance() == NoControlPart)
- return;
-
- GtkStyleContext* context = getStyleContext(GTK_TYPE_COMBO_BOX);
- gtk_style_context_save(context);
-
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
- gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(style.direction())));
-
- gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &border);
-
- gboolean interiorFocus;
- gint focusWidth, focusPad;
- gtk_style_context_get_style(context,
- "interior-focus", &interiorFocus,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad, NULL);
- focus = interiorFocus ? focusWidth + focusPad : 0;
-
- gtk_style_context_restore(context);
-
- context = getStyleContext(GTK_TYPE_SEPARATOR);
- gtk_style_context_save(context);
-
- GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(style.direction()));
- gtk_style_context_set_direction(context, direction);
- gtk_style_context_add_class(context, "separator");
-
- gboolean wideSeparators;
- gint separatorWidth;
- gtk_style_context_get_style(context,
- "wide-separators", &wideSeparators,
- "separator-width", &separatorWidth,
- NULL);
-
- // GTK+ always uses border.left, regardless of text direction. See gtkseperator.c.
- if (!wideSeparators)
- separatorWidth = border.left;
-
- separator = separatorWidth;
-
- gtk_style_context_restore(context);
-}
-
-int RenderThemeGtk::popupInternalPaddingLeft(RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0, separatorWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
- int left = borderWidth.left + focusWidth;
- if (style.direction() == RTL)
- left += separatorWidth + minArrowSize;
- return left;
-}
-
-int RenderThemeGtk::popupInternalPaddingRight(RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0, separatorWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
- int right = borderWidth.right + focusWidth;
- if (style.direction() == LTR)
- right += separatorWidth + minArrowSize;
- return right;
-}
-
-int RenderThemeGtk::popupInternalPaddingTop(RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0, separatorWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
- return borderWidth.top + focusWidth;
-}
-
-int RenderThemeGtk::popupInternalPaddingBottom(RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0, separatorWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth, separatorWidth);
- return borderWidth.bottom + focusWidth;
-}
-
-bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& r)
-{
- // FIXME: adopt subpixel themes.
- IntRect rect = IntRect(r);
-
- cairo_t* cairoContext = paintInfo.context->platformContext()->cr();
- GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()));
-
- // Paint the button.
- GtkStyleContext* buttonStyleContext = getStyleContext(GTK_TYPE_BUTTON);
- gtk_style_context_save(buttonStyleContext);
- gtk_style_context_set_direction(buttonStyleContext, direction);
- gtk_style_context_add_class(buttonStyleContext, GTK_STYLE_CLASS_BUTTON);
- renderButton(this, buttonStyleContext, renderObject, paintInfo, rect);
-
- // Get the inner rectangle.
- gint focusWidth, focusPad;
- GtkBorder* innerBorderPtr = 0;
- GtkBorder innerBorder = { 1, 1, 1, 1 };
- gtk_style_context_get_style(buttonStyleContext,
- "inner-border", &innerBorderPtr,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad,
- NULL);
- if (innerBorderPtr) {
- innerBorder = *innerBorderPtr;
- gtk_border_free(innerBorderPtr);
- }
-
- GtkBorder borderWidth;
- GtkStateFlags state = gtk_style_context_get_state(buttonStyleContext);
- gtk_style_context_get_border(buttonStyleContext, state, &borderWidth);
-
- focusWidth += focusPad;
- IntRect innerRect(rect.x() + innerBorder.left + borderWidth.left + focusWidth,
- rect.y() + innerBorder.top + borderWidth.top + focusWidth,
- rect.width() - borderWidth.left - borderWidth.right - innerBorder.left - innerBorder.right - (2 * focusWidth),
- rect.height() - borderWidth.top - borderWidth.bottom - innerBorder.top - innerBorder.bottom - (2 * focusWidth));
-
- if (isPressed(renderObject)) {
- gint childDisplacementX;
- gint childDisplacementY;
- gtk_style_context_get_style(buttonStyleContext,
- "child-displacement-x", &childDisplacementX,
- "child-displacement-y", &childDisplacementY,
- NULL);
- innerRect.move(childDisplacementX, childDisplacementY);
- }
- innerRect.setWidth(std::max(1, innerRect.width()));
- innerRect.setHeight(std::max(1, innerRect.height()));
-
- gtk_style_context_restore(buttonStyleContext);
-
- // Paint the arrow.
- GtkStyleContext* arrowStyleContext = getStyleContext(GTK_TYPE_ARROW);
- gtk_style_context_save(arrowStyleContext);
-
- gtk_style_context_set_direction(arrowStyleContext, direction);
- gtk_style_context_add_class(arrowStyleContext, "arrow");
- gtk_style_context_add_class(arrowStyleContext, GTK_STYLE_CLASS_BUTTON);
-
- gfloat arrowScaling;
- gtk_style_context_get_style(arrowStyleContext, "arrow-scaling", &arrowScaling, NULL);
-
- IntSize arrowSize(minArrowSize, innerRect.height());
- FloatPoint arrowPosition(innerRect.location());
- if (direction == GTK_TEXT_DIR_LTR)
- arrowPosition.move(innerRect.width() - arrowSize.width(), 0);
-
- // GTK+ actually fetches the xalign and valign values from the widget, but since we
- // don't have a widget here, we are just using the default xalign and valign values of 0.5.
- gint extent = std::min(arrowSize.width(), arrowSize.height()) * arrowScaling;
- arrowPosition.move((arrowSize.width() - extent) / 2, (arrowSize.height() - extent) / 2);
-
- gtk_style_context_set_state(arrowStyleContext, state);
- gtk_render_arrow(arrowStyleContext, cairoContext, G_PI, arrowPosition.x(), arrowPosition.y(), extent);
-
- gtk_style_context_restore(arrowStyleContext);
-
- // Paint the separator if needed.
- GtkStyleContext* separatorStyleContext = getStyleContext(GTK_TYPE_COMBO_BOX);
- gtk_style_context_save(separatorStyleContext);
-
- gtk_style_context_set_direction(separatorStyleContext, direction);
- gtk_style_context_add_class(separatorStyleContext, "separator");
-
- gboolean wideSeparators;
- gint separatorWidth;
- gtk_style_context_get_style(separatorStyleContext,
- "wide-separators", &wideSeparators,
- "separator-width", &separatorWidth,
- NULL);
- if (wideSeparators && !separatorWidth) {
- gtk_style_context_restore(separatorStyleContext);
- return false;
- }
-
- gtk_style_context_set_state(separatorStyleContext, state);
- IntPoint separatorPosition(arrowPosition.x(), innerRect.y());
- if (wideSeparators) {
- if (direction == GTK_TEXT_DIR_LTR)
- separatorPosition.move(-separatorWidth, 0);
- else
- separatorPosition.move(arrowSize.width(), 0);
-
- gtk_render_frame(separatorStyleContext, cairoContext,
- separatorPosition.x(), separatorPosition.y(),
- separatorWidth, innerRect.height());
- } else {
- GtkBorder padding;
- gtk_style_context_get_padding(separatorStyleContext, state, &padding);
- GtkBorder border;
- gtk_style_context_get_border(separatorStyleContext, state, &border);
-
- if (direction == GTK_TEXT_DIR_LTR)
- separatorPosition.move(-(padding.left + border.left), 0);
- else
- separatorPosition.move(arrowSize.width(), 0);
-
- cairo_save(cairoContext);
-
- // An extra clip prevents the separator bleeding outside of the specified rectangle because of subpixel positioning.
- cairo_rectangle(cairoContext, separatorPosition.x(), separatorPosition.y(), border.left, innerRect.height());
- cairo_clip(cairoContext);
- gtk_render_line(separatorStyleContext, cairoContext,
- separatorPosition.x(), separatorPosition.y(),
- separatorPosition.x(), innerRect.maxY());
- cairo_restore(cairoContext);
- }
-
- gtk_style_context_restore(separatorStyleContext);
- return false;
-}
-
-bool RenderThemeGtk::paintTextField(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
-{
- GtkStyleContext* context = getStyleContext(GTK_TYPE_ENTRY);
- gtk_style_context_save(context);
-
- gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction())));
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_ENTRY);
-
- guint flags = 0;
- if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
- flags |= GTK_STATE_FLAG_INSENSITIVE;
- else if (isFocused(renderObject))
- flags |= GTK_STATE_FLAG_FOCUSED;
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
-
- gtk_render_background(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
- gtk_render_frame(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
-
- if (isFocused(renderObject) && isEnabled(renderObject)) {
- gboolean interiorFocus;
- gint focusWidth, focusPad;
- gtk_style_context_get_style(context,
- "interior-focus", &interiorFocus,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad,
- NULL);
- if (!interiorFocus) {
- IntRect focusRect(rect);
- focusRect.inflate(focusWidth + focusPad);
- gtk_render_focus(context, paintInfo.context->platformContext()->cr(),
- focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
- }
- }
-
- gtk_style_context_restore(context);
-
- return false;
-}
-
-static void applySliderStyleContextClasses(GtkStyleContext* context, ControlPart part)
-{
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCALE);
- if (part == SliderHorizontalPart || part == SliderThumbHorizontalPart)
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_HORIZONTAL);
- else if (part == SliderVerticalPart || part == SliderThumbVerticalPart)
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_VERTICAL);
-}
-
-bool RenderThemeGtk::paintSliderTrack(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- ControlPart part = renderObject.style().appearance();
- ASSERT_UNUSED(part, part == SliderHorizontalPart || part == SliderVerticalPart || part == MediaVolumeSliderPart);
-
- GtkStyleContext* context = getStyleContext(GTK_TYPE_SCALE);
- gtk_style_context_save(context);
-
- gtk_style_context_set_direction(context, gtkTextDirection(renderObject.style().direction()));
- applySliderStyleContextClasses(context, part);
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH);
-
- if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
- gtk_style_context_set_state(context, GTK_STATE_FLAG_INSENSITIVE);
-
- gtk_render_background(context, paintInfo.context->platformContext()->cr(),
- rect.x(), rect.y(), rect.width(), rect.height());
- gtk_render_frame(context, paintInfo.context->platformContext()->cr(),
- rect.x(), rect.y(), rect.width(), rect.height());
-
- if (isFocused(renderObject)) {
- gint focusWidth, focusPad;
- gtk_style_context_get_style(context,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad, NULL);
- IntRect focusRect(rect);
- focusRect.inflate(focusWidth + focusPad);
- gtk_render_focus(context, paintInfo.context->platformContext()->cr(),
- focusRect.x(), focusRect.y(), focusRect.width(), focusRect.height());
- }
-
- gtk_style_context_restore(context);
- return false;
-}
-
-bool RenderThemeGtk::paintSliderThumb(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- ControlPart part = renderObject.style().appearance();
- ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
-
- GtkStyleContext* context = getStyleContext(GTK_TYPE_SCALE);
- gtk_style_context_save(context);
-
- gtk_style_context_set_direction(context, gtkTextDirection(renderObject.style().direction()));
- applySliderStyleContextClasses(context, part);
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_SLIDER);
-
- guint flags = 0;
- if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
- flags |= GTK_STATE_FLAG_INSENSITIVE;
- else if (isHovered(renderObject))
- flags |= GTK_STATE_FLAG_PRELIGHT;
- if (isPressed(renderObject))
- flags |= GTK_STATE_FLAG_ACTIVE;
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
-
- gtk_render_slider(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height(),
- part == SliderThumbHorizontalPart ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
-
- gtk_style_context_restore(context);
-
- return false;
-}
-
-void RenderThemeGtk::adjustSliderThumbSize(RenderStyle& style, Element&) const
-{
- ControlPart part = style.appearance();
- if (part != SliderThumbHorizontalPart && part != SliderThumbVerticalPart)
- return;
-
- gint sliderWidth, sliderLength;
- gtk_style_context_get_style(getStyleContext(GTK_TYPE_SCALE),
- "slider-width", &sliderWidth,
- "slider-length", &sliderLength,
- NULL);
- if (part == SliderThumbHorizontalPart) {
- style.setWidth(Length(sliderLength, Fixed));
- style.setHeight(Length(sliderWidth, Fixed));
- return;
- }
- ASSERT(part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
- style.setWidth(Length(sliderWidth, Fixed));
- style.setHeight(Length(sliderLength, Fixed));
-}
-
-bool RenderThemeGtk::paintProgressBar(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- if (!renderObject.isProgress())
- return true;
-
- GtkStyleContext* context = getStyleContext(GTK_TYPE_PROGRESS_BAR);
- gtk_style_context_save(context);
-
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH);
-
- gtk_render_background(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
- gtk_render_frame(context, paintInfo.context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
-
- gtk_style_context_restore(context);
-
- gtk_style_context_save(context);
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR);
-
-
- GtkBorder padding;
- gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
- IntRect progressRect(rect.x() + padding.left, rect.y() + padding.top,
- rect.width() - (padding.left + padding.right),
- rect.height() - (padding.top + padding.bottom));
- progressRect = RenderThemeGtk::calculateProgressRect(renderObject, progressRect);
-
- if (!progressRect.isEmpty())
- gtk_render_activity(context, paintInfo.context->platformContext()->cr(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height());
-
- gtk_style_context_restore(context);
- return false;
-}
-
-static gint spinButtonArrowSize(GtkStyleContext* context)
-{
- PangoFontDescription* fontDescription;
- gtk_style_context_get(context, static_cast<GtkStateFlags>(0), "font", &fontDescription, NULL);
- gint fontSize = pango_font_description_get_size(fontDescription);
- gint arrowSize = std::max(PANGO_PIXELS(fontSize), minSpinButtonArrowSize);
- pango_font_description_free(fontDescription);
-
- return arrowSize - arrowSize % 2; // Force even.
-}
-
-void RenderThemeGtk::adjustInnerSpinButtonStyle(StyleResolver&, RenderStyle& style, Element&) const
-{
- GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
-
- GtkBorder padding;
- gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
-
- int width = spinButtonArrowSize(context) + padding.left + padding.right;
- style.setWidth(Length(width, Fixed));
- style.setMinWidth(Length(width, Fixed));
-}
-
-static void paintSpinArrowButton(RenderTheme* theme, GtkStyleContext* context, const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect, GtkArrowType arrowType)
-{
- ASSERT(arrowType == GTK_ARROW_UP || arrowType == GTK_ARROW_DOWN);
-
- gtk_style_context_save(context);
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
-
- GtkTextDirection direction = gtk_style_context_get_direction(context);
- guint state = static_cast<guint>(gtk_style_context_get_state(context));
- if (!(state & GTK_STATE_FLAG_INSENSITIVE)) {
- if (theme->isPressed(renderObject)) {
- if ((arrowType == GTK_ARROW_UP && theme->isSpinUpButtonPartPressed(renderObject))
- || (arrowType == GTK_ARROW_DOWN && !theme->isSpinUpButtonPartPressed(renderObject)))
- state |= GTK_STATE_FLAG_ACTIVE;
- } else if (theme->isHovered(renderObject)) {
- if ((arrowType == GTK_ARROW_UP && theme->isSpinUpButtonPartHovered(renderObject))
- || (arrowType == GTK_ARROW_DOWN && !theme->isSpinUpButtonPartHovered(renderObject)))
- state |= GTK_STATE_FLAG_PRELIGHT;
- }
- }
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(state));
-
- // Paint button.
- IntRect buttonRect(rect);
- guint junction = gtk_style_context_get_junction_sides(context);
- if (arrowType == GTK_ARROW_UP)
- junction |= GTK_JUNCTION_BOTTOM;
- else {
- junction |= GTK_JUNCTION_TOP;
- buttonRect.move(0, rect.height() / 2);
- }
- buttonRect.setHeight(rect.height() / 2);
- gtk_style_context_set_junction_sides(context, static_cast<GtkJunctionSides>(junction));
-
- gtk_render_background(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
- gtk_render_frame(context, paintInfo.context->platformContext()->cr(), buttonRect.x(), buttonRect.y(), buttonRect.width(), buttonRect.height());
-
- // Paint arrow centered inside button.
- // This code is based on gtkspinbutton.c code.
- IntRect arrowRect;
- gdouble angle;
- if (arrowType == GTK_ARROW_UP) {
- angle = 0;
- arrowRect.setY(rect.y());
- arrowRect.setHeight(rect.height() / 2 - 2);
- } else {
- angle = G_PI;
- arrowRect.setY(rect.y() + buttonRect.y());
- arrowRect.setHeight(rect.height() - arrowRect.y() - 2);
- }
- arrowRect.setWidth(rect.width() - 3);
- if (direction == GTK_TEXT_DIR_LTR)
- arrowRect.setX(rect.x() + 1);
- else
- arrowRect.setX(rect.x() + 2);
-
- gint width = arrowRect.width() / 2;
- width -= width % 2 - 1; // Force odd.
- gint height = (width + 1) / 2;
-
- arrowRect.move((arrowRect.width() - width) / 2, (arrowRect.height() - height) / 2);
- gtk_render_arrow(context, paintInfo.context->platformContext()->cr(), angle, arrowRect.x(), arrowRect.y(), width);
-
- gtk_style_context_restore(context);
-}
-
-bool RenderThemeGtk::paintInnerSpinButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
-{
- GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
- gtk_style_context_save(context);
-
- GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()));
- gtk_style_context_set_direction(context, direction);
-
- guint flags = 0;
- if (!isEnabled(renderObject) || isReadOnlyControl(renderObject))
- flags |= GTK_STATE_FLAG_INSENSITIVE;
- else if (isFocused(renderObject))
- flags |= GTK_STATE_FLAG_FOCUSED;
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
- gtk_style_context_remove_class(context, GTK_STYLE_CLASS_ENTRY);
-
- paintSpinArrowButton(this, context, renderObject, paintInfo, rect, GTK_ARROW_UP);
- paintSpinArrowButton(this, context, renderObject, paintInfo, rect, GTK_ARROW_DOWN);
-
- gtk_style_context_restore(context);
-
- return false;
-}
-
-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);
-
- gtk_style_context_save(context);
-
- guint flags = 0;
- if (state == GTK_STATE_PRELIGHT)
- flags |= GTK_STATE_FLAG_PRELIGHT;
- else if (state == GTK_STATE_INSENSITIVE)
- flags |= GTK_STATE_FLAG_INSENSITIVE;
-
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
- gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(direction));
- GdkPixbuf* icon = gtk_icon_set_render_icon_pixbuf(iconSet, context, static_cast<GtkIconSize>(iconSize));
-
- gtk_style_context_restore(context);
-
- return adoptGRef(icon);
-}
-
-GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, const char* symbolicIconName, const char* fallbackStockIconName, gint direction, gint state, gint iconSize)
-{
- GtkStyleContext* context = getStyleContext(widgetType);
-
- gtk_style_context_save(context);
-
- guint flags = 0;
- if (state == GTK_STATE_PRELIGHT)
- flags |= GTK_STATE_FLAG_PRELIGHT;
- else if (state == GTK_STATE_INSENSITIVE)
- flags |= GTK_STATE_FLAG_INSENSITIVE;
-
- gtk_style_context_set_state(context, static_cast<GtkStateFlags>(flags));
- gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(direction));
- GtkIconInfo* info = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), symbolicIconName, iconSize,
- static_cast<GtkIconLookupFlags>(GTK_ICON_LOOKUP_FORCE_SVG | GTK_ICON_LOOKUP_FORCE_SIZE));
- GdkPixbuf* icon = 0;
- if (info) {
- icon = gtk_icon_info_load_symbolic_for_context(info, context, 0, 0);
- gtk_icon_info_free(info);
- }
-
- gtk_style_context_restore(context);
-
- if (!icon) {
- if (!fallbackStockIconName)
- return nullptr;
- return getStockIconForWidgetType(widgetType, fallbackStockIconName, direction, state, iconSize);
- }
-
- return adoptGRef(icon);
-}
-
-Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::platformInactiveSelectionBackgroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_ENTRY), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::platformActiveSelectionForegroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::platformInactiveSelectionForegroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::platformActiveListBoxSelectionBackgroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_TREE_VIEW), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::platformInactiveListBoxSelectionBackgroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_background_color(getStyleContext(GTK_TYPE_TREE_VIEW), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::platformActiveListBoxSelectionForegroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_color(getStyleContext(GTK_TYPE_TREE_VIEW), static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::platformInactiveListBoxSelectionForegroundColor() const
-{
- GdkRGBA gdkRGBAColor;
- gtk_style_context_get_color(getStyleContext(GTK_TYPE_TREE_VIEW), GTK_STATE_FLAG_SELECTED, &gdkRGBAColor);
- return gdkRGBAColor;
-}
-
-Color RenderThemeGtk::systemColor(CSSValueID cssValueId) const
-{
- GdkRGBA gdkRGBAColor;
-
- switch (cssValueId) {
- case CSSValueButtontext:
- gtk_style_context_get_color(getStyleContext(GTK_TYPE_BUTTON), GTK_STATE_FLAG_ACTIVE, &gdkRGBAColor);
- return gdkRGBAColor;
- case CSSValueCaptiontext:
- gtk_style_context_get_color(getStyleContext(GTK_TYPE_ENTRY), static_cast<GtkStateFlags>(0), &gdkRGBAColor);
- return gdkRGBAColor;
- default:
- return RenderTheme::systemColor(cssValueId);
- }
-}
-
-} // namespace WebCore
-
-#endif // !GTK_API_VERSION_2
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkScrollbarThemeGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp (173108 => 173109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp        2014-08-29 03:56:17 UTC (rev 173108)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp        2014-08-29 07:39:13 UTC (rev 173109)
</span><span class="lines">@@ -26,10 +26,13 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "ScrollbarThemeGtk.h"
</span><span class="cx">
</span><ins>+#include "PlatformContextCairo.h"
</ins><span class="cx"> #include "PlatformMouseEvent.h"
</span><span class="cx"> #include "RenderThemeGtk.h"
</span><span class="cx"> #include "ScrollView.h"
</span><span class="cx"> #include "Scrollbar.h"
</span><ins>+#include <gtk/gtk.h>
+#include <wtf/NeverDestroyed.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -50,6 +53,7 @@
</span><span class="cx"> // painting the thumb can be skipped. We don't have to be exact here.
</span><span class="cx"> return thumbLength(scrollbar) > 0;
</span><span class="cx"> #else
</span><ins>+ UNUSED_PARAM(scrollbar);
</ins><span class="cx"> return false;
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -75,6 +79,8 @@
</span><span class="cx"> // VerticalScrollbar alternate button
</span><span class="cx"> return IntRect(x, scrollbar->y() + scrollbar->height() - m_troughBorderWidth - (2 * size.height()), size.width(), size.height());
</span><span class="cx"> #else
</span><ins>+ UNUSED_PARAM(scrollbar);
+ UNUSED_PARAM(part);
</ins><span class="cx"> return IntRect();
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -105,6 +111,8 @@
</span><span class="cx"> // ForwardButtonStartPart (alternate button)
</span><span class="cx"> return IntRect(x, scrollbar->y() + m_troughBorderWidth + size.height(), size.width(), size.height());
</span><span class="cx"> #else
</span><ins>+ UNUSED_PARAM(scrollbar);
+ UNUSED_PARAM(part);
</ins><span class="cx"> return IntRect();
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -149,41 +157,69 @@
</span><span class="cx"> return IntRect(scrollbar->x(), scrollbar->y() + movementAxisPadding + startButtonsOffset,
</span><span class="cx"> thickness, scrollbar->height() - (2 * movementAxisPadding) - buttonsWidth);
</span><span class="cx"> #else
</span><ins>+ UNUSED_PARAM(scrollbar);
</ins><span class="cx"> return IntRect();
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #ifndef GTK_API_VERSION_2
</span><del>-static HashSet<ScrollbarThemeClient*>* gScrollbars;
</del><ins>+static void gtkStyleChangedCallback(GtkWidget*, ScrollbarThemeGtk* scrollbarTheme)
+{
+ scrollbarTheme->updateThemeProperties();
+}
</ins><span class="cx">
</span><ins>+ScrollbarThemeGtk::ScrollbarThemeGtk()
+ : m_context(static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get())->gtkScrollbarStyle())
+{
+ updateThemeProperties();
+ g_signal_connect(m_context, "changed", G_CALLBACK(gtkStyleChangedCallback), this);
+}
+
+void ScrollbarThemeGtk::updateThemeProperties()
+{
+ gtk_style_context_get_style(
+ m_context,
+ "min-slider-length", &m_minThumbLength,
+ "slider-width", &m_thumbFatness,
+ "trough-border", &m_troughBorderWidth,
+ "stepper-size", &m_stepperSize,
+ "stepper-spacing", &m_stepperSpacing,
+ "trough-under-steppers", &m_troughUnderSteppers,
+ "has-backward-stepper", &m_hasBackButtonStartPart,
+ "has-forward-stepper", &m_hasForwardButtonEndPart,
+ "has-secondary-backward-stepper", &m_hasBackButtonEndPart,
+ "has-secondary-forward-stepper", &m_hasForwardButtonStartPart,
+ nullptr);
+ updateScrollbarsFrameThickness();
+}
+
+typedef HashSet<ScrollbarThemeClient*> ScrollbarMap;
+
+static ScrollbarMap& scrollbarMap()
+{
+ static NeverDestroyed<ScrollbarMap> map;
+ return map;
+}
+
</ins><span class="cx"> void ScrollbarThemeGtk::registerScrollbar(ScrollbarThemeClient* scrollbar)
</span><span class="cx"> {
</span><del>- if (!gScrollbars)
- gScrollbars = new HashSet<ScrollbarThemeClient*>;
- gScrollbars->add(scrollbar);
</del><ins>+ scrollbarMap().add(scrollbar);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollbarThemeGtk::unregisterScrollbar(ScrollbarThemeClient* scrollbar)
</span><span class="cx"> {
</span><del>- gScrollbars->remove(scrollbar);
- if (gScrollbars->isEmpty()) {
- delete gScrollbars;
- gScrollbars = 0;
- }
</del><ins>+ scrollbarMap().remove(scrollbar);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollbarThemeGtk::updateScrollbarsFrameThickness()
</span><span class="cx"> {
</span><del>- if (!gScrollbars)
</del><ins>+ if (scrollbarMap().isEmpty())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // Update the thickness of every interior frame scrollbar widget. The
</span><span class="cx"> // platform-independent scrollbar them code isn't yet smart enough to get
</span><span class="cx"> // this information when it paints.
</span><del>- HashSet<ScrollbarThemeClient*>::iterator end = gScrollbars->end();
- for (HashSet<ScrollbarThemeClient*>::iterator it = gScrollbars->begin(); it != end; ++it) {
- ScrollbarThemeClient* scrollbar = (*it);
-
</del><ins>+ for (const auto& scrollbar : scrollbarMap()) {
</ins><span class="cx"> // Top-level scrollbar i.e. scrollbars who have a parent ScrollView
</span><span class="cx"> // with no parent are native, and thus do not need to be resized.
</span><span class="cx"> if (!scrollbar->parent() || !scrollbar->parent()->parent())
</span><span class="lines">@@ -208,6 +244,113 @@
</span><span class="cx"> return IntRect(trackRect.x() + (trackRect.width() - m_thumbFatness) / 2, trackRect.y() + thumbPos, m_thumbFatness, thumbLength(scrollbar));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void applyScrollbarStyleContextClasses(GtkStyleContext* context, ScrollbarOrientation orientation)
+{
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCROLLBAR);
+ gtk_style_context_add_class(context, orientation == VerticalScrollbar ? GTK_STYLE_CLASS_VERTICAL : GTK_STYLE_CLASS_HORIZONTAL);
+}
+
+void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
+{
+ // Paint the track background. If the trough-under-steppers property is true, this
+ // should be the full size of the scrollbar, but if is false, it should only be the
+ // track rect.
+ IntRect fullScrollbarRect(rect);
+ if (m_troughUnderSteppers)
+ fullScrollbarRect = IntRect(scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
+
+ gtk_style_context_save(m_context);
+
+ applyScrollbarStyleContextClasses(m_context, scrollbar->orientation());
+ gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_TROUGH);
+
+ gtk_render_background(m_context, context->platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+ gtk_render_frame(m_context, context->platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
+
+ gtk_style_context_restore(m_context);
+}
+
+void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
+{
+ gtk_style_context_save(m_context);
+
+ applyScrollbarStyleContextClasses(m_context, scrollbar->orientation());
+ gtk_style_context_add_class(m_context, "scrolled-window");
+ gtk_render_frame(m_context, context->platformContext()->cr(), scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
+
+ gtk_style_context_restore(m_context);
+}
+
+void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
+{
+ gtk_style_context_save(m_context);
+
+ ScrollbarOrientation orientation = scrollbar->orientation();
+ applyScrollbarStyleContextClasses(m_context, orientation);
+ gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SLIDER);
+
+ guint flags = 0;
+ if (scrollbar->pressedPart() == ThumbPart)
+ flags |= GTK_STATE_FLAG_ACTIVE;
+ if (scrollbar->hoveredPart() == ThumbPart)
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ gtk_style_context_set_state(m_context, static_cast<GtkStateFlags>(flags));
+
+ gtk_render_slider(m_context, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height(),
+ orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
+
+ gtk_style_context_restore(m_context);
+}
+
+void ScrollbarThemeGtk::paintButton(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part)
+{
+ gtk_style_context_save(m_context);
+
+ ScrollbarOrientation orientation = scrollbar->orientation();
+ applyScrollbarStyleContextClasses(m_context, orientation);
+
+ guint flags = 0;
+ if ((BackButtonStartPart == part && scrollbar->currentPos())
+ || (BackButtonEndPart == part && scrollbar->currentPos())
+ || (ForwardButtonEndPart == part && scrollbar->currentPos() != scrollbar->maximum())
+ || (ForwardButtonStartPart == part && scrollbar->currentPos() != scrollbar->maximum())) {
+ if (part == scrollbar->pressedPart())
+ flags |= GTK_STATE_FLAG_ACTIVE;
+ if (part == scrollbar->hoveredPart())
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ } else
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ gtk_style_context_set_state(m_context, static_cast<GtkStateFlags>(flags));
+
+ gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_BUTTON);
+ gtk_render_background(m_context, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+ gtk_render_frame(m_context, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
+
+ gfloat arrowScaling;
+ gtk_style_context_get_style(m_context, "arrow-scaling", &arrowScaling, nullptr);
+
+ double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling;
+ FloatPoint arrowPoint(
+ rect.x() + (rect.width() - arrowSize) / 2,
+ rect.y() + (rect.height() - arrowSize) / 2);
+
+ if (flags & GTK_STATE_FLAG_ACTIVE) {
+ gint arrowDisplacementX, arrowDisplacementY;
+ gtk_style_context_get_style(m_context, "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);
+ arrowPoint.move(arrowDisplacementX, arrowDisplacementY);
+ }
+
+ gdouble angle;
+ if (orientation == VerticalScrollbar)
+ angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI : 0;
+ else
+ angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2);
+
+ gtk_render_arrow(m_context, context->platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
+
+ gtk_style_context_restore(m_context);
+}
+
</ins><span class="cx"> bool ScrollbarThemeGtk::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect)
</span><span class="cx"> {
</span><span class="cx"> if (graphicsContext->paintingDisabled())
</span><span class="lines">@@ -254,8 +397,7 @@
</span><span class="cx"> scrollMask |= ThumbPart;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- ScrollbarControlPartMask allButtons = BackButtonStartPart | BackButtonEndPart
- | ForwardButtonStartPart | ForwardButtonEndPart;
</del><ins>+ ScrollbarControlPartMask allButtons = BackButtonStartPart | BackButtonEndPart | ForwardButtonStartPart | ForwardButtonEndPart;
</ins><span class="cx"> if (scrollMask & TrackBGPart || scrollMask & ThumbPart || scrollMask & allButtons)
</span><span class="cx"> paintScrollbarBackground(graphicsContext, scrollbar);
</span><span class="cx"> paintTrackBackground(graphicsContext, scrollbar, trackPaintRect);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkScrollbarThemeGtk3cpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp (173108 => 173109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp        2014-08-29 03:56:17 UTC (rev 173108)
+++ trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp        2014-08-29 07:39:13 UTC (rev 173109)
</span><span class="lines">@@ -1,183 +0,0 @@
</span><del>-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollbarThemeGtk.h"
-
-#ifndef GTK_API_VERSION_2
-
-#include "PlatformContextCairo.h"
-#include "PlatformMouseEvent.h"
-#include "RenderThemeGtk.h"
-#include "ScrollView.h"
-#include "Scrollbar.h"
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-static void gtkStyleChangedCallback(GtkWidget*, ScrollbarThemeGtk* scrollbarTheme)
-{
- scrollbarTheme->updateThemeProperties();
-}
-
-ScrollbarThemeGtk::ScrollbarThemeGtk()
- : m_context(static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get())->gtkScrollbarStyle())
-{
- updateThemeProperties();
- g_signal_connect(m_context, "changed", G_CALLBACK(gtkStyleChangedCallback), this);
-}
-
-void ScrollbarThemeGtk::updateThemeProperties()
-{
- gtk_style_context_get_style(m_context,
- "min-slider-length", &m_minThumbLength,
- "slider-width", &m_thumbFatness,
- "trough-border", &m_troughBorderWidth,
- "stepper-size", &m_stepperSize,
- "stepper-spacing", &m_stepperSpacing,
- "trough-under-steppers", &m_troughUnderSteppers,
- "has-backward-stepper", &m_hasBackButtonStartPart,
- "has-forward-stepper", &m_hasForwardButtonEndPart,
- "has-secondary-backward-stepper", &m_hasBackButtonEndPart,
- "has-secondary-forward-stepper", &m_hasForwardButtonStartPart,
- NULL);
- updateScrollbarsFrameThickness();
-}
-
-static void applyScrollbarStyleContextClasses(GtkStyleContext* context, ScrollbarOrientation orientation)
-{
- gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCROLLBAR);
- gtk_style_context_add_class(context, orientation == VerticalScrollbar ? GTK_STYLE_CLASS_VERTICAL : GTK_STYLE_CLASS_HORIZONTAL);
-}
-
-void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
-{
- // Paint the track background. If the trough-under-steppers property is true, this
- // should be the full size of the scrollbar, but if is false, it should only be the
- // track rect.
- IntRect fullScrollbarRect(rect);
- if (m_troughUnderSteppers)
- fullScrollbarRect = IntRect(scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
-
- gtk_style_context_save(m_context);
-
- applyScrollbarStyleContextClasses(m_context, scrollbar->orientation());
- gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_TROUGH);
-
- gtk_render_background(m_context, context->platformContext()->cr(),
- fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
- gtk_render_frame(m_context, context->platformContext()->cr(),
- fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height());
-
- gtk_style_context_restore(m_context);
-}
-
-void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
-{
- gtk_style_context_save(m_context);
-
- applyScrollbarStyleContextClasses(m_context, scrollbar->orientation());
- gtk_style_context_add_class(m_context, "scrolled-window");
- gtk_render_frame(m_context, context->platformContext()->cr(), scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());
-
- gtk_style_context_restore(m_context);
-}
-
-void ScrollbarThemeGtk::paintThumb(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
-{
- gtk_style_context_save(m_context);
-
- ScrollbarOrientation orientation = scrollbar->orientation();
- applyScrollbarStyleContextClasses(m_context, orientation);
- gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_SLIDER);
-
- guint flags = 0;
- if (scrollbar->pressedPart() == ThumbPart)
- flags |= GTK_STATE_FLAG_ACTIVE;
- if (scrollbar->hoveredPart() == ThumbPart)
- flags |= GTK_STATE_FLAG_PRELIGHT;
- gtk_style_context_set_state(m_context, static_cast<GtkStateFlags>(flags));
-
- gtk_render_slider(m_context, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height(),
- orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
-
- gtk_style_context_restore(m_context);
-}
-
-void ScrollbarThemeGtk::paintButton(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part)
-{
- gtk_style_context_save(m_context);
-
- ScrollbarOrientation orientation = scrollbar->orientation();
- applyScrollbarStyleContextClasses(m_context, orientation);
-
- guint flags = 0;
- if ((BackButtonStartPart == part && scrollbar->currentPos())
- || (BackButtonEndPart == part && scrollbar->currentPos())
- || (ForwardButtonEndPart == part && scrollbar->currentPos() != scrollbar->maximum())
- || (ForwardButtonStartPart == part && scrollbar->currentPos() != scrollbar->maximum())) {
- if (part == scrollbar->pressedPart())
- flags |= GTK_STATE_FLAG_ACTIVE;
- if (part == scrollbar->hoveredPart())
- flags |= GTK_STATE_FLAG_PRELIGHT;
- } else
- flags |= GTK_STATE_FLAG_INSENSITIVE;
- gtk_style_context_set_state(m_context, static_cast<GtkStateFlags>(flags));
-
- gtk_style_context_add_class(m_context, GTK_STYLE_CLASS_BUTTON);
- gtk_render_background(m_context, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
- gtk_render_frame(m_context, context->platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height());
-
- gfloat arrowScaling;
- gtk_style_context_get_style(m_context, "arrow-scaling", &arrowScaling, NULL);
-
- double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling;
- FloatPoint arrowPoint(rect.x() + (rect.width() - arrowSize) / 2,
- rect.y() + (rect.height() - arrowSize) / 2);
-
- if (flags & GTK_STATE_FLAG_ACTIVE) {
- gint arrowDisplacementX, arrowDisplacementY;
- gtk_style_context_get_style(m_context,
- "arrow-displacement-x", &arrowDisplacementX,
- "arrow-displacement-y", &arrowDisplacementY,
- NULL);
- arrowPoint.move(arrowDisplacementX, arrowDisplacementY);
- }
-
- gdouble angle;
- if (orientation == VerticalScrollbar) {
- angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI : 0;
- } else {
- angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2);
- }
-
- gtk_render_arrow(m_context, context->platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize);
-
- gtk_style_context_restore(m_context);
-}
-
-} // namespace WebCore
-
-#endif // !GTK_API_VERSION_2
</del></span></pre>
</div>
</div>
</body>
</html>