diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2015-09-15 16:31:46 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2015-09-17 13:31:12 +0200 |
commit | 357419dc8dcb20e9ffbc468fdba6e174797533b2 (patch) | |
tree | 90d2b2bc7cc6cdc3b8aea77df51035eb90fbf856 /components/layout/construct.rs | |
parent | 34d9a6091b07d7a57ede438f5467faf3fedfa6ae (diff) | |
download | servo-357419dc8dcb20e9ffbc468fdba6e174797533b2.tar.gz servo-357419dc8dcb20e9ffbc468fdba6e174797533b2.zip |
layout: Query and maintain the position of the insertion point
throughout layout for input elements.
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r-- | components/layout/construct.rs | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index dd1d58a6acc..a0b85802a66 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -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, |