Skip to content

style: Support anonymous box pseudo-elements - #10815

Merged
bors-servo merged 18 commits into
servo:masterfrom
emilio:anonbox-gcs
Apr 29, 2016
Merged

bors-servo merged 18 commits into
servo:masterfrom
emilio:anonbox-gcs

Conversation

@emilio

@emilio emilio commented Apr 23, 2016

Copy link
Copy Markdown
Member

This is a work-in-progress that:

  • Adds support for some pseudo-elements to skip the cascade entirely, in an analogous way to Gecko's anonymous box pseudo-elements.
  • Takes rid of StylistWrapper, and uses Arc::get_mut instead.
  • Uses the first bullet to precompute the -servo-details-content pseudo's style.

I'd like @bholley to take a look before following, do you think that the aproach is the correct?
Also, @SimonSapin could want to put some eyes on it.

Depends on servo/rust-selectors#81


This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/selector_matching.rs, components/style/data.rs, components/style/servo.rs, components/style/selector_impl.rs, components/style/traversal.rs, components/style/context.rs, components/style/dom.rs

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style and layout code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 23, 2016
@mbrubeck mbrubeck assigned bholley and unassigned mbrubeck Apr 23, 2016
@bholley

bholley commented Apr 23, 2016 •

Copy link
Copy Markdown
Contributor

Nice! A few random questions after a very brief and incomplete look at this:

  • What changed so that we can now get rid of StylistWrapper so easily?
  • The selectors for -servo-details-content in the UA stylesheet are not of the form *|*. Presumably that means they can't use this system, right? Should we change the UA stylesheet?
  • If the data is the same for the whole document, hanging a separate arc to it off of every node seems suboptimal. Is that what's happening here, or did I miss something?

@emilio

emilio commented Apr 23, 2016 •

Copy link
Copy Markdown
Member Author

Sorry for the extra comment, but Github ate the quotes on my previous one, and doesn't want to show them again.

What changed so that we can now get rid of StylistWrapper so easily?

Nothing, Arc::get_mut I guess, but this could have been changed a long
time before if I'm not wrong.

The selectors for -servo-details-content in the UA stylesheet are
not of the form |. Presumably that means they can't use this system,
right? Should we change the UA stylesheet?

Yes, in fact I changed them (see the
diff
)

If the data is the same for the whole document, hanging a separate
arc to it off of every node seems suboptimal. Is that what's happening
here, or did I miss something?

Agreed, but we can't do anything else other than passing around the
precomputed data as an argument everywhere else, and that's a huge
change I didn't felt like making for this PR (due to time constraints).

The cool part is that with this change we can pass over more common data
to the nodes without more overhead, but agreed that a common structure
passed from the callers would be more optimal.

Now I think more about it, iff layout workers are per-document (which
right now I think they are), and initialize_data is called from that
same thread (I think it is, I'd have to look at the code), we could
rely on a thread-local store updated just when we call Stylist::update
from the layout thread, without having to do huge changes to layout
traversal.

That'd reduce the overhead from one Arc clone per node to one clone per
layout worker. What do you think about that? To get zero cloning you'll
have to lock when accessing it if I'm not wrong.

If you think this can't land without it, let me know and I'll make one
of those changes (though the first one is pretty big and prone to bitrot
for my limited time right now).

@SimonSapin

SimonSapin commented Apr 23, 2016 •

Copy link
Copy Markdown
Member

That'd reduce the overhead from one Arc clone per node to one clone per layout worker

Arc::clone is one atomic integer increment, which sounds sounds relatively cheap compared to everything we do to cascade styles for one node. If it’s easy go for it, but I’d say don’t spend too much time on this.

That said I’m completely guessing, you’d have to benchmark it to be sure.

@emilio

emilio commented Apr 23, 2016

Copy link
Copy Markdown
Member Author

Yeah, I think @bholley's concern is more memory-related (one extra pointer per node), but I feel the same here, I'd rather focus on be correct and later speed things up if required.

@emilio
emilio force-pushed the anonbox-gcs branch 2 times, most recently from 5ca03f7 to 1b499bd Compare April 23, 2016 12:36
@emilio

emilio commented Apr 23, 2016 •

Copy link
Copy Markdown
Member Author

@bholley: I dind't have thought about inheritance, which Gecko relies a ton on.

Just added a few patches to add support for it.

@bholley

bholley commented Apr 23, 2016 •

Copy link
Copy Markdown
Contributor

Yeah, I was worried about memory rather than clone overhead. We have memory tests that complain whenever Node gets bigger. The memory reporters don't see into PrivateStyleData so the test doesn't notice, but this does grow Node by one pointer.

In general I think passing some sort of general context from the caller is the right thing to do. Is it just annoying to pass, or does it also require parameterizing a bunch of stuff? It seems like having a SharedStyleContext available at most points in the cascade is probably worthwhile. I'm fine for it to be done in a followup though if it adds too much churn in this PR.

I'd like to avoid relying on TLS too much if possible, since some of the thread invariants may change (i.e. we will probably end up sharing threads between documents at some point).

@emilio
emilio force-pushed the anonbox-gcs branch 2 times, most recently from 8d7b70c to 92e75e6 Compare April 24, 2016 17:48
@emilio

emilio commented Apr 24, 2016 •

Copy link
Copy Markdown
Member Author

@bholley: Added a bunch of changes that take rid of the extra field, take a look.

Also, building stylo I get a crash in a Can't handle namespaces yet assertion.

I'll take a look at it later if I have the time, but it's trivial to implementServo_GetComputedValuesForAnonymousBox if we pass the shared context to it now.

I made a few changes to pseudo-elements, so I'm going to do a try run:

@bors-servo: try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 96db48f with merge 11be268...

bors-servo pushed a commit that referenced this pull request Apr 24, 2016
[WIP] style: Support anonymous box pseudo-elements

This is a work-in-progress that:

 * Adds support for some pseudo-elements to skip the cascade entirely, in an analogous way to Gecko's anonymous box pseudo-elements.
 * Takes rid of `StylistWrapper`, and uses `Arc::get_mut` instead.
 * Uses the first bullet to precompute the `-servo-details-content` pseudo's style.

I'd like @bholley to take a look before following, do you think that the aproach is the correct?
Also, @SimonSapin could want to put some eyes on it.

Depends on servo/rust-selectors#81

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10815)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-tests-failed The changes caused existing tests to fail. labels Apr 24, 2016
@emilio

emilio commented Apr 24, 2016 •

Copy link
Copy Markdown
Member Author

@bors-servo: try

It seems that the toml [replaces] syntax must be at a top-level target, so I had to add the directive for all the ports.

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 92d684d with merge 7b08d0d...

bors-servo pushed a commit that referenced this pull request Apr 24, 2016
[WIP] style: Support anonymous box pseudo-elements

This is a work-in-progress that:

 * Adds support for some pseudo-elements to skip the cascade entirely, in an analogous way to Gecko's anonymous box pseudo-elements.
 * Takes rid of `StylistWrapper`, and uses `Arc::get_mut` instead.
 * Uses the first bullet to precompute the `-servo-details-content` pseudo's style.

I'd like @bholley to take a look before following, do you think that the aproach is the correct?
Also, @SimonSapin could want to put some eyes on it.

Depends on servo/rust-selectors#81

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10815)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Apr 24, 2016
@highfive

highfive commented Apr 24, 2016 •

Copy link
Copy Markdown

Moved to a gist to not overload the thread.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Apr 29, 2016
@emilio

emilio commented Apr 29, 2016

Copy link
Copy Markdown
Member Author

@bors-servo: r=SimonSapin,bholley

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 15a32fa has been approved by SimonSapin,bholley

@highfive highfive assigned emilio and unassigned bholley Apr 29, 2016
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 29, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 15a32fa with merge 407f991...

bors-servo pushed a commit that referenced this pull request Apr 29, 2016
style: Support anonymous box pseudo-elements

This is a work-in-progress that:

 * Adds support for some pseudo-elements to skip the cascade entirely, in an analogous way to Gecko's anonymous box pseudo-elements.
 * Takes rid of `StylistWrapper`, and uses `Arc::get_mut` instead.
 * Uses the first bullet to precompute the `-servo-details-content` pseudo's style.

I'd like @bholley to take a look before following, do you think that the aproach is the correct?
Also, @SimonSapin could want to put some eyes on it.

Depends on servo/rust-selectors#81

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10815)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows

@bors-servo
bors-servo merged commit 15a32fa into servo:master Apr 29, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 29, 2016
bors-servo pushed a commit that referenced this pull request May 4, 2016
style: Add infrastructure to support lazy pseudo-elements

This builds on top of #10815, so it's really just the last commit the one that should be reviewed.

I tried to apply the new infrastructure to servo, but failed (for now?).

The problem with it is that it'd require `ThreadSafeLayoutElement` to implement `selectors::Element`, which is a lot of work and might be racy (not totally sure about it though). Thus, I prefered to keep selectors eager until knowing that it's safe to do it.

r? @mbrubeck for style changes, @bholley for the geckolib changes (minimal for now, glue + a list of lazy PEs must be added)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10934)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request May 4, 2016
style: Add infrastructure to support lazy pseudo-elements

This builds on top of #10815, so it's really just the last commit the one that should be reviewed.

I tried to apply the new infrastructure to servo, but failed (for now?).

The problem with it is that it'd require `ThreadSafeLayoutElement` to implement `selectors::Element`, which is a lot of work and might be racy (not totally sure about it though). Thus, I prefered to keep selectors eager until knowing that it's safe to do it.

r? @mbrubeck for style changes, @bholley for the geckolib changes (minimal for now, glue + a list of lazy PEs must be added)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10934)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants