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.
33 #include "core/rendering/svg/RenderSVGModelObject.h"
36 #include "core/rendering/svg/RenderSVGRoot.h"
37 #include "core/rendering/svg/SVGResourcesCache.h"
38 #include "core/svg/SVGGraphicsElement.h"
42 RenderSVGModelObject::RenderSVGModelObject(SVGElement* node)
47 bool RenderSVGModelObject::isChildAllowed(RenderObject* child, RenderStyle*) const
49 return child->isSVG() && !(child->isSVGInline() || child->isSVGInlineText());
52 LayoutRect RenderSVGModelObject::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
54 return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer);
57 void RenderSVGModelObject::computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const
59 SVGRenderSupport::computeFloatRectForRepaint(this, repaintContainer, repaintRect, fixed);
62 void RenderSVGModelObject::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed) const
64 SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
67 const RenderObject* RenderSVGModelObject::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
69 return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap);
72 void RenderSVGModelObject::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
74 IntRect rect = enclosingIntRect(strokeBoundingBox());
75 rect.moveBy(roundedIntPoint(accumulatedOffset));
79 void RenderSVGModelObject::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
81 quads.append(localToAbsoluteQuad(strokeBoundingBox(), 0 /* mode */, wasFixed));
84 void RenderSVGModelObject::willBeDestroyed()
86 SVGResourcesCache::clientDestroyed(this);
87 RenderObject::willBeDestroyed();
90 void RenderSVGModelObject::computeLayerHitTestRects(LayerHitTestRects& rects) const
92 // Using just the rect for the SVGRoot is good enough for now.
93 SVGRenderSupport::findTreeRootObject(this)->computeLayerHitTestRects(rects);
96 void RenderSVGModelObject::addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const
98 // We don't walk into SVG trees at all - just report their container.
101 void RenderSVGModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
103 if (diff == StyleDifferenceLayout) {
104 setNeedsBoundariesUpdate();
105 if (style()->hasTransform())
106 setNeedsTransformUpdate();
109 RenderObject::styleDidChange(diff, oldStyle);
110 SVGResourcesCache::clientStyleChanged(this, diff, style());
113 bool RenderSVGModelObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction)
115 ASSERT_NOT_REACHED();
119 // The SVG addFocusRingRects() method adds rects in local coordinates so the default absoluteFocusRingQuads
120 // returns incorrect values for SVG objects. Overriding this method provides access to the absolute bounds.
121 void RenderSVGModelObject::absoluteFocusRingQuads(Vector<FloatQuad>& quads)
123 quads.append(localToAbsoluteQuad(FloatQuad(repaintRectInLocalCoordinates())));
126 } // namespace WebCore