Skip to content

Commit bb57b2f

Browse files
yurketnupurbaghel
authored andcommitted
Move paintWorklet from "Window" to "CSS" according to new specification
Relevant discussion: w3c/css-houdini-drafts#410
1 parent 3432806 commit bb57b2f

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

components/script/dom/css.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use cssparser::{Parser, ParserInput, serialize_identifier};
66
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
77
use dom::bindings::error::Fallible;
88
use dom::bindings::reflector::Reflector;
9+
use dom::bindings::root::DomRoot;
910
use dom::bindings::str::DOMString;
1011
use dom::window::Window;
12+
use dom::worklet::Worklet;
1113
use dom_struct::dom_struct;
1214
use style::context::QuirksMode;
1315
use style::parser::ParserContext;
@@ -63,4 +65,9 @@ impl CSS {
6365
false
6466
}
6567
}
68+
69+
///
70+
pub fn PaintWorklet(win: &Window) -> DomRoot<Worklet> {
71+
win.paint_worklet()
72+
}
6673
}

components/script/dom/webidls/CSS.webidl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ partial interface CSS {
1717
static boolean supports(DOMString property, DOMString value);
1818
static boolean supports(DOMString conditionText);
1919
};
20+
21+
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
22+
partial interface CSS {
23+
[SameObject, Pref="dom.worklet.enabled"] static readonly attribute Worklet paintWorklet;
24+
};

components/script/dom/webidls/Window.webidl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,3 @@ partial interface Window {
196196
readonly attribute TestRunner testRunner;
197197
//readonly attribute EventSender eventSender;
198198
};
199-
200-
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
201-
partial interface Window {
202-
[SameObject, Pref="dom.worklet.enabled"] readonly attribute Worklet paintWorklet;
203-
};

components/script/dom/window.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,17 +1022,17 @@ impl WindowMethods for Window {
10221022
fetch::Fetch(&self.upcast(), input, init)
10231023
}
10241024

1025-
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
1026-
fn PaintWorklet(&self) -> DomRoot<Worklet> {
1027-
self.paint_worklet.or_init(|| self.new_paint_worklet())
1028-
}
1029-
10301025
fn TestRunner(&self) -> DomRoot<TestRunner> {
10311026
self.test_runner.or_init(|| TestRunner::new(self.upcast()))
10321027
}
10331028
}
10341029

10351030
impl Window {
1031+
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
1032+
pub fn paint_worklet(&self) -> DomRoot<Worklet> {
1033+
self.paint_worklet.or_init(|| self.new_paint_worklet())
1034+
}
1035+
10361036
pub fn task_canceller(&self) -> TaskCanceller {
10371037
TaskCanceller {
10381038
cancelled: Some(self.ignore_further_async_events.borrow().clone()),

tests/wpt/mozilla/tests/mozilla/css-paint-api/css-paint-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// requestAnimationFrame. In the second frame, we take a screenshot, that makes
33
// sure that we already have a full frame.
44
function importPaintWorkletAndTerminateTestAfterAsyncPaint(code) {
5-
if (typeof paintWorklet == "undefined") {
5+
if (typeof CSS.paintWorklet == "undefined") {
66
takeScreenshot();
77
} else {
88
var blob = new Blob([code], {type: 'text/javascript'});
9-
paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
9+
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
1010
requestAnimationFrame(function() {
1111
requestAnimationFrame(function() {
1212
takeScreenshot();

tests/wpt/mozilla/tests/mozilla/css-paint-api/valid-image-after-load.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
var blob = new Blob([document.getElementById('code').textContent],
3131
{type: 'text/javascript'});
3232
var frame_cnt = 0;
33-
paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
33+
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
3434
var el = document.getElementById('output');
3535
el.style.backgroundImage = 'paint(green)';
3636
requestAnimationFrame(function() {

tests/wpt/mozilla/tests/mozilla/css-paint-api/valid-image-before-load.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
var blob = new Blob([document.getElementById('code').textContent],
3434
{type: 'text/javascript'});
3535
var frame_cnt = 0;
36-
paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
36+
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
3737
requestAnimationFrame(function() {
3838
takeScreenshot(frame_cnt);
3939
});

0 commit comments

Comments
 (0)