aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlimageelement.rs
diff options
context:
space:
mode:
authorpaavininanda <paavininanda@gmail.com>2018-07-22 15:48:43 +0530
committerpaavininanda <paavininanda@gmail.com>2018-09-20 23:59:31 +0530
commit3f24d67928d1948ee2e2d6363ee900d1df35bbe8 (patch)
tree7ff0e91b1471e8bd90f91ec31e999831f5f6279b /components/script/dom/htmlimageelement.rs
parenta6dbfdd29f9b3f0ce0c13adc79fad99538a9a44b (diff)
downloadservo-3f24d67928d1948ee2e2d6363ee900d1df35bbe8.tar.gz
servo-3f24d67928d1948ee2e2d6363ee900d1df35bbe8.zip
Adding relevant mutations and new test results
Diffstat (limited to 'components/script/dom/htmlimageelement.rs')
-rw-r--r--components/script/dom/htmlimageelement.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 4ef2fccc79d..ca9243beb1b 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -872,7 +872,7 @@ impl HTMLImageElement {
}
/// <https://html.spec.whatwg.org/multipage/#update-the-image-data>
- fn update_the_image_data(&self) {
+ pub fn update_the_image_data(&self) {
let document = document_from_node(self);
let window = document.window();
let elem = self.upcast::<Element>();
@@ -1574,15 +1574,11 @@ impl VirtualMethods for HTMLImageElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &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") |
+ &local_name!("sizes") => self.update_the_image_data(),
_ => {},
}
- if let Some(parent) = self.upcast::<Node>().GetParentElement() {
- if parent.is::<HTMLPictureElement>() {
- self.update_the_image_data();
- }
- }
}
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
@@ -1645,6 +1641,9 @@ impl VirtualMethods for HTMLImageElement {
if tree_in_doc {
document.register_responsive_image(self);
}
+
+ // The element is inserted into a picture parent element
+ // https://html.spec.whatwg.org/multipage/#relevant-mutations
if let Some(parent) = self.upcast::<Node>().GetParentElement() {
if parent.is::<HTMLPictureElement>() {
self.update_the_image_data();
@@ -1656,6 +1655,12 @@ impl VirtualMethods for HTMLImageElement {
self.super_type().unwrap().unbind_from_tree(context);
let document = document_from_node(self);
document.unregister_responsive_image(self);
+
+ // The element is removed from a picture parent element
+ // https://html.spec.whatwg.org/multipage/#relevant-mutations
+ if context.parent.is::<HTMLPictureElement>() {
+ self.update_the_image_data();
+ }
}
}