Changeset 84978 in webkit


Ignore:
Timestamp:
Apr 26, 2011 4:31:59 PM (13 years ago)
Author:
Martin Robinson
Message:

2011-04-26 Martin Robinson <mrobinson@igalia.com>

Reviewed by Eric Seidel.

[GTK] fast/block/float/overhanging-tall-block.html crashes in the bots
https://bugs.webkit.org/show_bug.cgi?id=58818

  • platform/gtk/Skipped: Unskip a test which is no longer crashing.

2011-04-26 Martin Robinson <mrobinson@igalia.com>

Reviewed by Eric Seidel.

[GTK] fast/block/float/overhanging-tall-block.html crashes in the bots
https://bugs.webkit.org/show_bug.cgi?id=58818

Prevent allocating scratch buffers larger than the target GdkDrawable
when creating a WidgetRenderingContext. This prevents incredibly large
widgets from crashing the X Server. This change also allowed greatly
simplifying the way that the painting offset is calculated.

  • platform/gtk/WidgetRenderingContext.cpp: (WebCore::WidgetRenderingContext::WidgetRenderingContext): Never allocate a pixmap larger than the target GdkDrawable. (WebCore::WidgetRenderingContext::~WidgetRenderingContext): Calculate the offset of the blit by looking at the location of the target rect itself, rather than delaying the calculation up to this point. (WebCore::WidgetRenderingContext::calculateClipRect): Added. (WebCore::WidgetRenderingContext::gtkPaintBox): Use the new calculateClipRectHelper. (WebCore::WidgetRenderingContext::gtkPaintFlatBox): Ditto. (WebCore::WidgetRenderingContext::gtkPaintFocus): Ditto. (WebCore::WidgetRenderingContext::gtkPaintSlider): Ditto. (WebCore::WidgetRenderingContext::gtkPaintCheck): Ditto. (WebCore::WidgetRenderingContext::gtkPaintOption): Ditto. (WebCore::WidgetRenderingContext::gtkPaintShadow): Ditto. (WebCore::WidgetRenderingContext::gtkPaintArrow): Ditto. (WebCore::WidgetRenderingContext::gtkPaintVLine): Ditto.
  • platform/gtk/WidgetRenderingContext.h: Remove some now unused members. Add a member to store the IntSize mapping from the coordinates of the target to the coordinates of the scratch buffer.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84975 r84978  
     12011-04-26  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [GTK]  fast/block/float/overhanging-tall-block.html crashes in the bots
     6        https://bugs.webkit.org/show_bug.cgi?id=58818
     7
     8        * platform/gtk/Skipped: Unskip a test which is no longer crashing.
     9
    1102011-04-26  Mario Sanchez Prada  <msanchez@igalia.com>
    211
  • trunk/LayoutTests/platform/gtk/Skipped

    r84975 r84978  
    183183# https://bugs.webkit.org/show_bug.cgi?id=56309
    184184svg/text/text-deco-01-b.svg
    185 
    186 # https://bugs.webkit.org/show_bug.cgi?id=58818
    187 fast/block/float/overhanging-tall-block.html
    188185
    189186# https://bugs.webkit.org/show_bug.cgi?id=58988
  • trunk/Source/WebCore/ChangeLog

    r84976 r84978  
     12011-04-26  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [GTK]  fast/block/float/overhanging-tall-block.html crashes in the bots
     6        https://bugs.webkit.org/show_bug.cgi?id=58818
     7
     8        Prevent allocating scratch buffers larger than the target GdkDrawable
     9        when creating a WidgetRenderingContext. This prevents incredibly large
     10        widgets from crashing the X Server. This change also allowed greatly
     11        simplifying the way that the painting offset is calculated.
     12
     13        * platform/gtk/WidgetRenderingContext.cpp:
     14        (WebCore::WidgetRenderingContext::WidgetRenderingContext): Never allocate a pixmap
     15        larger than the target GdkDrawable.
     16        (WebCore::WidgetRenderingContext::~WidgetRenderingContext): Calculate the offset of the
     17        blit by looking at the location of the target rect itself, rather than delaying the
     18        calculation up to this point.
     19        (WebCore::WidgetRenderingContext::calculateClipRect): Added.
     20        (WebCore::WidgetRenderingContext::gtkPaintBox): Use the new calculateClipRectHelper.
     21        (WebCore::WidgetRenderingContext::gtkPaintFlatBox): Ditto.
     22        (WebCore::WidgetRenderingContext::gtkPaintFocus): Ditto.
     23        (WebCore::WidgetRenderingContext::gtkPaintSlider): Ditto.
     24        (WebCore::WidgetRenderingContext::gtkPaintCheck): Ditto.
     25        (WebCore::WidgetRenderingContext::gtkPaintOption): Ditto.
     26        (WebCore::WidgetRenderingContext::gtkPaintShadow): Ditto.
     27        (WebCore::WidgetRenderingContext::gtkPaintArrow): Ditto.
     28        (WebCore::WidgetRenderingContext::gtkPaintVLine): Ditto.
     29        * platform/gtk/WidgetRenderingContext.h: Remove some now unused members. Add
     30        a member to store the IntSize mapping from the coordinates of the target to the coordinates
     31        of the scratch buffer.
     32
    1332011-04-26  Patrick Gansterer  <paroga@webkit.org>
    234
  • trunk/Source/WebCore/platform/gtk/WidgetRenderingContext.cpp

    r82962 r84978  
    7878    // paint directly to the target drawable. This will not render CSS rotational transforms properly.
    7979    if (!theme->m_themePartsHaveRGBAColormap && graphicsContext->gdkWindow()) {
    80         m_paintRect = graphicsContext->getCTM().mapRect(targetRect);
    8180        m_target = graphicsContext->gdkWindow();
    8281        return;
    8382    }
    8483
     84    // We never want to create a scratch buffer larger than the size of our target GdkDrawable.
     85    // This prevents giant pixmap allocations for very large widgets in smaller views.
     86    int maxWidth = 0, maxHeight = 0;
     87    gdk_drawable_get_size(graphicsContext->gdkWindow(), &maxWidth, &maxHeight);
     88    m_targetRect.setSize(m_targetRect.size().shrunkTo(IntSize(maxWidth, maxHeight)));
     89
    8590    // Widgets sometimes need to draw outside their boundaries for things such as
    8691    // exterior focus. We want to allocate a some extra pixels in our surface for this.
    87     m_extraSpace = IntSize(15, 15);
    88 
    89     // Offset the target rectangle so that the extra space is within the boundaries of the scratch buffer.
    90     m_paintRect = IntRect(IntPoint(m_extraSpace.width(), m_extraSpace.height()),
    91                                    m_targetRect.size());
    92 
    93     int width = m_targetRect.width() + (m_extraSpace.width() * 2);
    94     int height = m_targetRect.height() + (m_extraSpace.height() * 2);
     92    static int extraSpace = 15;
     93    m_targetRect.inflate(extraSpace);
     94
     95    // This offset will map a point in the coordinate system of the widget to the coordinate system of the painting buffer.
     96    m_paintOffset = targetRect.location() - m_targetRect.location();
     97
     98    int width = m_targetRect.width() + (extraSpace * 2);
     99    int height = m_targetRect.height() + (extraSpace * 2);
    95100    int scratchWidth = 0;
    96101    int scratchHeight = 0;
     
    133138    RefPtr<cairo_pattern_t> previousSource(cairo_get_source(cairoContext));
    134139
    135     // The blit rectangle is the original target rectangle adjusted for any extra space.
    136     IntRect fullTargetRect(m_targetRect);
    137     fullTargetRect.inflateX(m_extraSpace.width());
    138     fullTargetRect.inflateY(m_extraSpace.height());
    139 
    140     gdk_cairo_set_source_pixmap(cairoContext, gScratchBuffer, fullTargetRect.x(), fullTargetRect.y());
    141     cairo_rectangle(cairoContext, fullTargetRect.x(), fullTargetRect.y(), fullTargetRect.width(), fullTargetRect.height());
     140    gdk_cairo_set_source_pixmap(cairoContext, gScratchBuffer, m_targetRect.x(), m_targetRect.y());
     141    cairo_rectangle(cairoContext, m_targetRect.x(), m_targetRect.y(), m_targetRect.width(), m_targetRect.height());
    142142    cairo_fill(cairoContext);
    143143    cairo_set_source(cairoContext, previousSource.get());
     
    145145}
    146146
     147void WidgetRenderingContext::calculateClipRect(const IntRect& rect, GdkRectangle* clipRect)
     148{
     149    clipRect->x = m_paintOffset.width() + rect.x();
     150    clipRect->y = m_paintOffset.height() + rect.y();
     151    clipRect->width = m_targetRect.width();
     152    clipRect->height = m_targetRect.height();
     153}
     154
    147155void WidgetRenderingContext::gtkPaintBox(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
    148156{
    149     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
     157    GdkRectangle clipRect;
     158    calculateClipRect(rect, &clipRect);
    150159
    151160    // Some widgets also need their allocation adjusted to account for extra space.
     
    153162    GtkAllocation allocation;
    154163    gtk_widget_get_allocation(widget, &allocation);
    155     allocation.x += m_paintRect.x;
    156     allocation.y += m_paintRect.y;
     164    allocation.x += clipRect.x;
     165    allocation.y += clipRect.y;
    157166    gtk_widget_set_allocation(widget, &allocation);
    158167
    159     gtk_paint_box(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect,
    160                   widget, detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
     168    gtk_paint_box(gtk_widget_get_style(widget), m_target, stateType, shadowType, &clipRect,
     169                  widget, detail, clipRect.x, clipRect.y, rect.width(), rect.height());
    161170}
    162171
    163172void WidgetRenderingContext::gtkPaintFlatBox(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
    164173{
    165     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    166     gtk_paint_flat_box(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect,
    167                        widget, detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
     174    GdkRectangle clipRect;
     175    calculateClipRect(rect, &clipRect);
     176    gtk_paint_flat_box(gtk_widget_get_style(widget), m_target, stateType, shadowType, &clipRect,
     177                       widget, detail, clipRect.x, clipRect.y, rect.width(), rect.height());
    168178}
    169179
    170180void WidgetRenderingContext::gtkPaintFocus(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, const gchar* detail)
    171181{
    172     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    173     gtk_paint_focus(gtk_widget_get_style(widget), m_target, stateType, &paintRect, widget,
    174                     detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
     182    GdkRectangle clipRect;
     183    calculateClipRect(rect, &clipRect);
     184    gtk_paint_focus(gtk_widget_get_style(widget), m_target, stateType, &clipRect, widget,
     185                    detail, clipRect.x, clipRect.y, rect.width(), rect.height());
    175186}
    176187
    177188void WidgetRenderingContext::gtkPaintSlider(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail, GtkOrientation orientation)
    178189{
    179     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    180     gtk_paint_slider(gtk_widget_get_style(widget), m_target, stateType, shadowType, &m_paintRect, widget,
    181                      detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height, orientation);
     190    GdkRectangle clipRect;
     191    calculateClipRect(rect, &clipRect);
     192    gtk_paint_slider(gtk_widget_get_style(widget), m_target, stateType, shadowType, &clipRect, widget,
     193                     detail, clipRect.x, clipRect.y, rect.width(), rect.height(), orientation);
    182194}
    183195
    184196void WidgetRenderingContext::gtkPaintCheck(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
    185197{
    186     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    187     gtk_paint_check(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget,
    188                     detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
     198    GdkRectangle clipRect;
     199    calculateClipRect(rect, &clipRect);
     200    gtk_paint_check(gtk_widget_get_style(widget), m_target, stateType, shadowType, &clipRect, widget,
     201                    detail, clipRect.x, clipRect.y, rect.width(), rect.height());
    189202}
    190203
    191204void WidgetRenderingContext::gtkPaintOption(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
    192205{
    193     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    194     gtk_paint_option(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget,
    195                      detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
     206    GdkRectangle clipRect;
     207    calculateClipRect(rect, &clipRect);
     208    gtk_paint_option(gtk_widget_get_style(widget), m_target, stateType, shadowType, &clipRect, widget,
     209                     detail, clipRect.x, clipRect.y, rect.width(), rect.height());
    196210}
    197211
    198212void WidgetRenderingContext::gtkPaintShadow(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
    199213{
    200     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    201     gtk_paint_shadow(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget,
    202                      detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
     214    GdkRectangle clipRect;
     215    calculateClipRect(rect, &clipRect);
     216    gtk_paint_shadow(gtk_widget_get_style(widget), m_target, stateType, shadowType, &clipRect, widget,
     217                     detail, clipRect.x, clipRect.y, rect.width(), rect.height());
    203218}
    204219
    205220void WidgetRenderingContext::gtkPaintArrow(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, int arrowDirection, const gchar* detail)
    206221{
    207     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    208     gtk_paint_arrow(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget, detail,
    209                     static_cast<GtkArrowType>(arrowDirection), TRUE, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
     222    GdkRectangle clipRect;
     223    calculateClipRect(rect, &clipRect);
     224    gtk_paint_arrow(gtk_widget_get_style(widget), m_target, stateType, shadowType, &clipRect, widget, detail,
     225                    static_cast<GtkArrowType>(arrowDirection), TRUE, clipRect.x, clipRect.y, rect.width(), rect.height());
    210226}
    211227
    212228void WidgetRenderingContext::gtkPaintVLine(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, const gchar* detail)
    213229{
    214     GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    215     gtk_paint_vline(gtk_widget_get_style(widget), m_target, stateType, &paintRect, widget, detail,
    216                     paintRect.y, paintRect.y + paintRect.height, paintRect.x);
     230    GdkRectangle clipRect;
     231    calculateClipRect(rect, &clipRect);
     232    gtk_paint_vline(gtk_widget_get_style(widget), m_target, stateType, &clipRect, widget, detail,
     233                    clipRect.y, clipRect.y + rect.height(), clipRect.x);
    217234
    218235}
  • trunk/Source/WebCore/platform/gtk/WidgetRenderingContext.h

    r77993 r84978  
    5353
    5454private:
     55    void calculateClipRect(const IntRect&, GdkRectangle*);
     56
    5557    GraphicsContext* m_graphicsContext;
    5658    IntRect m_targetRect;
    57     GdkRectangle m_paintRect;
    58     IntSize m_extraSpace;
     59    IntSize m_paintOffset;
    5960    bool m_hadError;
    6061    GdkDrawable* m_target;
Note: See TracChangeset for help on using the changeset viewer.