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

Unified Diff: third_party/WebKit/Source/core/dom/DOMMatrix.cpp

Issue 2380713004: [GeometryInterface] Add setMatrixValue(transfromList) function. (Closed)
Patch Set: [GeometryInterface] Add setMatrixValue(transfromList) function. Created 4 years, 2 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 | « third_party/WebKit/Source/core/dom/DOMMatrix.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrix.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/DOMMatrix.cpp
diff --git a/third_party/WebKit/Source/core/dom/DOMMatrix.cpp b/third_party/WebKit/Source/core/dom/DOMMatrix.cpp
index 966810654a5eed9950886b24b46a341f051a327b..de14957fd2e6b3909b7afadc109e2fbde2207782 100644
--- a/third_party/WebKit/Source/core/dom/DOMMatrix.cpp
+++ b/third_party/WebKit/Source/core/dom/DOMMatrix.cpp
@@ -4,6 +4,14 @@
#include "core/dom/DOMMatrix.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/layout/api/LayoutViewItem.h"
+#include "core/style/ComputedStyle.h"
+
namespace blink {
DOMMatrix* DOMMatrix::create(ExceptionState& exceptionState) {
@@ -245,4 +253,53 @@ DOMMatrix* DOMMatrix::invertSelf() {
return this;
}
+DOMMatrix* DOMMatrix::setMatrixValue(const String& inputString,
+ 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 nullptr;
+ }
+
+ if (value->isIdentifierValue()) {
+ DCHECK(toCSSIdentifierValue(value)->getValueID() == CSSValueNone);
+ m_matrix->makeIdentity();
+ m_is2D = true;
+ return this;
+ }
+
+ if (TransformBuilder::hasRelativeLengths(toCSSValueList(*value))) {
+ exceptionState.throwDOMException(SyntaxError,
+ "Relative lengths not supported.");
+ return nullptr;
+ }
+
+ 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 nullptr;
+ }
+
+ m_matrix->makeIdentity();
+ operations.apply(FloatSize(0, 0), *m_matrix);
+
+ m_is2D = !operations.has3DOperation();
+
+ return this;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrix.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrix.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698