2 * Copyright (c) 2009, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "core/rendering/svg/RenderSVGModelObject.h"
34 #include "core/rendering/RenderLayer.h"
35 #include "core/rendering/RenderView.h"
36 #include "core/rendering/svg/RenderSVGContainer.h"
37 #include "core/rendering/svg/RenderSVGRoot.h"
38 #include "core/rendering/svg/SVGRenderSupport.h"
39 #include "core/rendering/svg/SVGResourcesCache.h"
40 #include "core/svg/SVGGraphicsElement.h"
44 RenderSVGModelObject::RenderSVGModelObject(SVGElement* node)
49 bool RenderSVGModelObject::isChildAllowed(RenderObject* child, RenderStyle*) const
51 return child->isSVG() && !(child->isSVGInline() || child->isSVGInlineText());
54 LayoutRect RenderSVGModelObject::clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState) const
56 return SVGRenderSupport::clippedOverflowRectForPaintInvalidation(this, paintInvalidationContainer, paintInvalidationState);
59 void RenderSVGModelObject::computeFloatRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, FloatRect& paintInvalidationRect, const PaintInvalidationState* paintInvalidationState) const
61 SVGRenderSupport::computeFloatRectForPaintInvalidation(this, paintInvalidationContainer, paintInvalidationRect, paintInvalidationState);
64 void RenderSVGModelObject::mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const
66 SVGRenderSupport::mapLocalToContainer(this, paintInvalidationContainer, transformState, wasFixed, paintInvalidationState);
69 const RenderObject* RenderSVGModelObject::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
71 return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap);
74 void RenderSVGModelObject::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
76 IntRect rect = enclosingIntRect(strokeBoundingBox());
77 rect.moveBy(roundedIntPoint(accumulatedOffset));
81 void RenderSVGModelObject::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
83 quads.append(localToAbsoluteQuad(strokeBoundingBox(), 0 /* mode */, wasFixed));
86 void RenderSVGModelObject::willBeDestroyed()
88 SVGResourcesCache::clientDestroyed(this);
89 RenderObject::willBeDestroyed();
92 void RenderSVGModelObject::computeLayerHitTestRects(LayerHitTestRects& rects) const
94 // Using just the rect for the SVGRoot is good enough for now.
95 SVGRenderSupport::findTreeRootObject(this)->computeLayerHitTestRects(rects);
98 void RenderSVGModelObject::addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const
100 // We don't walk into SVG trees at all - just report their container.
103 void RenderSVGModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
105 if (diff.needsFullLayout()) {
106 setNeedsBoundariesUpdate();
107 if (style()->hasTransform())
108 setNeedsTransformUpdate();
111 RenderObject::styleDidChange(diff, oldStyle);
112 SVGResourcesCache::clientStyleChanged(this, diff, style());
115 bool RenderSVGModelObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction)
117 ASSERT_NOT_REACHED();
121 // The SVG addFocusRingRects() method adds rects in local coordinates so the default absoluteFocusRingQuads
122 // returns incorrect values for SVG objects. Overriding this method provides access to the absolute bounds.
123 void RenderSVGModelObject::absoluteFocusRingQuads(Vector<FloatQuad>& quads)
125 quads.append(localToAbsoluteQuad(FloatQuad(paintInvalidationRectInLocalCoordinates())));
128 InvalidationReason RenderSVGModelObject::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState, const RenderLayerModelObject& paintInvalidationContainer)
130 ForceHorriblySlowRectMapping slowRectMapping(&paintInvalidationState);
132 return RenderObject::invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationContainer);