mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Adding relevant mutations and new test results
This commit is contained in:
parent
a6dbfdd29f
commit
3f24d67928
8 changed files with 83 additions and 127 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,16 +2,20 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::HTMLSourceElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElementMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::root::{Dom, Root};
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::document::Document;
|
||||
use dom::element::AttributeMutation;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::htmlimageelement::HTMLImageElement;
|
||||
use dom::htmlmediaelement::HTMLMediaElement;
|
||||
use dom::node::Node;
|
||||
use dom::node::{Node, UnbindContext};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix};
|
||||
|
@ -46,6 +50,14 @@ impl HTMLSourceElement {
|
|||
HTMLSourceElementBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
fn iterate_next_html_image_element_siblings(next_siblings_iterator: impl Iterator<Item=Root<Dom<Node>>>) {
|
||||
for next_sibling in next_siblings_iterator {
|
||||
if let Some(html_image_element_sibling) = next_sibling.downcast::<HTMLImageElement>() {
|
||||
html_image_element_sibling.update_the_image_data();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualMethods for HTMLSourceElement {
|
||||
|
@ -53,6 +65,18 @@ impl VirtualMethods for HTMLSourceElement {
|
|||
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
match attr.local_name() {
|
||||
&local_name!("srcset") | &local_name!("sizes") |
|
||||
&local_name!("media") | &local_name!("type") => {
|
||||
let next_sibling_iterator = self.upcast::<Node>().following_siblings();
|
||||
HTMLSourceElement::iterate_next_html_image_element_siblings(next_sibling_iterator);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
/// <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);
|
||||
|
@ -60,6 +84,16 @@ impl VirtualMethods for HTMLSourceElement {
|
|||
if let Some(media) = parent.downcast::<HTMLMediaElement>() {
|
||||
media.handle_source_child_insertion();
|
||||
}
|
||||
let next_sibling_iterator = self.upcast::<Node>().following_siblings();
|
||||
HTMLSourceElement::iterate_next_html_image_element_siblings(next_sibling_iterator);
|
||||
}
|
||||
|
||||
fn unbind_from_tree(&self, context: &UnbindContext) {
|
||||
self.super_type().unwrap().unbind_from_tree(context);
|
||||
if let Some(next_sibling) = context.next_sibling {
|
||||
let next_sibling_iterator = next_sibling.inclusively_following_siblings();
|
||||
HTMLSourceElement::iterate_next_html_image_element_siblings(next_sibling_iterator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ impl Node {
|
|||
},
|
||||
}
|
||||
|
||||
let context = UnbindContext::new(self, prev_sibling.r(), cached_index);
|
||||
let context = UnbindContext::new(self, prev_sibling.r(), next_sibling.r(), cached_index);
|
||||
|
||||
child.prev_sibling.set(None);
|
||||
child.next_sibling.set(None);
|
||||
|
@ -2812,17 +2812,23 @@ pub struct UnbindContext<'a> {
|
|||
pub parent: &'a Node,
|
||||
/// The previous sibling of the inclusive ancestor that was removed.
|
||||
prev_sibling: Option<&'a Node>,
|
||||
/// The next sibling of the inclusive ancestor that was removed.
|
||||
pub next_sibling: Option<&'a Node>,
|
||||
/// Whether the tree is in a document.
|
||||
pub tree_in_doc: bool,
|
||||
}
|
||||
|
||||
impl<'a> UnbindContext<'a> {
|
||||
/// Create a new `UnbindContext` value.
|
||||
fn new(parent: &'a Node, prev_sibling: Option<&'a Node>, cached_index: Option<u32>) -> Self {
|
||||
fn new(parent: &'a Node,
|
||||
prev_sibling: Option<&'a Node>,
|
||||
next_sibling: Option<&'a Node>,
|
||||
cached_index: Option<u32>) -> Self {
|
||||
UnbindContext {
|
||||
index: Cell::new(cached_index),
|
||||
parent: parent,
|
||||
prev_sibling: prev_sibling,
|
||||
next_sibling: next_sibling,
|
||||
tree_in_doc: parent.is_in_doc(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
[viewport-change.html]
|
||||
type: testharness
|
||||
[picture: source (max-width:500px) broken image, img valid image, resize to wide]
|
||||
expected: FAIL
|
||||
expected: TIMEOUT
|
||||
|
||||
[picture: source (max-width:500px) valid image, img valid image, resize to wide]
|
||||
expected: FAIL
|
||||
expected: TIMEOUT
|
||||
|
||||
[picture: source (max-width:500px) valid image, img broken image, resize to narrow]
|
||||
expected: FAIL
|
||||
expected: TIMEOUT
|
||||
|
||||
[picture: source (max-width:500px) valid image, img valid image, resize to narrow]
|
||||
expected: FAIL
|
||||
expected: TIMEOUT
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
[non-active-document.html]
|
||||
type: testharness
|
||||
[DOMParser]
|
||||
expected: FAIL
|
||||
|
||||
[createHTMLDocument]
|
||||
expected: FAIL
|
||||
|
||||
[<template>]
|
||||
expected: FAIL
|
||||
|
|
@ -1,103 +1,32 @@
|
|||
[relevant-mutations.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
disabled: unstable failures and timeouts in release builds
|
||||
[src removed]
|
||||
expected: TIMEOUT
|
||||
[srcset is set to same value]
|
||||
expected: FAIL
|
||||
|
||||
[inserted into picture]
|
||||
expected: TIMEOUT
|
||||
[ancestor picture; previous sibling source inserted]
|
||||
expected: FAIL
|
||||
|
||||
[removed from picture]
|
||||
expected: TIMEOUT
|
||||
[picture is inserted; img has previous sibling source]
|
||||
expected: FAIL
|
||||
|
||||
[parent is picture, previous source inserted]
|
||||
expected: TIMEOUT
|
||||
[crossorigin state not changed: anonymous to foobar]
|
||||
expected: FAIL
|
||||
|
||||
[parent is picture, previous source removed]
|
||||
expected: TIMEOUT
|
||||
[crossorigin state not changed: empty to anonymous]
|
||||
expected: FAIL
|
||||
|
||||
[parent is picture, previous source has srcset set]
|
||||
expected: TIMEOUT
|
||||
[ancestor picture; previous sibling source removed]
|
||||
expected: FAIL
|
||||
|
||||
[parent is picture, previous source has srcset changed]
|
||||
expected: TIMEOUT
|
||||
[crossorigin state not changed: use-credentials to USE-CREDENTIALS]
|
||||
expected: FAIL
|
||||
|
||||
[parent is picture, previous source has srcset removed]
|
||||
expected: TIMEOUT
|
||||
[picture is inserted; img has following sibling source]
|
||||
expected: FAIL
|
||||
|
||||
[parent is picture, previous source has sizes set]
|
||||
expected: TIMEOUT
|
||||
[picture is inserted; img has srcset]
|
||||
expected: FAIL
|
||||
|
||||
[parent is picture, previous source has sizes changed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[parent is picture, previous source has sizes removed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[parent is picture, previous source has media set]
|
||||
expected: TIMEOUT
|
||||
|
||||
[parent is picture, previous source has media changed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[parent is picture, previous source has media removed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[parent is picture, previous source has type set]
|
||||
expected: TIMEOUT
|
||||
|
||||
[parent is picture, previous source has type changed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[parent is picture, previous source has type removed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[srcset set]
|
||||
expected: TIMEOUT
|
||||
|
||||
[srcset changed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[srcset removed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[sizes set]
|
||||
expected: TIMEOUT
|
||||
|
||||
[sizes changed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[sizes removed]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin absent to empty]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin absent to anonymous]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin absent to use-credentials]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin empty to absent]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin empty to use-credentials]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin anonymous to absent]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin anonymous to use-credentials]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin use-credentials to absent]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin use-credentials to empty]
|
||||
expected: TIMEOUT
|
||||
|
||||
[crossorigin use-credentials to anonymous]
|
||||
expected: TIMEOUT
|
||||
[picture is inserted; img has src]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[update-media.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[set media after src updates selected image]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
[texture-upload-size.html]
|
||||
expected: TIMEOUT
|
||||
[Overall test]
|
||||
expected: NOTRUN
|
||||
|
||||
[WebGL test #20: could not create image (SVG)]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #36: could not create image (SVG)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue