Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upstylo: Allow computing change hints during the traversal. #12645
Conversation
highfive
commented
Jul 29, 2016
highfive
commented
Jul 29, 2016
| @@ -47,6 +46,10 @@ impl<GeckoType, ServoType> ArcHelpers<GeckoType, ServoType> { | |||
| unsafe { transmute(owned) } | |||
| } | |||
|
|
|||
| pub unsafe fn borrow(borrowed: &Arc<ServoType>) -> *const &mut GeckoType { | |||
This comment has been minimized.
This comment has been minimized.
bholley
Jul 29, 2016
Contributor
Can we make this a closure-y API like |with| to avoid the unsafety here?
|
Generally seems reasonable, but will need some fiddling in light of https://bugzilla.mozilla.org/show_bug.cgi?id=1290335#c9 |
| /// ComputedValues in Servo and a StyleContext in Gecko. | ||
| /// | ||
| /// This must be obtained via the node. | ||
| type CascadeStyleSource; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bholley
Aug 1, 2016
Contributor
Also, please add a comment explaining why we do this dance with the style context (i.e. the inference from the caching).
| /// XXX: It's a bit unfortunate we need to pass the current computed values | ||
| /// as an argument here, but otherwise Servo would crash due to double | ||
| /// borrows to return it. | ||
| fn style_source<'a>(&'a self, |
This comment has been minimized.
This comment has been minimized.
| @@ -507,7 +507,8 @@ where Damage: TRestyleDamage { | |||
| frame); | |||
| if updated_style { | |||
| if let Some(damage) = damage { | |||
| *damage = *damage | Damage::compute(Some(style), &new_style); | |||
| *damage = | |||
| *damage | Damage::compute_for_layout(Some(style), &new_style); | |||
This comment has been minimized.
This comment has been minimized.
bholley
Aug 1, 2016
Contributor
Let's return the new style and let the caller handle it (or, if that doesn't work, let the caller provide a callback that gets passed the new style), and then remove the distinction between compute_for_layout and compute_for_cascade.
| @@ -47,6 +46,15 @@ impl<GeckoType, ServoType> ArcHelpers<GeckoType, ServoType> { | |||
| unsafe { transmute(owned) } | |||
| } | |||
|
|
|||
| pub fn borrow<F, Output>(borrowed: &Arc<ServoType>, cb: F) -> Output | |||
This comment has been minimized.
This comment has been minimized.
|
|
||
| unsafe { | ||
| let context_ptr = Gecko_GetStyleContext(self.node); | ||
| mem::transmute(context_ptr) |
This comment has been minimized.
This comment has been minimized.
|
@bors-servo delegate+ r=me with comments. |
|
|
|
@bors-servo: try |
stylo: Allow computing change hints during the traversal. <!-- Please describe your changes on the following line: --> --- <!-- 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 <!-- Either: --> - [x] These changes do not require tests because geckolib :-( <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> r? @bholley cc @heycam <!-- 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/12645) <!-- Reviewable:end -->
|
|
…ource" In the Gecko case, this style source would be the style context. In the servo case, it will be always the computed values. We could optimise this further in the case of stylo (from three FFI calls to one) if we use an API of the form CalcAndStore(node, new_cv). But that would imply borrowing the data twice from Servo (we also have borrow_data_unchecked fwiw, but...).
|
@bholley: I'll need you to review the last commit and the regen.py changes in the previous one. |
| use gecko_bindings::structs::nsRestyleHint; | ||
|
|
||
| check_enum_value_non_static!(nsRestyleHint::eRestyle_Self, RESTYLE_SELF.bits()); | ||
| // XXX This for servo actually means something like an hipotetical |
This comment has been minimized.
This comment has been minimized.
| // XXX This for servo actually means something like an hipotetical | ||
| // Restyle_AllDescendants (but without running selector matching on the | ||
| // element). ServoRestyleManager interprets it like that, but in practice we | ||
| // should align the behavior with Gecko adding a new restyle hint, maybe? |
This comment has been minimized.
This comment has been minimized.
|
lgtm |
|
@bors-servo: r=bholley |
|
|
|
|
stylo: Allow computing change hints during the traversal. <!-- Please describe your changes on the following line: --> --- <!-- 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 <!-- Either: --> - [x] These changes do not require tests because geckolib :-( <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> r? @bholley cc @heycam <!-- 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/12645) <!-- Reviewable:end -->
|
@bors-servo p=2 |
|
|
emilio commentedJul 29, 2016
•
edited by larsbergstrom
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsr? @bholley
cc @heycam
This change is