layout: Query and maintain the position of the insertion point

throughout layout for input elements.
This commit is contained in:
Patrick Walton 2015-09-15 16:31:46 -07:00
parent 34d9a6091b
commit 357419dc8d
6 changed files with 152 additions and 41 deletions

View file

@ -41,7 +41,7 @@ use table_rowgroup::TableRowGroupFlow;
use table_wrapper::TableWrapperFlow;
use text::TextRunScanner;
use traversal::PostorderNodeMutTraversal;
use wrapper::{PseudoElementType, ThreadSafeLayoutNode};
use wrapper::{PseudoElementType, TextContent, ThreadSafeLayoutNode};
use gfx::display_list::OpaqueNode;
use script::dom::characterdata::CharacterDataTypeId;
@ -583,7 +583,7 @@ impl<'a> FlowConstructor<'a> {
// Add whitespace results. They will be stripped out later on when
// between block elements, and retained when between inline elements.
let fragment_info = SpecificFragmentInfo::UnscannedText(
UnscannedTextFragmentInfo::from_text(" ".to_owned()));
UnscannedTextFragmentInfo::new(" ".to_owned(), None));
properties::modify_style_for_replaced_content(&mut whitespace_style);
properties::modify_style_for_text(&mut whitespace_style);
let fragment = Fragment::from_opaque_node_and_style(whitespace_node,
@ -714,31 +714,44 @@ impl<'a> FlowConstructor<'a> {
return
}
let insertion_point = node.insertion_point();
let mut style = (*style).clone();
properties::modify_style_for_text(&mut style);
for content_item in text_content {
let specific = match content_item {
ContentItem::String(string) => {
let info = UnscannedTextFragmentInfo::from_text(string);
SpecificFragmentInfo::UnscannedText(info)
}
content_item => {
let content_item = box GeneratedContentInfo::ContentItem(content_item);
SpecificFragmentInfo::GeneratedContent(content_item)
}
};
fragments.fragments
.push_back(Fragment::from_opaque_node_and_style(node.opaque(),
node.get_pseudo_element_type()
.strip(),
style.clone(),
node.restyle_damage(),
specific))
match text_content {
TextContent::Text(string) => {
let info = UnscannedTextFragmentInfo::new(string, insertion_point);
let specific_fragment_info = SpecificFragmentInfo::UnscannedText(info);
fragments.fragments.push_back(Fragment::from_opaque_node_and_style(
node.opaque(),
node.get_pseudo_element_type().strip(),
style.clone(),
node.restyle_damage(),
specific_fragment_info))
}
TextContent::GeneratedContent(content_items) => {
for content_item in content_items.into_iter() {
let specific_fragment_info = match content_item {
ContentItem::String(string) => {
let info = UnscannedTextFragmentInfo::new(string, None);
SpecificFragmentInfo::UnscannedText(info)
}
content_item => {
let content_item = box GeneratedContentInfo::ContentItem(content_item);
SpecificFragmentInfo::GeneratedContent(content_item)
}
};
fragments.fragments.push_back(Fragment::from_opaque_node_and_style(
node.opaque(),
node.get_pseudo_element_type().strip(),
style.clone(),
node.restyle_damage(),
specific_fragment_info))
}
}
}
}
/// Builds a flow for a node with `display: block`. This yields a `BlockFlow` with possibly
/// other `BlockFlow`s or `InlineFlow`s underneath it, depending on whether {ib} splits needed
/// to happen.
@ -851,7 +864,7 @@ impl<'a> FlowConstructor<'a> {
whitespace_damage)) => {
// Instantiate the whitespace fragment.
let fragment_info = SpecificFragmentInfo::UnscannedText(
UnscannedTextFragmentInfo::from_text(" ".to_owned()));
UnscannedTextFragmentInfo::new(" ".to_owned(), None));
properties::modify_style_for_replaced_content(&mut whitespace_style);
properties::modify_style_for_text(&mut whitespace_style);
let fragment = Fragment::from_opaque_node_and_style(whitespace_node,
@ -1199,7 +1212,7 @@ impl<'a> FlowConstructor<'a> {
unscanned_marker_fragments.push_back(Fragment::new(
node,
SpecificFragmentInfo::UnscannedText(
UnscannedTextFragmentInfo::from_text(text))));
UnscannedTextFragmentInfo::new(text, None))));
let marker_fragments = TextRunScanner::new().scan_for_runs(
&mut self.layout_context.font_context(),
unscanned_marker_fragments);
@ -1793,7 +1806,7 @@ fn control_chars_to_fragment(node: &InlineFragmentNodeInfo,
restyle_damage: RestyleDamage)
-> Fragment {
let info = SpecificFragmentInfo::UnscannedText(
UnscannedTextFragmentInfo::from_text(String::from(text)));
UnscannedTextFragmentInfo::new(String::from(text), None));
let mut style = node.style.clone();
properties::modify_style_for_text(&mut style);
Fragment::from_opaque_node_and_style(node.address,