style: Remove ServoStyleSheet usage.

Bug: 1457920
Reviewed-by: xidorn
MozReview-Commit-ID: LIBkovuQ6MB
This commit is contained in:
Emilio Cobos Álvarez 2018-04-30 19:23:14 +02:00
parent 9ed48952f5
commit 9d721072f5
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 39 additions and 35 deletions

View file

@ -8,7 +8,7 @@ use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use context::QuirksMode; use context::QuirksMode;
use dom::TElement; use dom::TElement;
use gecko_bindings::bindings::{self, RawServoStyleSet}; 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::structs::{StyleSheetInfo, nsIDocument};
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::media_queries::{MediaListKey, ToMediaListKey}; use invalidation::media_queries::{MediaListKey, ToMediaListKey};
@ -23,7 +23,7 @@ use stylist::Stylist;
/// Little wrapper to a Gecko style sheet. /// Little wrapper to a Gecko style sheet.
#[derive(Debug, Eq, PartialEq)] #[derive(Debug, Eq, PartialEq)]
pub struct GeckoStyleSheet(*const ServoStyleSheet); pub struct GeckoStyleSheet(*const DomStyleSheet);
impl ToMediaListKey for ::gecko::data::GeckoStyleSheet { impl ToMediaListKey for ::gecko::data::GeckoStyleSheet {
fn to_media_list_key(&self) -> MediaListKey { fn to_media_list_key(&self) -> MediaListKey {
@ -33,24 +33,24 @@ impl ToMediaListKey for ::gecko::data::GeckoStyleSheet {
} }
impl GeckoStyleSheet { impl GeckoStyleSheet {
/// Create a `GeckoStyleSheet` from a raw `ServoStyleSheet` pointer. /// Create a `GeckoStyleSheet` from a raw `DomStyleSheet` pointer.
#[inline] #[inline]
pub unsafe fn new(s: *const ServoStyleSheet) -> Self { pub unsafe fn new(s: *const DomStyleSheet) -> Self {
debug_assert!(!s.is_null()); debug_assert!(!s.is_null());
bindings::Gecko_StyleSheet_AddRef(s); bindings::Gecko_StyleSheet_AddRef(s);
Self::from_addrefed(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. /// already holds a strong reference.
#[inline] #[inline]
pub unsafe fn from_addrefed(s: *const ServoStyleSheet) -> Self { pub unsafe fn from_addrefed(s: *const DomStyleSheet) -> Self {
debug_assert!(!s.is_null()); debug_assert!(!s.is_null());
GeckoStyleSheet(s) GeckoStyleSheet(s)
} }
/// Get the raw `ServoStyleSheet` that we're wrapping. /// Get the raw `StyleSheet` that we're wrapping.
pub fn raw(&self) -> &ServoStyleSheet { pub fn raw(&self) -> &DomStyleSheet {
unsafe { &*self.0 } unsafe { &*self.0 }
} }

View file

@ -237,7 +237,7 @@ pub trait ToCssWithGuard {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub struct DeepCloneParams { pub struct DeepCloneParams {
/// The new sheet we're cloning rules into. /// 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. /// Parameters needed for deep clones.

View file

@ -14,7 +14,7 @@ use std::ptr;
use style::error_reporting::{ParseErrorReporter, ContextualParseError}; use style::error_reporting::{ParseErrorReporter, ContextualParseError};
use style::gecko_bindings::bindings::{Gecko_CreateCSSErrorReporter, Gecko_DestroyCSSErrorReporter}; use style::gecko_bindings::bindings::{Gecko_CreateCSSErrorReporter, Gecko_DestroyCSSErrorReporter};
use style::gecko_bindings::bindings::Gecko_ReportUnexpectedCSSError; 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::ErrorReporter as GeckoErrorReporter;
use style::gecko_bindings::structs::URLExtraData as RawUrlExtraData; use style::gecko_bindings::structs::URLExtraData as RawUrlExtraData;
use style::stylesheets::UrlExtraData; use style::stylesheets::UrlExtraData;
@ -27,9 +27,11 @@ pub struct ErrorReporter(*mut GeckoErrorReporter);
impl ErrorReporter { impl ErrorReporter {
/// Create a new instance of the Gecko error reporter. /// Create a new instance of the Gecko error reporter.
pub fn new(sheet: *mut ServoStyleSheet, pub fn new(
sheet: *mut DomStyleSheet,
loader: *mut Loader, loader: *mut Loader,
extra_data: *mut RawUrlExtraData) -> ErrorReporter { extra_data: *mut RawUrlExtraData,
) -> Self {
unsafe { unsafe {
let url = extra_data.as_ref() let url = extra_data.as_ref()
.map(|d| d.mBaseURI.raw::<nsIURI>()) .map(|d| d.mBaseURI.raw::<nsIURI>())

View file

@ -92,7 +92,7 @@ use style::gecko_bindings::structs;
use style::gecko_bindings::structs::{CallerType, CSSPseudoElementType, CompositeOperation}; use style::gecko_bindings::structs::{CallerType, CSSPseudoElementType, CompositeOperation};
use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets}; use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets};
use style::gecko_bindings::structs::{RawServoStyleRule, ComputedStyleStrong, RustString}; 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::{SheetParsingMode, nsAtom, nsCSSPropertyID};
use style::gecko_bindings::structs::{nsCSSFontDesc, nsCSSCounterDesc}; use style::gecko_bindings::structs::{nsCSSFontDesc, nsCSSCounterDesc};
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair}; use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
@ -1194,7 +1194,7 @@ fn mode_to_origin(mode: SheetParsingMode) -> Origin {
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes( pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
loader: *mut Loader, loader: *mut Loader,
stylesheet: *mut ServoStyleSheet, stylesheet: *mut DomStyleSheet,
load_data: *mut SheetLoadData, load_data: *mut SheetLoadData,
bytes: *const nsACString, bytes: *const nsACString,
mode: SheetParsingMode, mode: SheetParsingMode,
@ -1263,7 +1263,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8BytesAsync(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSet_AppendStyleSheet( pub extern "C" fn Servo_StyleSet_AppendStyleSheet(
raw_data: RawServoStyleSetBorrowed, raw_data: RawServoStyleSetBorrowed,
sheet: *const ServoStyleSheet, sheet: *const DomStyleSheet,
) { ) {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
@ -1288,7 +1288,7 @@ pub extern "C" fn Servo_AuthorStyles_Drop(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn Servo_AuthorStyles_AppendStyleSheet( pub unsafe extern "C" fn Servo_AuthorStyles_AppendStyleSheet(
styles: RawServoAuthorStylesBorrowedMut, styles: RawServoAuthorStylesBorrowedMut,
sheet: *const ServoStyleSheet, sheet: *const DomStyleSheet,
) { ) {
let styles = AuthorStyles::<GeckoStyleSheet>::from_ffi_mut(styles); let styles = AuthorStyles::<GeckoStyleSheet>::from_ffi_mut(styles);
@ -1301,8 +1301,8 @@ pub unsafe extern "C" fn Servo_AuthorStyles_AppendStyleSheet(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn Servo_AuthorStyles_InsertStyleSheetBefore( pub unsafe extern "C" fn Servo_AuthorStyles_InsertStyleSheetBefore(
styles: RawServoAuthorStylesBorrowedMut, styles: RawServoAuthorStylesBorrowedMut,
sheet: *const ServoStyleSheet, sheet: *const DomStyleSheet,
before_sheet: *const ServoStyleSheet, before_sheet: *const DomStyleSheet,
) { ) {
let styles = AuthorStyles::<GeckoStyleSheet>::from_ffi_mut(styles); let styles = AuthorStyles::<GeckoStyleSheet>::from_ffi_mut(styles);
@ -1319,7 +1319,7 @@ pub unsafe extern "C" fn Servo_AuthorStyles_InsertStyleSheetBefore(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn Servo_AuthorStyles_RemoveStyleSheet( pub unsafe extern "C" fn Servo_AuthorStyles_RemoveStyleSheet(
styles: RawServoAuthorStylesBorrowedMut, styles: RawServoAuthorStylesBorrowedMut,
sheet: *const ServoStyleSheet, sheet: *const DomStyleSheet,
) { ) {
let styles = AuthorStyles::<GeckoStyleSheet>::from_ffi_mut(styles); let styles = AuthorStyles::<GeckoStyleSheet>::from_ffi_mut(styles);
@ -1454,7 +1454,7 @@ pub unsafe extern "C" fn Servo_StyleSet_MediumFeaturesChanged(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSet_PrependStyleSheet( pub extern "C" fn Servo_StyleSet_PrependStyleSheet(
raw_data: RawServoStyleSetBorrowed, raw_data: RawServoStyleSetBorrowed,
sheet: *const ServoStyleSheet, sheet: *const DomStyleSheet,
) { ) {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
@ -1467,8 +1467,8 @@ pub extern "C" fn Servo_StyleSet_PrependStyleSheet(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore( pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(
raw_data: RawServoStyleSetBorrowed, raw_data: RawServoStyleSetBorrowed,
sheet: *const ServoStyleSheet, sheet: *const DomStyleSheet,
before_sheet: *const ServoStyleSheet before_sheet: *const DomStyleSheet
) { ) {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
@ -1485,7 +1485,7 @@ pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSet_RemoveStyleSheet( pub extern "C" fn Servo_StyleSet_RemoveStyleSheet(
raw_data: RawServoStyleSetBorrowed, raw_data: RawServoStyleSetBorrowed,
sheet: *const ServoStyleSheet sheet: *const DomStyleSheet
) { ) {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
@ -1560,7 +1560,7 @@ pub extern "C" fn Servo_StyleSheet_GetRules(
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSheet_Clone( pub extern "C" fn Servo_StyleSheet_Clone(
raw_sheet: RawServoStyleSheetContentsBorrowed, raw_sheet: RawServoStyleSheetContentsBorrowed,
reference_sheet: *const ServoStyleSheet, reference_sheet: *const DomStyleSheet,
) -> RawServoStyleSheetContentsStrong { ) -> RawServoStyleSheetContentsStrong {
use style::shared_lock::{DeepCloneParams, DeepCloneWithLock}; use style::shared_lock::{DeepCloneParams, DeepCloneWithLock};
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;
@ -1681,7 +1681,7 @@ pub extern "C" fn Servo_CssRules_InsertRule(
index: u32, index: u32,
nested: bool, nested: bool,
loader: *mut Loader, loader: *mut Loader,
gecko_stylesheet: *mut ServoStyleSheet, gecko_stylesheet: *mut DomStyleSheet,
rule_type: *mut u16, rule_type: *mut u16,
) -> nsresult { ) -> nsresult {
let loader = if loader.is_null() { let loader = if loader.is_null() {
@ -2136,16 +2136,16 @@ pub extern "C" fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, res
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_ImportRule_GetSheet( pub extern "C" fn Servo_ImportRule_GetSheet(
rule: RawServoImportRuleBorrowed, rule: RawServoImportRuleBorrowed,
) -> *const ServoStyleSheet { ) -> *const DomStyleSheet {
read_locked_arc(rule, |rule: &ImportRule| { 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] #[no_mangle]
pub extern "C" fn Servo_ImportRule_SetSheet( pub extern "C" fn Servo_ImportRule_SetSheet(
rule: RawServoImportRuleBorrowed, rule: RawServoImportRuleBorrowed,
sheet: *mut ServoStyleSheet, sheet: *mut DomStyleSheet,
) { ) {
write_locked_arc(rule, |rule: &mut ImportRule| { write_locked_arc(rule, |rule: &mut ImportRule| {
let sheet = unsafe { GeckoStyleSheet::new(sheet) }; let sheet = unsafe { GeckoStyleSheet::new(sheet) };

View file

@ -12,7 +12,7 @@ use style::gecko::global_style_data::GLOBAL_STYLE_DATA;
use style::gecko_bindings::bindings; use style::gecko_bindings::bindings;
use style::gecko_bindings::bindings::Gecko_LoadStyleSheet; use style::gecko_bindings::bindings::Gecko_LoadStyleSheet;
use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets}; 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::structs::URLExtraData;
use style::gecko_bindings::sugar::ownership::FFIArcHelpers; use style::gecko_bindings::sugar::ownership::FFIArcHelpers;
use style::gecko_bindings::sugar::refptr::RefPtr; use style::gecko_bindings::sugar::refptr::RefPtr;
@ -24,13 +24,15 @@ use style::stylesheets::StylesheetContents;
use style::stylesheets::import_rule::ImportSheet; use style::stylesheets::import_rule::ImportSheet;
use style::values::CssUrl; 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 { impl StylesheetLoader {
pub fn new(loader: *mut Loader, pub fn new(
parent: *mut ServoStyleSheet, loader: *mut Loader,
parent: *mut DomStyleSheet,
parent_load_data: *mut SheetLoadData, parent_load_data: *mut SheetLoadData,
reusable_sheets: *mut LoaderReusableStyleSheets) -> Self { reusable_sheets: *mut LoaderReusableStyleSheets,
) -> Self {
StylesheetLoader(loader, parent, parent_load_data, reusable_sheets) StylesheetLoader(loader, parent, parent_load_data, reusable_sheets)
} }
} }