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

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

Issue 898873002: CL for perf tryjob (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | Source/core/svg/SVGMaskElement.h » ('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, 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 14 matching lines...) Expand all
25 25
26 #include "bindings/core/v8/ExceptionMessages.h" 26 #include "bindings/core/v8/ExceptionMessages.h"
27 #include "bindings/core/v8/ExceptionState.h" 27 #include "bindings/core/v8/ExceptionState.h"
28 #include "core/SVGNames.h" 28 #include "core/SVGNames.h"
29 #include "core/css/CSSHelper.h" 29 #include "core/css/CSSHelper.h"
30 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
31 #include "core/rendering/RenderView.h" 31 #include "core/rendering/RenderView.h"
32 #include "core/rendering/svg/RenderSVGRoot.h" 32 #include "core/rendering/svg/RenderSVGRoot.h"
33 #include "core/rendering/svg/RenderSVGViewportContainer.h" 33 #include "core/rendering/svg/RenderSVGViewportContainer.h"
34 #include "core/svg/SVGSVGElement.h" 34 #include "core/svg/SVGSVGElement.h"
35 #include "platform/LengthFunctions.h"
35 #include "platform/fonts/FontMetrics.h" 36 #include "platform/fonts/FontMetrics.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 SVGLengthContext::SVGLengthContext(const SVGElement* context) 40 SVGLengthContext::SVGLengthContext(const SVGElement* context)
40 : m_context(context) 41 : m_context(context)
41 { 42 {
42 } 43 }
43 44
44 FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitT ypes::SVGUnitType type, const FloatRect& viewport, PassRefPtrWillBeRawPtr<SVGLen gth> passX, PassRefPtrWillBeRawPtr<SVGLength> passY, PassRefPtrWillBeRawPtr<SVGL ength> passWidth, PassRefPtrWillBeRawPtr<SVGLength> passHeight) 45 FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitT ypes::SVGUnitType type, const FloatRect& viewport, PassRefPtrWillBeRawPtr<SVGLen gth> passX, PassRefPtrWillBeRawPtr<SVGLength> passY, PassRefPtrWillBeRawPtr<SVGL ength> passWidth, PassRefPtrWillBeRawPtr<SVGLength> passHeight)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); 85 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN);
85 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { 86 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
86 SVGLengthContext lengthContext(context); 87 SVGLengthContext lengthContext(context);
87 return x->value(lengthContext); 88 return x->value(lengthContext);
88 } 89 }
89 90
90 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need t o be resolved in user space and then be considered in objectBoundingBox space. 91 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need t o be resolved in user space and then be considered in objectBoundingBox space.
91 return x->valueAsPercentage(); 92 return x->valueAsPercentage();
92 } 93 }
93 94
95 float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
96 {
97 if (length.isPercent())
98 return convertValueFromPercentageToUserUnits(length.value() / 100, mode, IGNORE_EXCEPTION);
99 if (length.isAuto())
100 return 0;
101
102 FloatSize viewportSize;
103 determineViewport(viewportSize);
104
105 switch (mode) {
106 case LengthModeWidth:
107 return floatValueForLength(length, viewportSize.width());
108 case LengthModeHeight:
109 return floatValueForLength(length, viewportSize.height());
110 case LengthModeOther:
111 return floatValueForLength(length, sqrtf(viewportSize.diagonalLengthSqua red() / 2));
112 };
113 return 0;
114 }
115
94 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit, ExceptionState& exceptionState) const 116 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit, ExceptionState& exceptionState) const
95 { 117 {
96 switch (fromUnit) { 118 switch (fromUnit) {
97 case LengthTypeUnknown: 119 case LengthTypeUnknown:
98 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(3, "SVGLengthType")); 120 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(3, "SVGLengthType"));
99 return 0; 121 return 0;
100 case LengthTypeNumber: 122 case LengthTypeNumber:
101 return value; 123 return value;
102 case LengthTypePX: 124 case LengthTypePX:
103 return value; 125 return value;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 333
312 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); 334 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement);
313 viewportSize = svg.currentViewBoxRect().size(); 335 viewportSize = svg.currentViewBoxRect().size();
314 if (viewportSize.isEmpty()) 336 if (viewportSize.isEmpty())
315 viewportSize = svg.currentViewportSize(); 337 viewportSize = svg.currentViewportSize();
316 338
317 return true; 339 return true;
318 } 340 }
319 341
320 } 342 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | Source/core/svg/SVGMaskElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698