aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/construct.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2016-11-21 18:13:40 -0500
committerJosh Matthews <josh@joshmatthews.net>2017-02-22 14:19:35 -0500
commitc890c9143cc1ae82e1116b8fb0c4e9eb478b8a03 (patch)
tree131dcf8dd5a2880562101497d958c02a31903183 /components/layout/construct.rs
parent78e8c31a4d1890260dda83f2db85672f693c1e97 (diff)
downloadservo-c890c9143cc1ae82e1116b8fb0c4e9eb478b8a03.tar.gz
servo-c890c9143cc1ae82e1116b8fb0c4e9eb478b8a03.zip
Make script thread initiate requests for images needed by layout.
In support of this goal, the layout thread collects information about CSS images that are missing image data and hands it off to the script thread after layout completes. The script thread stores a list of nodes that will need to be reflowed after the associated network request is complete. The script thread ensures that the nodes are not GCed while a request is ongoing, which the layout thread is incapable of guaranteeing. The image cache's API has also been redesigned in support of this work. No network requests are made by the new image cache, since it does not possess the document-specific information necessary to initiate them. Instead, there is now a single, synchronous query operation that optionally reserves a slot when a cache entry for a URL cannot be found. This reserved slot is then the responsibility of the queryer to populate with the contents of the network response for the URL once it is complete. Any subsequent queries for the same URL will be informed that the response is pending until that occurs. The changes to layout also remove the synchronous image loading code path, which means that reftests now test the same code that non-test binaries execute. The decision to take a screenshot now considers whether there are any outstanding image requests for layout in order to avoid intermittent failures in reftests that use CSS images.
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r--components/layout/construct.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index bbfe17d22b7..afdf903c500 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -351,11 +351,13 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
}
Some(LayoutNodeType::Element(LayoutElementType::HTMLImageElement)) => {
let image_info = box ImageFragmentInfo::new(node.image_url(),
+ node,
&self.layout_context);
SpecificFragmentInfo::Image(image_info)
}
Some(LayoutNodeType::Element(LayoutElementType::HTMLObjectElement)) => {
let image_info = box ImageFragmentInfo::new(node.object_data(),
+ node,
&self.layout_context);
SpecificFragmentInfo::Image(image_info)
}
@@ -1219,6 +1221,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
Either::First(ref url_value) => {
let image_info = box ImageFragmentInfo::new(url_value.url().map(|u| u.clone()),
+ node,
&self.layout_context);
vec![Fragment::new(node, SpecificFragmentInfo::Image(image_info), self.layout_context)]
}