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

Adding all the relevant mutations #21680

Merged
merged 1 commit into from Sep 20, 2018
Merged

Conversation

@paavininanda
Copy link
Contributor

paavininanda commented Sep 11, 2018


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix a subset of #11416
  • These changes do not require tests

This change is Reviewable

@highfive
Copy link

highfive commented Sep 11, 2018

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/document.rs, components/script/dom/htmlimageelement.rs, components/script/dom/window.rs, components/script/dom/htmlsourceelement.rs
  • @KiChjang: components/script/dom/document.rs, components/script/dom/htmlimageelement.rs, components/script/dom/window.rs, components/script/dom/htmlsourceelement.rs
@jdm jdm assigned jdm and unassigned ferjm Sep 11, 2018
@paavininanda paavininanda force-pushed the paavininanda:relevant_mut branch 3 times, most recently from 0c572aa to 8099b63 Sep 12, 2018
@paavininanda paavininanda changed the title Relevant mutations [WIP] Adding all the relevant mutations Sep 12, 2018
@paavininanda paavininanda force-pushed the paavininanda:relevant_mut branch from 8099b63 to f3bad89 Sep 12, 2018
@paavininanda
Copy link
Contributor Author

paavininanda commented Sep 13, 2018

@jdm No new test passed after adding the relevant mutations. Is there something that I am missing?

&local_name!("src") => self.update_the_image_data(),
&local_name!("srcset") => self.update_the_image_data(),
&local_name!("src") | &local_name!("srcset") |
&local_name!("width") | &local_name!("crossorigin") => self.update_the_image_data(),

This comment has been minimized.

&local_name!("src") => self.update_the_image_data(),
&local_name!("srcset") => self.update_the_image_data(),
&local_name!("src") | &local_name!("srcset") |
&local_name!("width") | &local_name!("crossorigin") => self.update_the_image_data(),
_ => {},
}
if let Some(parent) = self.upcast::<Node>().GetParentElement() {

This comment has been minimized.

@jdm

jdm Sep 13, 2018

Member

I don't think we want to update the image data whenever any attribute was modified and the parent is a picture element. I'm not sure why this code is here, so let's remove it.

@@ -1528,6 +1528,15 @@ impl VirtualMethods for HTMLImageElement {
self.super_type().unwrap().unbind_from_tree(context);
let document = document_from_node(self);
document.unregister_responsive_image(self);
if let Some(parent) = self.upcast::<Node>().GetParentElement() {

This comment has been minimized.

@jdm

jdm Sep 13, 2018

Member

I think we'll need to check context.parent here instead. Removing the node from the tree may mean that it has no parent element according to the Node APIs. This will address the " removed from a picture parent element" mutation.

if let Some(parent) = self.upcast::<Node>().GetParentElement() {
if parent.is::<HTMLPictureElement>() {
if let Some(previous_sibling) = self.upcast::<Node>().GetPreviousSibling() {
if previous_sibling.is::<HTMLSourceElement> () {

This comment has been minimized.

@jdm

jdm Sep 13, 2018

Member

Is this trying to address "The element's parent is a picture element and a source element that was a previous sibling is removed."? We need to check for that state in the HTMLSourceElement::unbind_from_tree instead.

This comment has been minimized.

@paavininanda

paavininanda Sep 14, 2018

Author Contributor

Yes, I tried to do it here because of the discussion that we had on Gitter. Will change this 👍

match attr.local_name() {
&local_name!("srcset") | &local_name!("sizes") |
&local_name!("media") | &local_name!("type") => {
if let Some(next_sibling) = self.upcast::<Node>().GetNextSibling() {

This comment has been minimized.

@jdm

jdm Sep 13, 2018

Member

We will need to iterate over self.upcast::<Node>().following_siblings() instead of just getting the immediately following sibling.

.map_or(false, |p| p.is::<HTMLPictureElement>());
if is_parent_picture {
img.update_the_image_data();
}

This comment has been minimized.

@jdm

jdm Sep 13, 2018

Member

I don't think it makes sense to implement these mutation checks here. It splits the implementation between multiple files so it's harder to understand how the pieces fit together.

}

pub fn unregister_responsive_image(&self, img: &HTMLImageElement) {
let index = self.responsive_images.borrow().iter().position(|x| **x == *img);
if let Some(i) = index {
self.responsive_images.borrow_mut().remove(i);
let elem = img.upcast::<Element>();

This comment has been minimized.

@jdm

jdm Sep 13, 2018

Member

Same here.

Copy link
Member

jdm left a comment

Closer!

if let Some(htmlimageelement_sibling) = next_sibling.downcast::<HTMLImageElement>() {
htmlimageelement_sibling.update_the_image_data();
let mut next_siblings_iterator = self.upcast::<Node>().following_siblings();
if let Some(next_sibling) = next_siblings_iterator.next() {

This comment has been minimized.

@jdm

jdm Sep 14, 2018

Member

You will want to use a for loop to iterate over all the siblings, not just check the immediate sibling.

This comment has been minimized.

@paavininanda

paavininanda Sep 14, 2018

Author Contributor

Oops, missed the loop by mistake.

&local_name!("srcset") | &local_name!("sizes") |
&local_name!("media") | &local_name!("type") => {
let mut next_siblings_iterator = self.upcast::<Node>().following_siblings();
if let Some(next_sibling) = next_siblings_iterator.next() {

This comment has been minimized.

@jdm

jdm Sep 14, 2018

Member

You will want to use a for loop to iterate over the siblings, rather than only checking the immediate sibling.

/// <https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted>
fn bind_to_tree(&self, tree_in_doc: bool) {
self.super_type().unwrap().bind_to_tree(tree_in_doc);
let parent = self.upcast::<Node>().GetParentNode().unwrap();
if let Some(media) = parent.downcast::<HTMLMediaElement>() {
media.handle_source_child_insertion();
}

let mut next_siblings_iterator = self.upcast::<Node>().following_siblings();
if let Some(next_sibling) = next_siblings_iterator.next() {

This comment has been minimized.

@jdm

jdm Sep 14, 2018

Member

It would be worth creating a helper function for the sibling iterator check to avoid duplicating this code.

fn unbind_from_tree(&self, context: &UnbindContext) {
self.super_type().unwrap().unbind_from_tree(context);

let mut next_siblings_iterator = self.upcast::<Node>().following_siblings();

This comment has been minimized.

@jdm

jdm Sep 14, 2018

Member

Because we're unbinding, we need to be careful. You will want to use the next_sibling member of UnbindContext and call inclusive_next_sibling on that node instead, then loop over the iterator.

This comment has been minimized.

@paavininanda

paavininanda Sep 14, 2018

Author Contributor

There is a prev_sibling in UnbindContext but not a next_sibling! I was trying to find it here - https://doc.servo.org/script/dom/node/struct.UnbindContext.html

This comment has been minimized.

@jdm

jdm Sep 14, 2018

Member

Go ahead and add one to UnbindContext, in that case!

@paavininanda paavininanda force-pushed the paavininanda:relevant_mut branch from 033c021 to 9e54f4a Sep 14, 2018
@jdm
Copy link
Member

jdm commented Sep 17, 2018

This looks great! Please also remove

disabled: unstable failures and timeouts in release builds
and update the test expectations for that test!

@jdm
jdm approved these changes Sep 17, 2018
@jdm
Copy link
Member

jdm commented Sep 17, 2018

Nice solution using impl Iterator, by the way!

@paavininanda paavininanda force-pushed the paavininanda:relevant_mut branch from 9e54f4a to 11e2ccd Sep 18, 2018
@jdm
Copy link
Member

jdm commented Sep 18, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Sep 18, 2018

📌 Commit 11e2ccd has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2018

Testing commit e5e863d with merge ce9ca37...

bors-servo added a commit that referenced this pull request Sep 20, 2018
Adding all the relevant mutations

<!-- Please describe your changes on the following line: -->

---
<!-- 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 a subset of #11416

<!-- Either: -->
- [x] These changes do not require tests

<!-- 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. -->

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

bors-servo commented Sep 20, 2018

💔 Test failed - linux-rel-css

@paavininanda
Copy link
Contributor Author

paavininanda commented Sep 20, 2018

@jdm These all seem to be intermittent failures!

@jdm
Copy link
Member

jdm commented Sep 20, 2018

I strongly suspect that these test result changes are not intermittent but triggered by #21751.

@paavininanda paavininanda force-pushed the paavininanda:relevant_mut branch from e5e863d to 3f24d67 Sep 20, 2018
@paavininanda
Copy link
Contributor Author

paavininanda commented Sep 20, 2018

@bors-servo r=jdm

@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2018

📌 Commit 3f24d67 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2018

Testing commit 3f24d67 with merge f813efd...

bors-servo added a commit that referenced this pull request Sep 20, 2018
Adding all the relevant mutations

<!-- Please describe your changes on the following line: -->

---
<!-- 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 a subset of #11416

<!-- Either: -->
- [x] These changes do not require tests

<!-- 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. -->

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

bors-servo commented Sep 20, 2018

💔 Test failed - linux-rel-css

@jdm
Copy link
Member

jdm commented Sep 20, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Sep 20, 2018

Testing commit 3f24d67 with merge fc0c191...

bors-servo added a commit that referenced this pull request Sep 20, 2018
Adding all the relevant mutations

<!-- Please describe your changes on the following line: -->

---
<!-- 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 a subset of #11416

<!-- Either: -->
- [x] These changes do not require tests

<!-- 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. -->

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

bors-servo commented Sep 20, 2018

@bors-servo bors-servo merged commit 3f24d67 into servo:master Sep 20, 2018
2 of 4 checks passed
2 of 4 checks passed
Taskcluster (pull_request) TaskGroup: failure
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
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.

None yet

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