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

ID and class selectors are ASCII case-insensitive in quirks mode. #17213

Merged
merged 7 commits into from Jun 12, 2017

Conversation

@SimonSapin
Copy link
Member

SimonSapin commented Jun 7, 2017

@highfive
Copy link

highfive commented Jun 7, 2017

Heads up! This PR modifies the following files:

  • @bholley: components/style/gecko_string_cache/mod.rs, components/style/lib.rs, components/style/gecko/snapshot_helpers.rs, components/style/restyle_hints.rs, components/style/invalidation/stylesheets.rs and 4 more
  • @KiChjang: components/script/dom/htmlcollection.rs, components/script/dom/element.rs, components/script/layout_wrapper.rs, components/script/dom/window.rs
  • @fitzgen: components/script/dom/htmlcollection.rs, components/script/dom/element.rs, components/script/layout_wrapper.rs, components/script/dom/window.rs
  • @emilio: components/style/gecko_string_cache/mod.rs, components/style/lib.rs, components/style/gecko/snapshot_helpers.rs, components/style/restyle_hints.rs, components/style/invalidation/stylesheets.rs and 4 more
@highfive
Copy link

highfive commented Jun 7, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify style and script code, but no tests are modified. Please consider adding a test!
@highfive highfive assigned emilio and unassigned KiChjang Jun 7, 2017
bors-servo added a commit that referenced this pull request Jun 7, 2017
ID and class selectors are ASCII case-insensitive in quirks mode.

https://bugzilla.mozilla.org/show_bug.cgi?id=1363778

<!-- 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/17213)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 7, 2017

Trying commit 67e7e60 with merge a9aa481...

@bors-servo
Copy link
Contributor

bors-servo commented Jun 7, 2017

💔 Test failed - linux-rel-wpt

@SimonSapin SimonSapin force-pushed the quirk-case branch from 67e7e60 to 2f827d0 Jun 7, 2017
@highfive highfive removed the S-tests-failed label Jun 7, 2017
@SimonSapin
Copy link
Member Author

SimonSapin commented Jun 7, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jun 7, 2017

Trying commit 2f827d0 with merge 6d6e1ef...

bors-servo added a commit that referenced this pull request Jun 7, 2017
ID and class selectors are ASCII case-insensitive in quirks mode.

https://bugzilla.mozilla.org/show_bug.cgi?id=1363778

<!-- 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/17213)
<!-- Reviewable:end -->
@SimonSapin
Copy link
Member Author

SimonSapin commented Jun 7, 2017

Per https://bugzilla.mozilla.org/show_bug.cgi?id=1363778#c9 this is missing some changes in stylist.rs.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 7, 2017

@SimonSapin SimonSapin force-pushed the quirk-case branch from 2f827d0 to aac36c4 Jun 8, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2017

Trying commit aac36c4 with merge d0f1c0b...

bors-servo added a commit that referenced this pull request Jun 8, 2017
ID and class selectors are ASCII case-insensitive in quirks mode.

https://bugzilla.mozilla.org/show_bug.cgi?id=1363778

<!-- 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/17213)
<!-- Reviewable:end -->
@SimonSapin SimonSapin force-pushed the quirk-case branch from aac36c4 to fd8f527 Jun 8, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2017

Trying commit fd8f527 with merge 585d57d...

bors-servo added a commit that referenced this pull request Jun 8, 2017
ID and class selectors are ASCII case-insensitive in quirks mode.

https://bugzilla.mozilla.org/show_bug.cgi?id=1363778

<!-- 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/17213)
<!-- Reviewable:end -->
@bzbarsky
Copy link
Contributor

bzbarsky commented Jun 8, 2017

So that gets unexpected passes. I'm a little worried about performance: it's adding a bunch of branches to hot paths and in the quirks case a bunch of to_ascii_lowercase() stuff.

The branches should really be able to be hoisted much higher: the quirks mode boolean is an invariant for a stylist as far as I know. We could conceivably even make things generic on the quirks mode if we wanted to; I just don't know what that would do to the codesize. For the to_ascii_lowercase bit, I'm not sure whether that's enough of a problem to try to do something where the actual key lookups are in-place ASCII-case-insensitive (which is what Gecko does). Might want to measure.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2017

The latest upstream changes (presumably #17225) made this pull request unmergeable. Please resolve the merge conflicts.

@SimonSapin
Copy link
Member Author

SimonSapin commented Jun 8, 2017

I don’t think making this completely generic works, we still want a runtime branch or dispatch at some point, even if hoisted higher.

As far as I can tell, Gecko does dynamic dispatch for this (a struct of function pointers): http://searchfox.org/mozilla-central/rev/1a054419976437d0778a2b89be1b00207a744e94/layout/style/nsCSSRuleProcessor.cpp#368-384 I don’t know which is preferable.

I considered in-place ASCII case-insensitive hash map lookups but for hashing atoms we use a pre-computed mHash member, and writing hasher in Rust that makes case-insensitive hashes compatible with that seemed tricky and likely to get out of sync. If we go that way we should FFI into C++ for case-insensitive hashing.

@bholley
Copy link
Contributor

bholley commented Jun 8, 2017

Yeah, I'm extremely worried about the branches here. I agree that we should make the decision once higher-up and then call monomorphized code.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 12, 2017

The latest upstream changes (presumably #17281) made this pull request unmergeable. Please resolve the merge conflicts.

@SimonSapin SimonSapin force-pushed the quirk-case branch from 9aff968 to fec93e6 Jun 12, 2017
@SimonSapin SimonSapin force-pushed the quirk-case branch from fec93e6 to b827139 Jun 12, 2017
@SimonSapin
Copy link
Member Author

SimonSapin commented Jun 12, 2017

Macros+generics stuff removed per IRC discussion http://logs.glob.uno/?c=mozilla%23servo&s=12+Jun+2017&e=12+Jun+2017#c695467 , added pre-computation of classes_and_ids_case_sensitivity in MatchingContext::new.

Some(Atom::from(ptr))
}
fn has_id(&self, id: &Atom, case_sensitivity: CaseSensitivity) -> bool {
self.get_id().map_or(false, |atom| case_sensitivity.eq_atom(&atom, id))

This comment has been minimized.

@bholley

bholley Jun 12, 2017

Contributor

We could tweak this to skip the refcount traffic from get_id(), which would probably be a significant win given that the atom refcounting is atomic. Can you either fix that here or file a followup?

This comment has been minimized.

@SimonSapin

SimonSapin Jun 12, 2017

Author Member

Done.

@bholley
Copy link
Contributor

bholley commented Jun 12, 2017

r=me with that.

@bors-servo delegate+

@bors-servo
Copy link
Contributor

bors-servo commented Jun 12, 2017

✌️ @SimonSapin can now approve this pull request

@SimonSapin
Copy link
Member Author

SimonSapin commented Jun 12, 2017

@bors-servo r=bholley

@bors-servo
Copy link
Contributor

bors-servo commented Jun 12, 2017

📌 Commit 138c03b has been approved by bholley

@bors-servo
Copy link
Contributor

bors-servo commented Jun 12, 2017

Testing commit 138c03b with merge 1b07730...

bors-servo added a commit that referenced this pull request Jun 12, 2017
ID and class selectors are ASCII case-insensitive in quirks mode.

https://bugzilla.mozilla.org/show_bug.cgi?id=1363778

<!-- 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/17213)
<!-- Reviewable:end -->
@SimonSapin
Copy link
Member Author

SimonSapin commented Jun 12, 2017

Copied from above:

--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1555,7 +1555,7 @@ needs-focus == 568441.html 568441-ref.html
 == 571347-1b.html 571347-1-ref.html
 == 571347-2a.html 571347-2-ref.html
 == 571347-2b.html 571347-2-ref.html
-fails-if(styloVsGecko||stylo) == 571347-2c.html 571347-2-ref.html
+== 571347-2c.html 571347-2-ref.html
 == 571347-2d.html 571347-2-ref.html
 == 571347-3.html 571347-3-ref.html
 == 572598-1.html 572598-ref.html
@@ -1667,7 +1667,7 @@ fuzzy-if(Android,8,500) fuzzy-if(skiaContent,2,1) fuzzy-if(webrender,3,19) == 63
 fuzzy-if(Android,8,500) == 637852-3.html 637852-3-ref.html
 == 641770-1.html 641770-1-ref.html
 == 641856-1.html 641856-1-ref.html
-fails-if(styloVsGecko||stylo) == 645491-1.html 645491-1-ref.html
+== 645491-1.html 645491-1-ref.html
 == 645647-1.html 645647-1-ref.html
 == 645647-2.html 645647-2-ref.html
 == 645768-1.html 645768-1-ref.html
@bors-servo
Copy link
Contributor

bors-servo commented Jun 12, 2017

@bors-servo bors-servo merged commit 138c03b into master Jun 12, 2017
3 of 4 checks passed
3 of 4 checks passed
dependency-ci Checking Dependencies
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bholley
Copy link
Contributor

bholley commented Jun 13, 2017

@SimonSapin SimonSapin deleted the quirk-case branch Jun 13, 2017
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

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