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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGGeometryElement.cpp

Issue 2912663002: Clean up creation of "detached" SVG* data type objects (Closed)
Patch Set: Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 2 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return 0; 123 return 0;
124 return AsPath().length(); 124 return AsPath().length();
125 } 125 }
126 126
127 SVGPointTearOff* SVGGeometryElement::getPointAtLength(float length) { 127 SVGPointTearOff* SVGGeometryElement::getPointAtLength(float length) {
128 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 128 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
129 129
130 FloatPoint point; 130 FloatPoint point;
131 if (GetLayoutObject()) 131 if (GetLayoutObject())
132 point = AsPath().PointAtLength(length); 132 point = AsPath().PointAtLength(length);
133 return SVGPointTearOff::Create(SVGPoint::Create(point), 0, 133 return SVGPointTearOff::CreateDetached(point);
134 kPropertyIsNotAnimVal);
135 } 134 }
136 135
137 float SVGGeometryElement::ComputePathLength() const { 136 float SVGGeometryElement::ComputePathLength() const {
138 return AsPath().length(); 137 return AsPath().length();
139 } 138 }
140 139
141 float SVGGeometryElement::PathLengthScaleFactor() const { 140 float SVGGeometryElement::PathLengthScaleFactor() const {
142 if (!pathLength()->IsSpecified()) 141 if (!pathLength()->IsSpecified())
143 return 1; 142 return 1;
144 float author_path_length = pathLength()->CurrentValue()->Value(); 143 float author_path_length = pathLength()->CurrentValue()->Value();
145 if (author_path_length < 0) 144 if (author_path_length < 0)
146 return 1; 145 return 1;
147 if (!author_path_length) 146 if (!author_path_length)
148 return 0; 147 return 0;
149 DCHECK(GetLayoutObject()); 148 DCHECK(GetLayoutObject());
150 float computed_path_length = ComputePathLength(); 149 float computed_path_length = ComputePathLength();
151 if (!computed_path_length) 150 if (!computed_path_length)
152 return 1; 151 return 1;
153 return computed_path_length / author_path_length; 152 return computed_path_length / author_path_length;
154 } 153 }
155 154
156 LayoutObject* SVGGeometryElement::CreateLayoutObject(const ComputedStyle&) { 155 LayoutObject* SVGGeometryElement::CreateLayoutObject(const ComputedStyle&) {
157 // By default, any subclass is expected to do path-based drawing. 156 // By default, any subclass is expected to do path-based drawing.
158 return new LayoutSVGPath(this); 157 return new LayoutSVGPath(this);
159 } 158 }
160 159
161 } // namespace blink 160 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAngleTearOff.cpp ('k') | third_party/WebKit/Source/core/svg/SVGGraphicsElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698