servo: Merge #10770 - Do not render the contents of block-level replaced elements (from notriddle:canvas_placeholder_block); r=mbrubeck
authorMichael Howell <michael@notriddle.com>
Fri, 22 Apr 2016 22:32:37 -0700
changeset 338604 06c586917f9c78f9825cf12b290187e2763ddf63
parent 338603 6391daaeb3a2092873c6a77efa8c69a45cd96021
child 338605 644b3a693d804943223293e3ee1b071a4b19aab8
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
servo: Merge #10770 - Do not render the contents of block-level replaced elements (from notriddle:canvas_placeholder_block); r=mbrubeck Fixes #10733 Source-Repo: https://github.com/servo/servo Source-Revision: 5a5e928cb9a0ab4f6556c63c70a88f5e7ade4f10
servo/components/layout/construct.rs
servo/components/layout/wrapper.rs
--- a/servo/components/layout/construct.rs
+++ b/servo/components/layout/construct.rs
@@ -614,28 +614,30 @@ impl<'a, ConcreteThreadSafeLayoutNode: T
         // Gather up fragments for the inline flows we might need to create.
         let mut inline_fragment_accumulator = InlineFragmentsAccumulator::new();
         let mut consecutive_siblings = vec!();
 
         inline_fragment_accumulator.fragments.push_all(initial_fragments);
 
         // List of absolute descendants, in tree order.
         let mut abs_descendants = AbsoluteDescendants::new();
-        for kid in node.children() {
-            if kid.get_pseudo_element_type() != PseudoElementType::Normal {
-                self.process(&kid);
-            }
+        if !node.is_replaced_content() {
+            for kid in node.children() {
+                if kid.get_pseudo_element_type() != PseudoElementType::Normal {
+                    self.process(&kid);
+                }
 
-            self.build_block_flow_using_construction_result_of_child(
-                &mut flow,
-                &mut consecutive_siblings,
-                node,
-                kid,
-                &mut inline_fragment_accumulator,
-                &mut abs_descendants);
+                self.build_block_flow_using_construction_result_of_child(
+                    &mut flow,
+                    &mut consecutive_siblings,
+                    node,
+                    kid,
+                    &mut inline_fragment_accumulator,
+                    &mut abs_descendants);
+            }
         }
 
         // Perform a final flush of any inline fragments that we were gathering up to handle {ib}
         // splits, after stripping ignorable whitespace.
         self.flush_inline_fragments_to_flow_or_list(inline_fragment_accumulator,
                                                     &mut flow,
                                                     &mut consecutive_siblings,
                                                     &mut abs_descendants,
@@ -678,17 +680,17 @@ impl<'a, ConcreteThreadSafeLayoutNode: T
     fn build_flow_for_block_like(&mut self, flow: FlowRef, node: &ConcreteThreadSafeLayoutNode)
                             -> ConstructionResult {
         let mut initial_fragments = IntermediateInlineFragments::new();
         let node_is_input_or_text_area =
            node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
                        HTMLElementTypeId::HTMLInputElement))) ||
            node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
                        HTMLElementTypeId::HTMLTextAreaElement)));
-        if node.get_pseudo_element_type().is_before_or_after() ||
+        if node.get_pseudo_element_type().is_replaced_content() ||
                 node_is_input_or_text_area {
             // A TextArea's text contents are displayed through the input text
             // box, so don't construct them.
             if node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
                         HTMLElementTypeId::HTMLTextAreaElement))) {
                 for kid in node.children() {
                     self.set_flow_construction_result(&kid, ConstructionResult::None)
                 }
@@ -1654,30 +1656,30 @@ trait NodeUtils {
     /// the old value.
     fn swap_out_construction_result(self) -> ConstructionResult;
 }
 
 impl<ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNode
                                              where ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode {
     fn is_replaced_content(&self) -> bool {
         match self.type_id() {
-            None |
             Some(NodeTypeId::CharacterData(_)) |
             Some(NodeTypeId::DocumentType) |
             Some(NodeTypeId::DocumentFragment) |
             Some(NodeTypeId::Document(_)) |
             Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
                         HTMLElementTypeId::HTMLImageElement))) |
             Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
                         HTMLElementTypeId::HTMLIFrameElement))) |
             Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
                         HTMLElementTypeId::HTMLCanvasElement))) => true,
             Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
                         HTMLElementTypeId::HTMLObjectElement))) => self.has_object_data(),
             Some(NodeTypeId::Element(_)) => false,
+            None => self.get_pseudo_element_type().is_replaced_content(),
         }
     }
 
     fn construction_result_mut(self, data: &mut PrivateLayoutData) -> &mut ConstructionResult {
         match self.get_pseudo_element_type() {
             PseudoElementType::Before(_) => &mut data.before_flow_construction_result,
             PseudoElementType::After (_) => &mut data.after_flow_construction_result,
             PseudoElementType::DetailsSummary(_) => &mut data.details_summary_flow_construction_result,
--- a/servo/components/layout/wrapper.rs
+++ b/servo/components/layout/wrapper.rs
@@ -625,17 +625,17 @@ pub enum PseudoElementType<T> {
 impl<T> PseudoElementType<T> {
     pub fn is_before(&self) -> bool {
         match *self {
             PseudoElementType::Before(_) => true,
             _ => false,
         }
     }
 
-    pub fn is_before_or_after(&self) -> bool {
+    pub fn is_replaced_content(&self) -> bool {
         match *self {
             PseudoElementType::Before(_) | PseudoElementType::After(_) => true,
             _ => false,
         }
     }
 
     pub fn strip(&self) -> PseudoElementType<()> {
         match *self {
@@ -1036,17 +1036,17 @@ impl<'ln> ThreadSafeLayoutNode for Servo
         }
     }
 
     fn can_be_fragmented(&self) -> bool {
         self.node.can_be_fragmented()
     }
 
     fn text_content(&self) -> TextContent {
-        if self.pseudo.is_before_or_after() {
+        if self.pseudo.is_replaced_content() {
             let data = &self.borrow_layout_data().unwrap().style_data;
 
             let style = if self.pseudo.is_before() {
                 data.per_pseudo.get(&PseudoElement::Before).unwrap()
             } else {
                 data.per_pseudo.get(&PseudoElement::After).unwrap()
             };