Bug 784809. Allow null for the repeat argument of canvas createPattern. r=peterv

This commit is contained in:
Boris Zbarsky 2012-08-23 12:23:23 -07:00
parent df4ab23274
commit 9d2ad14dab
3 changed files with 15 additions and 6 deletions

View File

@ -16078,9 +16078,17 @@ function test_2d_pattern_repeat_null() {
var canvas = document.getElementById('c494');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createPattern(canvas, null);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "SyntaxError" && _thrown.code == DOMException.SYNTAX_ERR, "should throw SyntaxError");
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var img = document.getElementById('green-1x1_2.png');
var pattern = ctx.createPattern(img, null);
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
@ -16119,7 +16127,8 @@ var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createPattern(canvas, undefined);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "SyntaxError" && _thrown.code == DOMException.SYNTAX_ERR, "should throw SyntaxError");
// XXXbz TODO fix bug 784869
} catch (e) { _thrown = e }; todo(_thrown && _thrown.name == "SyntaxError" && _thrown.code == DOMException.SYNTAX_ERR, "should throw SyntaxError");
}

View File

@ -93,7 +93,7 @@ enum CanvasMultiGetterType {
nsIDOMCanvasGradient createLinearGradient (in float x0, in float y0, in float x1, in float y1);
nsIDOMCanvasGradient createRadialGradient(in float x0, in float y0, in float r0, in float x1, in float y1, in float r1);
nsIDOMCanvasPattern createPattern(in nsIDOMHTMLElement image, [Null(Stringify)] in DOMString repetition);
nsIDOMCanvasPattern createPattern(in nsIDOMHTMLElement image, in DOMString repetition);
attribute float lineWidth; /* default 1 */
[binaryname(MozLineCap)]
attribute DOMString lineCap; /* "butt", "round", "square" (default) */

View File

@ -55,7 +55,7 @@ interface CanvasRenderingContext2D {
attribute any fillStyle; // (default black)
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
CanvasPattern createPattern((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, DOMString repetition);
CanvasPattern createPattern((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, DOMString? repetition);
// shadows
[Infallible]