зеркало из https://github.com/mozilla/gecko-dev.git
Bug 931389 - remove CanvasRenderingContext2D.mozDash/mozDashOffset. r=gw280, r=baku
--HG-- extra : rebase_source : 2192c147822a28796e24532b0df10a38a5481a55
This commit is contained in:
Родитель
a640f97b00
Коммит
50934d0360
|
@ -4440,39 +4440,6 @@ CanvasRenderingContext2D::GetLineJoin(nsAString& aLinejoinStyle, ErrorResult& aE
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::SetMozDash(JSContext* aCx,
|
||||
const JS::Value& aMozDash,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsTArray<Float> dash;
|
||||
aError = JSValToDashArray(aCx, aMozDash, dash);
|
||||
if (!aError.Failed()) {
|
||||
ContextState& state = CurrentState();
|
||||
state.dash = Move(dash);
|
||||
if (state.dash.IsEmpty()) {
|
||||
state.dashOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::GetMozDash(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
DashArrayToJSVal(CurrentState().dash, aCx, aRetval, aError);
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::SetMozDashOffset(double aMozDashOffset)
|
||||
{
|
||||
ContextState& state = CurrentState();
|
||||
if (!state.dash.IsEmpty()) {
|
||||
state.dashOffset = aMozDashOffset;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::SetLineDash(const Sequence<double>& aSegments,
|
||||
ErrorResult& aRv)
|
||||
|
|
|
@ -365,10 +365,6 @@ public:
|
|||
mozilla::ErrorResult& aError);
|
||||
void GetFillRule(nsAString& aFillRule);
|
||||
void SetFillRule(const nsAString& aFillRule);
|
||||
void GetMozDash(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
|
||||
mozilla::ErrorResult& aError);
|
||||
void SetMozDash(JSContext* aCx, const JS::Value& aMozDash,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
void SetLineDash(const Sequence<double>& aSegments,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
@ -377,12 +373,6 @@ public:
|
|||
void SetLineDashOffset(double aOffset);
|
||||
double LineDashOffset() const;
|
||||
|
||||
double MozDashOffset()
|
||||
{
|
||||
return CurrentState().dashOffset;
|
||||
}
|
||||
void SetMozDashOffset(double aMozDashOffset);
|
||||
|
||||
void GetMozTextStyle(nsAString& aMozTextStyle)
|
||||
{
|
||||
GetFont(aMozTextStyle);
|
||||
|
|
|
@ -250,7 +250,6 @@ tags = imagebitmap
|
|||
tags = imagebitmap
|
||||
[test_ImageData_ctor.html]
|
||||
[test_isPointInStroke.html]
|
||||
[test_mozDashOffset.html]
|
||||
[test_mozGetAsFile.html]
|
||||
[test_strokeText_throw.html]
|
||||
[test_toBlob.html]
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
window.onload=function(){
|
||||
var c=document.getElementById("myCanvas").getContext("2d");
|
||||
c.beginPath();
|
||||
c.mozDash = [1,1];
|
||||
c.setLineDash([1,1]);
|
||||
c.strokeRect(10, 10, 200, 200);
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for mozDashOffset</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display">
|
||||
<canvas id="c" width="100" height="100"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script>
|
||||
try {
|
||||
var canvas = document.getElementById('c');
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.mozDash = [1, 1];
|
||||
|
||||
ctx.mozDashOffset = 1;
|
||||
ctx.mozDashOffset = Infinity;
|
||||
ok(ctx.mozDashOffset === 1, "ctx.mozDashOffset === 1");
|
||||
|
||||
ctx.mozDashOffset = 1;
|
||||
ctx.mozDashOffset = -Infinity;
|
||||
ok(ctx.mozDashOffset === 1, "ctx.mozDashOffset === 1");
|
||||
|
||||
ctx.mozDashOffset = 1;
|
||||
ctx.mozDashOffset = NaN;
|
||||
ok(ctx.mozDashOffset === 1, "ctx.mozDashOffset === 1");
|
||||
} catch(e) {
|
||||
ok(false, "unexpected exception thrown in: test_mozDashOffset.html");
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -153,12 +153,6 @@ interface CanvasRenderingContext2D {
|
|||
[Throws]
|
||||
attribute object mozCurrentTransformInverse;
|
||||
|
||||
[Throws]
|
||||
attribute any mozDash; /* default |null| */
|
||||
|
||||
[LenientFloat]
|
||||
attribute double mozDashOffset; /* default 0.0 */
|
||||
|
||||
[SetterThrows]
|
||||
attribute DOMString mozTextStyle;
|
||||
|
||||
|
|
|
@ -6,20 +6,20 @@ window.onload = function() {
|
|||
|
||||
ctx.lineWidth = 5;
|
||||
|
||||
ctx.mozDash = [ 5, 10 ]; // 5 on, 10 off
|
||||
ctx.setLineDash([ 5, 10 ]); // 5 on, 10 off
|
||||
ctx.moveTo(50, 50);
|
||||
ctx.lineTo(250, 50);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
|
||||
ctx.mozDashOffset = 5;
|
||||
ctx.lineDashOffset = 5;
|
||||
ctx.moveTo(50, 100);
|
||||
ctx.lineTo(250, 100);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
|
||||
ctx.mozDashOffset = 5;
|
||||
ctx.mozDash = [ 5 ]; // 5 on, 5 off
|
||||
ctx.lineDashOffset = 5;
|
||||
ctx.setLineDash([ 5 ]); // 5 on, 5 off
|
||||
ctx.moveTo(50, 150);
|
||||
ctx.lineTo(250, 150);
|
||||
ctx.stroke();
|
||||
|
|
|
@ -6,70 +6,83 @@ window.onload = function() {
|
|||
try {
|
||||
var ctx = document.getElementById("c1").getContext("2d");
|
||||
|
||||
assert(null === ctx.mozDash,
|
||||
"Default dash is null (no dash)");
|
||||
assert(0 == ctx.mozDashOffset,
|
||||
"Default dashOffset is 0 (no dash)");
|
||||
assert(0 === ctx.getLineDash().length,
|
||||
"Default dash is [ ] (none)");
|
||||
assert(0 === ctx.lineDashOffset,
|
||||
"Default dashOffset is 0 (none)");
|
||||
|
||||
ctx.mozDash = [ 2 ];
|
||||
assert(1 == ctx.mozDash.length && 2 == ctx.mozDash[0],
|
||||
ctx.setLineDash([ 2 ]);
|
||||
assert(2 === ctx.getLineDash().length &&
|
||||
2 === ctx.getLineDash()[0] &&
|
||||
2 === ctx.getLineDash()[1],
|
||||
"dash = [ 2 ] works");
|
||||
ctx.mozDash = null;
|
||||
assert(null === ctx.mozDash,
|
||||
"dash = null resets to null");
|
||||
ctx.mozDash = [ 2 ];
|
||||
ctx.mozDash = undefined;
|
||||
assert(null === ctx.mozDash,
|
||||
"dash = undefined resets to null");
|
||||
ctx.mozDash = [ 2 ];
|
||||
ctx.mozDash = [ ];
|
||||
assert(null === ctx.mozDash,
|
||||
"dash = [] resets to null");
|
||||
ctx.setLineDash([ 2 ]);
|
||||
ctx.setLineDash([ ]);
|
||||
assert(0 === ctx.getLineDash().length,
|
||||
"dash = [ ] works");
|
||||
ctx.setLineDash([ 2 ]);
|
||||
ctx.setLineDash([ 0, 0, 0 ]);
|
||||
assert(6 === ctx.getLineDash().length,
|
||||
0 === ctx.getLineDash()[0] &&
|
||||
0 === ctx.getLineDash()[1] &&
|
||||
0 === ctx.getLineDash()[2] &&
|
||||
0 === ctx.getLineDash()[3] &&
|
||||
0 === ctx.getLineDash()[4] &&
|
||||
0 === ctx.getLineDash()[5],
|
||||
"dash = [ 0, 0, 0 ] works");
|
||||
|
||||
ctx.mozDash = [ 2 ];
|
||||
assert(0 == ctx.mozDashOffset, "dashOffset is 0");
|
||||
ctx.mozDashOffset = 1;
|
||||
assert(1 == ctx.mozDashOffset, "Setting dashOffset succeeded");
|
||||
ctx.mozDash = null;
|
||||
assert(0 == ctx.mozDashOffset, "Disabling dash resets dashOffset");
|
||||
ctx.mozDash = [ 2 ];
|
||||
assert(0 == ctx.mozDashOffset, "Previous dashOffset isn't remembered");
|
||||
ctx.mozDash = null;
|
||||
ctx.setLineDash([ 2 ]);
|
||||
assert(0 === ctx.lineDashOffset, "dashOffset is 0");
|
||||
ctx.lineDashOffset = 1;
|
||||
assert(1 === ctx.lineDashOffset, "Setting dashOffset succeeded");
|
||||
ctx.setLineDash([ ]);
|
||||
assert(1 === ctx.lineDashOffset, "Changing dash does not reset dashOffset");
|
||||
|
||||
// NB: might want to add a |.dash = number| special case,
|
||||
// don't test that it fails here. Might also want to add a
|
||||
// |.dash = [0]| special case for resetting, so don't test
|
||||
// that either.
|
||||
var badVals = [ -1,
|
||||
null,
|
||||
undefined,
|
||||
"",
|
||||
"string",
|
||||
/* According to the WebIDL sequence-ifying
|
||||
* (really they mean array-ifying here)
|
||||
* algorithm, objects without .length
|
||||
* properties convert to a 0-length arrays.
|
||||
* This seems ... odd, since by the book we're
|
||||
* forced to accept |ctx.dash = Function|,
|
||||
* e.g., but there it is.
|
||||
*/
|
||||
// { obj: true },
|
||||
[ "array of string" ],
|
||||
[ -1 ],
|
||||
[ 0, 0, 0 ],
|
||||
[ 2, "string" ],
|
||||
];
|
||||
ctx.mozDash = [ 2 ];
|
||||
{ obj: true },
|
||||
function() {}
|
||||
]
|
||||
ctx.setLineDash([ 2 ]);
|
||||
for (var i = 0; i < badVals.length; ++i) {
|
||||
var error = false;
|
||||
try { ctx.mozDash = badVals[i]; }
|
||||
try { ctx.setLineDash(badVals[i]); }
|
||||
catch(e) { error = true; }
|
||||
assert(error && 1 == ctx.mozDash.length && 2 == ctx.mozDash[0],
|
||||
"Expected |dash = "+ badVals[i] +"| to throw exception and not change .dash");
|
||||
assert(error &&
|
||||
2 === ctx.getLineDash().length &&
|
||||
2 === ctx.getLineDash()[0] &&
|
||||
2 === ctx.getLineDash()[1],
|
||||
"Expected setLineDash("+ badVals[i] +") to throw exception and not change dash");
|
||||
}
|
||||
ctx.mozDash = null;
|
||||
|
||||
var ignoredVals = [
|
||||
[ "array of string" ],
|
||||
[ -1 ],
|
||||
[ 2, "string" ],
|
||||
];
|
||||
ctx.setLineDash([ 2 ]);
|
||||
for (var i = 0; i < ignoredVals.length; ++i) {
|
||||
ctx.setLineDash(ignoredVals[i]);
|
||||
assert(2 === ctx.getLineDash().length &&
|
||||
2 === ctx.getLineDash()[0] &&
|
||||
2 === ctx.getLineDash()[1],
|
||||
"Expected |setLineDash(" + ignoredVals[i] + ") to not change dash");
|
||||
}
|
||||
|
||||
ctx.setLineDash([ 2 ]);
|
||||
ctx.save();
|
||||
ctx.mozDash = [ 2 ];
|
||||
ctx.setLineDash([ 1, 1, 1, 1 ]);
|
||||
ctx.restore();
|
||||
assert(null === ctx.mozDash,
|
||||
assert(2 === ctx.getLineDash().length &&
|
||||
2 === ctx.getLineDash()[0] &&
|
||||
2 === ctx.getLineDash()[1],
|
||||
"dash was saved then restored");
|
||||
} catch (e) {
|
||||
document.body.innerHTML = "FAIL: "+ e.toString();
|
||||
|
|
Загрузка…
Ссылка в новой задаче