Changeset 116693 in webkit


Ignore:
Timestamp:
May 10, 2012 3:08:27 PM (12 years ago)
Author:
jchaffraix@webkit.org
Message:

Crash in computedCSSPadding* functions due to RenderImage::imageDimensionsChanged called during attachment
https://bugs.webkit.org/show_bug.cgi?id=85912

Reviewed by Eric Seidel.

Source/WebCore:

Tests: fast/images/link-body-content-imageDimensionChanged-crash.html

fast/images/script-counter-imageDimensionChanged-crash.html

The bug comes from CSS generated images that could end up calling imageDimensionsChanged during attachment. As the
rest of the code (e.g. computedCSSPadding*) would assumes that we are already inserted in the tree, we would crash.

The solution is to bail out in this case as newly inserted RenderObject will trigger layout later on and properly
handle what we would be doing as part of imageDimensionChanged (the only exception being updating our intrinsic
size which should be done as part of imageDimensionsChanged).

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::imageDimensionsChanged):

LayoutTests:

  • fast/images/link-body-content-imageDimensionChanged-crash-expected.txt: Added.
  • fast/images/link-body-content-imageDimensionChanged-crash.html: Added.
  • fast/images/script-counter-imageDimensionChanged-crash-expected.txt: Added.
  • fast/images/script-counter-imageDimensionChanged-crash.html: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116685 r116693  
     12012-05-10  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Crash in computedCSSPadding* functions due to RenderImage::imageDimensionsChanged called during attachment
     4        https://bugs.webkit.org/show_bug.cgi?id=85912
     5
     6        Reviewed by Eric Seidel.
     7
     8        * fast/images/link-body-content-imageDimensionChanged-crash-expected.txt: Added.
     9        * fast/images/link-body-content-imageDimensionChanged-crash.html: Added.
     10        * fast/images/script-counter-imageDimensionChanged-crash-expected.txt: Added.
     11        * fast/images/script-counter-imageDimensionChanged-crash.html: Added.
     12
    1132012-05-10  Brady Eidson  <beidson@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r116691 r116693  
     12012-05-10  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Crash in computedCSSPadding* functions due to RenderImage::imageDimensionsChanged called during attachment
     4        https://bugs.webkit.org/show_bug.cgi?id=85912
     5
     6        Reviewed by Eric Seidel.
     7
     8        Tests: fast/images/link-body-content-imageDimensionChanged-crash.html
     9               fast/images/script-counter-imageDimensionChanged-crash.html
     10
     11        The bug comes from CSS generated images that could end up calling imageDimensionsChanged during attachment. As the
     12        rest of the code (e.g. computedCSSPadding*) would assumes that we are already inserted in the tree, we would crash.
     13
     14        The solution is to bail out in this case as newly inserted RenderObject will trigger layout later on and properly
     15        handle what we would be doing as part of imageDimensionChanged (the only exception being updating our intrinsic
     16        size which should be done as part of imageDimensionsChanged).
     17
     18        * rendering/RenderImage.cpp:
     19        (WebCore::RenderImage::imageDimensionsChanged):
     20
    1212012-05-10  Adam Barth  <abarth@webkit.org>
    222
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r114437 r116693  
    189189void RenderImage::imageDimensionsChanged(bool imageSizeChanged, const IntRect* rect)
    190190{
     191    bool intrinsicSizeChanged = updateIntrinsicSizeIfNeeded(m_imageResource->imageSize(style()->effectiveZoom()), imageSizeChanged);
     192
     193    // In the case of generated image content using :before/:after/content, we might not be
     194    // in the render tree yet. In that case, we just need to update our intrinsic size.
     195    // layout() will be called after we are inserted in the tree which will take care of
     196    // what we are doing here.
     197    if (!containingBlock())
     198        return;
     199
    191200    bool shouldRepaint = true;
    192     if (updateIntrinsicSizeIfNeeded(m_imageResource->imageSize(style()->effectiveZoom()), imageSizeChanged)) {
    193         // In the case of generated image content using :before/:after, we might not be in the
    194         // render tree yet.  In that case, we don't need to worry about check for layout, since we'll get a
    195         // layout when we get added in to the render tree hierarchy later.
    196         if (containingBlock()) {
    197             // lets see if we need to relayout at all..
    198             int oldwidth = width();
    199             int oldheight = height();
    200             if (!preferredLogicalWidthsDirty())
    201                 setPreferredLogicalWidthsDirty(true);
    202             computeLogicalWidth();
    203             computeLogicalHeight();
    204 
    205             if (imageSizeChanged || width() != oldwidth || height() != oldheight) {
    206                 shouldRepaint = false;
    207                 if (!selfNeedsLayout())
    208                     setNeedsLayout(true);
    209             }
    210 
    211             setWidth(oldwidth);
    212             setHeight(oldheight);
    213         }
     201    if (intrinsicSizeChanged) {
     202        // lets see if we need to relayout at all..
     203        int oldwidth = width();
     204        int oldheight = height();
     205        if (!preferredLogicalWidthsDirty())
     206            setPreferredLogicalWidthsDirty(true);
     207        computeLogicalWidth();
     208        computeLogicalHeight();
     209
     210        if (imageSizeChanged || width() != oldwidth || height() != oldheight) {
     211            shouldRepaint = false;
     212            if (!selfNeedsLayout())
     213                setNeedsLayout(true);
     214        }
     215
     216        setWidth(oldwidth);
     217        setHeight(oldheight);
    214218    }
    215219
Note: See TracChangeset for help on using the changeset viewer.