From 9d721072f585c10a27d72ae52ea7a5c77e3f6eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 30 Apr 2018 19:23:14 +0200 Subject: [PATCH] style: Remove ServoStyleSheet usage. Bug: 1457920 Reviewed-by: xidorn MozReview-Commit-ID: LIBkovuQ6MB --- components/style/gecko/data.rs | 16 +++++++-------- components/style/shared_lock.rs | 2 +- ports/geckolib/error_reporter.rs | 10 +++++---- ports/geckolib/glue.rs | 32 ++++++++++++++--------------- ports/geckolib/stylesheet_loader.rs | 14 +++++++------ 5 files changed, 39 insertions(+), 35 deletions(-) diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index ac41eaa14c3..a4ed8294ac2 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -8,7 +8,7 @@ use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use context::QuirksMode; use dom::TElement; use gecko_bindings::bindings::{self, RawServoStyleSet}; -use gecko_bindings::structs::{self, RawGeckoPresContextOwned, ServoStyleSetSizes, ServoStyleSheet}; +use gecko_bindings::structs::{self, RawGeckoPresContextOwned, ServoStyleSetSizes, StyleSheet as DomStyleSheet}; use gecko_bindings::structs::{StyleSheetInfo, nsIDocument}; use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; use invalidation::media_queries::{MediaListKey, ToMediaListKey}; @@ -23,7 +23,7 @@ use stylist::Stylist; /// Little wrapper to a Gecko style sheet. #[derive(Debug, Eq, PartialEq)] -pub struct GeckoStyleSheet(*const ServoStyleSheet); +pub struct GeckoStyleSheet(*const DomStyleSheet); impl ToMediaListKey for ::gecko::data::GeckoStyleSheet { fn to_media_list_key(&self) -> MediaListKey { @@ -33,24 +33,24 @@ impl ToMediaListKey for ::gecko::data::GeckoStyleSheet { } impl GeckoStyleSheet { - /// Create a `GeckoStyleSheet` from a raw `ServoStyleSheet` pointer. + /// Create a `GeckoStyleSheet` from a raw `DomStyleSheet` pointer. #[inline] - pub unsafe fn new(s: *const ServoStyleSheet) -> Self { + pub unsafe fn new(s: *const DomStyleSheet) -> Self { debug_assert!(!s.is_null()); bindings::Gecko_StyleSheet_AddRef(s); Self::from_addrefed(s) } - /// Create a `GeckoStyleSheet` from a raw `ServoStyleSheet` pointer that + /// Create a `GeckoStyleSheet` from a raw `DomStyleSheet` pointer that /// already holds a strong reference. #[inline] - pub unsafe fn from_addrefed(s: *const ServoStyleSheet) -> Self { + pub unsafe fn from_addrefed(s: *const DomStyleSheet) -> Self { debug_assert!(!s.is_null()); GeckoStyleSheet(s) } - /// Get the raw `ServoStyleSheet` that we're wrapping. - pub fn raw(&self) -> &ServoStyleSheet { + /// Get the raw `StyleSheet` that we're wrapping. + pub fn raw(&self) -> &DomStyleSheet { unsafe { &*self.0 } } diff --git a/components/style/shared_lock.rs b/components/style/shared_lock.rs index 9bb54a274c6..e79f684a7bb 100644 --- a/components/style/shared_lock.rs +++ b/components/style/shared_lock.rs @@ -237,7 +237,7 @@ pub trait ToCssWithGuard { #[cfg(feature = "gecko")] pub struct DeepCloneParams { /// The new sheet we're cloning rules into. - pub reference_sheet: *const ::gecko_bindings::structs::ServoStyleSheet, + pub reference_sheet: *const ::gecko_bindings::structs::StyleSheet, } /// Parameters needed for deep clones. diff --git a/ports/geckolib/error_reporter.rs b/ports/geckolib/error_reporter.rs index 7e59f416ff2..3faddf7dcd2 100644 --- a/ports/geckolib/error_reporter.rs +++ b/ports/geckolib/error_reporter.rs @@ -14,7 +14,7 @@ use std::ptr; use style::error_reporting::{ParseErrorReporter, ContextualParseError}; use style::gecko_bindings::bindings::{Gecko_CreateCSSErrorReporter, Gecko_DestroyCSSErrorReporter}; use style::gecko_bindings::bindings::Gecko_ReportUnexpectedCSSError; -use style::gecko_bindings::structs::{Loader, ServoStyleSheet, nsIURI}; +use style::gecko_bindings::structs::{Loader, StyleSheet as DomStyleSheet, nsIURI}; use style::gecko_bindings::structs::ErrorReporter as GeckoErrorReporter; use style::gecko_bindings::structs::URLExtraData as RawUrlExtraData; use style::stylesheets::UrlExtraData; @@ -27,9 +27,11 @@ pub struct ErrorReporter(*mut GeckoErrorReporter); impl ErrorReporter { /// Create a new instance of the Gecko error reporter. - pub fn new(sheet: *mut ServoStyleSheet, - loader: *mut Loader, - extra_data: *mut RawUrlExtraData) -> ErrorReporter { + pub fn new( + sheet: *mut DomStyleSheet, + loader: *mut Loader, + extra_data: *mut RawUrlExtraData, + ) -> Self { unsafe { let url = extra_data.as_ref() .map(|d| d.mBaseURI.raw::()) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 96c93209340..0b0ca198806 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -92,7 +92,7 @@ use style::gecko_bindings::structs; use style::gecko_bindings::structs::{CallerType, CSSPseudoElementType, CompositeOperation}; use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets}; use style::gecko_bindings::structs::{RawServoStyleRule, ComputedStyleStrong, RustString}; -use style::gecko_bindings::structs::{ServoStyleSheet, SheetLoadData, SheetLoadDataHolder}; +use style::gecko_bindings::structs::{StyleSheet as DomStyleSheet, SheetLoadData, SheetLoadDataHolder}; use style::gecko_bindings::structs::{SheetParsingMode, nsAtom, nsCSSPropertyID}; use style::gecko_bindings::structs::{nsCSSFontDesc, nsCSSCounterDesc}; use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair}; @@ -1194,7 +1194,7 @@ fn mode_to_origin(mode: SheetParsingMode) -> Origin { #[no_mangle] pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes( loader: *mut Loader, - stylesheet: *mut ServoStyleSheet, + stylesheet: *mut DomStyleSheet, load_data: *mut SheetLoadData, bytes: *const nsACString, mode: SheetParsingMode, @@ -1263,7 +1263,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8BytesAsync( #[no_mangle] pub extern "C" fn Servo_StyleSet_AppendStyleSheet( raw_data: RawServoStyleSetBorrowed, - sheet: *const ServoStyleSheet, + sheet: *const DomStyleSheet, ) { let global_style_data = &*GLOBAL_STYLE_DATA; let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); @@ -1288,7 +1288,7 @@ pub extern "C" fn Servo_AuthorStyles_Drop( #[no_mangle] pub unsafe extern "C" fn Servo_AuthorStyles_AppendStyleSheet( styles: RawServoAuthorStylesBorrowedMut, - sheet: *const ServoStyleSheet, + sheet: *const DomStyleSheet, ) { let styles = AuthorStyles::::from_ffi_mut(styles); @@ -1301,8 +1301,8 @@ pub unsafe extern "C" fn Servo_AuthorStyles_AppendStyleSheet( #[no_mangle] pub unsafe extern "C" fn Servo_AuthorStyles_InsertStyleSheetBefore( styles: RawServoAuthorStylesBorrowedMut, - sheet: *const ServoStyleSheet, - before_sheet: *const ServoStyleSheet, + sheet: *const DomStyleSheet, + before_sheet: *const DomStyleSheet, ) { let styles = AuthorStyles::::from_ffi_mut(styles); @@ -1319,7 +1319,7 @@ pub unsafe extern "C" fn Servo_AuthorStyles_InsertStyleSheetBefore( #[no_mangle] pub unsafe extern "C" fn Servo_AuthorStyles_RemoveStyleSheet( styles: RawServoAuthorStylesBorrowedMut, - sheet: *const ServoStyleSheet, + sheet: *const DomStyleSheet, ) { let styles = AuthorStyles::::from_ffi_mut(styles); @@ -1454,7 +1454,7 @@ pub unsafe extern "C" fn Servo_StyleSet_MediumFeaturesChanged( #[no_mangle] pub extern "C" fn Servo_StyleSet_PrependStyleSheet( raw_data: RawServoStyleSetBorrowed, - sheet: *const ServoStyleSheet, + sheet: *const DomStyleSheet, ) { let global_style_data = &*GLOBAL_STYLE_DATA; let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); @@ -1467,8 +1467,8 @@ pub extern "C" fn Servo_StyleSet_PrependStyleSheet( #[no_mangle] pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore( raw_data: RawServoStyleSetBorrowed, - sheet: *const ServoStyleSheet, - before_sheet: *const ServoStyleSheet + sheet: *const DomStyleSheet, + before_sheet: *const DomStyleSheet ) { let global_style_data = &*GLOBAL_STYLE_DATA; let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); @@ -1485,7 +1485,7 @@ pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore( #[no_mangle] pub extern "C" fn Servo_StyleSet_RemoveStyleSheet( raw_data: RawServoStyleSetBorrowed, - sheet: *const ServoStyleSheet + sheet: *const DomStyleSheet ) { let global_style_data = &*GLOBAL_STYLE_DATA; let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); @@ -1560,7 +1560,7 @@ pub extern "C" fn Servo_StyleSheet_GetRules( #[no_mangle] pub extern "C" fn Servo_StyleSheet_Clone( raw_sheet: RawServoStyleSheetContentsBorrowed, - reference_sheet: *const ServoStyleSheet, + reference_sheet: *const DomStyleSheet, ) -> RawServoStyleSheetContentsStrong { use style::shared_lock::{DeepCloneParams, DeepCloneWithLock}; let global_style_data = &*GLOBAL_STYLE_DATA; @@ -1681,7 +1681,7 @@ pub extern "C" fn Servo_CssRules_InsertRule( index: u32, nested: bool, loader: *mut Loader, - gecko_stylesheet: *mut ServoStyleSheet, + gecko_stylesheet: *mut DomStyleSheet, rule_type: *mut u16, ) -> nsresult { let loader = if loader.is_null() { @@ -2136,16 +2136,16 @@ pub extern "C" fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, res #[no_mangle] pub extern "C" fn Servo_ImportRule_GetSheet( rule: RawServoImportRuleBorrowed, -) -> *const ServoStyleSheet { +) -> *const DomStyleSheet { read_locked_arc(rule, |rule: &ImportRule| { - rule.stylesheet.as_sheet().unwrap().raw() as *const ServoStyleSheet + rule.stylesheet.as_sheet().unwrap().raw() as *const DomStyleSheet }) } #[no_mangle] pub extern "C" fn Servo_ImportRule_SetSheet( rule: RawServoImportRuleBorrowed, - sheet: *mut ServoStyleSheet, + sheet: *mut DomStyleSheet, ) { write_locked_arc(rule, |rule: &mut ImportRule| { let sheet = unsafe { GeckoStyleSheet::new(sheet) }; diff --git a/ports/geckolib/stylesheet_loader.rs b/ports/geckolib/stylesheet_loader.rs index 0c320fee897..7ed1db57bc3 100644 --- a/ports/geckolib/stylesheet_loader.rs +++ b/ports/geckolib/stylesheet_loader.rs @@ -12,7 +12,7 @@ use style::gecko::global_style_data::GLOBAL_STYLE_DATA; use style::gecko_bindings::bindings; use style::gecko_bindings::bindings::Gecko_LoadStyleSheet; use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets}; -use style::gecko_bindings::structs::{ServoStyleSheet, SheetLoadData, SheetLoadDataHolder}; +use style::gecko_bindings::structs::{StyleSheet as DomStyleSheet, SheetLoadData, SheetLoadDataHolder}; use style::gecko_bindings::structs::URLExtraData; use style::gecko_bindings::sugar::ownership::FFIArcHelpers; use style::gecko_bindings::sugar::refptr::RefPtr; @@ -24,13 +24,15 @@ use style::stylesheets::StylesheetContents; use style::stylesheets::import_rule::ImportSheet; use style::values::CssUrl; -pub struct StylesheetLoader(*mut Loader, *mut ServoStyleSheet, *mut SheetLoadData, *mut LoaderReusableStyleSheets); +pub struct StylesheetLoader(*mut Loader, *mut DomStyleSheet, *mut SheetLoadData, *mut LoaderReusableStyleSheets); impl StylesheetLoader { - pub fn new(loader: *mut Loader, - parent: *mut ServoStyleSheet, - parent_load_data: *mut SheetLoadData, - reusable_sheets: *mut LoaderReusableStyleSheets) -> Self { + pub fn new( + loader: *mut Loader, + parent: *mut DomStyleSheet, + parent_load_data: *mut SheetLoadData, + reusable_sheets: *mut LoaderReusableStyleSheets, + ) -> Self { StylesheetLoader(loader, parent, parent_load_data, reusable_sheets) } }