2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2009 Google, Inc. All rights reserved.
5 * Copyright (C) 2009 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
23 #ifndef RenderSVGRoot_h
24 #define RenderSVGRoot_h
27 #include "FloatRect.h"
28 #include "RenderReplaced.h"
30 #include "SVGRenderSupport.h"
34 class AffineTransform;
37 class RenderSVGRoot FINAL : public RenderReplaced {
39 explicit RenderSVGRoot(SVGSVGElement&);
40 virtual ~RenderSVGRoot();
42 SVGSVGElement& svgSVGElement() const;
44 bool isEmbeddedThroughSVGImage() const;
45 bool isEmbeddedThroughFrameContainingSVGDocument() const;
47 virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const OVERRIDE;
49 bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; }
50 virtual void setNeedsBoundariesUpdate() OVERRIDE { m_needsBoundariesOrTransformUpdate = true; }
51 virtual bool needsBoundariesUpdate() OVERRIDE { return m_needsBoundariesOrTransformUpdate; }
52 virtual void setNeedsTransformUpdate() OVERRIDE { m_needsBoundariesOrTransformUpdate = true; }
54 IntSize containerSize() const { return m_containerSize; }
55 void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; }
57 virtual bool hasRelativeDimensions() const OVERRIDE;
58 virtual bool hasRelativeIntrinsicLogicalWidth() const OVERRIDE;
59 virtual bool hasRelativeLogicalHeight() const OVERRIDE;
61 // localToBorderBoxTransform maps local SVG viewport coordinates to local CSS box coordinates.
62 const AffineTransform& localToBorderBoxTransform() const { return m_localToBorderBoxTransform; }
64 // The flag is cleared at the beginning of each layout() pass. Elements then call this
65 // method during layout when they are invalidated by a filter.
66 static void addResourceForClientInvalidation(RenderSVGResourceContainer*);
68 bool hasSVGShadow() const { return m_hasSVGShadow; }
69 void setHasSVGShadow(bool hasShadow) { m_hasSVGShadow = hasShadow; }
72 void element() const WTF_DELETED_FUNCTION;
74 virtual bool isSVGRoot() const OVERRIDE { return true; }
75 virtual const char* renderName() const OVERRIDE { return "RenderSVGRoot"; }
77 virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = ComputeActual) const OVERRIDE;
78 virtual LayoutUnit computeReplacedLogicalHeight() const OVERRIDE;
79 virtual void layout() OVERRIDE;
80 virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
82 virtual void willBeDestroyed() OVERRIDE;
83 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
84 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
85 virtual void removeChild(RenderObject&) OVERRIDE;
87 virtual const AffineTransform& localToParentTransform() const OVERRIDE;
89 bool fillContains(const FloatPoint&) const;
90 bool strokeContains(const FloatPoint&) const;
92 virtual FloatRect objectBoundingBox() const OVERRIDE { return m_objectBoundingBox; }
93 virtual FloatRect strokeBoundingBox() const OVERRIDE { return m_strokeBoundingBox; }
94 virtual FloatRect repaintRectInLocalCoordinates() const OVERRIDE { return m_repaintBoundingBox; }
95 virtual FloatRect repaintRectInLocalCoordinatesExcludingSVGShadow() const { return m_repaintBoundingBoxExcludingShadow; }
97 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
99 virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE;
100 virtual void computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const OVERRIDE;
102 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const OVERRIDE;
103 virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const OVERRIDE;
105 virtual bool canBeSelectionLeaf() const OVERRIDE { return false; }
106 virtual bool canHaveChildren() const OVERRIDE { return true; }
108 void updateCachedBoundaries();
109 void buildLocalToBorderBoxTransform();
111 IntSize m_containerSize;
112 FloatRect m_objectBoundingBox;
113 bool m_objectBoundingBoxValid;
114 FloatRect m_strokeBoundingBox;
115 FloatRect m_repaintBoundingBox;
116 FloatRect m_repaintBoundingBoxExcludingShadow;
117 mutable AffineTransform m_localToParentTransform;
118 AffineTransform m_localToBorderBoxTransform;
119 HashSet<RenderSVGResourceContainer*> m_resourcesNeedingToInvalidateClients;
120 bool m_isLayoutSizeChanged : 1;
121 bool m_needsBoundariesOrTransformUpdate : 1;
122 bool m_hasSVGShadow : 1;
125 RENDER_OBJECT_TYPE_CASTS(RenderSVGRoot, isSVGRoot())
127 } // namespace WebCore
129 #endif // ENABLE(SVG)
130 #endif // RenderSVGRoot_h