auto merge of #3600 : pcwalton/servo/pseudo-unshareable, r=mbrubeck

Makes multiple `<br>` elements work, since those are implemented via
`before` pseudos.

r? @mbrubeck
This commit is contained in:
bors-servo 2014-10-09 00:06:32 -06:00
commit 15b508ac10
6 changed files with 29 additions and 7 deletions

View file

@ -8,7 +8,8 @@ use css::node_style::StyledNode;
use construct::FlowConstructor;
use context::LayoutContext;
use util::{LayoutDataAccess, LayoutDataWrapper};
use wrapper::{LayoutElement, LayoutNode, PostorderNodeMutTraversal, ThreadSafeLayoutNode, TLayoutNode};
use wrapper::{LayoutElement, LayoutNode, PostorderNodeMutTraversal, ThreadSafeLayoutNode};
use wrapper::{TLayoutNode};
use script::dom::node::{TextNodeTypeId};
use servo_util::bloom::BloomFilter;
@ -233,11 +234,13 @@ impl StyleSharingCandidate {
}
match (&self.class, element.get_attr(&ns!(""), "class")) {
(&None, Some(_)) | (&Some(_), None) => return false,
(&Some(ref this_class), Some(element_class)) if element_class != this_class.as_slice() => {
(&Some(ref this_class), Some(element_class))
if element_class != this_class.as_slice() => {
return false
}
(&Some(_), Some(_)) | (&None, None) => {}
}
true
}
}
@ -440,7 +443,9 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
Some(After),
&mut applicable_declarations.after);
*shareable = applicable_declarations.normal_shareable
*shareable = applicable_declarations.normal_shareable &&
applicable_declarations.before.len() == 0 &&
applicable_declarations.after.len() == 0
}
unsafe fn share_style_if_possible(&self,
@ -537,7 +542,8 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
// First, check to see whether we can share a style with someone.
let sharing_result = unsafe {
self.share_style_if_possible(layout_context.style_sharing_candidate_cache(), parent.clone())
self.share_style_if_possible(layout_context.style_sharing_candidate_cache(),
parent.clone())
};
// Otherwise, match and cascade selectors.

View file

@ -16,8 +16,8 @@ use layout_task::{AssignBSizesAndStoreOverflowTraversal, AssignISizesTraversal};
use layout_task::{BubbleISizesTraversal};
use url::Url;
use util::{LayoutDataAccess, LayoutDataWrapper, OpaqueNodeMethods};
use wrapper::{layout_node_to_unsafe_layout_node, layout_node_from_unsafe_layout_node, LayoutNode, PostorderNodeMutTraversal};
use wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode};
use wrapper::{layout_node_to_unsafe_layout_node, layout_node_from_unsafe_layout_node, LayoutNode};
use wrapper::{PostorderNodeMutTraversal, ThreadSafeLayoutNode, UnsafeLayoutNode};
use gfx::display_list::OpaqueNode;
use servo_util::bloom::BloomFilter;

View file

@ -633,7 +633,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
}
}
pub fn get_pseudo_element_type(&self) -> PseudoElementType {
pub fn get_pseudo_element_type(&self) -> PseudoElementType {
self.pseudo
}

View file

@ -167,3 +167,4 @@ fragment=top != ../html/acid2.html acid2_ref.html
== box_sizing_border_box_a.html box_sizing_border_box_ref.html
!= input_height_a.html input_height_ref.html
== pre_ignorable_whitespace_a.html pre_ignorable_whitespace_ref.html
== many_brs_a.html many_brs_ref.html

View file

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
Cupcakes<br>are<br>supremely<br>delicious.
</body>
</html>

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<body>
<div>Cupcakes</div>
<div>are</div>
<div>supremely</div>
<div>delicious.</div>
</body>
</html>