Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / svg / RenderSVGRoot.h
1 /*
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.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #ifndef RenderSVGRoot_h
24 #define RenderSVGRoot_h
25
26 #include "core/rendering/RenderReplaced.h"
27 #include "core/rendering/svg/SVGRenderSupport.h"
28 #include "platform/geometry/FloatRect.h"
29
30 namespace WebCore {
31
32 class AffineTransform;
33 class SVGElement;
34
35 class RenderSVGRoot FINAL : public RenderReplaced {
36 public:
37     explicit RenderSVGRoot(SVGElement*);
38     virtual ~RenderSVGRoot();
39
40     bool isEmbeddedThroughSVGImage() const;
41     bool isEmbeddedThroughFrameContainingSVGDocument() const;
42
43     virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const OVERRIDE;
44
45     RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
46     RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
47
48     const RenderObjectChildList* children() const { return &m_children; }
49     RenderObjectChildList* children() { return &m_children; }
50
51     bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; }
52     virtual void setNeedsBoundariesUpdate() OVERRIDE { m_needsBoundariesOrTransformUpdate = true; }
53     virtual void setNeedsTransformUpdate() OVERRIDE { m_needsBoundariesOrTransformUpdate = true; }
54
55     IntSize containerSize() const { return m_containerSize; }
56     void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; }
57
58     virtual bool hasRelativeIntrinsicLogicalWidth() const OVERRIDE;
59     virtual bool hasRelativeLogicalHeight() const OVERRIDE;
60     virtual bool visibleForTouchAction() const OVERRIDE { return true; }
61
62     // localToBorderBoxTransform maps local SVG viewport coordinates to local CSS box coordinates.
63     const AffineTransform& localToBorderBoxTransform() const { return m_localToBorderBoxTransform; }
64
65 private:
66     virtual RenderObjectChildList* virtualChildren() OVERRIDE { return children(); }
67     virtual const RenderObjectChildList* virtualChildren() const OVERRIDE { return children(); }
68
69     virtual const char* renderName() const OVERRIDE { return "RenderSVGRoot"; }
70     virtual bool isSVGRoot() const OVERRIDE { return true; }
71     virtual bool isSVG() const OVERRIDE { return true; }
72
73     virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const OVERRIDE;
74     virtual LayoutUnit computeReplacedLogicalHeight() const OVERRIDE;
75     virtual void layout() OVERRIDE;
76     virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
77
78     virtual void willBeDestroyed() OVERRIDE;
79     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
80     virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
81     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
82     virtual void removeChild(RenderObject*) OVERRIDE;
83     virtual bool canHaveWhitespaceChildren() const OVERRIDE { return false; }
84
85     virtual void insertedIntoTree() OVERRIDE;
86     virtual void willBeRemovedFromTree() OVERRIDE;
87
88     virtual const AffineTransform& localToParentTransform() const OVERRIDE;
89
90     virtual FloatRect objectBoundingBox() const OVERRIDE { return m_objectBoundingBox; }
91     virtual FloatRect strokeBoundingBox() const OVERRIDE { return m_strokeBoundingBox; }
92     virtual FloatRect repaintRectInLocalCoordinates() const OVERRIDE { return m_repaintBoundingBox; }
93
94     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
95
96     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE;
97     virtual void computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const OVERRIDE;
98
99     virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const OVERRIDE;
100     virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const OVERRIDE;
101
102     virtual bool canBeSelectionLeaf() const OVERRIDE { return false; }
103     virtual bool canHaveChildren() const OVERRIDE { return true; }
104
105     void updateCachedBoundaries();
106     void buildLocalToBorderBoxTransform();
107
108     RenderObjectChildList m_children;
109     IntSize m_containerSize;
110     FloatRect m_objectBoundingBox;
111     bool m_objectBoundingBoxValid;
112     FloatRect m_strokeBoundingBox;
113     FloatRect m_repaintBoundingBox;
114     mutable AffineTransform m_localToParentTransform;
115     AffineTransform m_localToBorderBoxTransform;
116     bool m_isLayoutSizeChanged : 1;
117     bool m_needsBoundariesOrTransformUpdate : 1;
118 };
119
120 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGRoot, isSVGRoot());
121
122 } // namespace WebCore
123
124 #endif // RenderSVGRoot_h