OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2006 Apple Computer, Inc | 5 * Copyright (C) 2006 Apple Computer, Inc |
6 * Copyright (C) 2009 Google, Inc. | 6 * Copyright (C) 2009 Google, Inc. |
7 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> | 7 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> |
8 * Copyright (C) 2011 University of Szeged | 8 * Copyright (C) 2011 University of Szeged |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
11 * modify it under the terms of the GNU Library General Public | 11 * modify it under the terms of the GNU Library General Public |
12 * License as published by the Free Software Foundation; either | 12 * License as published by the Free Software Foundation; either |
13 * version 2 of the License, or (at your option) any later version. | 13 * version 2 of the License, or (at your option) any later version. |
14 * | 14 * |
15 * This library is distributed in the hope that it will be useful, | 15 * This library is distributed in the hope that it will be useful, |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 * Library General Public License for more details. | 18 * Library General Public License for more details. |
19 * | 19 * |
20 * You should have received a copy of the GNU Library General Public License | 20 * You should have received a copy of the GNU Library General Public License |
21 * along with this library; see the file COPYING.LIB. If not, write to | 21 * along with this library; see the file COPYING.LIB. If not, write to |
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 * Boston, MA 02110-1301, USA. | 23 * Boston, MA 02110-1301, USA. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef LayoutSVGShape_h | 26 #ifndef LayoutSVGShape_h |
27 #define LayoutSVGShape_h | 27 #define LayoutSVGShape_h |
28 | 28 |
| 29 #include "core/layout/svg/LayoutSVGModelObject.h" |
29 #include "core/layout/svg/SVGMarkerData.h" | 30 #include "core/layout/svg/SVGMarkerData.h" |
30 #include "core/rendering/svg/RenderSVGModelObject.h" | |
31 #include "platform/geometry/FloatRect.h" | 31 #include "platform/geometry/FloatRect.h" |
32 #include "platform/transforms/AffineTransform.h" | 32 #include "platform/transforms/AffineTransform.h" |
33 #include "wtf/OwnPtr.h" | 33 #include "wtf/OwnPtr.h" |
34 #include "wtf/Vector.h" | 34 #include "wtf/Vector.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class FloatPoint; | 38 class FloatPoint; |
39 class PointerEventsHitRules; | 39 class PointerEventsHitRules; |
40 class SVGGraphicsElement; | 40 class SVGGraphicsElement; |
41 | 41 |
42 enum ShapeGeometryCodePath { | 42 enum ShapeGeometryCodePath { |
43 PathGeometry, | 43 PathGeometry, |
44 RectGeometryFastPath, | 44 RectGeometryFastPath, |
45 EllipseGeometryFastPath | 45 EllipseGeometryFastPath |
46 }; | 46 }; |
47 | 47 |
48 class LayoutSVGShape : public RenderSVGModelObject { | 48 class LayoutSVGShape : public LayoutSVGModelObject { |
49 public: | 49 public: |
50 explicit LayoutSVGShape(SVGGraphicsElement*); | 50 explicit LayoutSVGShape(SVGGraphicsElement*); |
51 virtual ~LayoutSVGShape(); | 51 virtual ~LayoutSVGShape(); |
52 | 52 |
53 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; } | 53 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; } |
54 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp
date = true; } | 54 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp
date = true; } |
55 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda
te = true; } | 55 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda
te = true; } |
56 | 56 |
57 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin
terEventsHitRules); | 57 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin
terEventsHitRules); |
58 | 58 |
59 Path& path() const | 59 Path& path() const |
60 { | 60 { |
61 ASSERT(m_path); | 61 ASSERT(m_path); |
62 return *m_path; | 62 return *m_path; |
63 } | 63 } |
64 bool hasPath() const { return m_path.get(); } | 64 bool hasPath() const { return m_path.get(); } |
65 | 65 |
66 virtual bool isShapeEmpty() const { return path().isEmpty(); } | 66 virtual bool isShapeEmpty() const { return path().isEmpty(); } |
67 | 67 |
68 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect()
== VE_NON_SCALING_STROKE; } | 68 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect()
== VE_NON_SCALING_STROKE; } |
69 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const; | 69 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const; |
70 AffineTransform nonScalingStrokeTransform() const; | 70 AffineTransform nonScalingStrokeTransform() const; |
71 virtual AffineTransform localTransform() const override final { return m_loc
alTransform ? *m_localTransform : RenderSVGModelObject::localTransform(); } | 71 virtual AffineTransform localTransform() const override final { return m_loc
alTransform ? *m_localTransform : LayoutSVGModelObject::localTransform(); } |
72 | 72 |
73 virtual const Vector<MarkerPosition>* markerPositions() const { return 0; } | 73 virtual const Vector<MarkerPosition>* markerPositions() const { return 0; } |
74 | 74 |
75 float strokeWidth() const; | 75 float strokeWidth() const; |
76 | 76 |
77 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry
; } | 77 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry
; } |
78 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return 0; } | 78 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return 0; } |
79 | 79 |
80 virtual FloatRect objectBoundingBox() const override final { return m_fillBo
undingBox; } | 80 virtual FloatRect objectBoundingBox() const override final { return m_fillBo
undingBox; } |
81 | 81 |
82 protected: | 82 protected: |
83 void clearPath() { m_path.clear(); } | 83 void clearPath() { m_path.clear(); } |
84 void createPath(); | 84 void createPath(); |
85 | 85 |
86 virtual void updateShapeFromElement(); | 86 virtual void updateShapeFromElement(); |
87 virtual bool shapeDependentStrokeContains(const FloatPoint&); | 87 virtual bool shapeDependentStrokeContains(const FloatPoint&); |
88 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c
onst; | 88 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c
onst; |
89 | 89 |
90 // Give LayoutSVGPath a hook for updating markers in updateShapeFromElement. | 90 // Give LayoutSVGPath a hook for updating markers in updateShapeFromElement. |
91 virtual void processMarkerPositions() { }; | 91 virtual void processMarkerPositions() { }; |
92 | 92 |
93 FloatRect m_fillBoundingBox; | 93 FloatRect m_fillBoundingBox; |
94 FloatRect m_strokeBoundingBox; | 94 FloatRect m_strokeBoundingBox; |
95 | 95 |
96 private: | 96 private: |
97 // Hit-detection separated for the fill and the stroke | 97 // Hit-detection separated for the fill and the stroke |
98 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul
e fillRule = RULE_NONZERO); | 98 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul
e fillRule = RULE_NONZERO); |
99 bool strokeContains(const FloatPoint&, bool requiresStroke = true); | 99 bool strokeContains(const FloatPoint&, bool requiresStroke = true); |
100 | 100 |
101 virtual const AffineTransform& localToParentTransform() const override final
{ return m_localTransform ? *m_localTransform : RenderSVGModelObject::localToPa
rentTransform(); } | 101 virtual const AffineTransform& localToParentTransform() const override final
{ return m_localTransform ? *m_localTransform : LayoutSVGModelObject::localToPa
rentTransform(); } |
102 | 102 |
103 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectSVGShape || RenderSVGModelObject::isOfType(type); } | 103 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectSVGShape || LayoutSVGModelObject::isOfType(type); } |
104 virtual const char* renderName() const override { return "LayoutSVGShape"; } | 104 virtual const char* renderName() const override { return "LayoutSVGShape"; } |
105 | 105 |
106 virtual void layout() override final; | 106 virtual void layout() override final; |
107 virtual void paint(const PaintInfo&, const LayoutPoint&) override final; | 107 virtual void paint(const PaintInfo&, const LayoutPoint&) override final; |
108 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit
ionalOffset) const override final; | 108 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit
ionalOffset) const override final; |
109 | 109 |
110 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const F
loatPoint& pointInParent, HitTestAction) override final; | 110 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const F
loatPoint& pointInParent, HitTestAction) override final; |
111 | 111 |
112 virtual FloatRect strokeBoundingBox() const override final { return m_stroke
BoundingBox; } | 112 virtual FloatRect strokeBoundingBox() const override final { return m_stroke
BoundingBox; } |
113 FloatRect calculateObjectBoundingBox() const; | 113 FloatRect calculateObjectBoundingBox() const; |
114 FloatRect calculateStrokeBoundingBox() const; | 114 FloatRect calculateStrokeBoundingBox() const; |
115 void updatePaintInvalidationBoundingBox(); | 115 void updatePaintInvalidationBoundingBox(); |
116 void updateLocalTransform(); | 116 void updateLocalTransform(); |
117 | 117 |
118 private: | 118 private: |
119 OwnPtr<AffineTransform> m_localTransform; | 119 OwnPtr<AffineTransform> m_localTransform; |
120 OwnPtr<Path> m_path; | 120 OwnPtr<Path> m_path; |
121 | 121 |
122 bool m_needsBoundariesUpdate : 1; | 122 bool m_needsBoundariesUpdate : 1; |
123 bool m_needsShapeUpdate : 1; | 123 bool m_needsShapeUpdate : 1; |
124 bool m_needsTransformUpdate : 1; | 124 bool m_needsTransformUpdate : 1; |
125 }; | 125 }; |
126 | 126 |
127 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGShape, isSVGShape()); | 127 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGShape, isSVGShape()); |
128 | 128 |
129 } | 129 } |
130 | 130 |
131 #endif | 131 #endif |
OLD | NEW |