Skip to content

Commit

Permalink
Devirtualize nsIAtom.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Sep 27, 2017
1 parent 0160aae commit 7019d42
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
3 changes: 1 addition & 2 deletions components/style/gecko/media_queries.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -165,7 +164,7 @@ impl Device {
// mMediaEmulated.
let context = self.pres_context();
let medium_to_use = if context.mIsEmulatingMedia() != 0 {
context.mMediaEmulated.raw::<nsIAtom>()
context.mMediaEmulated.mRawPtr
} else {
context.mMedium
};
Expand Down
16 changes: 7 additions & 9 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -124,7 +124,7 @@ impl ComputedValues {
pub fn pseudo(&self) -> Option<PseudoElement> {
use string_cache::Atom;

let atom = (self.0)._base.mPseudoTag.raw::<structs::nsIAtom>();
let atom = (self.0)._base.mPseudoTag.mRawPtr;
if atom.is_null() {
return None;
}
Expand Down Expand Up @@ -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::<nsIAtom>();
let atom = self.gecko.mTransitions[index].mUnknownProperty.mRawPtr;
debug_assert!(!atom.is_null());
TransitionProperty::Unsupported(CustomIdent(atom.into()))
} else if property == eCSSPropertyExtra_no_properties {
Expand All @@ -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;
Expand All @@ -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::<nsIAtom>();
let atom = other.gecko.mTransitions[index].mUnknownProperty.mRawPtr;
debug_assert!(!atom.is_null());
unsafe { Gecko_StyleTransition_SetUnsupportedProperty(transition, atom) };
}
Expand Down Expand Up @@ -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()
)
}
Expand Down Expand Up @@ -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::<structs::nsIAtom>(servo.0.into_addrefed()) }
unsafe { gecko.mRawPtr = servo.0.into_addrefed() }
}
}

Expand Down
5 changes: 2 additions & 3 deletions components/style/properties/longhand/font.mako.rs
Expand Up @@ -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::<nsIAtom>() !=
context.builder.get_parent_font().gecko().mLanguage.raw::<nsIAtom>() ||
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 {
Expand Down
4 changes: 2 additions & 2 deletions components/style/stylist.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -1588,7 +1588,7 @@ impl ExtraStyleData {
guard: &SharedRwLockReadGuard,
rule: &Arc<Locked<CounterStyleRule>>,
) {
let name = rule.read_with(guard).mName.raw::<nsIAtom>().into();
let name = rule.read_with(guard).mName.mRawPtr.into();
self.counter_styles.insert(name, rule.clone());
}

Expand Down
3 changes: 1 addition & 2 deletions components/style/values/specified/font.rs
Expand Up @@ -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
Expand All @@ -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::<nsIAtom>(), |atom| {
let base_size = unsafe { Atom::with(gecko_font.mLanguage.mRawPtr, |atom| {
cx.font_metrics_provider.get_size(atom, gecko_font.mGenericID).0
}) };

Expand Down

0 comments on commit 7019d42

Please sign in to comment.