Skip to content

style: Add infrastructure to support lazy pseudo-elements - #10934

Merged
bors-servo merged 8 commits into
servo:masterfrom
emilio:other-gecko-pseudos
May 4, 2016
Merged

bors-servo merged 8 commits into
servo:masterfrom
emilio:other-gecko-pseudos

Conversation

@emilio

@emilio emilio commented Apr 29, 2016 •

Copy link
Copy Markdown
Member

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)


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/servo.rs, components/style/traversal.rs, components/style/matching.rs, components/style/media_queries.rs, components/style/restyle_hints.rs, components/style/dom.rs, components/style/context.rs, components/style/selector_impl.rs

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 29, 2016
Comment thread components/layout/wrapper.rs Outdated
PseudoElementCascadeType::Lazy => {
panic!("Lazy pseudo-elements can't be used in Servo \
since accessing the DOM tree during layout \
could be unsafe.")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not totally sure about this, @mbrubeck, do you know if it'd be safe for ServoThreadSafeLayoutElement to implement selectors::Element? (that is, getting parent, siblings...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it would not be, but I'll let @mbrubeck confirm. Might need to think a bit on how this fits into the Servo model.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it is unsafe for a ThreadSafeLayoutNode to access its parents or siblings.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could still use a subset of selector-matching though (attributes + tag name at least), enough for avoiding doing the whole cascade for some private pseudos, like ::-servo-details-summary, which only needs access to the details tag and the open attribute.

Would this be desirable (with appropriate docs of course), or is it just a lot of overhead? I think it can be worth it but I'd like to know your opinion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems reasonable to me; I guess all it would require is an impl of Element that just returns None for things like parent_element.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, just did that and cleaned it up a bit, feel free to re-review the changes :)

@bholley

bholley commented Apr 29, 2016

Copy link
Copy Markdown
Contributor

geckolib changes look good modulo that one change.

/// A wrapper around elements that ensures layout can only ever access safe properties and cannot
/// race on elements.
/// A wrapper around elements that ensures layout can only
/// ever access safe properties and cannot race on elements.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Rust style is to wrap at 99 columns. I don't care too deeply about exactly where comments wrap, but if you can configure your editor not to re-format things to 80 columns, it would make reviews a little easier.

@mbrubeck

Copy link
Copy Markdown
Contributor

The Servo changes are good; r=mbrubeck with the commented-out code removed. Note: I left a couple of other review comments but then deleted them because they were incorrect. (This is what I get for using GitHub comments instead of Reviewable.) Please disregard any comments that no longer appear in the GitHub UI.

@mbrubeck mbrubeck added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 29, 2016
@notriddle

notriddle commented Apr 30, 2016 •

Copy link
Copy Markdown
Contributor

Now that #10815 is merged, should this commit be rebased on top of it (so that GitHub only lists one commit for this PR)?

@bholley

bholley commented Apr 30, 2016

Copy link
Copy Markdown
Contributor

Yes. I'm guessing @emilio will do that sometime when he's awake. :-)

@emilio
emilio force-pushed the other-gecko-pseudos branch from 3c3e9ef to b1002cb Compare April 30, 2016 11:43
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Apr 30, 2016
@emilio
emilio force-pushed the other-gecko-pseudos branch from b1002cb to 1446e24 Compare April 30, 2016 16:15
@highfive

highfive commented May 3, 2016

Copy link
Copy Markdown

New code was committed to pull request.

emilio added 2 commits May 3, 2016 19:01
These can't be supported in Servo as of right now, because I'm not
totally sure the accesses that should be done in layout would be
thread-safe.

It can be revisited later though.
@emilio
emilio force-pushed the other-gecko-pseudos branch from cb98bac to 845b2d9 Compare May 3, 2016 17:02
@highfive

highfive commented May 3, 2016

Copy link
Copy Markdown

New code was committed to pull request.

@emilio
emilio force-pushed the other-gecko-pseudos branch from 845b2d9 to 1138b89 Compare May 3, 2016 17:27
@highfive

highfive commented May 3, 2016

Copy link
Copy Markdown

New code was committed to pull request.

@emilio emilio changed the title [WIP] style: Add infrastructure to support lazy pseudo-elements style: Add infrastructure to support lazy pseudo-elements May 3, 2016
@mbrubeck mbrubeck added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 3, 2016
@mbrubeck

mbrubeck commented May 3, 2016

Copy link
Copy Markdown
Contributor

-S-awaiting-review +S-needs-code-changes


Reviewed 6 of 6 files at r1, 2 of 11 files at r2, 3 of 7 files at r19, 3 of 6 files at r23, 3 of 3 files at r24.
Review status: all files reviewed at latest revision, 6 unresolved discussions.


components/layout/wrapper.rs, line 1360 [r24] (raw file):
Is it a programming error if this is ever called? If so, maybe change these from warn! to panic! or debug_assert!(false, ...).


components/style/selector_impl.rs, line 117 [r24] (raw file):
This TODO comment is done. \o/ (A note about ::selection would still be appropriate.)


Comments from Reviewable

@emilio
emilio force-pushed the other-gecko-pseudos branch from 1138b89 to 1800c23 Compare May 3, 2016 18:36
@emilio
emilio force-pushed the other-gecko-pseudos branch from c961f77 to 0f7b70c Compare May 3, 2016 22:44
@highfive highfive removed the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label May 3, 2016
@highfive

highfive commented May 3, 2016

Copy link
Copy Markdown

New code was committed to pull request.

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 3, 2016
@emilio

emilio commented May 3, 2016

Copy link
Copy Markdown
Member Author

Ok, rebased, typo fixed, and implemented Servo_GetComputedValuesForPseudoElement for stylo.

r? @bholley (for the stylo changes, the rest is reviewed)


Review status: 9 of 13 files reviewed at latest revision, 3 unresolved discussions.


docs/components/style.md, line 126 [r26] (raw file):
Done.


Comments from Reviewable

@highfive highfive assigned bholley and unassigned mbrubeck May 3, 2016
Comment thread ports/geckolib/glue.rs
}
};

let pseudo = match pseudo_element_from_atom(pseudo_tag, /* ua_stylesheet = */ true) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to pass the appropriate value here from the caller right? I'll add a TODO.

@bholley

bholley commented May 4, 2016

Copy link
Copy Markdown
Contributor

Looks great!

@bors-servo r=bholley,mbrubeck

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 0f7b70c has been approved by bholley,mbrubeck

@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 May 4, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0f7b70c with merge 04012c1...

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

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels May 4, 2016
@highfive

highfive commented May 4, 2016

Copy link
Copy Markdown
  ▶ TIMEOUT [expected OK] /html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-auto.html
  │ 
  └ Xlib:  extension &#34;XFree86-VidModeExtension&#34; missing on display &#34;:0&#34;.

  ▶ Unexpected subtest result in /html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-auto.html:
  │ TIMEOUT [expected PASS] placeholder: &#39;iframe&#39;, containerWidthStyle: &#39;400px&#39;, containerHeightStyle: &#39;400px&#39;, placeholderWidthAttr: &#39;100&#39;, svgViewBoxAttr: &#39;0 0 100 200&#39;, svgWidthAttr: &#39;25%&#39;, svgHeightAttr: &#39;25%&#39;, 
  └   → Test timed out

  ▶ TIMEOUT [expected OK] /html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-fixed.html
  │ 
  └ Xlib:  extension &#34;XFree86-VidModeExtension&#34; missing on display &#34;:0&#34;.

  ▶ Unexpected subtest result in /html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-fixed.html:
  │ TIMEOUT [expected PASS] placeholder: &#39;iframe&#39;, containerHeightStyle: &#39;400px&#39;, placeholderWidthAttr: &#39;100&#39;, placeholderHeightAttr: &#39;100px&#39;, svgViewBoxAttr: &#39;0 0 100 200&#39;, svgWidthAttr: &#39;25%&#39;, svgHeightAttr: &#39;25%&#39;, 
  └   → Test timed out

  ▶ TIMEOUT [expected OK] /html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-percentage.html
  │ 
  └ Xlib:  extension &#34;XFree86-VidModeExtension&#34; missing on display &#34;:0&#34;.

  ▶ Unexpected subtest result in /html/rendering/replaced-elements/svg-embedded-sizing/svg-in-iframe-percentage.html:
  │ TIMEOUT [expected PASS] placeholder: &#39;iframe&#39;, containerHeightStyle: &#39;400px&#39;, placeholderWidthAttr: &#39;100&#39;, placeholderHeightAttr: &#39;100%&#39;, svgViewBoxAttr: &#39;0 0 100 200&#39;, svgWidthAttr: &#39;25%&#39;, svgHeightAttr: &#39;25%&#39;, 
  └   → Test timed out

@emilio

emilio commented May 4, 2016

Copy link
Copy Markdown
Member Author

@bors-servo: retry

#10457

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0f7b70c with merge 29823cb...

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 -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels May 4, 2016
@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 0f7b70c into servo:master May 4, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 4, 2016
@emilio
emilio deleted the other-gecko-pseudos branch May 4, 2016 14:10
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.

6 participants