diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index aadf55dd6a7..e8bfdf6dbc7 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1409,19 +1409,36 @@ impl<'le> TElement for GeckoElement<'le> { // If we are a NAC pseudo-element, we want to get rules from our // rule_hash_target, that is, our originating element. let mut current = Some(self.rule_hash_target()); - while let Some(element) = current { + // TODO(emilio): Deal with Shadow DOM separately than with XBL + // (right now we still rely on get_xbl_binding_parent()). + // + // That will allow to clean up a bunch in + // push_applicable_declarations. + if let Some(shadow) = element.shadow_root() { + debug_assert!(!shadow.mServoStyles.mPtr.is_null()); + let author_styles = unsafe { + &*(shadow.mServoStyles.mPtr + as *const structs::RawServoAuthorStyles + as *const bindings::RawServoAuthorStyles) + }; + + let author_styles: &'a _ = AuthorStyles::::from_ffi(author_styles); + f(&author_styles.data, author_styles.quirks_mode); + if element != *self { + break; + } + } + if let Some(binding) = element.xbl_binding() { binding.each_xbl_cascade_data(&mut f); // If we're not looking at our original element, allow the // binding to cut off style inheritance. - if element != *self { - if !binding.inherits_style() { - // Go no further; we're not inheriting style from - // anything above here. - break; - } + if element != *self && !binding.inherits_style() { + // Go no further; we're not inheriting style from + // anything above here. + break; } } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 9f6a64e0dd1..1896b87fa71 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1149,6 +1149,40 @@ pub unsafe extern "C" fn Servo_AuthorStyles_AppendStyleSheet( styles.stylesheets.append_stylesheet(None, sheet, &guard); } +#[no_mangle] +pub unsafe extern "C" fn Servo_AuthorStyles_InsertStyleSheetBefore( + styles: RawServoAuthorStylesBorrowedMut, + sheet: *const ServoStyleSheet, + before_sheet: *const ServoStyleSheet, +) { + let styles = AuthorStyles::::from_ffi_mut(styles); + + let global_style_data = &*GLOBAL_STYLE_DATA; + let guard = global_style_data.shared_lock.read(); + styles.stylesheets.insert_stylesheet_before( + None, + GeckoStyleSheet::new(sheet), + GeckoStyleSheet::new(before_sheet), + &guard, + ); +} + +#[no_mangle] +pub unsafe extern "C" fn Servo_AuthorStyles_RemoveStyleSheet( + styles: RawServoAuthorStylesBorrowedMut, + sheet: *const ServoStyleSheet, +) { + let styles = AuthorStyles::::from_ffi_mut(styles); + + let global_style_data = &*GLOBAL_STYLE_DATA; + let guard = global_style_data.shared_lock.read(); + styles.stylesheets.remove_stylesheet( + None, + GeckoStyleSheet::new(sheet), + &guard, + ); +} + #[no_mangle] pub unsafe extern "C" fn Servo_AuthorStyles_ForceDirty( styles: RawServoAuthorStylesBorrowedMut,