Index: third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
diff --git a/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp b/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
index a3cc1da8182c721b93b902f67c7778c802ccabcd..3a32c32e8ef7eb02e0ac5516cabefb2c67a8b944 100644 |
--- a/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
+++ b/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
@@ -5,10 +5,17 @@ |
#include "core/dom/DOMMatrixReadOnly.h" |
#include "bindings/core/v8/V8ObjectBuilder.h" |
+#include "core/css/CSSIdentifierValue.h" |
+#include "core/css/CSSToLengthConversionData.h" |
+#include "core/css/CSSValueList.h" |
+#include "core/css/parser/CSSParser.h" |
+#include "core/css/resolver/TransformBuilder.h" |
#include "core/dom/DOMMatrix.h" |
#include "core/dom/DOMMatrixInit.h" |
#include "core/dom/DOMPoint.h" |
#include "core/dom/DOMPointInit.h" |
+#include "core/layout/api/LayoutViewItem.h" |
+#include "core/style/ComputedStyle.h" |
namespace blink { |
namespace { |
@@ -89,6 +96,11 @@ DOMMatrixReadOnly* DOMMatrixReadOnly::create(ExceptionState& exceptionState) { |
return new DOMMatrixReadOnly(TransformationMatrix()); |
} |
+DOMMatrixReadOnly* DOMMatrixReadOnly::create(const String& transformList, |
+ ExceptionState& exceptionState) { |
+ return new DOMMatrixReadOnly(transformList, exceptionState); |
zino
2016/11/30 13:39:31
DOMMatrixReadOnly*
matrix = new DOMMatrixReadOnly(
Hwanseung Lee
2016/11/30 14:00:31
Done.
|
+} |
+ |
DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, |
ExceptionState& exceptionState) { |
if (sequence.size() != 6 && sequence.size() != 16) { |
@@ -255,6 +267,12 @@ DOMPoint* DOMMatrixReadOnly::transformPoint(const DOMPointInit& point) { |
return DOMPoint::create(x, y, z, w); |
} |
+DOMMatrixReadOnly::DOMMatrixReadOnly(const String& inputString, |
zino
2016/11/30 13:39:31
This constructor is unncessary I think :)
Please
Hwanseung Lee
2016/11/30 14:00:31
Done.
|
+ ExceptionState& exceptionState) { |
+ m_matrix = TransformationMatrix::create(); |
+ setMatrixValueInternal(inputString, exceptionState); |
+} |
+ |
DOMMatrixReadOnly::DOMMatrixReadOnly(const TransformationMatrix& matrix, |
bool is2D) { |
m_matrix = TransformationMatrix::create(matrix); |
@@ -332,4 +350,53 @@ ScriptValue DOMMatrixReadOnly::toJSONForBinding( |
return result.scriptValue(); |
} |
+void DOMMatrixReadOnly::setMatrixValueInternal(const String& inputString, |
zino
2016/11/30 13:39:31
Could you please rename this to better name? (e.g.
Hwanseung Lee
2016/11/30 14:00:31
Done.
|
+ ExceptionState& exceptionState) { |
+ DEFINE_STATIC_LOCAL(String, identityMatrix2D, ("matrix(1, 0, 0, 1, 0, 0)")); |
+ String string = inputString; |
+ if (string.isEmpty()) |
+ string = identityMatrix2D; |
+ |
+ const CSSValue* value = |
+ CSSParser::parseSingleValue(CSSPropertyTransform, string); |
+ |
+ if (!value || value->isCSSWideKeyword()) { |
+ exceptionState.throwDOMException(SyntaxError, |
+ "Failed to parse '" + inputString + "'."); |
+ return; |
+ } |
+ |
+ if (value->isIdentifierValue()) { |
+ DCHECK(toCSSIdentifierValue(value)->getValueID() == CSSValueNone); |
+ m_matrix->makeIdentity(); |
+ m_is2D = true; |
+ return; |
+ } |
+ |
+ if (TransformBuilder::hasRelativeLengths(toCSSValueList(*value))) { |
+ exceptionState.throwDOMException(SyntaxError, |
+ "Relative lengths not supported."); |
+ return; |
+ } |
+ |
+ const ComputedStyle& initialStyle = ComputedStyle::initialStyle(); |
+ TransformOperations operations = TransformBuilder::createTransformOperations( |
+ *value, CSSToLengthConversionData(&initialStyle, &initialStyle, |
+ LayoutViewItem(nullptr), 1.0f)); |
+ |
+ if (operations.dependsOnBoxSize()) { |
+ exceptionState.throwDOMException(SyntaxError, |
+ "The transformation depends on the box " |
+ "size, which is not supported."); |
+ return; |
+ } |
+ |
+ m_matrix->makeIdentity(); |
+ operations.apply(FloatSize(0, 0), *m_matrix); |
+ |
+ m_is2D = !operations.has3DOperation(); |
+ |
+ return; |
+} |
+ |
} // namespace blink |