mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1082663 - Fix for bug 1082663 - DOMMatrix does not implement stringifier from spec. r=bz
This commit is contained in:
parent
7dfaec718d
commit
eea6af4b41
@ -286,6 +286,23 @@ DOMMatrixReadOnly::ToFloat64Array(JSContext* aCx, JS::MutableHandle<JSObject*> a
|
||||
aResult.set(&value.toObject());
|
||||
}
|
||||
|
||||
void
|
||||
DOMMatrixReadOnly::Stringify(nsAString& aResult)
|
||||
{
|
||||
nsAutoString matrixStr;
|
||||
if (mMatrix3D) {
|
||||
matrixStr.AppendPrintf("matrix3d(%g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g)",
|
||||
M11(), M12(), M13(), M14(),
|
||||
M21(), M22(), M23(), M24(),
|
||||
M31(), M32(), M33(), M34(),
|
||||
M41(), M42(), M43(), M44());
|
||||
} else {
|
||||
matrixStr.AppendPrintf("matrix(%g, %g, %g, %g, %g, %g)", A(), B(), C(), D(), E(), F());
|
||||
}
|
||||
|
||||
aResult = matrixStr;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMMatrix, mParent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMMatrix, AddRef)
|
||||
|
@ -124,6 +124,7 @@ public:
|
||||
void ToFloat64Array(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aResult,
|
||||
ErrorResult& aRv) const;
|
||||
void Stringify(nsAString& aResult);
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
nsAutoPtr<gfx::Matrix> mMatrix2D;
|
||||
|
@ -145,7 +145,8 @@ function main()
|
||||
testTranslate3D,
|
||||
testScale3D,
|
||||
test3D,
|
||||
testParsing
|
||||
testParsing,
|
||||
testStringify
|
||||
];
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
try{
|
||||
@ -706,6 +707,19 @@ function testParsing()
|
||||
ok(CompareDOMMatrix(m2, m), "string parsing didn't match");
|
||||
}
|
||||
|
||||
|
||||
function testStringify() {
|
||||
var m = new DOMMatrix();
|
||||
var s = "" + m;
|
||||
ok(s == "matrix" + formatMatrix(m), "stringifier 1 produced wrong result: " + s);
|
||||
m.a = 100;
|
||||
s = "" + m;
|
||||
ok(s == "matrix" + formatMatrix(m), "stringifier 2 produced wrong result: " + s);
|
||||
m.m43 = 200;
|
||||
s = "" + m;
|
||||
ok(s == "matrix3d" + formatMatrix(m), "stringifier 3 produced wrong result:" + s);
|
||||
}
|
||||
|
||||
window.addEventListener("load", main, false);
|
||||
|
||||
</script>
|
||||
|
@ -76,6 +76,7 @@ interface DOMMatrixReadOnly {
|
||||
DOMPoint transformPoint(optional DOMPointInit point);
|
||||
[Throws] Float32Array toFloat32Array();
|
||||
[Throws] Float64Array toFloat64Array();
|
||||
stringifier;
|
||||
};
|
||||
|
||||
[Pref="layout.css.DOMMatrix.enabled",
|
||||
|
Loading…
Reference in New Issue
Block a user