diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/rendering/RenderSVGImage.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/rendering/RenderSVGImage.cpp | 103 |
1 files changed, 46 insertions, 57 deletions
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderSVGImage.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderSVGImage.cpp index 61f65a0..b38352e 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderSVGImage.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderSVGImage.cpp @@ -3,8 +3,7 @@ Copyright (C) 2006 Apple Computer, Inc. Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> - - This file is part of the WebKit project + Copyright (C) 2009, Google, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -29,8 +28,10 @@ #include "Attr.h" #include "FloatConversion.h" +#include "FloatQuad.h" #include "GraphicsContext.h" #include "PointerEventsHitRules.h" +#include "RenderLayer.h" #include "SVGImageElement.h" #include "SVGLength.h" #include "SVGPreserveAspectRatio.h" @@ -125,41 +126,25 @@ void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& s } } -bool RenderSVGImage::calculateLocalTransform() -{ - TransformationMatrix oldTransform = m_localTransform; - m_localTransform = static_cast<SVGStyledTransformableElement*>(element())->animatedLocalTransform(); - return (m_localTransform != oldTransform); -} - void RenderSVGImage::layout() { ASSERT(needsLayout()); - - IntRect oldBounds; - IntRect oldOutlineBox; - bool checkForRepaint = checkForRepaintDuringLayout(); - if (checkForRepaint) { - oldBounds = absoluteClippedOverflowRect(); - oldOutlineBox = absoluteOutlineBounds(); - } - - calculateLocalTransform(); + + LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); + + SVGImageElement* image = static_cast<SVGImageElement*>(node()); + m_localTransform = image->animatedLocalTransform(); // minimum height - m_height = errorOccurred() ? intrinsicSize().height() : 0; + setHeight(errorOccurred() ? intrinsicSize().height() : 0); calcWidth(); calcHeight(); - SVGImageElement* image = static_cast<SVGImageElement*>(node()); m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image)); - calculateAbsoluteBounds(); - - if (checkForRepaint) - repaintAfterLayoutIfNeeded(oldBounds, oldOutlineBox); - + repainter.repaintAfterLayout(); + setNeedsLayout(false); } @@ -169,7 +154,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int) return; paintInfo.context->save(); - paintInfo.context->concatCTM(localTransform()); + paintInfo.context->concatCTM(localToParentTransform()); if (paintInfo.phase == PaintPhaseForeground) { SVGResourceFilter* filter = 0; @@ -186,14 +171,16 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int) adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio()); paintInfo.context->drawImage(image(), destRect, srcRect); - - finishRenderSVGContent(this, paintInfo, m_localBounds, filter, savedInfo.context); + finishRenderSVGContent(this, paintInfo, filter, savedInfo.context); } - + + if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth()) + paintOutline(paintInfo.context, 0, 0, width(), height(), style()); + paintInfo.context->restore(); } -bool RenderSVGImage::nodeAtPoint(const HitTestRequest&, HitTestResult& result, int _x, int _y, int, int, HitTestAction hitTestAction) +bool RenderSVGImage::nodeAtFloatPoint(const HitTestRequest&, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction) { // We only draw in the forground phase, so we only hit-test then. if (hitTestAction != HitTestForeground) @@ -203,12 +190,11 @@ bool RenderSVGImage::nodeAtPoint(const HitTestRequest&, HitTestResult& result, i bool isVisible = (style()->visibility() == VISIBLE); if (isVisible || !hitRules.requireVisible) { - double localX, localY; - absoluteTransform().inverse().map(_x, _y, &localX, &localY); + FloatPoint localPoint = localToParentTransform().inverse().mapPoint(pointInParent); if (hitRules.canHitFill) { - if (m_localBounds.contains(narrowPrecisionToFloat(localX), narrowPrecisionToFloat(localY))) { - updateHitTestResult(result, IntPoint(_x, _y)); + if (m_localBounds.contains(localPoint)) { + updateHitTestResult(result, roundedIntPoint(localPoint)); return true; } } @@ -217,60 +203,63 @@ bool RenderSVGImage::nodeAtPoint(const HitTestRequest&, HitTestResult& result, i return false; } -bool RenderSVGImage::requiresLayer() +bool RenderSVGImage::nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int, HitTestAction) { + ASSERT_NOT_REACHED(); return false; } -FloatRect RenderSVGImage::relativeBBox(bool) const +FloatRect RenderSVGImage::objectBoundingBox() const { return m_localBounds; } +FloatRect RenderSVGImage::repaintRectInLocalCoordinates() const +{ + FloatRect repaintRect = m_localBounds; + + // Filters can paint outside the image content + repaintRect.unite(filterBoundingBoxForRenderer(this)); + + return repaintRect; +} + void RenderSVGImage::imageChanged(WrappedImagePtr image, const IntRect* rect) { RenderImage::imageChanged(image, rect); // We override to invalidate a larger rect, since SVG images can draw outside their "bounds" - repaintRectangle(absoluteClippedOverflowRect()); + repaintRectangle(absoluteClippedOverflowRect()); // FIXME: Isn't this just repaint()? } -void RenderSVGImage::calculateAbsoluteBounds() +IntRect RenderSVGImage::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) { - // FIXME: broken with CSS transforms - FloatRect absoluteRect = absoluteTransform().mapRect(relativeBBox(true)); - -#if ENABLE(SVG_FILTERS) - // Filters can expand the bounding box - SVGResourceFilter* filter = getFilterById(document(), style()->svgStyle()->filter()); - if (filter) - absoluteRect.unite(filter->filterBBoxForItemBBox(absoluteRect)); -#endif - - if (!absoluteRect.isEmpty()) - absoluteRect.inflate(1); // inflate 1 pixel for antialiasing + return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer); +} - m_absoluteBounds = enclosingIntRect(absoluteRect); +void RenderSVGImage::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) +{ + SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); } -IntRect RenderSVGImage::absoluteClippedOverflowRect() +void RenderSVGImage::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const { - return m_absoluteBounds; + SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState); } void RenderSVGImage::addFocusRingRects(GraphicsContext* graphicsContext, int, int) { // this is called from paint() after the localTransform has already been applied - IntRect contentRect = enclosingIntRect(relativeBBox()); + IntRect contentRect = enclosingIntRect(repaintRectInLocalCoordinates()); graphicsContext->addFocusRingRect(contentRect); } -void RenderSVGImage::absoluteRects(Vector<IntRect>& rects, int, int, bool) +void RenderSVGImage::absoluteRects(Vector<IntRect>& rects, int, int) { rects.append(absoluteClippedOverflowRect()); } -void RenderSVGImage::absoluteQuads(Vector<FloatQuad>& quads, bool) +void RenderSVGImage::absoluteQuads(Vector<FloatQuad>& quads) { quads.append(FloatRect(absoluteClippedOverflowRect())); } |