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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | Source/core/svg/SVGMaskElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGLengthContext.cpp
diff --git a/Source/core/svg/SVGLengthContext.cpp b/Source/core/svg/SVGLengthContext.cpp
index 9c1a4d15c19902e297c787185e7235ac2ac2bef3..e559e889822dcc24a026de6f2cababcf0070044d 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -32,6 +32,7 @@
#include "core/rendering/svg/RenderSVGRoot.h"
#include "core/rendering/svg/RenderSVGViewportContainer.h"
#include "core/svg/SVGSVGElement.h"
+#include "platform/LengthFunctions.h"
#include "platform/fonts/FontMetrics.h"
namespace blink {
@@ -91,6 +92,27 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
return x->valueAsPercentage();
}
+float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
+{
+ if (length.isPercent())
+ return convertValueFromPercentageToUserUnits(length.value() / 100, mode, IGNORE_EXCEPTION);
+ if (length.isAuto())
+ return 0;
+
+ FloatSize viewportSize;
+ determineViewport(viewportSize);
+
+ switch (mode) {
+ case LengthModeWidth:
+ return floatValueForLength(length, viewportSize.width());
+ case LengthModeHeight:
+ return floatValueForLength(length, viewportSize.height());
+ case LengthModeOther:
+ return floatValueForLength(length, sqrtf(viewportSize.diagonalLengthSquared() / 2));
+ };
+ return 0;
+}
+
float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit, ExceptionState& exceptionState) const
{
switch (fromUnit) {
« 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