aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/canvasrenderingcontext2d.rs
diff options
context:
space:
mode:
authorBrandon Fairchild <csbit32@gmail.com>2015-12-31 11:48:15 -0500
committerBrandon Fairchild <csbit32@gmail.com>2015-12-31 11:48:15 -0500
commit1ccab328f9bc7e2952bbbfe7591804b6ce65ee9e (patch)
tree7e43ee463696e2294a71f0a674afa13b6e7895ea /components/script/dom/canvasrenderingcontext2d.rs
parent0f5c614609fd8867a9e7c27b8a398ea7d877c714 (diff)
downloadservo-1ccab328f9bc7e2952bbbfe7591804b6ce65ee9e.tar.gz
servo-1ccab328f9bc7e2952bbbfe7591804b6ce65ee9e.zip
Support empty strings as the repeat argument (CreatePattern)
According to the third step in the specification [1], createPattern should let the repetition argument be "repeat" when it is the empty string. The code in CanvasRenderingContext2D::CreatePattern did not implement this step and instead threw a SyntaxError exception when an empty string was supplied as the repetition argument. Fixes #9079. [1] https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern
Diffstat (limited to 'components/script/dom/canvasrenderingcontext2d.rs')
-rw-r--r--components/script/dom/canvasrenderingcontext2d.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs
index 05a4b875852..40cbb90a6a8 100644
--- a/components/script/dom/canvasrenderingcontext2d.rs
+++ b/components/script/dom/canvasrenderingcontext2d.rs
@@ -1147,7 +1147,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern
fn CreatePattern(&self,
image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D,
- repetition: DOMString)
+ mut repetition: DOMString)
-> Fallible<Root<CanvasPattern>> {
let (image_data, image_size) = match image {
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(ref image) => {
@@ -1169,6 +1169,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
}
};
+ if repetition.is_empty() {
+ repetition.push_str("repeat");
+ }
+
if let Ok(rep) = RepetitionStyle::from_str(&repetition) {
Ok(CanvasPattern::new(self.global.root().r(),
image_data,