mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
layout: Fix display of new text in textarea
elements (#32886)
Previously `<textarea>` was just displaying node contents, which is the original text content, not the one updated by later typing. This change fixes that issue. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
c06a6a764e
commit
a64f75b62f
8 changed files with 30 additions and 31 deletions
|
@ -169,32 +169,43 @@ fn traverse_children_of<'dom, Node>(
|
||||||
{
|
{
|
||||||
traverse_pseudo_element(WhichPseudoElement::Before, parent_element, context, handler);
|
traverse_pseudo_element(WhichPseudoElement::Before, parent_element, context, handler);
|
||||||
|
|
||||||
for child in iter_child_nodes(parent_element) {
|
let is_text_input_element = matches!(
|
||||||
if child.is_text_node() {
|
|
||||||
let info = NodeAndStyleInfo::new(child, child.style(context));
|
|
||||||
handler.handle_text(&info, child.to_threadsafe().node_text_content());
|
|
||||||
} else if child.is_element() {
|
|
||||||
traverse_element(child, context, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches!(
|
|
||||||
parent_element.type_id(),
|
parent_element.type_id(),
|
||||||
LayoutNodeType::Element(LayoutElementType::HTMLInputElement)
|
LayoutNodeType::Element(LayoutElementType::HTMLInputElement)
|
||||||
) {
|
);
|
||||||
|
|
||||||
|
let is_textarea_element = matches!(
|
||||||
|
parent_element.type_id(),
|
||||||
|
LayoutNodeType::Element(LayoutElementType::HTMLTextAreaElement)
|
||||||
|
);
|
||||||
|
|
||||||
|
if is_text_input_element || is_textarea_element {
|
||||||
let info = NodeAndStyleInfo::new(parent_element, parent_element.style(context));
|
let info = NodeAndStyleInfo::new(parent_element, parent_element.style(context));
|
||||||
|
|
||||||
// The addition of zero-width space here forces the text input to have an inline formatting
|
if is_text_input_element {
|
||||||
// context that might otherwise be trimmed if there's no text. This is important to ensure
|
// The addition of zero-width space here forces the text input to have an inline formatting
|
||||||
// that the input element is at least as tall as the line gap of the caret:
|
// context that might otherwise be trimmed if there's no text. This is important to ensure
|
||||||
// <https://drafts.csswg.org/css-ui/#element-with-default-preferred-size>.
|
// that the input element is at least as tall as the line gap of the caret:
|
||||||
//
|
// <https://drafts.csswg.org/css-ui/#element-with-default-preferred-size>.
|
||||||
// TODO: Is there a less hacky way to do this?
|
//
|
||||||
handler.handle_text(&info, "\u{200B}".into());
|
// TODO: Is there a less hacky way to do this?
|
||||||
|
handler.handle_text(&info, "\u{200B}".into());
|
||||||
|
}
|
||||||
|
|
||||||
handler.handle_text(&info, parent_element.to_threadsafe().node_text_content());
|
handler.handle_text(&info, parent_element.to_threadsafe().node_text_content());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !is_text_input_element && !is_textarea_element {
|
||||||
|
for child in iter_child_nodes(parent_element) {
|
||||||
|
if child.is_text_node() {
|
||||||
|
let info = NodeAndStyleInfo::new(child, child.style(context));
|
||||||
|
handler.handle_text(&info, child.to_threadsafe().node_text_content());
|
||||||
|
} else if child.is_element() {
|
||||||
|
traverse_element(child, context, handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
traverse_pseudo_element(WhichPseudoElement::After, parent_element, context, handler);
|
traverse_pseudo_element(WhichPseudoElement::After, parent_element, context, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
[.target > * 1]
|
[.target > * 1]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[.target > * 5]
|
[.target > * 11]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[dir_auto-textarea-script-N-EN.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[multiline-placeholder-cr.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[multiline-placeholder-crlf.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[multiline-placeholder.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[placeholder-white-space.tentative.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[textarea_placeholder.html]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue