Skip to content

Dirty elements whose selectors are affected by sibling changes - #9722

Merged
bors-servo merged 1 commit into
servo:masterfrom
mbrubeck:slow-selector
Feb 24, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
mbrubeck:slow-selector

Conversation

@mbrubeck

Copy link
Copy Markdown
Contributor

This fixes incremental layout of nodes that match pseudo-class selectors such as :first-child, :nth-child, :last-child, :first-of-type, etc. Fixes #8191 and other intermittent layout bugs.

This code is based on the following flags from Gecko:
https://hg.mozilla.org/mozilla-central/file/e1cf617a1f28/dom/base/nsINode.h#l134

Depends on servo/rust-selectors#71. r? @SimonSapin

There are a couple of TODO items in this commit, but I'd appreciate feedback on the general approach before I finish it up. (Also, if someone who knows more than I do could give some advice about atomic orderings...)

Review on Reviewable

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify layout and script 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 Feb 22, 2016
@KiChjang

Copy link
Copy Markdown
Contributor

If this fixes #8191, then you may want to re-enable the test again, since I have disabled it in #9716.

@mbrubeck mbrubeck added the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Feb 22, 2016
@mbrubeck

Copy link
Copy Markdown
Contributor Author

Re-enabled two disabled tests, and finished one of the TODO items.

@nox

nox commented Feb 23, 2016

Copy link
Copy Markdown
Contributor

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


Reviewed 6 of 6 files at r1.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


components/script/dom/node.rs, line 2403 [r1] (raw file):
Why "previously-existing"?


components/script/dom/node.rs, line 2438 [r1] (raw file):
You didn't cover ChildrenMutation::Insert: just because this is not an Append doesn't mean a new first Element didn't get inserted.

Also I would replace the catch-all _ => None by:

ChildrenMutation::Insert(…) => …,
ChildrenMutation::Replace { prev: None, next: None, .. } => unreachable!(),
ChildrenMutation::ReplaceAll { .. } => None,

Comments from the review on Reviewable.io

@nox nox 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 Feb 23, 2016
@nox nox self-assigned this Feb 23, 2016
@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 Feb 23, 2016
@mbrubeck

Copy link
Copy Markdown
Contributor Author

Addressed review comments. Note: This still depends on servo/rust-selectors#72 and will need a cargo update after that is published.


Review status: 5 of 6 files reviewed at latest revision, 2 unresolved discussions.


components/script/dom/node.rs, line 2403 [r1] (raw file):
That was redundant; removed it.


components/script/dom/node.rs, line 2438 [r1] (raw file):
Good catch, thanks! The same applies to Replace { prev: Some, next: Some }. Both are handled correctly, now.


Comments from the review on Reviewable.io

@mbrubeck
mbrubeck force-pushed the slow-selector branch 2 times, most recently from a33677f to 7cb1926 Compare February 23, 2016 23:56
@mbrubeck mbrubeck removed the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Feb 23, 2016
@mbrubeck

Copy link
Copy Markdown
Contributor Author

Rebased, cargo updated, and re-enabled two more tests. This is now ready to merge after r+.

@pcwalton

Copy link
Copy Markdown
Contributor

This looks good to me. Exciting!

@KiChjang

Copy link
Copy Markdown
Contributor

Fails tidy:

./components/script/dom/element.rs:69: use statement is not in alphabetical order

    expected: selectors::matching::{HAS_SLOW_SELECTOR, HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS}

    found: selectors::matching::{DeclarationBlock, ElementFlags, matches}

@KiChjang

Copy link
Copy Markdown
Contributor

Also fails a couple of interesting unit tests:

failures:

---- size_of::size_div stdout ----

    thread 'size_of::size_div' panicked at 'Your changes have increased the stack size of commonly used DOM struct HTMLDivElement from 320 to 328. These structs are present in large quantities in the DOM, and increasing the size may dramatically affect our memory footprint. Please consider choosing a design which avoids this increase. If you feel that the increase is necessary, update to the new size in script/tests.rs.', /home/travis/build/servo/servo/tests/unit/script/size_of.rs:44

note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- size_of::size_element stdout ----

    thread 'size_of::size_element' panicked at 'Your changes have increased the stack size of commonly used DOM struct Element from 304 to 312. These structs are present in large quantities in the DOM, and increasing the size may dramatically affect our memory footprint. Please consider choosing a design which avoids this increase. If you feel that the increase is necessary, update to the new size in script/tests.rs.', /home/travis/build/servo/servo/tests/unit/script/size_of.rs:42

---- size_of::size_htmlelement stdout ----

    thread 'size_of::size_htmlelement' panicked at 'Your changes have increased the stack size of commonly used DOM struct HTMLElement from 320 to 328. These structs are present in large quantities in the DOM, and increasing the size may dramatically affect our memory footprint. Please consider choosing a design which avoids this increase. If you feel that the increase is necessary, update to the new size in script/tests.rs.', /home/travis/build/servo/servo/tests/unit/script/size_of.rs:43

---- size_of::size_span stdout ----

    thread 'size_of::size_span' panicked at 'Your changes have increased the stack size of commonly used DOM struct HTMLSpanElement from 320 to 328. These structs are present in large quantities in the DOM, and increasing the size may dramatically affect our memory footprint. Please consider choosing a design which avoids this increase. If you feel that the increase is necessary, update to the new size in script/tests.rs.', /home/travis/build/servo/servo/tests/unit/script/size_of.rs:45

This fixes incremental layout of nodes that match pseudo-class selectors such
as :first-child, :nth-child, :last-child, :first-of-type, etc.

* Fixes servo#8191
* Fixes servo#9063
* Fixes servo#9303
* Fixes servo#9448

This code is based on the following flags from Gecko:
https://hg.mozilla.org/mozilla-central/file/e1cf617a1f28/dom/base/nsINode.h#l134
@mbrubeck

Copy link
Copy Markdown
Contributor Author

Fixed the tidy error, and updated the expected sizes in size_of.rs. I think the size increase is basically unavoidable; we are adding new info to Element that we didn't have before. We could cram the info into NodeFlags instead but it only has space for one more flag, and is not thread-safe.

@nox

nox commented Feb 24, 2016

Copy link
Copy Markdown
Contributor

@bors-servo r+


Reviewed 1 of 1 files at r2, 2 of 2 files at r3, 7 of 7 files at r4.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 9739189 has been approved by nox

@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 Feb 24, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 9739189 with merge 438b3a4...

bors-servo pushed a commit that referenced this pull request Feb 24, 2016
Dirty elements whose selectors are affected by sibling changes

This fixes incremental layout of nodes that match pseudo-class selectors such as :first-child, :nth-child, :last-child, :first-of-type, etc.  Fixes #8191 and other intermittent layout bugs.

This code is based on the following flags from Gecko:
https://hg.mozilla.org/mozilla-central/file/e1cf617a1f28/dom/base/nsINode.h#l134

Depends on servo/rust-selectors#71. r? @SimonSapin

There are a couple of TODO items in this commit, but I'd appreciate feedback on the general approach before I finish it up.  (Also, if someone who knows more than I do could give some advice about atomic orderings...)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9722)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit 9739189 into servo:master Feb 24, 2016
@mbrubeck
mbrubeck deleted the slow-selector branch May 2, 2017 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent failure in /_mozilla/css/last_of_type_pseudo_a.html

6 participants