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

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

Merged
merged 8 commits into from May 4, 2016

Conversation

@emilio
Copy link
Member

emilio commented Apr 29, 2016

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

highfive commented Apr 29, 2016

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

highfive commented Apr 29, 2016

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
PseudoElementCascadeType::Lazy => {
panic!("Lazy pseudo-elements can't be used in Servo \
since accessing the DOM tree during layout \
could be unsafe.")

This comment has been minimized.

@emilio

emilio Apr 29, 2016

Author Member

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

This comment has been minimized.

@bholley

bholley Apr 29, 2016

Contributor

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.

This comment has been minimized.

@mbrubeck

mbrubeck Apr 29, 2016

Contributor

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

This comment has been minimized.

@emilio

emilio Apr 30, 2016

Author Member

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.

This comment has been minimized.

@mbrubeck

mbrubeck May 2, 2016

Contributor

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.

This comment has been minimized.

@emilio

emilio May 3, 2016

Author Member

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

MozTreeDropFeedback | MozSVGMarkerAnonChild |
MozSVGOuterSVGAnonChild | MozSVGForeignContent |
MozSVGText => true,
_ => false,

This comment has been minimized.

@bholley

bholley Apr 29, 2016

Contributor

Seems like we should make this an ADT?

This comment has been minimized.

@emilio

emilio Apr 29, 2016

Author Member

Done

@bholley
Copy link
Contributor

bholley commented Apr 29, 2016

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.

This comment has been minimized.

@mbrubeck

mbrubeck Apr 29, 2016

Contributor

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.

// data.style_data.per_pseudo
// .insert(style_pseudo.clone(), new_style.unwrap())
// }
}

This comment has been minimized.

@mbrubeck

mbrubeck Apr 29, 2016

Contributor

Please remove the commented-out code before merging.

@mbrubeck
Copy link
Contributor

mbrubeck commented Apr 29, 2016

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.

@notriddle
Copy link
Contributor

notriddle commented Apr 30, 2016

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
Copy link
Contributor

bholley commented Apr 30, 2016

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

@emilio emilio force-pushed the emilio:other-gecko-pseudos branch from 3c3e9ef to b1002cb Apr 30, 2016
@emilio emilio force-pushed the emilio:other-gecko-pseudos branch from b1002cb to 1446e24 Apr 30, 2016
@highfive
Copy link

highfive commented May 3, 2016

New code was committed to pull request.

emilio added 2 commits Apr 29, 2016
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 emilio:other-gecko-pseudos branch from cb98bac to 845b2d9 May 3, 2016
@highfive
Copy link

highfive commented May 3, 2016

New code was committed to pull request.

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

highfive commented May 3, 2016

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
Copy link
Contributor

mbrubeck commented May 3, 2016

-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 emilio:other-gecko-pseudos branch from 1138b89 to 1800c23 May 3, 2016
emilio added 3 commits May 3, 2016
…youtElement methods
Thanks to Simon for the feedback :)
@emilio emilio force-pushed the emilio:other-gecko-pseudos branch from c961f77 to 0f7b70c May 3, 2016
@highfive
Copy link

highfive commented May 3, 2016

New code was committed to pull request.

@emilio
Copy link
Member Author

emilio commented May 3, 2016

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
}
};

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

This comment has been minimized.

@bholley

bholley May 4, 2016

Contributor

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

@bholley
Copy link
Contributor

bholley commented May 4, 2016

Looks great!

@bors-servo r=bholley,mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented May 4, 2016

📌 Commit 0f7b70c has been approved by bholley,mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented May 4, 2016

Testing commit 0f7b70c with merge 04012c1...

bors-servo added 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
Contributor

bors-servo commented May 4, 2016

💔 Test failed - linux-rel

@highfive
Copy link

highfive commented May 4, 2016

  ▶ 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
Copy link
Member Author

emilio commented May 4, 2016

@bors-servo
Copy link
Contributor

bors-servo commented May 4, 2016

Testing commit 0f7b70c with merge 29823cb...

bors-servo added 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
Contributor

bors-servo commented May 4, 2016

@bors-servo bors-servo merged commit 0f7b70c into servo:master May 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
@emilio emilio deleted the emilio:other-gecko-pseudos branch May 4, 2016
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

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