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

RadioNodeList liveness #25435

Merged
merged 1 commit into from Jan 11, 2020
Merged

RadioNodeList liveness #25435

merged 1 commit into from Jan 11, 2020

Conversation

@pshaughn
Copy link
Member

pshaughn commented Jan 5, 2020

When the named getter of a form's .elements gets a list, that list is now a live view into the form, passing a WPT test that removes a node and then looks at the list again.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #25415 (GitHub issue number if applicable)
  • There are tests for these changes
@highfive
Copy link

highfive commented Jan 5, 2020

Heads up! This PR modifies the following files:

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

pshaughn commented Jan 5, 2020

There are still more test failures than I'd expect. It might be better to leave this one unmerged until I've looked into them more.

@KiChjang
Copy link
Member

KiChjang commented Jan 6, 2020

Just making sure, is there any overlap between this PR and #22264?

@pshaughn
Copy link
Member Author

pshaughn commented Jan 6, 2020

I was unaware of #22264, @KiChjang. I've been treating the different subcases of live NodeLists as different problems and have been working on them in this, #25424, and #25428. It looks like I've been following a very different strategy from you, and #25424 passes some tests that #22264 doesn't.

I understand that you might feel you have priority on this and that I should step away from it to let you keep working on your version. If you do feel that way, let me know and I'll back off; I didn't intend to invalidate anyone else's work.

@pshaughn
Copy link
Member Author

pshaughn commented Jan 6, 2020

Related issues that this change from static to live doesn't solve: #25429 (an element is staying gettable too long because it's not leaving the past names map), #21495 (an element with a form= attribute that appears earlier on the page than the form with that ID isn't getting into form.controls), #12978 (named getter can't get an element named addEventListener), #25036 (getOwnPropertyDescriptor doesn't find an element even when the named getter does)

@pshaughn
Copy link
Member Author

pshaughn commented Jan 6, 2020

It occurs to me that, since this is always looking at form.controls and the past names map and never at the DOM tree directly, it could be optimized with a cursor like #22264 without even needing a mutation observer. It would just need to invalidate or repair the cursor on every code path that changes form.controls or the past names map.

@pshaughn pshaughn force-pushed the pshaughn:radio branch from fce8349 to ba733a4 Jan 6, 2020
@pshaughn
Copy link
Member Author

pshaughn commented Jan 6, 2020

This push fixes the one bug I had that is within the purview of the list-getting itself (I wasn't excluding input type=image on the check that had to exclude it); it does not take into account the idea of using a cursor for performance.

@bors-servo
Copy link
Contributor

bors-servo commented Jan 6, 2020

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

@jdm
Copy link
Member

jdm commented Jan 9, 2020

@highfive highfive assigned Manishearth and unassigned jdm Jan 9, 2020
}
}

pub fn iter<'a>(&'a self) -> impl Iterator<Item = DomRoot<Node>> + 'a {
let len = self.Length();
// There is room for optimization here in non-simple cases,
// as calling Item repeatedly on a live list can involve redundant work.

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jan 10, 2020

Member

File a followup for this?

Copy link
Member

Manishearth left a comment

We should probably have a followup filed to move everything to mutation observers

}
if candidates_length == 0 {
candidates = RadioNodeList::new_images(&window, self, name.clone());
candidates_length = candidates.Length();

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jan 10, 2020

Member

we could use a separate function that just returns if there are zero, 1, or more (returning the element if it's one)

Copy link
Member

Manishearth left a comment

We should probably have a followup filed to move everything to mutation observers

@pshaughn pshaughn force-pushed the pshaughn:radio branch 2 times, most recently from 1f42647 to 22513ac Jan 10, 2020
@bors-servo
Copy link
Contributor

bors-servo commented Jan 10, 2020

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

…rformance optimization
@pshaughn pshaughn force-pushed the pshaughn:radio branch from 8f91243 to d59aed6 Jan 11, 2020
@jdm
Copy link
Member

jdm commented Jan 11, 2020

@bors-servo r=Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jan 11, 2020

📌 Commit d59aed6 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jan 11, 2020

Testing commit d59aed6 with merge c506983...

bors-servo added a commit that referenced this pull request Jan 11, 2020
RadioNodeList liveness

When the named getter of a form's .elements gets a list, that list is now a live view into the form, passing a WPT test that removes a node and then looks at the list again.

---
<!-- 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 #25415 (GitHub issue number if applicable)

<!-- 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 11, 2020

☀️ Test successful - status-taskcluster
Approved by: Manishearth
Pushing c506983 to master...

@bors-servo bors-servo merged commit d59aed6 into servo:master Jan 11, 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.

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