Bug 1324618 part 2. Add some comments to may_generate_pseudo; no real behavior changes for now. r?emilio draft
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 26 Jun 2017 15:55:56 -0700
changeset 600464 fb5c14c11b4619c4f50cd5c8ca469bc387f895e3
parent 600463 c949a723c9f37f606483329a9c0d2ed26f8a99b8
child 600465 75352e319572489ee0f91e9a10b651b50199e7a5
push id65775
push userbzbarsky@mozilla.com
push dateTue, 27 Jun 2017 01:04:33 +0000
reviewersemilio
bugs1324618
milestone56.0a1
Bug 1324618 part 2. Add some comments to may_generate_pseudo; no real behavior changes for now. r?emilio MozReview-Commit-ID: 8WxT6jyBH4O
servo/components/style/dom.rs
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -421,19 +421,29 @@ pub trait TElement : Eq + PartialEq + De
     /// Whether a given element may generate a pseudo-element.
     ///
     /// This is useful to avoid computing, for example, pseudo styles for
     /// `::-first-line` or `::-first-letter`, when we know it won't affect us.
     ///
     /// TODO(emilio, bz): actually implement the logic for it.
     fn may_generate_pseudo(
         &self,
-        _pseudo: &PseudoElement,
+        pseudo: &PseudoElement,
         _primary_style: &ComputedValues,
     ) -> bool {
+        // ::before/::after are always supported for now, though we could try to
+        // optimize out leaf elements.
+
+        // ::first-letter and ::first-line are only supported for block-inside
+        // things, and only in Gecko, not Servo.  Unfortunately, Gecko has
+        // block-inside things that might have any computed display value due to
+        // things like fieldsets, legends, etc.  Need to figure out how this
+        // should work.
+        debug_assert!(pseudo.is_eager(),
+                      "Someone called may_generate_pseudo with a non-eager pseudo.");
         true
     }
 
     /// Returns true if this element may have a descendant needing style processing.
     ///
     /// Note that we cannot guarantee the existence of such an element, because
     /// it may have been removed from the DOM between marking it for restyle and
     /// the actual restyle traversal.