From 7019d425230326fe6a1398b3c4639249e3d2afba Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 27 Sep 2017 12:40:31 +1000 Subject: [PATCH] Devirtualize nsIAtom. --- components/style/gecko/media_queries.rs | 3 +-- components/style/properties/gecko.mako.rs | 16 +++++++--------- .../style/properties/longhand/font.mako.rs | 5 ++--- components/style/stylist.rs | 4 ++-- components/style/values/specified/font.rs | 3 +-- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 130651cbd72..394cd5c1833 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -18,7 +18,6 @@ use gecko_bindings::structs::{nsCSSKeyword, nsCSSProps_KTableEntry, nsCSSValue, use gecko_bindings::structs::{nsMediaExpression_Range, nsMediaFeature}; use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType, nsMediaFeature_RequirementFlags}; use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned}; -use gecko_bindings::structs::nsIAtom; use media_queries::MediaType; use parser::ParserContext; use properties::{ComputedValues, StyleBuilder}; @@ -165,7 +164,7 @@ impl Device { // mMediaEmulated. let context = self.pres_context(); let medium_to_use = if context.mIsEmulatingMedia() != 0 { - context.mMediaEmulated.raw::() + context.mMediaEmulated.mRawPtr } else { context.mMedium }; diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index fece19bb10e..eef9fc89a59 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -124,7 +124,7 @@ impl ComputedValues { pub fn pseudo(&self) -> Option { use string_cache::Atom; - let atom = (self.0)._base.mPseudoTag.raw::(); + let atom = (self.0)._base.mPseudoTag.mRawPtr; if atom.is_null() { return None; } @@ -3235,11 +3235,10 @@ fn static_assert() { use gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_no_properties; use gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_variable; use gecko_bindings::structs::nsCSSPropertyID::eCSSProperty_UNKNOWN; - use gecko_bindings::structs::nsIAtom; let property = self.gecko.mTransitions[index].mProperty; if property == eCSSProperty_UNKNOWN || property == eCSSPropertyExtra_variable { - let atom = self.gecko.mTransitions[index].mUnknownProperty.raw::(); + let atom = self.gecko.mTransitions[index].mUnknownProperty.mRawPtr; debug_assert!(!atom.is_null()); TransitionProperty::Unsupported(CustomIdent(atom.into())) } else if property == eCSSPropertyExtra_no_properties { @@ -3258,7 +3257,6 @@ fn static_assert() { pub fn copy_transition_property_from(&mut self, other: &Self) { use gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_variable; use gecko_bindings::structs::nsCSSPropertyID::eCSSProperty_UNKNOWN; - use gecko_bindings::structs::nsIAtom; unsafe { self.gecko.mTransitions.ensure_len(other.gecko.mTransitions.len()) }; let count = other.gecko.mTransitionPropertyCount; @@ -3268,7 +3266,7 @@ fn static_assert() { transition.mProperty = other.gecko.mTransitions[index].mProperty; if transition.mProperty == eCSSProperty_UNKNOWN || transition.mProperty == eCSSPropertyExtra_variable { - let atom = other.gecko.mTransitions[index].mUnknownProperty.raw::(); + let atom = other.gecko.mTransitions[index].mUnknownProperty.mRawPtr; debug_assert!(!atom.is_null()); unsafe { Gecko_StyleTransition_SetUnsupportedProperty(transition, atom) }; } @@ -3533,12 +3531,12 @@ fn static_assert() { use gecko_bindings::structs::nsIAtom; use values::CustomIdent; - if self.gecko.mWillChange.mBuffer.len() == 0 { + if self.gecko.mWillChange.len() == 0 { T::Auto } else { T::AnimateableFeatures( - self.gecko.mWillChange.mBuffer.iter().map(|gecko_atom| { - CustomIdent((*gecko_atom as *mut nsIAtom).into()) + self.gecko.mWillChange.iter().map(|gecko_atom| { + CustomIdent((gecko_atom.mRawPtr as *mut nsIAtom).into()) }).collect() ) } @@ -5161,7 +5159,7 @@ clip-path } else if servo.0 == atom!("stroke-opacity") { self.gecko.mContextPropsBits |= structs::NS_STYLE_CONTEXT_PROPERTY_STROKE_OPACITY as u8; } - unsafe { gecko.set_raw_from_addrefed::(servo.0.into_addrefed()) } + unsafe { gecko.mRawPtr = servo.0.into_addrefed() } } } diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 79ab5ff33db..9cbfd2d088e 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -660,11 +660,10 @@ ${helpers.single_keyword_system("font-variant-caps", // we could use clone_language and clone_font_family() here but that's // expensive. Do it only in gecko mode for now. % if product == "gecko": - use gecko_bindings::structs::nsIAtom; // if the language or generic changed, we need to recalculate // the font size from the stored font-size origin information. - if context.builder.get_font().gecko().mLanguage.raw::() != - context.builder.get_parent_font().gecko().mLanguage.raw::() || + if context.builder.get_font().gecko().mLanguage.mRawPtr != + context.builder.get_parent_font().gecko().mLanguage.mRawPtr || context.builder.get_font().gecko().mGenericID != context.builder.get_parent_font().gecko().mGenericID { if let Some(info) = computed.keyword_info { diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 6b2c47ad992..7e89db40957 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -11,7 +11,7 @@ use dom::TElement; use element_state::ElementState; use font_metrics::FontMetricsProvider; #[cfg(feature = "gecko")] -use gecko_bindings::structs::{nsIAtom, ServoStyleSetSizes, StyleRuleInclusion}; +use gecko_bindings::structs::{ServoStyleSetSizes, StyleRuleInclusion}; use hashglobe::FailedAllocationError; use invalidation::element::invalidation_map::InvalidationMap; use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey}; @@ -1588,7 +1588,7 @@ impl ExtraStyleData { guard: &SharedRwLockReadGuard, rule: &Arc>, ) { - let name = rule.read_with(guard).mName.raw::().into(); + let name = rule.read_with(guard).mName.mRawPtr.into(); self.counter_styles.insert(name, rule.clone()); } diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index 417d2909413..f7ba7af4f12 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -168,7 +168,6 @@ impl ToComputedValue for KeywordSize { type ComputedValue = NonNegativeLength; #[inline] fn to_computed_value(&self, cx: &Context) -> NonNegativeLength { - use gecko_bindings::structs::nsIAtom; use values::specified::length::au_to_int_px; // Data from nsRuleNode.cpp in Gecko // Mapping from base size and HTML size to pixels @@ -194,7 +193,7 @@ impl ToComputedValue for KeywordSize { // XXXManishearth handle quirks mode (bug 1401322) let ref gecko_font = cx.style().get_font().gecko(); - let base_size = unsafe { Atom::with(gecko_font.mLanguage.raw::(), |atom| { + let base_size = unsafe { Atom::with(gecko_font.mLanguage.mRawPtr, |atom| { cx.font_metrics_provider.get_size(atom, gecko_font.mGenericID).0 }) };