Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: Source/core/layout/svg/LayoutSVGShape.h

Issue 1158583003: Reduce how often LayoutSVGShape::updateShapeFromElement is called (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix marker regression Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 PathGeometry, 43 PathGeometry,
44 RectGeometryFastPath, 44 RectGeometryFastPath,
45 EllipseGeometryFastPath 45 EllipseGeometryFastPath
46 }; 46 };
47 47
48 class LayoutSVGShape : public LayoutSVGModelObject { 48 class LayoutSVGShape : public LayoutSVGModelObject {
49 public: 49 public:
50 explicit LayoutSVGShape(SVGGeometryElement*); 50 explicit LayoutSVGShape(SVGGeometryElement*);
51 virtual ~LayoutSVGShape(); 51 virtual ~LayoutSVGShape();
52 52
53 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override final;
54
53 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; } 55 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; }
54 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp date = true; } 56 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp date = true; }
55 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda te = true; } 57 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda te = true; }
56 58
57 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin terEventsHitRules); 59 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin terEventsHitRules);
58 60
59 Path& path() const 61 Path& path() const
60 { 62 {
61 ASSERT(m_path); 63 ASSERT(m_path);
62 return *m_path; 64 return *m_path;
63 } 65 }
64 bool hasPath() const { return m_path.get(); }
65 66
66 virtual bool isShapeEmpty() const { return path().isEmpty(); } 67 virtual bool isShapeEmpty() const { return path().isEmpty(); }
67 68
68 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; } 69 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; }
69 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const; 70 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const;
70 AffineTransform nonScalingStrokeTransform() const; 71 AffineTransform nonScalingStrokeTransform() const;
71 virtual AffineTransform localTransform() const override final { return m_loc alTransform ? *m_localTransform : LayoutSVGModelObject::localTransform(); } 72 virtual AffineTransform localTransform() const override final { return m_loc alTransform ? *m_localTransform : LayoutSVGModelObject::localTransform(); }
72 73
73 virtual const Vector<MarkerPosition>* markerPositions() const { return nullp tr; } 74 virtual const Vector<MarkerPosition>* markerPositions() const { return nullp tr; }
74 75
75 float strokeWidth() const; 76 float strokeWidth() const;
76 77
77 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry ; } 78 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry ; }
78 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return nullpt r; } 79 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return nullpt r; }
79 80
80 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; } 81 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; }
81 82
82 virtual const char* name() const override { return "LayoutSVGShape"; } 83 virtual const char* name() const override { return "LayoutSVGShape"; }
83 84
84 protected: 85 protected:
85 void clearPath() { m_path.clear(); } 86 void clearPath() { m_path.clear(); }
86 void createPath();
87 87
88 // Reconstruct the Path. Subclasses may use geometry knowledge to avoid crea ting a Path.
88 virtual void updateShapeFromElement(); 89 virtual void updateShapeFromElement();
90
91 virtual void updateStrokeAndFillBoundingBoxes();
92
89 // Calculates an inclusive bounding box of this shape as if this shape has 93 // Calculates an inclusive bounding box of this shape as if this shape has
90 // a stroke. If this shape has a stroke, then m_strokeBoundingBox is returne d; 94 // a stroke. If this shape has a stroke, then m_strokeBoundingBox is returne d;
91 // otherwise, estimates a bounding box (not necessarily tight) that would 95 // otherwise, estimates a bounding box (not necessarily tight) that would
92 // include this shape's stroke bounding box if it had a stroke. 96 // include this shape's stroke bounding box if it had a stroke.
93 virtual FloatRect hitTestStrokeBoundingBox() const; 97 virtual FloatRect hitTestStrokeBoundingBox() const;
94 virtual bool shapeDependentStrokeContains(const FloatPoint&); 98 virtual bool shapeDependentStrokeContains(const FloatPoint&);
95 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst; 99 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst;
96 100
97 FloatRect m_fillBoundingBox; 101 FloatRect m_fillBoundingBox;
98 FloatRect m_strokeBoundingBox; 102 FloatRect m_strokeBoundingBox;
99 103
100 private: 104 private:
101 // Hit-detection separated for the fill and the stroke 105 // Hit-detection separated for the fill and the stroke
102 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO); 106 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO);
103 bool strokeContains(const FloatPoint&, bool requiresStroke = true); 107 bool strokeContains(const FloatPoint&, bool requiresStroke = true);
104 108
105 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform ? *m_localTransform : LayoutSVGModelObject::localToPa rentTransform(); } 109 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform ? *m_localTransform : LayoutSVGModelObject::localToPa rentTransform(); }
106 110
107 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectSVGShape || LayoutSVGModelObject::isOfType(type); } 111 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectSVGShape || LayoutSVGModelObject::isOfType(type); }
108 virtual void layout() override final; 112 virtual void layout() override final;
109 virtual void paint(const PaintInfo&, const LayoutPoint&) override final; 113 virtual void paint(const PaintInfo&, const LayoutPoint&) override final;
110 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset) const override final; 114 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset) const override final;
111 115
112 virtual bool nodeAtFloatPoint(HitTestResult&, const FloatPoint& pointInParen t, HitTestAction) override final; 116 virtual bool nodeAtFloatPoint(HitTestResult&, const FloatPoint& pointInParen t, HitTestAction) override final;
113 117
114 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; } 118 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; }
115 FloatRect calculateObjectBoundingBox() const; 119
116 FloatRect calculateStrokeBoundingBox() const;
117 void updatePaintInvalidationBoundingBox(); 120 void updatePaintInvalidationBoundingBox();
118 void updateLocalTransform(); 121 void updateLocalTransform();
119 122
120 private: 123 private:
121 OwnPtr<AffineTransform> m_localTransform; 124 OwnPtr<AffineTransform> m_localTransform;
122 OwnPtr<Path> m_path; 125 OwnPtr<Path> m_path;
123 126
124 bool m_needsBoundariesUpdate : 1; 127 bool m_needsBoundariesUpdate : 1;
125 bool m_needsShapeUpdate : 1; 128 bool m_needsShapeUpdate : 1;
126 bool m_needsTransformUpdate : 1; 129 bool m_needsTransformUpdate : 1;
127 }; 130 };
128 131
129 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGShape, isSVGShape()); 132 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGShape, isSVGShape());
130 133
131 } 134 }
132 135
133 #endif 136 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698