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

make Document.getElementsByName a live collection #25428

Merged
merged 1 commit into from Feb 28, 2020

Conversation

@pshaughn
Copy link
Member

pshaughn commented Jan 3, 2020

Another new case for NodeList; this and the labels live collection in #25424 are in the pipeline simultaneously, so one of them will need a merge resolution when the other one lands.

Iterating over many same-named elements is potentially slower than it has to be, since getting the nth element from the live view always starts from the start of the tree.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #25147
  • There are tests for these changes
@highfive
Copy link

highfive commented Jan 3, 2020

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/nodelist.rs, components/script/dom/document.rs
  • @KiChjang: components/script/dom/nodelist.rs, components/script/dom/document.rs
@pshaughn
Copy link
Member Author

pshaughn commented Jan 4, 2020

@bors-servo try=wpt

bors-servo added a commit that referenced this pull request Jan 4, 2020
make Document.getElementsByName a live collection

Another new case for NodeList; this and the labels live collection in #25424 are in the pipeline simultaneously, so one of them will need a merge resolution when the other one lands.

Iterating over many same-named elements is potentially slower than it has to be, since getting the nth element from the live view always starts from the start of the tree.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25147

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Jan 4, 2020

Trying commit fd489fc with merge ae3096b...

@bors-servo
Copy link
Contributor

bors-servo commented Jan 4, 2020

☀️ Test successful - status-taskcluster
State: approved= try=True

@asajeffrey
Copy link
Member

asajeffrey commented Jan 6, 2020

ChildrenList uses a cursor to avoid the problem of a niave iteration over the list taking O(n^2) time rather than O(n). Can we do the same for ElementByNameList?

@asajeffrey
Copy link
Member

asajeffrey commented Jan 6, 2020

Also, #22264 (comment) may apply to this PR too?

@pshaughn
Copy link
Member Author

pshaughn commented Jan 6, 2020

@asajeffrey: Yes to both questions, and indeed #22264 was an attempt to do it that way. I think #22264 might have been successful for the .getElementsByName subcase and only ran into trouble in the .labels case, so I could look into using that work here.

@pshaughn
Copy link
Member Author

pshaughn commented Jan 7, 2020

I don't think I understand everything #22264 was doing with mutation observers. I understand the part within document.rs where it's using a mutation observer message to know when to mark the list stale, but I don't follow the changes to mutationobserver.rs. I might just need a fresher look in the morning though.

@jdm
Copy link
Member

jdm commented Feb 12, 2020

@pshaughn What's the status here? Is this still waiting on a review?

@pshaughn
Copy link
Member Author

pshaughn commented Feb 12, 2020

I don't know how to make it fast. If slow and spec-compliant is better than fast and not-spec-compliant, then this is ready to review; if not then this should just be closed.

@jdm
Copy link
Member

jdm commented Feb 12, 2020

I am inclined to start with slow and correct, since that gets us closer to web compatibility than no implementation at all.

@pshaughn pshaughn force-pushed the pshaughn:livebyname branch from fd489fc to 007a6cd Feb 15, 2020
@jdm
Copy link
Member

jdm commented Feb 28, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Feb 28, 2020

📌 Commit 007a6cd has been approved by jdm

@highfive highfive assigned jdm and unassigned asajeffrey Feb 28, 2020
@bors-servo
Copy link
Contributor

bors-servo commented Feb 28, 2020

Testing commit 007a6cd with merge 33c1574...

bors-servo added a commit that referenced this pull request Feb 28, 2020
make Document.getElementsByName a live collection

Another new case for NodeList; this and the labels live collection in #25424 are in the pipeline simultaneously, so one of them will need a merge resolution when the other one lands.

Iterating over many same-named elements is potentially slower than it has to be, since getting the nth element from the live view always starts from the start of the tree.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25147

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 28, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Feb 28, 2020

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Feb 28, 2020

Testing commit 007a6cd with merge 134d1f9...

@bors-servo
Copy link
Contributor

bors-servo commented Feb 28, 2020

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing 134d1f9 to master...

@bors-servo bors-servo merged commit 134d1f9 into servo:master Feb 28, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
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.

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