summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-22 01:30:41 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-22 01:30:41 +0000
commit4fea401af7447e1fe098b989ec07193b1b9080bf (patch)
tree2f5712e2a61b0dc50920219234592900ae878d7d /webkit/port
parentc736303377d5fc8f086cd9d2e8e373aa69a246ce (diff)
downloadchromium_src-4fea401af7447e1fe098b989ec07193b1b9080bf.zip
chromium_src-4fea401af7447e1fe098b989ec07193b1b9080bf.tar.gz
chromium_src-4fea401af7447e1fe098b989ec07193b1b9080bf.tar.bz2
Correctly render scroll bars on web frames by setting a matrix translation on the cairo surface in the canvas's GdkSkiaObjet that matches the canvas's matrix translation. Change rendering of some other widgets (buttons, entry fields, etc) that were being translated manually.
Review URL: http://codereview.chromium.org/11562 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5890 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/platform/chromium/RenderThemeGtk.cpp38
-rw-r--r--webkit/port/platform/graphics/skia/GdkSkia.cc5
2 files changed, 23 insertions, 20 deletions
diff --git a/webkit/port/platform/chromium/RenderThemeGtk.cpp b/webkit/port/platform/chromium/RenderThemeGtk.cpp
index e05e9c5..98af73c 100644
--- a/webkit/port/platform/chromium/RenderThemeGtk.cpp
+++ b/webkit/port/platform/chromium/RenderThemeGtk.cpp
@@ -159,35 +159,33 @@ static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderOb
break;
}
- AffineTransform ctm = i.context->getCTM();
-
- IntPoint pos = ctm.mapPoint(rect.location());
- GdkRectangle gdkRect;
- gdkRect.x = pos.x();
- gdkRect.y = pos.y();
- gdkRect.width = rect.width();
- gdkRect.height = rect.height();
- GtkTextDirection direction = gtkTextDirection(o->style()->direction());
-
PlatformContextSkia* pcs = i.context->platformContext();
SkCanvas* canvas = pcs->canvas();
if (!canvas)
return false;
- const SkIRect clip_region = canvas->getTotalClip().getBounds();
+ GdkRectangle gdkRect;
+ gdkRect.x = rect.x();
+ gdkRect.y = rect.y();
+ gdkRect.width = rect.width();
+ gdkRect.height = rect.height();
+ // getTotalClip returns the currently set clip region in device coordinates,
+ // so we have to apply the current transform (actually we only support translations)
+ // to get the page coordinates that our gtk widget rendering expects.
+ // We invert it because we want to map from device coordinates to page coordinates.
+ const SkIRect clip_region = canvas->getTotalClip().getBounds();
+ AffineTransform ctm = i.context->getCTM().inverse();
+ IntPoint pos = ctm.mapPoint(IntPoint(SkScalarRound(clip_region.fLeft), SkScalarRound(clip_region.fTop)));
GdkRectangle gdkClipRect;
- gdkClipRect.x = clip_region.fLeft;
- gdkClipRect.y = clip_region.fTop;
- gdkClipRect.width = clip_region.width();
- gdkClipRect.height = clip_region.height();
-
- gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect);
+ gdkClipRect.x = pos.x();
+ gdkClipRect.y = pos.y();
+ gdkClipRect.width = SkScalarRound(clip_region.width());
+ gdkClipRect.height = SkScalarRound(clip_region.height());
- const gint r =
- moz_gtk_widget_paint(type, pcs->gdk_skia(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS;
+ GtkTextDirection direction = gtkTextDirection(o->style()->direction());
- return r;
+ return moz_gtk_widget_paint(type, pcs->gdk_skia(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS;
}
static void setButtonPadding(RenderStyle* style)
diff --git a/webkit/port/platform/graphics/skia/GdkSkia.cc b/webkit/port/platform/graphics/skia/GdkSkia.cc
index 4774aaf..8613192 100644
--- a/webkit/port/platform/graphics/skia/GdkSkia.cc
+++ b/webkit/port/platform/graphics/skia/GdkSkia.cc
@@ -465,6 +465,11 @@ gdk_skia_ref_cairo_surface(GdkDrawable *drawable) {
CAIRO_FORMAT_ARGB32, dev->width(), dev->height(), bm->rowBytes());
}
+ SkMatrix matrix = skia->canvas->getTotalMatrix();
+ int x_shift = SkScalarRound(matrix.getTranslateX());
+ int y_shift = SkScalarRound(matrix.getTranslateY());
+
+ cairo_surface_set_device_offset(skia->surface, x_shift, y_shift);
return cairo_surface_reference(skia->surface);
}