Auto merge of #17150 - asajeffrey:script-paint-worklets-plumbing, r=jdm

Implemented the plumbing for paint worklets

<!-- Please describe your changes on the following line: -->

This PR implements the plumbing for paint worklets:

* Adding CSS values for paint worklets.
* Implementing a skeleton for the `PaintWorkletGlobalScope` webidl.
* Implementing an executor for paint worklet tasks, and passing it from script to layout.
* Building the display list items for paint worklet images.

This PR does not implement registering or calling paint worklets in JS.

Before it merges, this PR needs a reftest added for basic paint worklet functionality.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17150)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-07 11:57:07 -07:00 committed by GitHub
commit bf46da065d
23 changed files with 600 additions and 156 deletions

View file

@ -27,6 +27,10 @@ pub enum Image<Gradient, ImageRect> {
Rect(ImageRect),
/// A `-moz-element(# <element-id>)`
Element(Atom),
/// A paint worklet image.
/// https://drafts.css-houdini.org/css-paint-api/
#[cfg(feature = "servo")]
PaintWorklet(PaintWorklet),
}
/// A CSS gradient.
@ -128,6 +132,23 @@ pub struct ColorStop<Color, LengthOrPercentage> {
pub position: Option<LengthOrPercentage>,
}
/// Specified values for a paint worklet.
/// https://drafts.css-houdini.org/css-paint-api/
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct PaintWorklet {
/// The name the worklet was registered with.
pub name: Atom,
}
impl ToCss for PaintWorklet {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
dest.write_str("paint(")?;
serialize_identifier(&*self.name.to_string(), dest)?;
dest.write_str(")")
}
}
/// Values for `moz-image-rect`.
///
/// `-moz-image-rect(<uri>, top, right, bottom, left);`
@ -150,6 +171,8 @@ impl<G, R> fmt::Debug for Image<G, R>
Image::Url(ref url) => url.to_css(f),
Image::Gradient(ref grad) => grad.fmt(f),
Image::Rect(ref rect) => rect.fmt(f),
#[cfg(feature = "servo")]
Image::PaintWorklet(ref paint_worklet) => paint_worklet.fmt(f),
Image::Element(ref selector) => {
f.write_str("-moz-element(#")?;
serialize_identifier(&selector.to_string(), f)?;
@ -167,6 +190,8 @@ impl<G, R> ToCss for Image<G, R>
Image::Url(ref url) => url.to_css(dest),
Image::Gradient(ref gradient) => gradient.to_css(dest),
Image::Rect(ref rect) => rect.to_css(dest),
#[cfg(feature = "servo")]
Image::PaintWorklet(ref paint_worklet) => paint_worklet.to_css(dest),
Image::Element(ref selector) => {
dest.write_str("-moz-element(#")?;
serialize_identifier(&selector.to_string(), dest)?;