Bug 1408310 - Part 2: Use CSS parser for DOMMatrix::SetMatrixValue. r=baku,heycam
Now, we use the CSS parser, instead of SVG parser, so we also need to update the tests of DOMMatrix, i.e. we don't support unitless tranform list on CSS parser. MozReview-Commit-ID: 86F992rIa4J
This commit is contained in:
@@ -9,9 +9,7 @@
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/WebKitCSSMatrixBinding.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsCSSParser.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsStyleTransformMatrix.h"
|
||||
#include "RuleNodeCacheConditions.h"
|
||||
|
||||
namespace mozilla {
|
||||
@@ -61,58 +59,7 @@ WebKitCSSMatrix*
|
||||
WebKitCSSMatrix::SetMatrixValue(const nsAString& aTransformList,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
// An empty string is a no-op.
|
||||
if (aTransformList.IsEmpty()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
nsCSSValue value;
|
||||
nsCSSParser parser;
|
||||
bool parseSuccess = parser.ParseTransformProperty(aTransformList,
|
||||
true,
|
||||
value);
|
||||
if (!parseSuccess) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// A value of "none" results in a 2D identity matrix.
|
||||
if (value.GetUnit() == eCSSUnit_None) {
|
||||
mMatrix3D = nullptr;
|
||||
mMatrix2D = new gfx::Matrix();
|
||||
return this;
|
||||
}
|
||||
|
||||
// A value other than a transform-list is a syntax error.
|
||||
if (value.GetUnit() != eCSSUnit_SharedList) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RuleNodeCacheConditions dummy;
|
||||
nsStyleTransformMatrix::TransformReferenceBox dummyBox;
|
||||
bool contains3dTransform = false;
|
||||
gfx::Matrix4x4 transform = nsStyleTransformMatrix::ReadTransforms(
|
||||
value.GetSharedListValue()->mHead,
|
||||
nullptr, nullptr, dummy, dummyBox,
|
||||
nsPresContext::AppUnitsPerCSSPixel(),
|
||||
&contains3dTransform);
|
||||
|
||||
if (!contains3dTransform) {
|
||||
mMatrix3D = nullptr;
|
||||
mMatrix2D = new gfx::Matrix();
|
||||
|
||||
SetA(transform._11);
|
||||
SetB(transform._12);
|
||||
SetC(transform._21);
|
||||
SetD(transform._22);
|
||||
SetE(transform._41);
|
||||
SetF(transform._42);
|
||||
} else {
|
||||
mMatrix3D = new gfx::Matrix4x4(transform);
|
||||
mMatrix2D = nullptr;
|
||||
}
|
||||
|
||||
DOMMatrix::SetMatrixValue(aTransformList, aRv);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user