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

Unified Diff: Source/core/svg/SVGLengthContext.cpp

Issue 727683003: CL for perf tryjob Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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') | Tools/run-perf-test.cfg » ('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 d141761e87c8578f805b95bd1c72ee7de4832846..b1991a5b27eeedcf715ac2bf9a643df72d48b4da 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -41,10 +41,12 @@ SVGLengthContext::SVGLengthContext(const SVGElement* context)
{
}
-SVGLengthContext::SVGLengthContext(const SVGElement* context, const FloatRect& viewport)
- : m_context(context)
- , m_overridenViewport(viewport)
+static float valueInSpecifiedUnitsWithPercentAdjustment(const SVGLength& length)
{
+ // 100% = 100.0 instead of 1.0 for historical reasons.
+ if (length.unitType() == LengthTypePercentage)
+ return length.valueInSpecifiedUnits() / 100;
+ return length.valueInSpecifiedUnits();
}
FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitTypes::SVGUnitType type, const FloatRect& viewport, PassRefPtrWillBeRawPtr<SVGLength> passX, PassRefPtrWillBeRawPtr<SVGLength> passY, PassRefPtrWillBeRawPtr<SVGLength> passWidth, PassRefPtrWillBeRawPtr<SVGLength> passHeight)
@@ -55,17 +57,17 @@ FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitT
RefPtrWillBeRawPtr<SVGLength> height = passHeight;
ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN);
- if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
- SVGLengthContext lengthContext(context);
- return FloatRect(x->value(lengthContext), y->value(lengthContext), width->value(lengthContext), height->value(lengthContext));
+ if (type != SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE && !viewport.isEmpty()) {
+ const FloatSize& viewportSize = viewport.size();
+ return FloatRect(
+ convertValueFromPercentageToUserUnits(valueInSpecifiedUnitsWithPercentAdjustment(*x), x->unitMode(), viewportSize) + viewport.x(),
+ convertValueFromPercentageToUserUnits(valueInSpecifiedUnitsWithPercentAdjustment(*y), y->unitMode(), viewportSize) + viewport.y(),
+ convertValueFromPercentageToUserUnits(valueInSpecifiedUnitsWithPercentAdjustment(*width), width->unitMode(), viewportSize),
+ convertValueFromPercentageToUserUnits(valueInSpecifiedUnitsWithPercentAdjustment(*height), height->unitMode(), viewportSize));
}
- SVGLengthContext lengthContext(context, viewport);
- return FloatRect(
- x->value(lengthContext) + viewport.x(),
- y->value(lengthContext) + viewport.y(),
- width->value(lengthContext),
- height->value(lengthContext));
+ SVGLengthContext lengthContext(context);
+ return FloatRect(x->value(lengthContext), y->value(lengthContext), width->value(lengthContext), height->value(lengthContext));
}
FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitTypes::SVGUnitType type, PassRefPtrWillBeRawPtr<SVGLength> passX, PassRefPtrWillBeRawPtr<SVGLength> passY)
@@ -99,14 +101,6 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit, ExceptionState& exceptionState) const
{
- // If the SVGLengthContext carries a custom viewport, force resolving against it.
- if (!m_overridenViewport.isEmpty()) {
- // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
- if (fromUnit == LengthTypePercentage)
- value /= 100;
- return convertValueFromPercentageToUserUnits(value, mode, exceptionState);
- }
-
switch (fromUnit) {
case LengthTypeUnknown:
exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::argumentNullOrIncorrectType(3, "SVGLengthType"));
@@ -197,7 +191,11 @@ float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLe
exceptionState.throwDOMException(NotSupportedError, "The viewport could not be determined.");
return 0;
}
+ return convertValueFromPercentageToUserUnits(value, mode, viewportSize);
+}
+float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLengthMode mode, const FloatSize& viewportSize)
+{
switch (mode) {
case LengthModeWidth:
return value * viewportSize.width();
@@ -293,12 +291,6 @@ bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const
if (!m_context)
return false;
- // If an overriden viewport is given, it has precedence.
- if (!m_overridenViewport.isEmpty()) {
- viewportSize = m_overridenViewport.size();
- return true;
- }
-
// Root <svg> element lengths are resolved against the top level viewport.
if (m_context->isOutermostSVGSVGElement()) {
viewportSize = toSVGSVGElement(m_context)->currentViewportSize();
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | Tools/run-perf-test.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698