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

Use the information of Document::idmap for selector matching #3314

Open
tetsuharuohzeki opened this issue Sep 12, 2014 · 7 comments
Open

Use the information of Document::idmap for selector matching #3314

tetsuharuohzeki opened this issue Sep 12, 2014 · 7 comments

Comments

@tetsuharuohzeki
Copy link
Member

@tetsuharuohzeki tetsuharuohzeki commented Sep 12, 2014

We have the table to cache the position of all id-ed elements in DOM Tree as Document::idmap.

In other browsers, they also have same information and use it for optimize ID selector matching.
So we should use it.

@JIoJIaJIu
Copy link
Contributor

@JIoJIaJIu JIoJIaJIu commented Feb 26, 2015

i take it, please

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Feb 26, 2015

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Feb 27, 2015

I imagine how this would help selectors API (where for a selector and a document we find elements), but not for stylesheets (where for a given element we find style rules that match). @saneyuki, do you know how it’s used in other browsers?

@JIoJIaJIu, line 665 now is in the middle of fn click_event_filter_by_disabled_state. I assume you meant to link to something else? When viewing code on GitHub, you can press the y key on your keyboard to go to an URL for the same thing but with a commit hash instead of a branch name in the URL.

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Feb 27, 2015

That link was to the getElementById implementation.

@JIoJIaJIu
Copy link
Contributor

@JIoJIaJIu JIoJIaJIu commented Mar 1, 2015

thank you for tip @SimonSapin

fn GetElementById(self, id: DOMString) -> Option<Temporary<Element>> {

@tetsuharuohzeki
Copy link
Member Author

@tetsuharuohzeki tetsuharuohzeki commented Mar 4, 2015

@SimonSapin

Other browsers use the id information in DOM tree as fast path for selector matching if it provides id selector. They try to match id selector at first. It fallback down the later path if the fast path failed.

Gecko & Blink have some fast path. but I feel their path are primitive.

WebKit does the most aggressive optimization for selector matching including about id selector.
Today, WebKit's fast path is for selector JIT mainly. But their some optimization are not only for selector JIT.

I don't know how much of their path is used from non-JIT one now and how we can implement some of them without JIT approach...
(As an aside, @Constellation knows the implementation details of them very very much, he might answer more details if we ask some their tricks).

Gecko

Blink

WebKit

And I heard from @Constellation that WebKit used to have non-JIT fast path more but they removed them because Selector JIT beat non-JIT fast path.

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
5 participants
You can’t perform that action at this time.