Index: third_party/WebKit/Source/core/css/cssom/CSSTranslation.cpp |
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSTranslation.cpp b/third_party/WebKit/Source/core/css/cssom/CSSTranslation.cpp |
index 49e26c1e8ab545c3f0831b19debdc5906e64d833..192b7a1e24977903c68f498fca043bc0f0b65b85 100644 |
--- a/third_party/WebKit/Source/core/css/cssom/CSSTranslation.cpp |
+++ b/third_party/WebKit/Source/core/css/cssom/CSSTranslation.cpp |
@@ -18,6 +18,37 @@ CSSTranslation* CSSTranslation::create(CSSLengthValue* x, CSSLengthValue* y, CSS |
return new CSSTranslation(x, y, z); |
} |
+CSSTranslation* CSSTranslation::fromCSSValue(const CSSValue& value) |
+{ |
+ if (!value.isFunctionValue()) |
+ return nullptr; |
+ |
+ const CSSFunctionValue& cssFunctionValue = toCSSFunctionValue(value); |
+ if (cssFunctionValue.length() < 2) |
+ return nullptr; |
+ |
+ CSSLengthValue* x = CSSLengthValue::fromCSSValue(*cssFunctionValue.item(0)); |
+ CSSLengthValue* y = CSSLengthValue::fromCSSValue(*cssFunctionValue.item(1)); |
+ if (!x || !y) |
+ return nullptr; |
+ |
+ if (cssFunctionValue.functionType() == CSSValueTranslate) { |
+ if (cssFunctionValue.length() != 2) |
+ return nullptr; |
+ return CSSTranslation::create(x, y); |
+ } |
+ |
+ if (cssFunctionValue.functionType() == CSSValueTranslate3d) { |
+ if (cssFunctionValue.length() != 3) |
+ return nullptr; |
+ CSSLengthValue* z = CSSLengthValue::fromCSSValue(*cssFunctionValue.item(2)); |
+ if (!z || z->containsPercent()) |
+ return nullptr; |
+ return new CSSTranslation(x, y, z); |
+ } |
+ return nullptr; |
+} |
+ |
CSSFunctionValue* CSSTranslation::toCSSValue() const |
{ |
CSSFunctionValue* result = CSSFunctionValue::create(is2D() ? CSSValueTranslate : CSSValueTranslate3d); |