New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement paint worklet properties #17364
Merged
bors-servo
merged 1 commit into
servo:master
from
asajeffrey:script-paint-worklets-properties
Jul 12, 2017
+353
−118
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
| @@ -1165,17 +1165,24 @@ impl FragmentDisplayListBuilding for Fragment { | ||
| let size = unbordered_box.size.to_physical(style.writing_mode); | ||
| let name = paint_worklet.name.clone(); | ||
|
|
||
| // If the script thread has not added any paint worklet modules, there is nothing to do! | ||
| let executor = match state.layout_context.paint_worklet_executor { | ||
| Some(ref executor) => executor, | ||
| None => return debug!("Worklet {} called before any paint modules are added.", name), | ||
| // Get the painter, and the computed values for its properties. | ||
| let (properties, painter) = match state.layout_context.registered_painters.read().get(&name) { | ||
| Some(registered_painter) => ( | ||
| registered_painter.properties | ||
| .iter() | ||
| .filter_map(|(name, id)| id.as_shorthand().err().map(|id| (name, id))) | ||
asajeffrey
Author
Member
|
||
| .map(|(name, id)| (name.clone(), style.computed_value_to_string(id))) | ||
| .collect(), | ||
| registered_painter.painter.clone() | ||
| ), | ||
| None => return debug!("Worklet {} called before registration.", name), | ||
| }; | ||
|
|
||
| // TODO: add a one-place cache to avoid drawing the paint image every time. | ||
| // https://github.com/servo/servo/issues/17369 | ||
| debug!("Drawing a paint image {}({},{}).", name, size.width.to_px(), size.height.to_px()); | ||
| let (sender, receiver) = ipc::channel().unwrap(); | ||
| executor.draw_a_paint_image(name, size, sender); | ||
| painter.draw_a_paint_image(size, properties, sender); | ||
|
|
||
| // TODO: timeout | ||
| let webrender_image = match receiver.recv() { | ||
| @@ -0,0 +1,46 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| use dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSSStyleValueMethods; | ||
| use dom::bindings::codegen::Bindings::CSSStyleValueBinding::Wrap; | ||
| use dom::bindings::js::Root; | ||
| use dom::bindings::reflector::Reflector; | ||
| use dom::bindings::reflector::reflect_dom_object; | ||
| use dom::bindings::str::DOMString; | ||
| use dom::globalscope::GlobalScope; | ||
| use dom_struct::dom_struct; | ||
|
|
||
| #[dom_struct] | ||
| pub struct CSSStyleValue { | ||
| reflector: Reflector, | ||
| value: String, | ||
| } | ||
|
|
||
| impl CSSStyleValue { | ||
| fn new_inherited(value: String) -> CSSStyleValue { | ||
| CSSStyleValue { | ||
| reflector: Reflector::new(), | ||
| value: value, | ||
| } | ||
| } | ||
|
|
||
| pub fn new(global: &GlobalScope, value: String) -> Root<CSSStyleValue> { | ||
| reflect_dom_object(box CSSStyleValue::new_inherited(value), global, Wrap) | ||
| } | ||
| } | ||
|
|
||
| impl CSSStyleValueMethods for CSSStyleValue { | ||
| /// https://drafts.css-houdini.org/css-typed-om-1/#CSSStyleValue-stringification-behavior | ||
| fn Stringifier(&self) -> DOMString { | ||
| DOMString::from(&*self.value) | ||
| } | ||
|
|
||
| /// This attribute is no longer part of the `CSSStyleValue` interface, | ||
| /// but is still used in some examples. | ||
| /// https://github.com/GoogleChrome/houdini-samples/issues/16 | ||
| // check-tidy: no specs after this line | ||
| fn CssText(&self) -> DOMString { | ||
| self.Stringifier() | ||
| } | ||
| } |
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Didn't we already filter them when registering?