Auto merge of #20080 - ferjm:innertext.cleanup, r=emilio

Minor cleanup of element.innerText

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- 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/20080)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-20 08:43:48 -05:00 committed by GitHub
commit 8fdcfb2dfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 18 deletions

View file

@ -1009,15 +1009,16 @@ fn inner_text_collection_steps<N: LayoutNode>(node: N,
},
Display::TableRow if !is_last_table_row() => {
// Step 7.
items.push(InnerTextItem::Text(String::from("\u{000A}" /* line feed */)));
items.push(InnerTextItem::Text(String::from(
"\u{000A}", /* line feed */
)));
},
_ => (),
}
// Step 9.
if is_block_level_or_table_caption(&display) {
items.insert(0, InnerTextItem::RequiredLineBreakCount(1));
items.push(InnerTextItem::RequiredLineBreakCount(1));
Display::Block | Display::Flex | Display::TableCaption | Display::Table => {
// Step 9.
items.insert(0, InnerTextItem::RequiredLineBreakCount(1));
items.push(InnerTextItem::RequiredLineBreakCount(1));
},
_ => {},
}
}
@ -1033,11 +1034,3 @@ fn is_last_table_row() -> bool {
// FIXME(ferjm) Implement this.
false
}
fn is_block_level_or_table_caption(display: &Display) -> bool {
match *display {
Display::Block | Display::Flex |
Display::TableCaption | Display::Table => true,
_ => false,
}
}

View file

@ -478,8 +478,7 @@ fn append_text_node_to_fragment(
text: String
) {
let text = Text::new(DOMString::from(text), document);
let node = DomRoot::upcast::<Node>(text);
fragment.upcast::<Node>().AppendChild(&node).unwrap();
fragment.upcast::<Node>().AppendChild(&text.upcast()).unwrap();
}
// https://html.spec.whatwg.org/multipage/#attr-data-*