summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/gtk/RenderThemeGtk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/gtk/RenderThemeGtk.cpp')
-rw-r--r--WebCore/platform/gtk/RenderThemeGtk.cpp73
1 files changed, 51 insertions, 22 deletions
diff --git a/WebCore/platform/gtk/RenderThemeGtk.cpp b/WebCore/platform/gtk/RenderThemeGtk.cpp
index 0113b9e..bf8b8d7 100644
--- a/WebCore/platform/gtk/RenderThemeGtk.cpp
+++ b/WebCore/platform/gtk/RenderThemeGtk.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2007 Apple Inc.
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2008 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -20,9 +21,12 @@
*/
#include "config.h"
+#include "RenderThemeGtk.h"
+
+#include "AffineTransform.h"
+#include "GraphicsContext.h"
#include "NotImplemented.h"
#include "RenderObject.h"
-#include "RenderThemeGtk.h"
#include "gtkdrawing.h"
#include <gdk/gdk.h>
@@ -35,25 +39,31 @@ RenderTheme* theme()
return &gtkTheme;
}
+static bool mozGtkInitialized = false;
+
RenderThemeGtk::RenderThemeGtk()
: m_gtkWindow(0)
, m_gtkContainer(0)
, m_gtkEntry(0)
, m_gtkTreeView(0)
{
+ if (!mozGtkInitialized) {
+ mozGtkInitialized = true;
+ moz_gtk_init();
+ }
}
-static bool supportsFocus(EAppearance appearance)
+static bool supportsFocus(ControlPart appearance)
{
switch (appearance) {
- case PushButtonAppearance:
- case ButtonAppearance:
- case TextFieldAppearance:
- case TextAreaAppearance:
- case SearchFieldAppearance:
- case MenulistAppearance:
- case RadioAppearance:
- case CheckboxAppearance:
+ case PushButtonPart:
+ case ButtonPart:
+ case TextFieldPart:
+ case TextAreaPart:
+ case SearchFieldPart:
+ case MenulistPart:
+ case RadioPart:
+ case CheckboxPart:
return true;
default:
return false;
@@ -70,11 +80,11 @@ bool RenderThemeGtk::controlSupportsTints(const RenderObject* o) const
return isEnabled(o);
}
-short RenderThemeGtk::baselinePosition(const RenderObject* o) const
+int RenderThemeGtk::baselinePosition(const RenderObject* o) const
{
// FIXME: This strategy is possibly incorrect for the GTK+ port.
- if (o->style()->appearance() == CheckboxAppearance ||
- o->style()->appearance() == RadioAppearance)
+ if (o->style()->appearance() == CheckboxPart ||
+ o->style()->appearance() == RadioPart)
return o->marginTop() + o->height() - 2;
return RenderTheme::baselinePosition(o);
}
@@ -151,12 +161,31 @@ static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderOb
break;
}
- IntPoint pos = i.context->translatePoint(rect.location());
+ AffineTransform ctm = i.context->getCTM();
+
+ IntPoint pos = ctm.mapPoint(rect.location());
GdkRectangle gdkRect = IntRect(pos.x(), pos.y(), rect.width(), rect.height());
GtkTextDirection direction = gtkTextDirection(o->style()->direction());
- // FIXME: Pass the real clip region.
- return moz_gtk_widget_paint(type, i.context->gdkDrawable(), &gdkRect, &gdkRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS;
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,4,0)
+ // Find the clip rectangle
+ cairo_t *cr = i.context->platformContext();
+ double clipX1, clipX2, clipY1, clipY2;
+ cairo_clip_extents(cr, &clipX1, &clipY1, &clipX2, &clipY2);
+
+ GdkRectangle gdkClipRect;
+ gdkClipRect.width = clipX2 - clipX1;
+ gdkClipRect.height = clipY2 - clipY1;
+ IntPoint clipPos = ctm.mapPoint(IntPoint(clipX1, clipY1));
+ gdkClipRect.x = clipPos.x();
+ gdkClipRect.y = clipPos.y();
+
+ gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect);
+#else
+ GdkRectangle gdkClipRect = gdkRect;
+#endif
+
+ return moz_gtk_widget_paint(type, i.context->gdkDrawable(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS;
}
static void setButtonPadding(RenderStyle* style)
@@ -169,7 +198,7 @@ static void setButtonPadding(RenderStyle* style)
style->setPaddingBottom(Length(padding / 2, Fixed));
}
-static void setToggleSize(RenderStyle* style, EAppearance appearance)
+static void setToggleSize(RenderStyle* style, ControlPart appearance)
{
// The width and height are both specified, so we shouldn't change them.
if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
@@ -179,11 +208,11 @@ static void setToggleSize(RenderStyle* style, EAppearance appearance)
gint indicator_size, indicator_spacing;
switch (appearance) {
- case CheckboxAppearance:
+ case CheckboxPart:
if (moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS)
return;
break;
- case RadioAppearance:
+ case RadioPart:
if (moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS)
return;
break;
@@ -203,7 +232,7 @@ static void setToggleSize(RenderStyle* style, EAppearance appearance)
void RenderThemeGtk::setCheckboxSize(RenderStyle* style) const
{
- setToggleSize(style, RadioAppearance);
+ setToggleSize(style, RadioPart);
}
bool RenderThemeGtk::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
@@ -213,7 +242,7 @@ bool RenderThemeGtk::paintCheckbox(RenderObject* o, const RenderObject::PaintInf
void RenderThemeGtk::setRadioSize(RenderStyle* style) const
{
- setToggleSize(style, RadioAppearance);
+ setToggleSize(style, RadioPart);
}
bool RenderThemeGtk::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
@@ -224,7 +253,7 @@ bool RenderThemeGtk::paintRadio(RenderObject* o, const RenderObject::PaintInfo&
void RenderThemeGtk::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
{
// FIXME: Is this condition necessary?
- if (style->appearance() == PushButtonAppearance) {
+ if (style->appearance() == PushButtonPart) {
style->resetBorder();
style->setHeight(Length(Auto));
style->setWhiteSpace(PRE);