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

Implement `:lang` CSS pseudo-class #8219

Closed
eefriedman opened this issue Oct 27, 2015 · 8 comments
Closed

Implement `:lang` CSS pseudo-class #8219

eefriedman opened this issue Oct 27, 2015 · 8 comments
Assignees
Labels

Comments

@eefriedman
Copy link
Contributor

@eefriedman eefriedman commented Oct 27, 2015

Spec: http://www.w3.org/TR/selectors/#lang-pseudo . Information about how to actually determine the language of an element in HTML: https://html.spec.whatwg.org/multipage/dom.html#language . The XML specification has similar language: http://www.w3.org/TR/2008/PER-xml-20080205/#sec-lang-tag .

Requires some changes to https://github.com/servo/rust-selectors so it can parse :lang.

Should be straightforward to implement.

@jdm jdm added the A-content/css label Oct 27, 2015
@ajnirp
Copy link
Contributor

@ajnirp ajnirp commented Oct 28, 2015

Can I take this?

@eefriedman
Copy link
Contributor Author

@eefriedman eefriedman commented Oct 28, 2015

Sure. Feel free to ask if you need help.

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Nov 5, 2015

To avoid walking up the tree during selector matching we’ll want to cache the element’s language on every element’s DOM node, and update it on DOM tree changes.

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Mar 7, 2016

Now that servo/rust-selectors#75 has landed, the parsing support for :lang can be implemented in components/style/selector_impl.rs by adding a parse_non_ts_functional_pseudo_class method like in tests for servo/rust-selectors#75

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Feb 7, 2017

The algorithm described in https://html.spec.whatwg.org/multipage/dom.html#language to determine the language of an element involves traversing the tree to look at ancestors. Since that can be expensive and might be used repeatedly during selector matching, we likely want to cache the result of that algorithm on each element nodes. (And take care to update it when e.g. a lang attribute is changed through the DOM.)

bors-servo added a commit that referenced this issue Feb 9, 2017
Support lang pseudo class

Fixes #8219.
bors-servo added a commit that referenced this issue Feb 9, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 10, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 11, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 13, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 13, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 15, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 16, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 16, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
@Manishearth
Copy link
Member

@Manishearth Manishearth commented Feb 16, 2017

This doesn't seem to handle inheritance of the lang attr?

Gecko implements some of the lang stuff as if it were a pres attr setting a secret internal inherit property.

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Feb 16, 2017

Gecko implements some of the lang stuff as if it were a pres attr setting a secret internal inherit property

That’s what what I understand is going on…

SelectorMatches(), when encountering CSSPseudoClassType::lang, calls aElement->GetLang() which looks for a lang attribute and calls GetParent in a loop. As far as I can tell, there is no caching at all.

http://searchfox.org/mozilla-central/rev/cac6cb6a10afb8ebb2ecfbeeedaff7c66f57dd75/layout/style/nsCSSRuleProcessor.cpp#1803
http://searchfox.org/mozilla-central/rev/cac6cb6a10afb8ebb2ecfbeeedaff7c66f57dd75/dom/base/nsIContent.h#940

bors-servo added a commit that referenced this issue Feb 18, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 20, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 20, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 20, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 21, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 22, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 22, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 23, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 28, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Feb 28, 2017
Support lang pseudo class

Fixes #8219.

<!-- 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/15464)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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