mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Move paintWorklet from "Window" to "CSS" according to new specification
Relevant discussion: https://github.com/w3c/css-houdini-drafts/issues/410
This commit is contained in:
parent
9e1479bbdd
commit
c7e3def9b2
7 changed files with 21 additions and 14 deletions
|
@ -6,8 +6,10 @@ use cssparser::{Parser, ParserInput, serialize_identifier};
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::reflector::Reflector;
|
use dom::bindings::reflector::Reflector;
|
||||||
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
use dom::worklet::Worklet;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use style::context::QuirksMode;
|
use style::context::QuirksMode;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
|
@ -63,4 +65,9 @@ impl CSS {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet>
|
||||||
|
pub fn PaintWorklet(win: &Window) -> DomRoot<Worklet> {
|
||||||
|
win.paint_worklet()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,3 +17,8 @@ partial interface CSS {
|
||||||
static boolean supports(DOMString property, DOMString value);
|
static boolean supports(DOMString property, DOMString value);
|
||||||
static boolean supports(DOMString conditionText);
|
static boolean supports(DOMString conditionText);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
|
||||||
|
partial interface CSS {
|
||||||
|
[SameObject, Pref="dom.worklet.enabled"] static readonly attribute Worklet paintWorklet;
|
||||||
|
};
|
||||||
|
|
|
@ -196,8 +196,3 @@ partial interface Window {
|
||||||
readonly attribute TestRunner testRunner;
|
readonly attribute TestRunner testRunner;
|
||||||
//readonly attribute EventSender eventSender;
|
//readonly attribute EventSender eventSender;
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
|
|
||||||
partial interface Window {
|
|
||||||
[SameObject, Pref="dom.worklet.enabled"] readonly attribute Worklet paintWorklet;
|
|
||||||
};
|
|
||||||
|
|
|
@ -1022,17 +1022,17 @@ impl WindowMethods for Window {
|
||||||
fetch::Fetch(&self.upcast(), input, init)
|
fetch::Fetch(&self.upcast(), input, init)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
|
|
||||||
fn PaintWorklet(&self) -> DomRoot<Worklet> {
|
|
||||||
self.paint_worklet.or_init(|| self.new_paint_worklet())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn TestRunner(&self) -> DomRoot<TestRunner> {
|
fn TestRunner(&self) -> DomRoot<TestRunner> {
|
||||||
self.test_runner.or_init(|| TestRunner::new(self.upcast()))
|
self.test_runner.or_init(|| TestRunner::new(self.upcast()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
|
||||||
|
pub fn paint_worklet(&self) -> DomRoot<Worklet> {
|
||||||
|
self.paint_worklet.or_init(|| self.new_paint_worklet())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn task_canceller(&self) -> TaskCanceller {
|
pub fn task_canceller(&self) -> TaskCanceller {
|
||||||
TaskCanceller {
|
TaskCanceller {
|
||||||
cancelled: Some(self.ignore_further_async_events.borrow().clone()),
|
cancelled: Some(self.ignore_further_async_events.borrow().clone()),
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
// requestAnimationFrame. In the second frame, we take a screenshot, that makes
|
// requestAnimationFrame. In the second frame, we take a screenshot, that makes
|
||||||
// sure that we already have a full frame.
|
// sure that we already have a full frame.
|
||||||
function importPaintWorkletAndTerminateTestAfterAsyncPaint(code) {
|
function importPaintWorkletAndTerminateTestAfterAsyncPaint(code) {
|
||||||
if (typeof paintWorklet == "undefined") {
|
if (typeof CSS.paintWorklet == "undefined") {
|
||||||
takeScreenshot();
|
takeScreenshot();
|
||||||
} else {
|
} else {
|
||||||
var blob = new Blob([code], {type: 'text/javascript'});
|
var blob = new Blob([code], {type: 'text/javascript'});
|
||||||
paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
|
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
|
||||||
requestAnimationFrame(function() {
|
requestAnimationFrame(function() {
|
||||||
requestAnimationFrame(function() {
|
requestAnimationFrame(function() {
|
||||||
takeScreenshot();
|
takeScreenshot();
|
||||||
|
|
|
@ -30,7 +30,7 @@ if (window.testRunner) {
|
||||||
var blob = new Blob([document.getElementById('code').textContent],
|
var blob = new Blob([document.getElementById('code').textContent],
|
||||||
{type: 'text/javascript'});
|
{type: 'text/javascript'});
|
||||||
var frame_cnt = 0;
|
var frame_cnt = 0;
|
||||||
paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
|
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
|
||||||
var el = document.getElementById('output');
|
var el = document.getElementById('output');
|
||||||
el.style.backgroundImage = 'paint(green)';
|
el.style.backgroundImage = 'paint(green)';
|
||||||
requestAnimationFrame(function() {
|
requestAnimationFrame(function() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ el.style.backgroundImage = 'paint(green)';
|
||||||
var blob = new Blob([document.getElementById('code').textContent],
|
var blob = new Blob([document.getElementById('code').textContent],
|
||||||
{type: 'text/javascript'});
|
{type: 'text/javascript'});
|
||||||
var frame_cnt = 0;
|
var frame_cnt = 0;
|
||||||
paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
|
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
|
||||||
requestAnimationFrame(function() {
|
requestAnimationFrame(function() {
|
||||||
takeScreenshot(frame_cnt);
|
takeScreenshot(frame_cnt);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue