Commit 1423ab53 authored by zimmermann@webkit.org's avatar zimmermann@webkit.org

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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66599 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 53660b43
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:
2010-09-01 Mahesh Kulkarni <mahesh.kulkarni@nokia.com>
Reviewed by Laszlo Gombos.
This tests that load dispatching works when there are no
direct listeners, but there are capturing event listeners on an ancestor. Bug 16447
Passed
This tests load dispatching order with externalResourcesRequired. Bug 16447
Passed
This tests normal load dispatching order. Bug 16447
Passed
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'height' attribute of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'preserveAspectRatio' attribute of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'width' attribute of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'x' attribute of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'y' attribute of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'height' property of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'preserveAspectRatio' property of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'width' property of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'x' property of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
SVG 1.1 dynamic update tests
Tests dynamic updates of the 'y' property of the SVGImageElement object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
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.
......@@ -5,6 +5,7 @@
Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org>
Copyright (C) 2009, Google, Inc.
Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -32,6 +33,7 @@
#include "FloatQuad.h"
#include "GraphicsContext.h"
#include "PointerEventsHitRules.h"
#include "RenderImageResource.h"
#include "RenderLayer.h"
#include "RenderSVGResourceContainer.h"
#include "RenderSVGResourceFilter.h"
......@@ -44,10 +46,16 @@
namespace WebCore {
RenderSVGImage::RenderSVGImage(SVGImageElement* impl)
: RenderImage(impl)
: RenderSVGModelObject(impl)
, m_needsTransformUpdate(true)
, m_imageResource(RenderImageResource::create())
{
setImageResource(RenderImageResource::create());
m_imageResource->initialize(this);
}
RenderSVGImage::~RenderSVGImage()
{
m_imageResource->shutdown();
}
void RenderSVGImage::layout()
......@@ -64,12 +72,6 @@ void RenderSVGImage::layout()
updateCachedBoundariesInParents = true;
}
// minimum height
setHeight(imageResource()->errorOccurred() ? intrinsicSize().height() : 0);
calcWidth();
calcHeight();
// FIXME: Optimize caching the repaint rects.
FloatRect oldBoundaries = m_localBounds;
m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image));
......@@ -84,7 +86,7 @@ void RenderSVGImage::layout()
// If our bounds changed, notify the parents.
if (updateCachedBoundariesInParents)
RenderImage::setNeedsBoundariesUpdate();
RenderSVGModelObject::setNeedsBoundariesUpdate();
repainter.repaintAfterLayout();
setNeedsLayout(false);
......@@ -92,58 +94,43 @@ void RenderSVGImage::layout()
void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
{
if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN)
if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || !m_imageResource->hasImage())
return;
paintInfo.context->save();
paintInfo.context->concatCTM(localToParentTransform());
if (paintInfo.phase == PaintPhaseForeground) {
PaintInfo savedInfo(paintInfo);
if (SVGRenderSupport::prepareToRenderSVGContent(this, paintInfo)) {
Image* image = imageResource()->image();
FloatRect destRect = m_localBounds;
FloatRect srcRect(0, 0, image->width(), image->height());
SVGImageElement* imageElt = static_cast<SVGImageElement*>(node());
if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
imageElt->preserveAspectRatio().transformRect(destRect, srcRect);
FloatRect boundingBox = repaintRectInLocalCoordinates();
if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
return;
paintInfo.context->drawImage(image, DeviceColorSpace, destRect, srcRect);
}
SVGRenderSupport::finishRenderSVGContent(this, paintInfo, savedInfo.context);
}
PaintInfo childPaintInfo(paintInfo);
bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
childPaintInfo.context->save();
childPaintInfo.applyTransform(m_localTransform);
if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
paintOutline(paintInfo.context, 0, 0, width(), height());
if (childPaintInfo.phase == PaintPhaseForeground) {
PaintInfo savedInfo(childPaintInfo);
paintInfo.context->restore();
}
if (SVGRenderSupport::prepareToRenderSVGContent(this, childPaintInfo)) {
Image* image = m_imageResource->image();
FloatRect destRect = m_localBounds;
FloatRect srcRect(0, 0, image->width(), image->height());
void RenderSVGImage::destroy()
{
SVGResourcesCache::clientDestroyed(this);
RenderImage::destroy();
}
SVGImageElement* imageElement = static_cast<SVGImageElement*>(node());
if (imageElement->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
imageElement->preserveAspectRatio().transformRect(destRect, srcRect);
void RenderSVGImage::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
{
if (diff == StyleDifferenceLayout)
setNeedsBoundariesUpdate();
RenderImage::styleWillChange(diff, newStyle);
}
childPaintInfo.context->drawImage(image, DeviceColorSpace, destRect, srcRect);
}
void RenderSVGImage::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderImage::styleDidChange(diff, oldStyle);
SVGResourcesCache::clientStyleChanged(this, diff, style());
}
SVGRenderSupport::finishRenderSVGContent(this, childPaintInfo, savedInfo.context);
}
void RenderSVGImage::updateFromElement()
{
RenderImage::updateFromElement();
SVGResourcesCache::clientUpdatedFromElement(this, style());
if (drawsOutline)
paintOutline(childPaintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
static_cast<int>(boundingBox.width()), static_cast<int>(boundingBox.height()));
childPaintInfo.context->restore();
}
}
bool RenderSVGImage::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction)
......@@ -171,12 +158,6 @@ bool RenderSVGImage::nodeAtFloatPoint(const HitTestRequest& request, HitTestResu
return false;
}
bool RenderSVGImage::nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int, HitTestAction)
{
ASSERT_NOT_REACHED();
return false;
}
FloatRect RenderSVGImage::repaintRectInLocalCoordinates() const
{
// If we already have a cached repaint rect, return that
......@@ -189,10 +170,8 @@ FloatRect RenderSVGImage::repaintRectInLocalCoordinates() const
return m_cachedLocalRepaintRect;
}
void RenderSVGImage::imageChanged(WrappedImagePtr image, const IntRect* rect)
void RenderSVGImage::imageChanged(WrappedImagePtr, const IntRect*)
{
RenderImage::imageChanged(image, rect);
// The image resource defaults to nullImage until the resource arrives.
// This empty image may be cached by SVG resources which must be invalidated.
if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this))
......@@ -204,21 +183,6 @@ void RenderSVGImage::imageChanged(WrappedImagePtr image, const IntRect* rect)
repaint();
}
IntRect RenderSVGImage::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer)
{
return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer);
}
void RenderSVGImage::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
{
SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
}
void RenderSVGImage::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const
{
SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState);
}
void RenderSVGImage::addFocusRingRects(Vector<IntRect>& rects, int, int)
{
// this is called from paint() after the localTransform has already been applied
......@@ -227,17 +191,6 @@ void RenderSVGImage::addFocusRingRects(Vector<IntRect>& rects, int, int)
rects.append(contentRect);
}
void RenderSVGImage::absoluteRects(Vector<IntRect>&, int, int)
{
// This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used.
ASSERT_NOT_REACHED();
}
void RenderSVGImage::absoluteQuads(Vector<FloatQuad>& quads)
{
quads.append(localToAbsoluteQuad(strokeBoundingBox()));
}
}
} // namespace WebCore
#endif // ENABLE(SVG)
......@@ -3,6 +3,7 @@
Copyright (C) 2006, 2009 Apple Inc. All rights reserved.
Copyright (C) 2007 Rob Buis <buis@kde.org>
Copyright (C) 2009 Google, Inc.
Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -26,20 +27,25 @@
#if ENABLE(SVG)
#include "AffineTransform.h"
#include "FloatRect.h"
#include "RenderImage.h"
#include "RenderSVGModelObject.h"
#include "SVGPreserveAspectRatio.h"
#include "SVGRenderSupport.h"
namespace WebCore {
class RenderImageResource;
class SVGImageElement;
class RenderSVGImage : public RenderImage {
class RenderSVGImage : public RenderSVGModelObject {
public:
RenderSVGImage(SVGImageElement*);
virtual ~RenderSVGImage();
virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
RenderImageResource* imageResource() { return m_imageResource.get(); }
const RenderImageResource* imageResource() const { return m_imageResource.get(); }
private:
virtual const char* renderName() const { return "RenderSVGImage"; }
virtual bool isSVGImage() const { return true; }
......@@ -50,29 +56,16 @@ private:
virtual FloatRect strokeBoundingBox() const { return m_localBounds; }
virtual FloatRect repaintRectInLocalCoordinates() const;
virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
virtual void absoluteQuads(Vector<FloatQuad>&);
virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
virtual void layout();
virtual void paint(PaintInfo&, int parentX, int parentY);
virtual void destroy();
virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void updateFromElement();
virtual bool requiresLayer() const { return false; }
virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
virtual AffineTransform localTransform() const { return m_localTransform; }
......@@ -80,6 +73,7 @@ private:
AffineTransform m_localTransform;
FloatRect m_localBounds;
mutable FloatRect m_cachedLocalRepaintRect;
OwnPtr<RenderImageResource> m_imageResource;
};
inline RenderSVGImage* toRenderSVGImage(RenderObject* object)
......
......@@ -39,7 +39,7 @@
namespace WebCore {
// Most renderers in the SVG rendering tree will inherit from this class
// but not all. (e.g. RenderSVGForeignObject, RenderSVGBlock, RenderSVGImage) thus methods
// but not all. (e.g. RenderSVGForeignObject, RenderSVGBlock) thus methods
// required by SVG renders need to be declared on RenderObject, but shared
// logic can go in this class or in SVGRenderSupport.
......
......@@ -26,6 +26,7 @@
#include "Attribute.h"
#include "CSSPropertyNames.h"
#include "RenderImageResource.h"
#include "RenderSVGImage.h"
#include "RenderSVGResource.h"
#include "SVGDocument.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment