Skip to content
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

stylo: Allow computing change hints during the traversal. #12645

Merged
merged 5 commits into from Aug 4, 2016

Conversation

@emilio
Copy link
Member

emilio commented Jul 29, 2016


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because geckolib :-(

r? @bholley
cc @heycam


This change is Reviewable

@highfive
Copy link

highfive commented Jul 29, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/gecko_glue.rs, components/style/sequential.rs, components/style/dom.rs, components/style/traversal.rs, components/style/matching.rs
  • @KiChjang: components/script_layout_interface/restyle_damage.rs
@highfive
Copy link

highfive commented Jul 29, 2016

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify style code, but no tests are modified. Please consider adding a test!
@@ -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.

@bholley

bholley Jul 29, 2016

Contributor

Can we make this a closure-y API like |with| to avoid the unsafety here?

@bholley
Copy link
Contributor

bholley commented Jul 29, 2016

Generally seems reasonable, but will need some fiddling in light of https://bugzilla.mozilla.org/show_bug.cgi?id=1290335#c9

@emilio emilio force-pushed the emilio:stylo branch from 3adbd53 to ca7c2f0 Jul 29, 2016
/// ComputedValues in Servo and a StyleContext in Gecko.
///
/// This must be obtained via the node.
type CascadeStyleSource;

This comment has been minimized.

@bholley

bholley Aug 1, 2016

Contributor

Let's call this PreExistingComputedValues?

This comment has been minimized.

@bholley

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.

@bholley

bholley Aug 1, 2016

Contributor

existing_style_for_restyle_damage?

@@ -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.

@bholley

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.

@bholley

bholley Aug 1, 2016

Contributor

with_gecko?


unsafe {
let context_ptr = Gecko_GetStyleContext(self.node);
mem::transmute(context_ptr)

This comment has been minimized.

@bholley

bholley Aug 1, 2016

Contributor

unsafe { context_ptr.as_ref() } ?

@bholley
Copy link
Contributor

bholley commented Aug 1, 2016

@bors-servo delegate+

r=me with comments.

@bors-servo
Copy link
Contributor

bors-servo commented Aug 1, 2016

✌️ @emilio can now approve this pull request

@emilio emilio force-pushed the emilio:stylo branch from ca7c2f0 to 769cdc5 Aug 1, 2016
@emilio
Copy link
Member Author

emilio commented Aug 1, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Aug 1, 2016

Trying commit 769cdc5 with merge 9fc5d76...

bors-servo added a commit that referenced this pull request Aug 1, 2016
 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
Copy link
Contributor

bors-servo commented Aug 1, 2016

emilio added 3 commits Jul 28, 2016
…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...).
@emilio emilio force-pushed the emilio:stylo branch from 32f8e49 to 616ab07 Aug 3, 2016
@emilio
Copy link
Member Author

emilio commented Aug 3, 2016

@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.

@bholley

bholley Aug 3, 2016

Contributor

"a hypothetical"

// 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.

@bholley

bholley Aug 3, 2016

Contributor

Reference the bug we have on file for doing that?

@bholley
Copy link
Contributor

bholley commented Aug 3, 2016

lgtm

emilio added 2 commits Aug 3, 2016
Turns out eRestyle_LaterSiblings was not really matching, sigh...
@emilio emilio force-pushed the emilio:stylo branch from 616ab07 to 444e8f8 Aug 3, 2016
@emilio
Copy link
Member Author

emilio commented Aug 3, 2016

@bors-servo: r=bholley

@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

📌 Commit 444e8f8 has been approved by bholley

@bors-servo
Copy link
Contributor

bors-servo commented Aug 4, 2016

Testing commit 444e8f8 with merge cbf71a2...

bors-servo added a commit that referenced this pull request Aug 4, 2016
 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 -->
@bholley
Copy link
Contributor

bholley commented Aug 4, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Aug 4, 2016

@bors-servo bors-servo merged commit 444e8f8 into servo:master Aug 4, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Aug 4, 2016
4 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.