From f7db5743f4f508f611fbdb7e8aa5fb99b41dd30a Mon Sep 17 00:00:00 2001 From: George Roman Date: Thu, 10 Jan 2019 16:07:12 +0200 Subject: [PATCH] Ignore children of void elements when serializing --- components/script/dom/servoparser/html.rs | 10 +- .../serializing.html.ini | 400 ------------------ 2 files changed, 4 insertions(+), 406 deletions(-) diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index 62fe26153ed1..45ef625a5eef 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -153,6 +153,10 @@ struct SerializationIterator { } fn rev_children_iter(n: &Node) -> impl Iterator> { + if n.downcast::().map_or(false, |e| e.is_void()) { + return Node::new_document_node().rev_children(); + } + match n.downcast::() { Some(t) => t.Content().upcast::().rev_children(), None => n.rev_children(), @@ -210,12 +214,6 @@ impl<'a> Serialize for &'a Node { ) -> io::Result<()> { let node = *self; - if let TraversalScope::ChildrenOnly(_) = traversal_scope { - if node.downcast::().map_or(false, |e| e.is_void()) { - return Ok(()); - } - } - let iter = SerializationIterator::new(node, traversal_scope != IncludeNode); for cmd in iter { diff --git a/tests/wpt/metadata/html/syntax/serializing-html-fragments/serializing.html.ini b/tests/wpt/metadata/html/syntax/serializing-html-fragments/serializing.html.ini index df554bda2262..cd2be7f9afbb 100644 --- a/tests/wpt/metadata/html/syntax/serializing-html-fragments/serializing.html.ini +++ b/tests/wpt/metadata/html/syntax/serializing-html-fragments/serializing.html.ini @@ -5,403 +5,3 @@ [outerHTML Attribute in non-standard namespace] expected: FAIL - - [innerHTML void as first child with following siblings area] - expected: FAIL - - [innerHTML void as first child with following siblings base] - expected: FAIL - - [innerHTML void as first child with following siblings basefont] - expected: FAIL - - [innerHTML void as first child with following siblings bgsound] - expected: FAIL - - [innerHTML void as first child with following siblings br] - expected: FAIL - - [innerHTML void as first child with following siblings col] - expected: FAIL - - [innerHTML void as first child with following siblings embed] - expected: FAIL - - [innerHTML void as first child with following siblings frame] - expected: FAIL - - [innerHTML void as first child with following siblings hr] - expected: FAIL - - [innerHTML void as first child with following siblings img] - expected: FAIL - - [innerHTML void as first child with following siblings input] - expected: FAIL - - [innerHTML void as first child with following siblings keygen] - expected: FAIL - - [innerHTML void as first child with following siblings link] - expected: FAIL - - [innerHTML void as first child with following siblings menuitem] - expected: FAIL - - [innerHTML void as first child with following siblings meta] - expected: FAIL - - [innerHTML void as first child with following siblings param] - expected: FAIL - - [innerHTML void as first child with following siblings source] - expected: FAIL - - [innerHTML void as first child with following siblings track] - expected: FAIL - - [innerHTML void as first child with following siblings wbr] - expected: FAIL - - [innerHTML void as second child with following siblings area] - expected: FAIL - - [innerHTML void as second child with following siblings base] - expected: FAIL - - [innerHTML void as second child with following siblings basefont] - expected: FAIL - - [innerHTML void as second child with following siblings bgsound] - expected: FAIL - - [innerHTML void as second child with following siblings br] - expected: FAIL - - [innerHTML void as second child with following siblings col] - expected: FAIL - - [innerHTML void as second child with following siblings embed] - expected: FAIL - - [innerHTML void as second child with following siblings frame] - expected: FAIL - - [innerHTML void as second child with following siblings hr] - expected: FAIL - - [innerHTML void as second child with following siblings img] - expected: FAIL - - [innerHTML void as second child with following siblings input] - expected: FAIL - - [innerHTML void as second child with following siblings keygen] - expected: FAIL - - [innerHTML void as second child with following siblings link] - expected: FAIL - - [innerHTML void as second child with following siblings menuitem] - expected: FAIL - - [innerHTML void as second child with following siblings meta] - expected: FAIL - - [innerHTML void as second child with following siblings param] - expected: FAIL - - [innerHTML void as second child with following siblings source] - expected: FAIL - - [innerHTML void as second child with following siblings track] - expected: FAIL - - [innerHTML void as second child with following siblings wbr] - expected: FAIL - - [innerHTML void as last child with preceding siblings area] - expected: FAIL - - [innerHTML void as last child with preceding siblings base] - expected: FAIL - - [innerHTML void as last child with preceding siblings basefont] - expected: FAIL - - [innerHTML void as last child with preceding siblings bgsound] - expected: FAIL - - [innerHTML void as last child with preceding siblings br] - expected: FAIL - - [innerHTML void as last child with preceding siblings col] - expected: FAIL - - [innerHTML void as last child with preceding siblings embed] - expected: FAIL - - [innerHTML void as last child with preceding siblings frame] - expected: FAIL - - [innerHTML void as last child with preceding siblings hr] - expected: FAIL - - [innerHTML void as last child with preceding siblings img] - expected: FAIL - - [innerHTML void as last child with preceding siblings input] - expected: FAIL - - [innerHTML void as last child with preceding siblings keygen] - expected: FAIL - - [innerHTML void as last child with preceding siblings link] - expected: FAIL - - [innerHTML void as last child with preceding siblings menuitem] - expected: FAIL - - [innerHTML void as last child with preceding siblings meta] - expected: FAIL - - [innerHTML void as last child with preceding siblings param] - expected: FAIL - - [innerHTML void as last child with preceding siblings source] - expected: FAIL - - [innerHTML void as last child with preceding siblings track] - expected: FAIL - - [innerHTML void as last child with preceding siblings wbr] - expected: FAIL - - [outerHTML Void context node area] - expected: FAIL - - [outerHTML Void context node base] - expected: FAIL - - [outerHTML Void context node basefont] - expected: FAIL - - [outerHTML Void context node bgsound] - expected: FAIL - - [outerHTML Void context node br] - expected: FAIL - - [outerHTML Void context node col] - expected: FAIL - - [outerHTML Void context node embed] - expected: FAIL - - [outerHTML Void context node frame] - expected: FAIL - - [outerHTML Void context node hr] - expected: FAIL - - [outerHTML Void context node img] - expected: FAIL - - [outerHTML Void context node input] - expected: FAIL - - [outerHTML Void context node keygen] - expected: FAIL - - [outerHTML Void context node link] - expected: FAIL - - [outerHTML Void context node menuitem] - expected: FAIL - - [outerHTML Void context node meta] - expected: FAIL - - [outerHTML Void context node param] - expected: FAIL - - [outerHTML Void context node source] - expected: FAIL - - [outerHTML Void context node track] - expected: FAIL - - [outerHTML Void context node wbr] - expected: FAIL - - [outerHTML void as first child with following siblings area] - expected: FAIL - - [outerHTML void as first child with following siblings base] - expected: FAIL - - [outerHTML void as first child with following siblings basefont] - expected: FAIL - - [outerHTML void as first child with following siblings bgsound] - expected: FAIL - - [outerHTML void as first child with following siblings br] - expected: FAIL - - [outerHTML void as first child with following siblings col] - expected: FAIL - - [outerHTML void as first child with following siblings embed] - expected: FAIL - - [outerHTML void as first child with following siblings frame] - expected: FAIL - - [outerHTML void as first child with following siblings hr] - expected: FAIL - - [outerHTML void as first child with following siblings img] - expected: FAIL - - [outerHTML void as first child with following siblings input] - expected: FAIL - - [outerHTML void as first child with following siblings keygen] - expected: FAIL - - [outerHTML void as first child with following siblings link] - expected: FAIL - - [outerHTML void as first child with following siblings menuitem] - expected: FAIL - - [outerHTML void as first child with following siblings meta] - expected: FAIL - - [outerHTML void as first child with following siblings param] - expected: FAIL - - [outerHTML void as first child with following siblings source] - expected: FAIL - - [outerHTML void as first child with following siblings track] - expected: FAIL - - [outerHTML void as first child with following siblings wbr] - expected: FAIL - - [outerHTML void as second child with following siblings area] - expected: FAIL - - [outerHTML void as second child with following siblings base] - expected: FAIL - - [outerHTML void as second child with following siblings basefont] - expected: FAIL - - [outerHTML void as second child with following siblings bgsound] - expected: FAIL - - [outerHTML void as second child with following siblings br] - expected: FAIL - - [outerHTML void as second child with following siblings col] - expected: FAIL - - [outerHTML void as second child with following siblings embed] - expected: FAIL - - [outerHTML void as second child with following siblings frame] - expected: FAIL - - [outerHTML void as second child with following siblings hr] - expected: FAIL - - [outerHTML void as second child with following siblings img] - expected: FAIL - - [outerHTML void as second child with following siblings input] - expected: FAIL - - [outerHTML void as second child with following siblings keygen] - expected: FAIL - - [outerHTML void as second child with following siblings link] - expected: FAIL - - [outerHTML void as second child with following siblings menuitem] - expected: FAIL - - [outerHTML void as second child with following siblings meta] - expected: FAIL - - [outerHTML void as second child with following siblings param] - expected: FAIL - - [outerHTML void as second child with following siblings source] - expected: FAIL - - [outerHTML void as second child with following siblings track] - expected: FAIL - - [outerHTML void as second child with following siblings wbr] - expected: FAIL - - [outerHTML void as last child with preceding siblings area] - expected: FAIL - - [outerHTML void as last child with preceding siblings base] - expected: FAIL - - [outerHTML void as last child with preceding siblings basefont] - expected: FAIL - - [outerHTML void as last child with preceding siblings bgsound] - expected: FAIL - - [outerHTML void as last child with preceding siblings br] - expected: FAIL - - [outerHTML void as last child with preceding siblings col] - expected: FAIL - - [outerHTML void as last child with preceding siblings embed] - expected: FAIL - - [outerHTML void as last child with preceding siblings frame] - expected: FAIL - - [outerHTML void as last child with preceding siblings hr] - expected: FAIL - - [outerHTML void as last child with preceding siblings img] - expected: FAIL - - [outerHTML void as last child with preceding siblings input] - expected: FAIL - - [outerHTML void as last child with preceding siblings keygen] - expected: FAIL - - [outerHTML void as last child with preceding siblings link] - expected: FAIL - - [outerHTML void as last child with preceding siblings menuitem] - expected: FAIL - - [outerHTML void as last child with preceding siblings meta] - expected: FAIL - - [outerHTML void as last child with preceding siblings param] - expected: FAIL - - [outerHTML void as last child with preceding siblings source] - expected: FAIL - - [outerHTML void as last child with preceding siblings track] - expected: FAIL - - [outerHTML void as last child with preceding siblings wbr] - expected: FAIL -