summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/platform/gtk/RenderThemeGtk2.cpp')
-rw-r--r--Source/WebCore/platform/gtk/RenderThemeGtk2.cpp108
1 files changed, 87 insertions, 21 deletions
diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp b/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
index fd391b7..e01508e 100644
--- a/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
+++ b/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp
@@ -32,6 +32,7 @@
#include "GtkVersioning.h"
#include "HTMLNames.h"
#include "MediaControlElements.h"
+#include "PaintInfo.h"
#include "RenderObject.h"
#include "TextDirection.h"
#include "UserAgentStyleSheets.h"
@@ -49,6 +50,45 @@ namespace WebCore {
// This is not a static method, because we want to avoid having GTK+ headers in RenderThemeGtk.h.
extern GtkTextDirection gtkTextDirection(TextDirection);
+static int mozGtkRefCount = 0;
+void RenderThemeGtk::platformInit()
+{
+ m_themePartsHaveRGBAColormap = true;
+ m_gtkWindow = 0;
+ m_gtkContainer = 0;
+ m_gtkButton = 0;
+ m_gtkEntry = 0;
+ m_gtkTreeView = 0;
+ m_gtkVScale = 0;
+ m_gtkHScale = 0;
+
+ memset(&m_themeParts, 0, sizeof(GtkThemeParts));
+ GdkColormap* colormap = gdk_screen_get_rgba_colormap(gdk_screen_get_default());
+ if (!colormap) {
+ m_themePartsHaveRGBAColormap = false;
+ colormap = gdk_screen_get_default_colormap(gdk_screen_get_default());
+ }
+ m_themeParts.colormap = colormap;
+
+ // Initialize the Mozilla theme drawing code.
+ if (!mozGtkRefCount) {
+ moz_gtk_init();
+ moz_gtk_use_theme_parts(&m_themeParts);
+ }
+ ++mozGtkRefCount;
+}
+
+RenderThemeGtk::~RenderThemeGtk()
+{
+ --mozGtkRefCount;
+
+ if (!mozGtkRefCount)
+ moz_gtk_shutdown();
+
+ if (m_gtkWindow)
+ gtk_widget_destroy(m_gtkWindow);
+}
+
#if ENABLE(VIDEO)
void RenderThemeGtk::initMediaColors()
{
@@ -63,13 +103,13 @@ void RenderThemeGtk::adjustRepaintRect(const RenderObject*, IntRect&)
{
}
-GtkStateType RenderThemeGtk::getGtkStateType(RenderObject* object)
+static GtkStateType getGtkStateType(RenderThemeGtk* theme, RenderObject* object)
{
- if (!isEnabled(object) || isReadOnlyControl(object))
+ if (!theme->isEnabled(object) || theme->isReadOnlyControl(object))
return GTK_STATE_INSENSITIVE;
- if (isPressed(object))
+ if (theme->isPressed(object))
return GTK_STATE_ACTIVE;
- if (isHovered(object))
+ if (theme->isHovered(object))
return GTK_STATE_PRELIGHT;
return GTK_STATE_NORMAL;
}
@@ -102,6 +142,18 @@ bool RenderThemeGtk::paintRenderObject(GtkThemeWidgetType type, RenderObject* re
gtkTextDirection(renderObject->style()->direction()));
}
+void RenderThemeGtk::getIndicatorMetrics(ControlPart part, int& indicatorSize, int& indicatorSpacing)
+{
+ ASSERT(part == CheckboxPart || part == RadioPart);
+ if (part == CheckboxPart) {
+ moz_gtk_checkbox_get_metrics(&indicatorSize, &indicatorSpacing);
+ return;
+ }
+
+ // RadioPart
+ moz_gtk_radio_get_metrics(&indicatorSize, &indicatorSpacing);
+}
+
static void setToggleSize(const RenderThemeGtk* theme, RenderStyle* style, ControlPart appearance)
{
// The width and height are both specified, so we shouldn't change them.
@@ -110,7 +162,7 @@ static void setToggleSize(const RenderThemeGtk* theme, RenderStyle* style, Contr
// FIXME: This is probably not correct use of indicatorSize and indicatorSpacing.
gint indicatorSize, indicatorSpacing;
- theme->getIndicatorMetrics(appearance, indicatorSize, indicatorSpacing);
+ RenderThemeGtk::getIndicatorMetrics(appearance, indicatorSize, indicatorSpacing);
// Other ports hard-code this to 13, but GTK+ users tend to demand the native look.
// It could be made a configuration option values other than 13 actually break site compatibility.
@@ -151,7 +203,7 @@ bool RenderThemeGtk::paintButton(RenderObject* object, const PaintInfo& info, co
IntRect buttonRect(IntPoint(), rect.size());
IntRect focusRect(buttonRect);
- GtkStateType state = getGtkStateType(object);
+ GtkStateType state = getGtkStateType(this, object);
gtk_widget_set_state(widget, state);
gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction()));
@@ -248,24 +300,24 @@ bool RenderThemeGtk::paintSliderTrack(RenderObject* object, const PaintInfo& inf
return false;
ControlPart part = object->style()->appearance();
- ASSERT(part == SliderHorizontalPart || part == SliderVerticalPart);
+ ASSERT(part == SliderHorizontalPart || part == SliderVerticalPart || part == MediaVolumeSliderPart);
// We shrink the trough rect slightly to make room for the focus indicator.
IntRect troughRect(IntPoint(), rect.size()); // This is relative to rect.
GtkWidget* widget = 0;
- if (part == SliderVerticalPart) {
- widget = gtkVScale();
- troughRect.inflateY(-gtk_widget_get_style(widget)->ythickness);
- } else {
+ if (part == SliderHorizontalPart) {
widget = gtkHScale();
troughRect.inflateX(-gtk_widget_get_style(widget)->xthickness);
+ } else {
+ widget = gtkVScale();
+ troughRect.inflateY(-gtk_widget_get_style(widget)->ythickness);
}
gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction()));
WidgetRenderingContext widgetContext(info.context, rect);
widgetContext.gtkPaintBox(troughRect, widget, GTK_STATE_ACTIVE, GTK_SHADOW_OUT, "trough");
if (isFocused(object))
- widgetContext.gtkPaintFocus(IntRect(IntPoint(), rect.size()), widget, getGtkStateType(object), "trough");
+ widgetContext.gtkPaintFocus(IntRect(IntPoint(), rect.size()), widget, getGtkStateType(this, object), "trough");
return false;
}
@@ -276,19 +328,19 @@ bool RenderThemeGtk::paintSliderThumb(RenderObject* object, const PaintInfo& inf
return false;
ControlPart part = object->style()->appearance();
- ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart);
+ ASSERT(part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
GtkWidget* widget = 0;
const char* detail = 0;
GtkOrientation orientation;
- if (part == SliderThumbVerticalPart) {
- widget = gtkVScale();
- detail = "vscale";
- orientation = GTK_ORIENTATION_VERTICAL;
- } else {
+ if (part == SliderThumbHorizontalPart) {
widget = gtkHScale();
detail = "hscale";
orientation = GTK_ORIENTATION_HORIZONTAL;
+ } else {
+ widget = gtkVScale();
+ detail = "vscale";
+ orientation = GTK_ORIENTATION_VERTICAL;
}
gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction()));
@@ -298,7 +350,7 @@ bool RenderThemeGtk::paintSliderThumb(RenderObject* object, const PaintInfo& inf
// on them.
IntRect thumbRect(IntPoint(), rect.size());
WidgetRenderingContext widgetContext(info.context, rect);
- widgetContext.gtkPaintSlider(thumbRect, widget, getGtkStateType(object), GTK_SHADOW_OUT, detail, orientation);
+ widgetContext.gtkPaintSlider(thumbRect, widget, getGtkStateType(this, object), GTK_SHADOW_OUT, detail, orientation);
return false;
}
@@ -306,7 +358,7 @@ void RenderThemeGtk::adjustSliderThumbSize(RenderObject* o) const
{
ControlPart part = o->style()->appearance();
#if ENABLE(VIDEO)
- if (part == MediaSliderThumbPart || part == MediaVolumeSliderThumbPart) {
+ if (part == MediaSliderThumbPart) {
adjustMediaSliderThumbSize(o);
return;
}
@@ -324,12 +376,26 @@ void RenderThemeGtk::adjustSliderThumbSize(RenderObject* o) const
o->style()->setHeight(Length(width, Fixed));
return;
}
- ASSERT(part == SliderThumbVerticalPart);
+ ASSERT(part == SliderThumbVerticalPart || part == MediaVolumeSliderThumbPart);
o->style()->setWidth(Length(width, Fixed));
o->style()->setHeight(Length(length, Fixed));
}
#if ENABLE(PROGRESS_TAG)
+double RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress*) const
+{
+ // FIXME: It doesn't look like there is a good way yet to support animated
+ // progress bars with the Mozilla theme drawing code.
+ return 0;
+}
+
+double RenderThemeGtk::animationDurationForProgressBar(RenderProgress*) const
+{
+ // FIXME: It doesn't look like there is a good way yet to support animated
+ // progress bars with the Mozilla theme drawing code.
+ return 0;
+}
+
bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
{
if (!renderObject->isProgress())