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

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: Put selfHasRelativeLengths back 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
« no previous file with comments | « Source/core/layout/svg/LayoutSVGRect.cpp ('k') | Source/core/layout/svg/LayoutSVGShape.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); }
65 64
66 virtual bool isShapeEmpty() const { return path().isEmpty(); } 65 virtual bool isShapeEmpty() const { return path().isEmpty(); }
67 66
68 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; } 67 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; }
69 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const; 68 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const;
70 AffineTransform nonScalingStrokeTransform() const; 69 AffineTransform nonScalingStrokeTransform() const;
71 virtual AffineTransform localTransform() const override final { return m_loc alTransform ? *m_localTransform : LayoutSVGModelObject::localTransform(); } 70 virtual AffineTransform localTransform() const override final { return m_loc alTransform ? *m_localTransform : LayoutSVGModelObject::localTransform(); }
72 71
73 virtual const Vector<MarkerPosition>* markerPositions() const { return nullp tr; } 72 virtual const Vector<MarkerPosition>* markerPositions() const { return nullp tr; }
74 73
75 float strokeWidth() const; 74 float strokeWidth() const;
76 75
77 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry ; } 76 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry ; }
78 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return nullpt r; } 77 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return nullpt r; }
79 78
80 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; } 79 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; }
81 80
82 virtual const char* name() const override { return "LayoutSVGShape"; } 81 virtual const char* name() const override { return "LayoutSVGShape"; }
83 82
84 protected: 83 protected:
85 void clearPath() { m_path.clear(); } 84 void clearPath() { m_path.clear(); }
86 void createPath();
87 85
86 // Reconstruct the Path. Subclasses may use geometry knowledge to avoid crea ting a Path.
88 virtual void updateShapeFromElement(); 87 virtual void updateShapeFromElement();
88
89 virtual void updateStrokeAndFillBoundingBoxes();
90
89 // Calculates an inclusive bounding box of this shape as if this shape has 91 // 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; 92 // 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 93 // otherwise, estimates a bounding box (not necessarily tight) that would
92 // include this shape's stroke bounding box if it had a stroke. 94 // include this shape's stroke bounding box if it had a stroke.
93 virtual FloatRect hitTestStrokeBoundingBox() const; 95 virtual FloatRect hitTestStrokeBoundingBox() const;
94 virtual bool shapeDependentStrokeContains(const FloatPoint&); 96 virtual bool shapeDependentStrokeContains(const FloatPoint&);
95 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst; 97 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst;
96 98
97 FloatRect m_fillBoundingBox; 99 FloatRect m_fillBoundingBox;
98 FloatRect m_strokeBoundingBox; 100 FloatRect m_strokeBoundingBox;
99 101
100 private: 102 private:
101 // Hit-detection separated for the fill and the stroke 103 // Hit-detection separated for the fill and the stroke
102 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO); 104 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO);
103 bool strokeContains(const FloatPoint&, bool requiresStroke = true); 105 bool strokeContains(const FloatPoint&, bool requiresStroke = true);
104 106
105 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform ? *m_localTransform : LayoutSVGModelObject::localToPa rentTransform(); } 107 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform ? *m_localTransform : LayoutSVGModelObject::localToPa rentTransform(); }
106 108
107 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectSVGShape || LayoutSVGModelObject::isOfType(type); } 109 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectSVGShape || LayoutSVGModelObject::isOfType(type); }
108 virtual void layout() override final; 110 virtual void layout() override final;
109 virtual void paint(const PaintInfo&, const LayoutPoint&) override final; 111 virtual void paint(const PaintInfo&, const LayoutPoint&) override final;
110 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset) const override final; 112 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset) const override final;
111 113
112 virtual bool nodeAtFloatPoint(HitTestResult&, const FloatPoint& pointInParen t, HitTestAction) override final; 114 virtual bool nodeAtFloatPoint(HitTestResult&, const FloatPoint& pointInParen t, HitTestAction) override final;
113 115
114 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; } 116 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; }
115 FloatRect calculateObjectBoundingBox() const; 117
116 FloatRect calculateStrokeBoundingBox() const;
117 void updatePaintInvalidationBoundingBox(); 118 void updatePaintInvalidationBoundingBox();
118 void updateLocalTransform(); 119 void updateLocalTransform();
119 120
120 private: 121 private:
121 OwnPtr<AffineTransform> m_localTransform; 122 OwnPtr<AffineTransform> m_localTransform;
122 OwnPtr<Path> m_path; 123 OwnPtr<Path> m_path;
123 124
124 bool m_needsBoundariesUpdate : 1; 125 bool m_needsBoundariesUpdate : 1;
125 bool m_needsShapeUpdate : 1; 126 bool m_needsShapeUpdate : 1;
126 bool m_needsTransformUpdate : 1; 127 bool m_needsTransformUpdate : 1;
127 }; 128 };
128 129
129 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGShape, isSVGShape()); 130 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGShape, isSVGShape());
130 131
131 } 132 }
132 133
133 #endif 134 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGRect.cpp ('k') | Source/core/layout/svg/LayoutSVGShape.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698