servo: Merge #18794 - style: use the XBL styleset quirks mode to match XBL rules (from emilio:xbl-quirks-mode); r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 09 Oct 2017 05:04:15 -0500
changeset 385091 ca72a7721ef77a7fb583d4cacc286659a33adb68
parent 385090 ca1126dea7c833ab9b0d26f62d2599e07eb84982
child 385092 5f336a4ae6ce6274feccb2054b1bd6f8dd0fb9ef
push id32646
push userarchaeopteryx@coole-files.de
push dateMon, 09 Oct 2017 21:47:29 +0000
treeherdermozilla-central@4afc55e7033c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1405543
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #18794 - style: use the XBL styleset quirks mode to match XBL rules (from emilio:xbl-quirks-mode); r=heycam This fixes bug 1405543. MozReview-Commit-ID: Dv3mt3Fb8Yp Source-Repo: https://github.com/servo/servo Source-Revision: 604cc4e311f1aec72599d43c5a0138b04c8b780d
servo/components/style/gecko/data.rs
servo/components/style/stylist.rs
--- a/servo/components/style/gecko/data.rs
+++ b/servo/components/style/gecko/data.rs
@@ -118,16 +118,21 @@ pub struct PerDocumentStyleDataImpl {
 /// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
 /// and unexpected races while trying to mutate it.
 pub struct PerDocumentStyleData(AtomicRefCell<PerDocumentStyleDataImpl>);
 
 impl PerDocumentStyleData {
     /// Create a dummy `PerDocumentStyleData`.
     pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
         let device = Device::new(pres_context);
+
+        // FIXME(emilio, tlin): How is this supposed to work with XBL? This is
+        // right now not always honored, see bug 1405543...
+        //
+        // Should we just force XBL Stylists to be NoQuirks?
         let quirks_mode = unsafe {
             (*device.pres_context().mDocument.raw::<nsIDocument>()).mCompatMode
         };
 
         PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
             stylist: Stylist::new(device, quirks_mode.into()),
         }))
     }
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -1265,22 +1265,31 @@ impl Stylist {
             debug!("skipping user rules");
         }
 
         // Step 3b: XBL rules.
         let cut_off_inheritance = element.each_xbl_stylist(|stylist| {
             // ServoStyleSet::CreateXBLServoStyleSet() loads XBL style sheets
             // under eAuthorSheetFeatures level.
             if let Some(map) = stylist.cascade_data.author.borrow_for_pseudo(pseudo_element) {
+                // NOTE(emilio): This is needed because the XBL stylist may
+                // think it has a different quirks mode than the document.
+                let mut matching_context = MatchingContext::new(
+                    context.matching_mode,
+                    context.bloom_filter,
+                    context.nth_index_cache.as_mut().map(|s| &mut **s),
+                    stylist.quirks_mode,
+                );
+
                 map.get_all_matching_rules(
                     element,
                     &rule_hash_target,
                     applicable_declarations,
-                    context,
-                    self.quirks_mode,
+                    &mut matching_context,
+                    stylist.quirks_mode,
                     flags_setter,
                     CascadeLevel::XBL,
                 );
             }
         });
 
         if rule_hash_target.matches_user_and_author_rules() && !only_default_rules {
             // Gecko skips author normal rules if cutting off inheritance.