Bug 40139

Summary: [GTK] Widgets do not support CSS transformations
Product: WebKit Reporter: Martin Robinson <mrobinson>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, alex, cgarcia, eric, gustavo, webkit.review.bot, xan.lopez
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Bug Depends on:    
Bug Blocks: 47836    
Attachments:
Description Flags
Patch for this issue
none
Updated patch for this issue
none
Patch against ToT (reason for build failure)
none
Patch updated with Alex's suggestions
none
Patch fixing scrollbar rendering issue
none
Patch with slightly updated design
none
Updated Patch none

Description Martin Robinson 2010-06-03 14:04:55 PDT
GTK+ themes require painting onto a GdkDrawable. In the common case this is the GdkPixmap of the widget window. Because this happens at a lower level than the GraphicsContext, nothing except the widget text honors the transformation matrix.

One approach to fixing this is to detect situations in which the GraphicsContext has a rotational transformation matrix and, in those cases, render onto an intermediary GdxPixbuf surface and then copy that to the graphics context.
Comment 1 Martin Robinson 2010-10-14 17:06:05 PDT
Created attachment 70805 [details]
Patch for this issue
Comment 2 Martin Robinson 2010-10-14 18:17:36 PDT
Comment on attachment 70805 [details]
Patch for this issue

Clearing flags, as I should have another patch coming which takes this idea a bit further.
Comment 3 Martin Robinson 2010-10-18 10:38:11 PDT
Created attachment 71056 [details]
Updated patch for this issue
Comment 4 WebKit Review Bot 2010-10-18 13:21:59 PDT
Attachment 71056 [details] did not build on gtk:
Build output: http://queues.webkit.org/results/4388070
Comment 5 Martin Robinson 2010-10-18 14:33:02 PDT
Created attachment 71083 [details]
Patch against ToT (reason for build failure)
Comment 6 Alejandro G. Castro 2010-10-19 05:22:36 PDT
Comment on attachment 71083 [details]
Patch against ToT (reason for build failure)

Patch looks like a very good idea :).

View in context: https://bugs.webkit.org/attachment.cgi?id=71083&action=review

> LayoutTests/ChangeLog:14
> +        * platform/gtk/fast/forms/slider-transformed-expected.txt: Added.

I think this file is not in the patch.

> WebCore/platform/gtk/RenderThemeGtk.cpp:169
> +    , m_themeParts(g_new0(GtkThemeParts, 1))
> +#ifdef GTK_API_VERSION_2
> +    , m_themePartsHaveRGBAColormap(true)
> +#endif
>  {
> -    if (!mozGtkRefCount) {
> -        moz_gtk_init();
>  
> -        // Use the theme parts for the default drawable.
> -        moz_gtk_use_theme_parts(partsForDrawable(0));
> +#ifdef GTK_API_VERSION_2
> +    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;
> +#endif

I was wondering if we could move this code and m_theme attributes to the WidgetRenderingContext object or to the gtkxdrawing. In any case we could leave it for future patches.

> WebCore/platform/gtk/WidgetRenderingContextGtk2.cpp:149
> +    // The origin of the blit is the original target rectangle adjusted for any extra space.
> +    IntPoint targetOrigin(m_targetRect.x() - m_extraSpace.width(),
> +                          m_targetRect.y() - m_extraSpace.height());

I think we can use IntRect and inflate to simplify this code.

> WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp:51
>  

I needed these modifications to compile WidgetRenderingContextGtk3.cpp:


diff --git a/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp b/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
index 693c40e..bd826d9 100644
--- a/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
+++ b/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
@@ -32,12 +32,12 @@ WidgetRenderingContext::WidgetRenderingContext(GraphicsContext* graphicsContext,
     : m_graphicsContext(graphicsContext)
     , m_targetRect(targetRect)
     , m_paintRect(targetRect)
-    , m_target(context->platformContext())
     , m_hadError(false)
+    , m_target(graphicsContext->platformContext())
 {
 }

-~WidgetRenderingContext::WidgetRenderingContext()
+WidgetRenderingContext::~WidgetRenderingContext()
 {
 }

@@ -47,4 +47,6 @@ bool WidgetRenderingContext::paintMozillaWidget(GtkThemeWidgetType type, GtkWidg
     return !m_hadError;
 }

+}
+
 #endif // !GTK_API_VERSION_2
Comment 7 Martin Robinson 2010-10-19 10:21:41 PDT
Comment on attachment 71083 [details]
Patch against ToT (reason for build failure)

View in context: https://bugs.webkit.org/attachment.cgi?id=71083&action=review

>> LayoutTests/ChangeLog:14
>> +        * platform/gtk/fast/forms/slider-transformed-expected.txt: Added.
> 
> I think this file is not in the patch.

It's the third one down on the pretty-diff. :)

>> WebCore/platform/gtk/RenderThemeGtk.cpp:169
>> +#endif
> 
> I was wondering if we could move this code and m_theme attributes to the WidgetRenderingContext object or to the gtkxdrawing. In any case we could leave it for future patches.

It needs to stay here as long as RenderThemeGtk manages widgets itself. Perhaps if we eventually do away with WidgetRenderingContext (when the style changes land in GTK+ for instance) it might make sense to move it.

>> WebCore/platform/gtk/WidgetRenderingContextGtk2.cpp:149
>> +                          m_targetRect.y() - m_extraSpace.height());
> 
> I think we can use IntRect and inflate to simplify this code.

Hrm. Maybe IntPoint targetOrigin = m_targetRect.topLeft - toPoint(m_extraSpace);

>> WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp:51
>>  
> 
> I needed these modifications to compile WidgetRenderingContextGtk3.cpp:
> 
> 
> diff --git a/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp b/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
> index 693c40e..bd826d9 100644
> --- a/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
> +++ b/WebCore/platform/gtk/WidgetRenderingContextGtk3.cpp
> @@ -32,12 +32,12 @@ WidgetRenderingContext::WidgetRenderingContext(GraphicsContext* graphicsContext,
>      : m_graphicsContext(graphicsContext)
>      , m_targetRect(targetRect)
>      , m_paintRect(targetRect)
> -    , m_target(context->platformContext())
>      , m_hadError(false)
> +    , m_target(graphicsContext->platformContext())
>  {
>  }
> 
> -~WidgetRenderingContext::WidgetRenderingContext()
> +WidgetRenderingContext::~WidgetRenderingContext()
>  {
>  }
> 
> @@ -47,4 +47,6 @@ bool WidgetRenderingContext::paintMozillaWidget(GtkThemeWidgetType type, GtkWidg
>      return !m_hadError;
>  }
> 
> +}
> +
>  #endif // !GTK_API_VERSION_2

Thanks. I'll post a new patch with these fixes.
Comment 8 Martin Robinson 2010-10-19 10:44:35 PDT
Created attachment 71183 [details]
Patch updated with Alex's suggestions
Comment 9 Martin Robinson 2010-10-29 12:15:03 PDT
Created attachment 72362 [details]
Patch fixing scrollbar rendering issue
Comment 10 Martin Robinson 2010-11-02 22:03:18 PDT
Created attachment 72788 [details]
Patch with slightly updated design
Comment 11 Martin Robinson 2010-11-10 11:48:45 PST
Created attachment 73519 [details]
Updated Patch
Comment 12 Martin Robinson 2010-11-10 11:49:45 PST
Based on Xan's comments I've updated this patch:

1. It no longer includes the next patch in the series.
2. m_themeParts is now an inline array of the RenderThemeGtk objects and not a pointer.
3. Small fix for a CSS rotation issue.
Comment 13 Xan Lopez 2010-11-10 17:47:30 PST
Comment on attachment 73519 [details]
Updated Patch

r=me
Comment 14 Martin Robinson 2010-11-10 18:30:03 PST
Committed r71791: <http://trac.webkit.org/changeset/71791>
Comment 15 WebKit Review Bot 2010-11-10 19:25:08 PST
http://trac.webkit.org/changeset/71791 might have broken GTK Linux 64-bit Debug