aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-05-30 17:40:18 -0400
committerbors-servo <release+servo@mozilla.com>2014-05-30 17:40:18 -0400
commit68e3fb26a701ae0224f579b66606118eab1eedaf (patch)
treecf08b242f71dd21423a2fb99804bbbcd8cb4a4e5 /src
parent5f5897f4e41259bec345d86cf068508ca9e2ea2f (diff)
parent12097703ba81c29667777c522c58ebab97e7a903 (diff)
downloadservo-68e3fb26a701ae0224f579b66606118eab1eedaf.tar.gz
servo-68e3fb26a701ae0224f579b66606118eab1eedaf.zip
auto merge of #2523 : mrobinson/servo/background-color, r=pcwalton
The first layer implicitly provides the size of the page, but child layer background colors can still improperly override the body background color. This commit ensures that layer background colors only apply to layers with the same id and pipeline id. Additionally the root layer's unrendered color is defined by the first layer's background color, just like for size.
Diffstat (limited to 'src')
-rw-r--r--src/components/main/compositing/compositor.rs17
-rw-r--r--src/components/main/compositing/compositor_layer.rs14
-rw-r--r--src/components/main/compositing/compositor_task.rs5
-rw-r--r--src/test/ref/basic.list1
-rw-r--r--src/test/ref/position_fixed_background_color_a.html6
-rw-r--r--src/test/ref/position_fixed_background_color_b.html4
6 files changed, 37 insertions, 10 deletions
diff --git a/src/components/main/compositing/compositor.rs b/src/components/main/compositing/compositor.rs
index 1422e8e51f5..b14b5513bbf 100644
--- a/src/components/main/compositing/compositor.rs
+++ b/src/components/main/compositing/compositor.rs
@@ -267,9 +267,9 @@ impl IOCompositor {
chan.send(Some(azure_hl::current_graphics_metadata()));
}
- (Ok(CreateRootCompositorLayerIfNecessary(pipeline_id, layer_id, size)),
+ (Ok(CreateRootCompositorLayerIfNecessary(pipeline_id, layer_id, size, color)),
false) => {
- self.create_root_compositor_layer_if_necessary(pipeline_id, layer_id, size);
+ self.create_root_compositor_layer_if_necessary(pipeline_id, layer_id, size, color);
}
(Ok(CreateDescendantCompositorLayerIfNecessary(pipeline_id,
@@ -322,12 +322,11 @@ impl IOCompositor {
}
}
- // FIXME(#2004, pcwalton): Take the pipeline ID and layer ID into account.
- fn set_unrendered_color(&mut self, _: PipelineId, _: LayerId, color: Color) {
+ fn set_unrendered_color(&mut self, pipeline_id: PipelineId, layer_id: LayerId, color: Color) {
match self.compositor_layer {
- Some(ref mut layer) => layer.unrendered_color = color,
- None => {}
- }
+ Some(ref mut layer) => layer.set_unrendered_color(pipeline_id, layer_id, color),
+ None => false,
+ };
}
fn set_ids(&mut self,
@@ -353,7 +352,8 @@ impl IOCompositor {
fn create_root_compositor_layer_if_necessary(&mut self,
id: PipelineId,
layer_id: LayerId,
- size: Size2D<f32>) {
+ size: Size2D<f32>,
+ unrendered_color: Color) {
let (root_pipeline, root_layer_id) = match self.compositor_layer {
Some(ref compositor_layer) if compositor_layer.pipeline.id == id => {
(compositor_layer.pipeline.clone(), compositor_layer.id_of_first_child())
@@ -372,6 +372,7 @@ impl IOCompositor {
size,
self.opts.tile_size,
self.opts.cpu_painting);
+ new_layer.unrendered_color = unrendered_color;
let first_child = self.root_layer.first_child.borrow().clone();
match first_child {
diff --git a/src/components/main/compositing/compositor_layer.rs b/src/components/main/compositing/compositor_layer.rs
index 14c11fb9eda..5e936a07227 100644
--- a/src/components/main/compositing/compositor_layer.rs
+++ b/src/components/main/compositing/compositor_layer.rs
@@ -965,5 +965,19 @@ impl CompositorLayer {
pub fn id_of_first_child(&self) -> LayerId {
self.children.iter().next().expect("no first child!").child.id
}
+
+ pub fn set_unrendered_color(&mut self, pipeline_id: PipelineId, layer_id: LayerId, color: Color) -> bool {
+ if self.pipeline.id != pipeline_id || self.id != layer_id {
+ for child_layer in self.children.mut_iter() {
+ if child_layer.child.set_unrendered_color(pipeline_id, layer_id, color) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ self.unrendered_color = color;
+ return true;
+ }
}
diff --git a/src/components/main/compositing/compositor_task.rs b/src/components/main/compositing/compositor_task.rs
index 8891bb2575a..009ab920b52 100644
--- a/src/components/main/compositing/compositor_task.rs
+++ b/src/components/main/compositing/compositor_task.rs
@@ -96,7 +96,8 @@ impl RenderListener for CompositorChan {
if first {
self.chan.send(CreateRootCompositorLayerIfNecessary(pipeline_id,
metadata.id,
- size));
+ size,
+ metadata.background_color));
first = false
} else {
self.chan
@@ -166,7 +167,7 @@ pub enum Msg {
/// Tells the compositor to create the root layer for a pipeline if necessary (i.e. if no layer
/// with that ID exists).
- CreateRootCompositorLayerIfNecessary(PipelineId, LayerId, Size2D<f32>),
+ CreateRootCompositorLayerIfNecessary(PipelineId, LayerId, Size2D<f32>, Color),
/// Tells the compositor to create a descendant layer for a pipeline if necessary (i.e. if no
/// layer with that ID exists).
CreateDescendantCompositorLayerIfNecessary(PipelineId, LayerId, Rect<f32>, ScrollPolicy),
diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list
index 58215700bb6..408ef854596 100644
--- a/src/test/ref/basic.list
+++ b/src/test/ref/basic.list
@@ -75,3 +75,4 @@
== linebreak_simple_a.html linebreak_simple_b.html
== linebreak_inline_span_a.html linebreak_inline_span_b.html
== overconstrained_block.html overconstrained_block_ref.html
+== position_fixed_background_color_a.html position_fixed_background_color_b.html
diff --git a/src/test/ref/position_fixed_background_color_a.html b/src/test/ref/position_fixed_background_color_a.html
new file mode 100644
index 00000000000..64cf7a722bb
--- /dev/null
+++ b/src/test/ref/position_fixed_background_color_a.html
@@ -0,0 +1,6 @@
+<html>
+<body style="background:pink">
+ <div style="position: fixed;">
+ </div>
+</body>
+</html>
diff --git a/src/test/ref/position_fixed_background_color_b.html b/src/test/ref/position_fixed_background_color_b.html
new file mode 100644
index 00000000000..bbabcdf9388
--- /dev/null
+++ b/src/test/ref/position_fixed_background_color_b.html
@@ -0,0 +1,4 @@
+<html>
+<body style="background:pink">
+</body>
+</html>