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

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

Issue 2390773004: reflow comments in core/svg/ (Closed)
Patch Set: comments (heh!) Created 4 years, 2 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) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, 184 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context,
185 SVGUnitTypes::SVGUnitType type, 185 SVGUnitTypes::SVGUnitType type,
186 const SVGLength& x, 186 const SVGLength& x,
187 const SVGLength& y) { 187 const SVGLength& y) {
188 DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type); 188 DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type);
189 if (type == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) { 189 if (type == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) {
190 SVGLengthContext lengthContext(context); 190 SVGLengthContext lengthContext(context);
191 return FloatPoint(x.value(lengthContext), y.value(lengthContext)); 191 return FloatPoint(x.value(lengthContext), y.value(lengthContext));
192 } 192 }
193 193
194 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to be resolved in user space and then be considered in objectBoundingBox space. 194 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to
195 // be resolved in user space and then be considered in objectBoundingBox
196 // space.
195 return FloatPoint(x.valueAsPercentage(), y.valueAsPercentage()); 197 return FloatPoint(x.valueAsPercentage(), y.valueAsPercentage());
196 } 198 }
197 199
198 float SVGLengthContext::resolveLength(const SVGElement* context, 200 float SVGLengthContext::resolveLength(const SVGElement* context,
199 SVGUnitTypes::SVGUnitType type, 201 SVGUnitTypes::SVGUnitType type,
200 const SVGLength& x) { 202 const SVGLength& x) {
201 DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type); 203 DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type);
202 if (type == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) { 204 if (type == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) {
203 SVGLengthContext lengthContext(context); 205 SVGLengthContext lengthContext(context);
204 return x.value(lengthContext); 206 return x.value(lengthContext);
205 } 207 }
206 208
207 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to be resolved in user space and then be considered in objectBoundingBox space. 209 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to
210 // be resolved in user space and then be considered in objectBoundingBox
211 // space.
208 return x.valueAsPercentage(); 212 return x.valueAsPercentage();
209 } 213 }
210 214
211 float SVGLengthContext::valueForLength(const UnzoomedLength& unzoomedLength, 215 float SVGLengthContext::valueForLength(const UnzoomedLength& unzoomedLength,
212 SVGLengthMode mode) const { 216 SVGLengthMode mode) const {
213 return valueForLength(unzoomedLength.length(), 1, mode); 217 return valueForLength(unzoomedLength.length(), 1, mode);
214 } 218 }
215 219
216 float SVGLengthContext::valueForLength(const Length& length, 220 float SVGLengthContext::valueForLength(const Length& length,
217 const ComputedStyle& style, 221 const ComputedStyle& style,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return 0; 390 return 0;
387 391
388 return value * style->getFontMetrics().zeroWidth() / style->effectiveZoom(); 392 return value * style->getFontMetrics().zeroWidth() / style->effectiveZoom();
389 } 393 }
390 394
391 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const { 395 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const {
392 const ComputedStyle* style = computedStyleForLengthResolving(m_context); 396 const ComputedStyle* style = computedStyleForLengthResolving(m_context);
393 if (!style) 397 if (!style)
394 return 0; 398 return 0;
395 399
396 // Use of ceil allows a pixel match to the W3Cs expected output of coords-unit s-03-b.svg 400 // Use of ceil allows a pixel match to the W3Cs expected output of
397 // if this causes problems in real world cases maybe it would be best to remov e this 401 // coords-units-03-b.svg, if this causes problems in real world cases maybe it
402 // would be best to remove this.
398 float xHeight = 403 float xHeight =
399 ceilf(style->getFontMetrics().xHeight() / style->effectiveZoom()); 404 ceilf(style->getFontMetrics().xHeight() / style->effectiveZoom());
400 if (!xHeight) 405 if (!xHeight)
401 return 0; 406 return 0;
402 407
403 return value / xHeight; 408 return value / xHeight;
404 } 409 }
405 410
406 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const { 411 float SVGLengthContext::convertValueFromEXSToUserUnits(float value) const {
407 const ComputedStyle* style = computedStyleForLengthResolving(m_context); 412 const ComputedStyle* style = computedStyleForLengthResolving(m_context);
408 if (!style) 413 if (!style)
409 return 0; 414 return 0;
410 415
411 // Use of ceil allows a pixel match to the W3Cs expected output of coords-unit s-03-b.svg 416 // Use of ceil allows a pixel match to the W3Cs expected output of
412 // if this causes problems in real world cases maybe it would be best to remov e this 417 // coords-units-03-b.svg, if this causes problems in real world cases maybe it
418 // would be best to remove this.
413 return value * 419 return value *
414 ceilf(style->getFontMetrics().xHeight() / style->effectiveZoom()); 420 ceilf(style->getFontMetrics().xHeight() / style->effectiveZoom());
415 } 421 }
416 422
417 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const { 423 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const {
418 if (!m_context) 424 if (!m_context)
419 return false; 425 return false;
420 426
421 // Root <svg> element lengths are resolved against the top level viewport. 427 // Root <svg> element lengths are resolved against the top level viewport.
422 if (m_context->isOutermostSVGSVGElement()) { 428 if (m_context->isOutermostSVGSVGElement()) {
(...skipping 23 matching lines...) Expand all
446 const ComputedStyle* rootStyle = rootElementStyle(m_context); 452 const ComputedStyle* rootStyle = rootElementStyle(m_context);
447 if (!rootStyle) 453 if (!rootStyle)
448 return 0; 454 return 0;
449 455
450 CSSToLengthConversionData conversionData = CSSToLengthConversionData( 456 CSSToLengthConversionData conversionData = CSSToLengthConversionData(
451 style, rootStyle, m_context->document().layoutViewItem(), 1.0f); 457 style, rootStyle, m_context->document().layoutViewItem(), 1.0f);
452 Length length = primitiveValue.convertToLength(conversionData); 458 Length length = primitiveValue.convertToLength(conversionData);
453 return valueForLength(length, 1.0f, mode); 459 return valueForLength(length, 1.0f, mode);
454 } 460 }
455 } // namespace blink 461 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGLength.cpp ('k') | third_party/WebKit/Source/core/svg/SVGLengthList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698