Fixes background-color calculation for iframes. Fixes #1248

This commit is contained in:
Glenn Watson 2015-02-16 08:16:18 +10:00
parent 3e7dc57693
commit 7aacf90161
7 changed files with 29 additions and 4 deletions

View file

@ -666,7 +666,17 @@ impl LayoutTask {
// FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor
// it with extreme prejudice.
let mut color = color::white();
// The default computed value for background-color is transparent (see
// http://dev.w3.org/csswg/css-backgrounds/#background-color). However, we
// need to propagate the background color from the root HTML/Body
// element (http://dev.w3.org/csswg/css-backgrounds/#special-backgrounds) if
// it is non-transparent. The phrase in the spec "If the canvas background
// is not opaque, what shows through is UA-dependent." is handled by rust-layers
// clearing the frame buffer to white. This ensures that setting a background
// color on an iframe element, while the iframe content itself has a default
// transparent background color is handled correctly.
let mut color = color::transparent_black();
for child in node.traverse_preorder() {
if child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHtmlElement))) ||
child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement))) {

View file

@ -458,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "layers"
version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#1ef45363e38cb4257d99a4de6a43bf99c1a6f807"
source = "git+https://github.com/servo/rust-layers#7f0ab52e147b778c79b9378fe3ddd4d13055df84"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",

2
ports/cef/Cargo.lock generated
View file

@ -460,7 +460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "layers"
version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#1ef45363e38cb4257d99a4de6a43bf99c1a6f807"
source = "git+https://github.com/servo/rust-layers#7f0ab52e147b778c79b9378fe3ddd4d13055df84"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",

2
ports/gonk/Cargo.lock generated
View file

@ -378,7 +378,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "layers"
version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#1ef45363e38cb4257d99a4de6a43bf99c1a6f807"
source = "git+https://github.com/servo/rust-layers#7f0ab52e147b778c79b9378fe3ddd4d13055df84"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",

View file

@ -125,6 +125,7 @@ fragment=top != ../html/acid2.html acid2_ref.html
== background_image_position_a.html background_image_position_ref.html
== multiple_css_class_a.html multiple_css_class_b.html
== iframe/bg_color.html iframe/bg_color_ref.html
== iframe/simple.html iframe/simple_ref.html
== iframe/simple_inline_default.html iframe/simple_inline_default_ref.html
== iframe/simple_inline_width.html iframe/simple_inline_width_ref.html

View file

@ -0,0 +1,8 @@
<html>
<body style="background-color: blue; margin: 0;">
<div style="margin: 20px;">
<iframe src="about:blank" style="border: 0; background-color: green;">
</iframe>
</div>
</body>
</html>

View file

@ -0,0 +1,6 @@
<html>
<body style="background-color: blue; margin: 0;">
<div style="width: 300px; height: 150px; margin: 20px; background-color: green;">
</div>
</body>
</html>