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 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "core/rendering/svg/RenderSVGModelObject.h" | 29 #include "core/rendering/svg/RenderSVGModelObject.h" |
30 #include "core/rendering/svg/SVGMarkerData.h" | 30 #include "core/rendering/svg/SVGMarkerData.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 GraphicsContextStateSaver; | |
40 class PointerEventsHitRules; | 39 class PointerEventsHitRules; |
41 class SVGGraphicsElement; | 40 class SVGGraphicsElement; |
42 | 41 |
43 class RenderSVGShape : public RenderSVGModelObject { | 42 class RenderSVGShape : public RenderSVGModelObject { |
44 public: | 43 public: |
45 explicit RenderSVGShape(SVGGraphicsElement*); | 44 explicit RenderSVGShape(SVGGraphicsElement*); |
46 virtual ~RenderSVGShape(); | 45 virtual ~RenderSVGShape(); |
47 | 46 |
48 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; } | 47 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; } |
49 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp date = true; } | 48 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp date = true; } |
50 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda te = true; } | 49 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda te = true; } |
51 virtual void fillShape(GraphicsContext*) const; | |
52 virtual void strokeShape(GraphicsContext*) const; | |
53 | 50 |
54 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin terEventsHitRules); | 51 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin terEventsHitRules); |
55 | 52 |
56 Path& path() const | 53 Path& path() const |
57 { | 54 { |
58 ASSERT(m_path); | 55 ASSERT(m_path); |
59 return *m_path; | 56 return *m_path; |
60 } | 57 } |
58 bool hasPath() const { return m_path.get(); } | |
61 | 59 |
62 virtual bool isShapeEmpty() const { return path().isEmpty(); } | 60 virtual bool isShapeEmpty() const { return path().isEmpty(); } |
63 | 61 |
62 virtual FloatRect paintInvalidationRectInLocalCoordinates() const override f inal { return m_paintInvalidationBoundingBox; } | |
chrishtr
2014/10/27 03:34:11
Can this one be un-virtualized?
chrishtr
2014/10/27 03:34:12
Can this one be un-virtualized?
fs
2014/10/27 12:36:27
Not quite yet I think (still a few places calling
| |
63 | |
64 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; } | |
65 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const; | |
66 AffineTransform nonScalingStrokeTransform() const; | |
67 virtual AffineTransform localTransform() const override final { return m_loc alTransform; } | |
68 | |
69 virtual const Vector<MarkerPosition>* markerPositions() const { return 0; } | |
70 | |
71 float strokeWidth() const; | |
72 | |
73 virtual bool useRectRenderingFastPath() const { return false; } | |
74 virtual bool useEllipseRenderingFastPath() const { return false; } | |
fs
2014/10/27 12:36:27
Why two extension points for this? They'll be mutu
pdr.
2014/10/27 22:29:43
Good idea, done.
| |
75 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return 0; }; | |
fs
2014/10/27 12:36:27
Nit: Redundant ';'.
pdr.
2014/10/27 22:29:43
Done.
| |
76 | |
77 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; } | |
78 | |
64 protected: | 79 protected: |
65 virtual void updateShapeFromElement(); | 80 virtual void updateShapeFromElement(); |
66 virtual bool shapeDependentStrokeContains(const FloatPoint&); | 81 virtual bool shapeDependentStrokeContains(const FloatPoint&); |
67 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst; | 82 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst; |
68 float strokeWidth() const; | |
69 bool hasPath() const { return m_path.get(); } | |
70 bool hasSmoothStroke() const; | 83 bool hasSmoothStroke() const; |
71 | 84 |
72 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; } | 85 // Give RenderSVGPath a hook for updating markers in updateShapeFromElement. |
73 AffineTransform nonScalingStrokeTransform() const; | 86 virtual void processMarkerPositions() { }; |
fs
2014/10/27 12:36:27
Nit: Redundant ';'
| |
74 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const; | |
75 | 87 |
76 FloatRect m_fillBoundingBox; | 88 FloatRect m_fillBoundingBox; |
77 FloatRect m_strokeBoundingBox; | 89 FloatRect m_strokeBoundingBox; |
78 | 90 |
79 private: | 91 private: |
80 // Hit-detection separated for the fill and the stroke | 92 // Hit-detection separated for the fill and the stroke |
81 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO); | 93 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO); |
82 bool strokeContains(const FloatPoint&, bool requiresStroke = true); | 94 bool strokeContains(const FloatPoint&, bool requiresStroke = true); |
83 | 95 |
84 virtual FloatRect paintInvalidationRectInLocalCoordinates() const override f inal { return m_paintInvalidationBoundingBox; } | |
85 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform; } | 96 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform; } |
86 virtual AffineTransform localTransform() const override final { return m_loc alTransform; } | |
87 | 97 |
88 virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectSVGShape || RenderSVGModelObject::isOfType(type); } | 98 virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectSVGShape || RenderSVGModelObject::isOfType(type); } |
89 virtual const char* renderName() const override { return "RenderSVGShape"; } | 99 virtual const char* renderName() const override { return "RenderSVGShape"; } |
90 | 100 |
91 virtual void layout() override final; | 101 virtual void layout() override final; |
92 virtual void paint(PaintInfo&, const LayoutPoint&) override final; | 102 virtual void paint(PaintInfo&, const LayoutPoint&) override final; |
93 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset, const RenderLayerModelObject* paintContainer) const override final; | 103 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset, const RenderLayerModelObject* paintContainer) const override final; |
94 | 104 |
95 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const F loatPoint& pointInParent, HitTestAction) override final; | 105 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const F loatPoint& pointInParent, HitTestAction) override final; |
96 | 106 |
97 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; } | |
98 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; } | 107 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; } |
99 FloatRect calculateObjectBoundingBox() const; | 108 FloatRect calculateObjectBoundingBox() const; |
100 FloatRect calculateStrokeBoundingBox() const; | 109 FloatRect calculateStrokeBoundingBox() const; |
101 void updatePaintInvalidationBoundingBox(); | 110 void updatePaintInvalidationBoundingBox(); |
102 | 111 |
103 bool setupNonScalingStrokeContext(AffineTransform&, GraphicsContextStateSave r&); | |
104 | |
105 bool shouldGenerateMarkerPositions() const; | |
106 FloatRect markerRect(float strokeWidth) const; | |
107 void processMarkerPositions(); | |
108 | |
109 void paintMarkers(PaintInfo&); | |
110 | |
111 private: | 112 private: |
112 FloatRect m_paintInvalidationBoundingBox; | 113 FloatRect m_paintInvalidationBoundingBox; |
113 AffineTransform m_localTransform; | 114 AffineTransform m_localTransform; |
114 OwnPtr<Path> m_path; | 115 OwnPtr<Path> m_path; |
115 Vector<MarkerPosition> m_markerPositions; | |
116 | 116 |
117 bool m_needsBoundariesUpdate : 1; | 117 bool m_needsBoundariesUpdate : 1; |
118 bool m_needsShapeUpdate : 1; | 118 bool m_needsShapeUpdate : 1; |
119 bool m_needsTransformUpdate : 1; | 119 bool m_needsTransformUpdate : 1; |
120 }; | 120 }; |
121 | 121 |
122 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGShape, isSVGShape()); | 122 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGShape, isSVGShape()); |
123 | 123 |
124 } | 124 } |
125 | 125 |
126 #endif | 126 #endif |
OLD | NEW |