aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_thread/lib.rs
diff options
context:
space:
mode:
authorPyfisch <pyfisch@gmail.com>2018-02-11 21:00:32 +0100
committerPyfisch <pyfisch@gmail.com>2018-02-24 10:36:10 +0100
commit2d74bcfea5f74a8ba130615b2b5b5bd571623b4d (patch)
treea1496c8dc05b802d18e9e30bb2ee0f0f50d9adf1 /components/layout_thread/lib.rs
parenta5115139baca2d2a15831916d83964a4d374fae1 (diff)
downloadservo-2d74bcfea5f74a8ba130615b2b5b5bd571623b4d.tar.gz
servo-2d74bcfea5f74a8ba130615b2b5b5bd571623b4d.zip
Introduce a dedicated data structure for text queries
Add an IndexableText structure for text queries. Instead of linear search for a node this now uses a HashMap. Remove the now irrelevant fields from TextDisplayItem.
Diffstat (limited to 'components/layout_thread/lib.rs')
-rw-r--r--components/layout_thread/lib.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index a5c3e03293f..85d056d3d4a 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -68,7 +68,7 @@ use layout::context::LayoutContext;
use layout::context::RegisteredPainter;
use layout::context::RegisteredPainters;
use layout::context::malloc_size_of_persistent_local_context;
-use layout::display_list::ToLayout;
+use layout::display_list::{IndexableText, ToLayout};
use layout::display_list::WebRenderDisplayListConverter;
use layout::flow::{Flow, GetBaseFlow, ImmutableFlowUtils, MutableOwnedFlowUtils};
use layout::flow_ref::FlowRef;
@@ -515,6 +515,7 @@ impl LayoutThread {
LayoutThreadData {
constellation_chan: constellation_chan,
display_list: None,
+ indexable_text: IndexableText::default(),
content_box_response: None,
content_boxes_response: Vec::new(),
client_rect_response: Rect::zero(),
@@ -1002,6 +1003,9 @@ impl LayoutThread {
}
}
+ rw_data.indexable_text = std::mem::replace(
+ &mut build_state.indexable_text,
+ IndexableText::default());
rw_data.display_list = Some(Arc::new(build_state.to_display_list()));
}
}
@@ -1366,10 +1370,7 @@ impl LayoutThread {
Au::from_f32_px(point_in_node.y)
);
rw_data.text_index_response = TextIndexResponse(
- rw_data.display_list
- .as_ref()
- .expect("Tried to hit test with no display list")
- .text_index(opaque_node, point_in_node.to_layout())
+ rw_data.indexable_text.text_index(opaque_node, point_in_node)
);
},
ReflowGoal::NodeGeometryQuery(node) => {