auto merge of #1331 : SimonSapin/servo/visibility, r=pcwalton

http://www.w3.org/TR/CSS21/visufx.html#visibility

`visibility: collapse` is not supported yet because tables are not, either.

This fixes #1329.
This commit is contained in:
bors-servo 2013-12-04 10:07:06 -08:00
commit a92d430007
5 changed files with 45 additions and 1 deletions

View file

@ -28,7 +28,8 @@ use std::unstable::raw::Box;
use style::ComputedValues;
use style::computed_values::{
border_style, clear, float, font_family, font_style, line_height,
position, text_align, text_decoration, vertical_align, LengthOrPercentage, overflow};
position, text_align, text_decoration, vertical_align, LengthOrPercentage,
overflow, visibility};
use css::node_style::StyledNode;
use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData, ToGfxColor};
@ -1032,6 +1033,10 @@ impl RenderBoxUtils for @RenderBox {
box_bounds, absolute_box_bounds, self.debug_str());
debug!("RenderBox::build_display_list: dirty={}, offset={}", *dirty, *offset);
if base.nearest_ancestor_element().style().Box.visibility != visibility::visible {
return;
}
if absolute_box_bounds.intersects(dirty) {
debug!("RenderBox::build_display_list: intersected. Adding display item...");
} else {

View file

@ -373,6 +373,9 @@ pub mod longhands {
// CSS 2.1, Section 11 - Visual effects
${single_keyword("overflow", "visible hidden", inherited=False)} // TODO: scroll auto
// TODO: collapse. Well, do tables first.
${single_keyword("visibility", "visible hidden", inherited=True)}
// CSS 2.1, Section 12 - Generated content, automatic numbering, and lists
// CSS 2.1, Section 13 - Paged media

View file

@ -12,3 +12,4 @@
== first_of_type_pseudo_a.html first_of_type_pseudo_b.html
== last_of_type_pseudo_a.html last_of_type_pseudo_b.html
== only_of_type_pseudo_a.html only_of_type_pseudo_b.html
== visibility_hidden.html visibility_hidden_ref.html

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>'visibility: hidden' test</title>
<style type="text/css">
body { color: black; background: white }
.hidden { visibility: hidden; }
.visible { visibility: visible; }
</style>
</head>
<body>
<p>This should be visible.</p>
<div class="hidden">
<p>This should NOT be visible.</p>
<p class="visible">This should be visible.</p>
</div>
</body>
</html>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>'visibility: hidden' test</title>
<style type="text/css">
body { color: black; background: white }
</style>
</head>
<body>
<p>This should be visible.</p>
<div>
<!-- Use the same markup so that this test is not affected by broken margin collapsing. -->
<p>&nbsp;</p>
<p>This should be visible.</p>
</div>
</body>
</html>