Changeset 66599 in webkit


Ignore:
Timestamp:
Sep 1, 2010 7:01:15 AM (14 years ago)
Author:
Nikolas Zimmermann
Message:

2010-08-30 Patrick Gansterer <paroga@paroga.com>

Reviewed by Dirk Schulze.

RenderImage::imageChanged invalidates wrong area
https://bugs.webkit.org/show_bug.cgi?id=43779

Remove RenderImage inheritance from RenderSVGImage, it now inherits from RenderSVGModelObject.

  • rendering/RenderSVGImage.cpp: (WebCore::RenderSVGImage::RenderSVGImage): (WebCore::RenderSVGImage::~RenderSVGImage): (WebCore::RenderSVGImage::layout): (WebCore::RenderSVGImage::paint): (WebCore::RenderSVGImage::imageChanged):
  • rendering/RenderSVGImage.h: (WebCore::RenderSVGImage::imageResource):
  • rendering/RenderSVGModelObject.h:
  • svg/SVGImageElement.cpp:

2010-09-01 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

RenderImage::imageChanged invalidates wrong area
https://bugs.webkit.org/show_bug.cgi?id=43779

Rebaseline SVG image dumpAsText() tests.
A newline is gone from each of the results, after switching from RenderImage to RenderSVGModelObject in RenderSVGImage.

  • svg/custom/loadevents-capturing-expected.txt:
  • svg/custom/loadevents-externalresourcesrequired-expected.txt:
  • svg/custom/loadevents-normal-expected.txt:
  • svg/dynamic-updates/SVGImageElement-dom-height-attr-expected.txt:
  • svg/dynamic-updates/SVGImageElement-dom-preserveAspectRatio-attr-expected.txt:
  • svg/dynamic-updates/SVGImageElement-dom-width-attr-expected.txt:
  • svg/dynamic-updates/SVGImageElement-dom-x-attr-expected.txt:
  • svg/dynamic-updates/SVGImageElement-dom-y-attr-expected.txt:
  • svg/dynamic-updates/SVGImageElement-svgdom-height-prop-expected.txt:
  • svg/dynamic-updates/SVGImageElement-svgdom-preserveAspectRatio-prop-expected.txt:
  • svg/dynamic-updates/SVGImageElement-svgdom-width-prop-expected.txt:
  • svg/dynamic-updates/SVGImageElement-svgdom-x-prop-expected.txt:
  • svg/dynamic-updates/SVGImageElement-svgdom-y-prop-expected.txt:
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r66597 r66599  
     12010-09-01  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        RenderImage::imageChanged invalidates wrong area
     6        https://bugs.webkit.org/show_bug.cgi?id=43779
     7
     8        Rebaseline SVG image dumpAsText() tests.
     9        A newline is gone from each of the results, after switching from RenderImage to RenderSVGModelObject in RenderSVGImage.
     10
     11        * svg/custom/loadevents-capturing-expected.txt:
     12        * svg/custom/loadevents-externalresourcesrequired-expected.txt:
     13        * svg/custom/loadevents-normal-expected.txt:
     14        * svg/dynamic-updates/SVGImageElement-dom-height-attr-expected.txt:
     15        * svg/dynamic-updates/SVGImageElement-dom-preserveAspectRatio-attr-expected.txt:
     16        * svg/dynamic-updates/SVGImageElement-dom-width-attr-expected.txt:
     17        * svg/dynamic-updates/SVGImageElement-dom-x-attr-expected.txt:
     18        * svg/dynamic-updates/SVGImageElement-dom-y-attr-expected.txt:
     19        * svg/dynamic-updates/SVGImageElement-svgdom-height-prop-expected.txt:
     20        * svg/dynamic-updates/SVGImageElement-svgdom-preserveAspectRatio-prop-expected.txt:
     21        * svg/dynamic-updates/SVGImageElement-svgdom-width-prop-expected.txt:
     22        * svg/dynamic-updates/SVGImageElement-svgdom-x-prop-expected.txt:
     23        * svg/dynamic-updates/SVGImageElement-svgdom-y-prop-expected.txt:
     24
    1252010-09-01  Mahesh Kulkarni  <mahesh.kulkarni@nokia.com>
    226
  • trunk/LayoutTests/svg/custom/loadevents-capturing-expected.txt

    r32738 r66599  
    1 
    21This tests that load dispatching works when there are no
    32direct listeners, but there are capturing event listeners on an ancestor. Bug 16447
  • trunk/LayoutTests/svg/custom/loadevents-externalresourcesrequired-expected.txt

    r32738 r66599  
    1 
    21This tests load dispatching order with externalResourcesRequired. Bug 16447
    32Passed
  • trunk/LayoutTests/svg/custom/loadevents-normal-expected.txt

    r32738 r66599  
    1 
    21This tests normal load dispatching order. Bug 16447
    32Passed
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-dom-height-attr-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'height' attribute of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-dom-preserveAspectRatio-attr-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'preserveAspectRatio' attribute of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-dom-width-attr-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'width' attribute of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-dom-x-attr-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'x' attribute of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-dom-y-attr-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'y' attribute of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-svgdom-height-prop-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'height' property of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-svgdom-preserveAspectRatio-prop-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'preserveAspectRatio' property of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-svgdom-width-prop-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'width' property of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-svgdom-x-prop-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'x' property of the SVGImageElement object
  • trunk/LayoutTests/svg/dynamic-updates/SVGImageElement-svgdom-y-prop-expected.txt

    r35679 r66599  
    11SVG 1.1 dynamic update tests
    2 
    32
    43Tests dynamic updates of the 'y' property of the SVGImageElement object
  • trunk/WebCore/ChangeLog

    r66598 r66599  
     12010-08-30  Patrick Gansterer  <paroga@paroga.com>
     2
     3         Reviewed by Dirk Schulze.
     4
     5         RenderImage::imageChanged invalidates wrong area
     6         https://bugs.webkit.org/show_bug.cgi?id=43779
     7
     8         Remove RenderImage inheritance from RenderSVGImage, it now inherits from RenderSVGModelObject.
     9
     10         * rendering/RenderSVGImage.cpp:
     11         (WebCore::RenderSVGImage::RenderSVGImage):
     12         (WebCore::RenderSVGImage::~RenderSVGImage):
     13         (WebCore::RenderSVGImage::layout):
     14         (WebCore::RenderSVGImage::paint):
     15         (WebCore::RenderSVGImage::imageChanged):
     16         * rendering/RenderSVGImage.h:
     17         (WebCore::RenderSVGImage::imageResource):
     18         * rendering/RenderSVGModelObject.h:
     19         * svg/SVGImageElement.cpp:
     20
    1212010-09-01  Nikolas Zimmermann  <nzimmermann@rim.com>
    222
  • trunk/WebCore/rendering/RenderSVGImage.cpp

    r66598 r66599  
    66    Copyright (C) 2009, Google, Inc.
    77    Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
     8    Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
    89
    910    This library is free software; you can redistribute it and/or
     
    3334#include "GraphicsContext.h"
    3435#include "PointerEventsHitRules.h"
     36#include "RenderImageResource.h"
    3537#include "RenderLayer.h"
    3638#include "RenderSVGResourceContainer.h"
     
    4547
    4648RenderSVGImage::RenderSVGImage(SVGImageElement* impl)
    47     : RenderImage(impl)
     49    : RenderSVGModelObject(impl)
    4850    , m_needsTransformUpdate(true)
     51    , m_imageResource(RenderImageResource::create())
    4952{
    50     setImageResource(RenderImageResource::create());
     53    m_imageResource->initialize(this);
     54}
     55
     56RenderSVGImage::~RenderSVGImage()
     57{
     58    m_imageResource->shutdown();
    5159}
    5260
     
    6573    }
    6674
    67     // minimum height
    68     setHeight(imageResource()->errorOccurred() ? intrinsicSize().height() : 0);
    69 
    70     calcWidth();
    71     calcHeight();
    72 
    7375    // FIXME: Optimize caching the repaint rects.
    7476    FloatRect oldBoundaries = m_localBounds;
     
    8587    // If our bounds changed, notify the parents.
    8688    if (updateCachedBoundariesInParents)
    87         RenderImage::setNeedsBoundariesUpdate();
     89        RenderSVGModelObject::setNeedsBoundariesUpdate();
    8890
    8991    repainter.repaintAfterLayout();
     
    9395void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
    9496{
    95     if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN)
     97    if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || !m_imageResource->hasImage())
    9698        return;
    9799
    98     paintInfo.context->save();
    99     paintInfo.context->concatCTM(localToParentTransform());
     100    FloatRect boundingBox = repaintRectInLocalCoordinates();
     101    if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
     102        return;
    100103
    101     if (paintInfo.phase == PaintPhaseForeground) {
    102         PaintInfo savedInfo(paintInfo);
     104    PaintInfo childPaintInfo(paintInfo);
     105    bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
     106    if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
     107        childPaintInfo.context->save();
     108        childPaintInfo.applyTransform(m_localTransform);
    103109
    104         if (SVGRenderSupport::prepareToRenderSVGContent(this, paintInfo)) {
    105             Image* image = imageResource()->image();
    106             FloatRect destRect = m_localBounds;
    107             FloatRect srcRect(0, 0, image->width(), image->height());
     110        if (childPaintInfo.phase == PaintPhaseForeground) {
     111            PaintInfo savedInfo(childPaintInfo);
    108112
    109             SVGImageElement* imageElt = static_cast<SVGImageElement*>(node());
    110             if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
    111                 imageElt->preserveAspectRatio().transformRect(destRect, srcRect);
     113            if (SVGRenderSupport::prepareToRenderSVGContent(this, childPaintInfo)) {
     114                Image* image = m_imageResource->image();
     115                FloatRect destRect = m_localBounds;
     116                FloatRect srcRect(0, 0, image->width(), image->height());
    112117
    113             paintInfo.context->drawImage(image, DeviceColorSpace, destRect, srcRect);
     118                SVGImageElement* imageElement = static_cast<SVGImageElement*>(node());
     119                if (imageElement->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
     120                    imageElement->preserveAspectRatio().transformRect(destRect, srcRect);
     121
     122                childPaintInfo.context->drawImage(image, DeviceColorSpace, destRect, srcRect);
     123            }
     124
     125            SVGRenderSupport::finishRenderSVGContent(this, childPaintInfo, savedInfo.context);
    114126        }
    115         SVGRenderSupport::finishRenderSVGContent(this, paintInfo, savedInfo.context);
     127
     128        if (drawsOutline)
     129            paintOutline(childPaintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
     130                static_cast<int>(boundingBox.width()), static_cast<int>(boundingBox.height()));
     131       
     132        childPaintInfo.context->restore();
    116133    }
    117 
    118     if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
    119         paintOutline(paintInfo.context, 0, 0, width(), height());
    120 
    121     paintInfo.context->restore();
    122 }
    123 
    124 void RenderSVGImage::destroy()
    125 {
    126     SVGResourcesCache::clientDestroyed(this);
    127     RenderImage::destroy();
    128 }
    129 
    130 void RenderSVGImage::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
    131 {
    132     if (diff == StyleDifferenceLayout)
    133         setNeedsBoundariesUpdate();
    134     RenderImage::styleWillChange(diff, newStyle);
    135 }
    136 
    137 void RenderSVGImage::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
    138 {
    139     RenderImage::styleDidChange(diff, oldStyle);
    140     SVGResourcesCache::clientStyleChanged(this, diff, style());
    141 }
    142 
    143 void RenderSVGImage::updateFromElement()
    144 {
    145     RenderImage::updateFromElement();
    146     SVGResourcesCache::clientUpdatedFromElement(this, style());
    147134}
    148135
     
    172159}
    173160
    174 bool RenderSVGImage::nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int, HitTestAction)
    175 {
    176     ASSERT_NOT_REACHED();
    177     return false;
    178 }
    179 
    180161FloatRect RenderSVGImage::repaintRectInLocalCoordinates() const
    181162{
     
    190171}
    191172
    192 void RenderSVGImage::imageChanged(WrappedImagePtr image, const IntRect* rect)
     173void RenderSVGImage::imageChanged(WrappedImagePtr, const IntRect*)
    193174{
    194     RenderImage::imageChanged(image, rect);
    195 
    196175    // The image resource defaults to nullImage until the resource arrives.
    197176    // This empty image may be cached by SVG resources which must be invalidated.
     
    205184}
    206185
    207 IntRect RenderSVGImage::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer)
    208 {
    209     return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer);
    210 }
    211 
    212 void RenderSVGImage::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
    213 {
    214     SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
    215 }
    216 
    217 void RenderSVGImage::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const
    218 {
    219     SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState);
    220 }
    221 
    222186void RenderSVGImage::addFocusRingRects(Vector<IntRect>& rects, int, int)
    223187{
     
    228192}
    229193
    230 void RenderSVGImage::absoluteRects(Vector<IntRect>&, int, int)
    231 {
    232     // This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used.
    233     ASSERT_NOT_REACHED();
    234 }
    235 
    236 void RenderSVGImage::absoluteQuads(Vector<FloatQuad>& quads)
    237 {
    238     quads.append(localToAbsoluteQuad(strokeBoundingBox()));
    239 }
    240 
    241 }
     194} // namespace WebCore
    242195
    243196#endif // ENABLE(SVG)
  • trunk/WebCore/rendering/RenderSVGImage.h

    r66584 r66599  
    44    Copyright (C) 2007 Rob Buis <buis@kde.org>
    55    Copyright (C) 2009 Google, Inc.
     6    Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
    67
    78    This library is free software; you can redistribute it and/or
     
    2728#include "AffineTransform.h"
    2829#include "FloatRect.h"
    29 #include "RenderImage.h"
     30#include "RenderSVGModelObject.h"
    3031#include "SVGPreserveAspectRatio.h"
    3132#include "SVGRenderSupport.h"
     
    3334namespace WebCore {
    3435
     36class RenderImageResource;
    3537class SVGImageElement;
    3638
    37 class RenderSVGImage : public RenderImage {
     39class RenderSVGImage : public RenderSVGModelObject {
    3840public:
    3941    RenderSVGImage(SVGImageElement*);
     42    virtual ~RenderSVGImage();
    4043
    4144    virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
     45
     46    RenderImageResource* imageResource() { return m_imageResource.get(); }
     47    const RenderImageResource* imageResource() const { return m_imageResource.get(); }
    4248
    4349private:
     
    5157    virtual FloatRect repaintRectInLocalCoordinates() const;
    5258
    53     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
    54     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
    55 
    56     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
    57 
    58     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
    59     virtual void absoluteQuads(Vector<FloatQuad>&);
    6059    virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
    6160
    6261    virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
    63    
     62
    6463    virtual void layout();
    6564    virtual void paint(PaintInfo&, int parentX, int parentY);
    66 
    67     virtual void destroy();
    68     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
    69     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
    70     virtual void updateFromElement();
    7165
    7266    virtual bool requiresLayer() const { return false; }
    7367
    7468    virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
    75     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    7669
    7770    virtual AffineTransform localTransform() const { return m_localTransform; }
     
    8174    FloatRect m_localBounds;
    8275    mutable FloatRect m_cachedLocalRepaintRect;
     76    OwnPtr<RenderImageResource> m_imageResource;
    8377};
    8478
  • trunk/WebCore/rendering/RenderSVGModelObject.h

    r66584 r66599  
    4040
    4141// Most renderers in the SVG rendering tree will inherit from this class
    42 // but not all. (e.g. RenderSVGForeignObject, RenderSVGBlock, RenderSVGImage) thus methods
     42// but not all. (e.g. RenderSVGForeignObject, RenderSVGBlock) thus methods
    4343// required by SVG renders need to be declared on RenderObject, but shared
    4444// logic can go in this class or in SVGRenderSupport.
  • trunk/WebCore/svg/SVGImageElement.cpp

    r66498 r66599  
    2727#include "Attribute.h"
    2828#include "CSSPropertyNames.h"
     29#include "RenderImageResource.h"
    2930#include "RenderSVGImage.h"
    3031#include "RenderSVGResource.h"
Note: See TracChangeset for help on using the changeset viewer.