mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Fixes background-color calculation for iframes. Fixes #1248
This commit is contained in:
parent
3e7dc57693
commit
7aacf90161
7 changed files with 29 additions and 4 deletions
|
@ -666,7 +666,17 @@ impl LayoutTask {
|
||||||
|
|
||||||
// FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor
|
// FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor
|
||||||
// it with extreme prejudice.
|
// 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() {
|
for child in node.traverse_preorder() {
|
||||||
if child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHtmlElement))) ||
|
if child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHtmlElement))) ||
|
||||||
child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement))) {
|
child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement))) {
|
||||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -458,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#1ef45363e38cb4257d99a4de6a43bf99c1a6f807"
|
source = "git+https://github.com/servo/rust-layers#7f0ab52e147b778c79b9378fe3ddd4d13055df84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -460,7 +460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#1ef45363e38cb4257d99a4de6a43bf99c1a6f807"
|
source = "git+https://github.com/servo/rust-layers#7f0ab52e147b778c79b9378fe3ddd4d13055df84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
|
|
2
ports/gonk/Cargo.lock
generated
2
ports/gonk/Cargo.lock
generated
|
@ -378,7 +378,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#1ef45363e38cb4257d99a4de6a43bf99c1a6f807"
|
source = "git+https://github.com/servo/rust-layers#7f0ab52e147b778c79b9378fe3ddd4d13055df84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
|
|
|
@ -125,6 +125,7 @@ fragment=top != ../html/acid2.html acid2_ref.html
|
||||||
== background_image_position_a.html background_image_position_ref.html
|
== background_image_position_a.html background_image_position_ref.html
|
||||||
== multiple_css_class_a.html multiple_css_class_b.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.html iframe/simple_ref.html
|
||||||
== iframe/simple_inline_default.html iframe/simple_inline_default_ref.html
|
== iframe/simple_inline_default.html iframe/simple_inline_default_ref.html
|
||||||
== iframe/simple_inline_width.html iframe/simple_inline_width_ref.html
|
== iframe/simple_inline_width.html iframe/simple_inline_width_ref.html
|
||||||
|
|
8
tests/ref/iframe/bg_color.html
Normal file
8
tests/ref/iframe/bg_color.html
Normal 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>
|
6
tests/ref/iframe/bg_color_ref.html
Normal file
6
tests/ref/iframe/bg_color_ref.html
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue