Skip to content

Commit

Permalink
Rename nsIAtom as nsAtom.
Browse files Browse the repository at this point in the history
Bug 1400459 devirtualized nsIAtom so that it is no longer a subclass of
nsISupports. This means that nsAtom is now a better name for it than
nsIAtom.
  • Loading branch information
nnethercote committed Oct 8, 2017
1 parent 55a3793 commit 7628c12
Show file tree
Hide file tree
Showing 12 changed files with 12,752 additions and 12,752 deletions.
25,004 changes: 12,502 additions & 12,502 deletions components/style/gecko/generated/atom_macro.rs

Large diffs are not rendered by default.

148 changes: 74 additions & 74 deletions components/style/gecko/generated/bindings.rs

Large diffs are not rendered by default.

Expand Up @@ -867,7 +867,7 @@ None
}

/// Get a PseudoInfo for a pseudo
pub fn pseudo_info(&self) -> (*mut structs::nsIAtom, CSSPseudoElementType) {
pub fn pseudo_info(&self) -> (*mut structs::nsAtom, CSSPseudoElementType) {
(self.atom().as_ptr(), self.pseudo_type())
}

Expand Down
254 changes: 127 additions & 127 deletions components/style/gecko/generated/structs.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/style/gecko/pseudo_element_definition.mako.rs
Expand Up @@ -143,7 +143,7 @@ impl PseudoElement {
}

/// Get a PseudoInfo for a pseudo
pub fn pseudo_info(&self) -> (*mut structs::nsIAtom, CSSPseudoElementType) {
pub fn pseudo_info(&self) -> (*mut structs::nsAtom, CSSPseudoElementType) {
(self.atom().as_ptr(), self.pseudo_type())
}

Expand Down
10 changes: 5 additions & 5 deletions components/style/gecko/regen_atoms.py
Expand Up @@ -42,14 +42,14 @@ class GkAtomSource:
PATTERN = re.compile('^(GK_ATOM)\((.+),\s*"(.*)"\)')
FILE = "include/nsGkAtomList.h"
CLASS = "nsGkAtoms"
TYPE = "nsIAtom"
TYPE = "nsAtom"


class CSSPseudoElementsAtomSource:
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\((.+),\s*"(.*)",')
FILE = "include/nsCSSPseudoElementList.h"
CLASS = "nsCSSPseudoElements"
# NB: nsICSSPseudoElement is effectively the same as a nsIAtom, but we need
# NB: nsICSSPseudoElement is effectively the same as a nsAtom, but we need
# this for MSVC name mangling.
TYPE = "nsICSSPseudoElement"

Expand Down Expand Up @@ -163,14 +163,14 @@ def __exit__(self, type, value, traceback):
self.close()


IMPORTS = ("\nuse gecko_bindings::structs::nsIAtom;"
IMPORTS = ("\nuse gecko_bindings::structs::nsAtom;"
"\nuse string_cache::Atom;\n\n")

ATOM_TEMPLATE = (" #[link_name = \"{link_name}\"]\n"
" pub static {name}: *mut {type};")

UNSAFE_STATIC = ("#[inline(always)]\n"
"pub unsafe fn atom_from_static(ptr: *mut nsIAtom) -> Atom {\n"
"pub unsafe fn atom_from_static(ptr: *mut nsAtom) -> Atom {\n"
" Atom::from_static(ptr)\n"
"}\n\n")

Expand Down Expand Up @@ -220,7 +220,7 @@ def get_symbols(func):
f.write(IMPORTS)

for source in SOURCES:
if source.TYPE != "nsIAtom":
if source.TYPE != "nsAtom":
f.write("pub enum {} {{}}\n\n".format(source.TYPE))

f.write(UNSAFE_STATIC)
Expand Down
12 changes: 6 additions & 6 deletions components/style/gecko/snapshot_helpers.rs
Expand Up @@ -5,15 +5,15 @@
//! Element an snapshot common logic.

use CaseSensitivityExt;
use gecko_bindings::structs::nsIAtom;
use gecko_bindings::structs::nsAtom;
use gecko_string_cache::WeakAtom;
use selectors::attr::CaseSensitivity;
use std::{ptr, slice};
use string_cache::Atom;

/// A function that, given an element of type `T`, allows you to get a single
/// class or a class list.
pub type ClassOrClassList<T> = unsafe extern fn (T, *mut *mut nsIAtom, *mut *mut *mut nsIAtom) -> u32;
pub type ClassOrClassList<T> = unsafe extern fn (T, *mut *mut nsAtom, *mut *mut *mut nsAtom) -> u32;

/// Given an item `T`, a class name, and a getter function, return whether that
/// element has the class that `name` represents.
Expand All @@ -23,8 +23,8 @@ pub fn has_class<T>(item: T,
getter: ClassOrClassList<T>) -> bool
{
unsafe {
let mut class: *mut nsIAtom = ptr::null_mut();
let mut list: *mut *mut nsIAtom = ptr::null_mut();
let mut class: *mut nsAtom = ptr::null_mut();
let mut list: *mut *mut nsAtom = ptr::null_mut();
let length = getter(item, &mut class, &mut list);
match length {
0 => false,
Expand All @@ -46,8 +46,8 @@ pub fn each_class<F, T>(item: T,
where F: FnMut(&Atom)
{
unsafe {
let mut class: *mut nsIAtom = ptr::null_mut();
let mut list: *mut *mut nsIAtom = ptr::null_mut();
let mut class: *mut nsAtom = ptr::null_mut();
let mut list: *mut *mut nsAtom = ptr::null_mut();
let length = getter(item, &mut class, &mut list);
match length {
0 => {}
Expand Down
6 changes: 3 additions & 3 deletions components/style/gecko/wrapper.rs
Expand Up @@ -54,7 +54,7 @@ use gecko_bindings::bindings::Gecko_UnsetDirtyStyleAttr;
use gecko_bindings::bindings::Gecko_UpdateAnimations;
use gecko_bindings::structs;
use gecko_bindings::structs::{RawGeckoElement, RawGeckoNode, RawGeckoXBLBinding};
use gecko_bindings::structs::{nsIAtom, nsIContent, nsINode_BooleanFlag};
use gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag};
use gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT;
use gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO;
use gecko_bindings::structs::ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO;
Expand Down Expand Up @@ -2065,11 +2065,11 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
/// A few helpers to help with attribute selectors and snapshotting.
pub trait NamespaceConstraintHelpers {
/// Returns the namespace of the selector, or null otherwise.
fn atom_or_null(&self) -> *mut nsIAtom;
fn atom_or_null(&self) -> *mut nsAtom;
}

impl<'a> NamespaceConstraintHelpers for NamespaceConstraint<&'a Namespace> {
fn atom_or_null(&self) -> *mut nsIAtom {
fn atom_or_null(&self) -> *mut nsAtom {
match *self {
NamespaceConstraint::Any => ptr::null_mut(),
NamespaceConstraint::Specific(ref ns) => ns.0.as_ptr(),
Expand Down
34 changes: 17 additions & 17 deletions components/style/gecko_string_cache/mod.rs
Expand Up @@ -4,13 +4,13 @@

#![allow(unsafe_code)]

//! A drop-in replacement for string_cache, but backed by Gecko `nsIAtom`s.
//! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s.

use gecko_bindings::bindings::Gecko_AddRefAtom;
use gecko_bindings::bindings::Gecko_Atomize;
use gecko_bindings::bindings::Gecko_Atomize16;
use gecko_bindings::bindings::Gecko_ReleaseAtom;
use gecko_bindings::structs::{nsIAtom, nsIAtom_AtomKind};
use gecko_bindings::structs::{nsAtom, nsAtom_AtomKind};
use nsstring::{nsAString, nsStr};
use precomputed_hash::PrecomputedHash;
use std::ascii::AsciiExt;
Expand Down Expand Up @@ -46,9 +46,9 @@ pub struct Atom(*mut WeakAtom);
///
/// Only usable as `&'a WeakAtom`,
/// where `'a` is the lifetime of something that holds a strong reference to that atom.
pub struct WeakAtom(nsIAtom);
pub struct WeakAtom(nsAtom);

/// A BorrowedAtom for Gecko is just a weak reference to a `nsIAtom`, that
/// A BorrowedAtom for Gecko is just a weak reference to a `nsAtom`, that
/// hasn't been bumped.
pub type BorrowedAtom<'a> = &'a WeakAtom;

Expand Down Expand Up @@ -92,9 +92,9 @@ unsafe impl Sync for Atom {}
unsafe impl Sync for WeakAtom {}

impl WeakAtom {
/// Construct a `WeakAtom` from a raw `nsIAtom`.
/// Construct a `WeakAtom` from a raw `nsAtom`.
#[inline]
pub unsafe fn new<'a>(atom: *const nsIAtom) -> &'a mut Self {
pub unsafe fn new<'a>(atom: *const nsAtom) -> &'a mut Self {
&mut *(atom as *mut WeakAtom)
}

Expand Down Expand Up @@ -149,7 +149,7 @@ impl WeakAtom {
#[inline]
pub fn is_static(&self) -> bool {
unsafe {
(*self.as_ptr()).mKind() == nsIAtom_AtomKind::StaticAtom as u32
(*self.as_ptr()).mKind() == nsAtom_AtomKind::StaticAtom as u32
}
}

Expand All @@ -169,9 +169,9 @@ impl WeakAtom {

/// Returns the atom as a mutable pointer.
#[inline]
pub fn as_ptr(&self) -> *mut nsIAtom {
let const_ptr: *const nsIAtom = &self.0;
const_ptr as *mut nsIAtom
pub fn as_ptr(&self) -> *mut nsAtom {
let const_ptr: *const nsAtom = &self.0;
const_ptr as *mut nsAtom
}

/// Convert this atom to ASCII lower-case
Expand Down Expand Up @@ -240,7 +240,7 @@ impl fmt::Display for WeakAtom {

impl Atom {
/// Execute a callback with the atom represented by `ptr`.
pub unsafe fn with<F, R>(ptr: *mut nsIAtom, callback: F) -> R where F: FnOnce(&Atom) -> R {
pub unsafe fn with<F, R>(ptr: *mut nsAtom, callback: F) -> R where F: FnOnce(&Atom) -> R {
let atom = Atom(WeakAtom::new(ptr));
let ret = callback(&atom);
mem::forget(atom);
Expand All @@ -254,7 +254,7 @@ impl Atom {
/// that way, now we have sugar for is_static, creating atoms using
/// Atom::from should involve almost no overhead.
#[inline]
unsafe fn from_static(ptr: *mut nsIAtom) -> Self {
unsafe fn from_static(ptr: *mut nsAtom) -> Self {
let atom = Atom(ptr as *mut WeakAtom);
debug_assert!(atom.is_static(),
"Called from_static for a non-static atom!");
Expand All @@ -264,16 +264,16 @@ impl Atom {
/// Creates an atom from a dynamic atom pointer that has already had AddRef
/// called on it.
#[inline]
pub unsafe fn from_addrefed(ptr: *mut nsIAtom) -> Self {
pub unsafe fn from_addrefed(ptr: *mut nsAtom) -> Self {
assert!(!ptr.is_null());
unsafe {
Atom(WeakAtom::new(ptr))
}
}

/// Convert this atom into an addrefed nsIAtom pointer.
/// Convert this atom into an addrefed nsAtom pointer.
#[inline]
pub fn into_addrefed(self) -> *mut nsIAtom {
pub fn into_addrefed(self) -> *mut nsAtom {
let ptr = self.as_ptr();
mem::forget(self);
ptr
Expand Down Expand Up @@ -375,9 +375,9 @@ impl From<String> for Atom {
}
}

impl From<*mut nsIAtom> for Atom {
impl From<*mut nsAtom> for Atom {
#[inline]
fn from(ptr: *mut nsIAtom) -> Atom {
fn from(ptr: *mut nsAtom) -> Atom {
assert!(!ptr.is_null());
unsafe {
let ret = Atom(WeakAtom::new(ptr));
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko_string_cache/namespace.rs
Expand Up @@ -4,7 +4,7 @@

//! A type to represent a namespace.

use gecko_bindings::structs::nsIAtom;
use gecko_bindings::structs::nsAtom;
use precomputed_hash::PrecomputedHash;
use std::borrow::Borrow;
use std::fmt;
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Borrow<WeakNamespace> for Namespace {
impl WeakNamespace {
/// Trivially construct a WeakNamespace.
#[inline]
pub unsafe fn new<'a>(atom: *mut nsIAtom) -> &'a Self {
pub unsafe fn new<'a>(atom: *mut nsAtom) -> &'a Self {
&*(atom as *const WeakNamespace)
}

Expand Down
8 changes: 4 additions & 4 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -175,7 +175,7 @@ impl Clone for ComputedValuesInner {
}
}

type PseudoInfo = (*mut structs::nsIAtom, structs::CSSPseudoElementType);
type PseudoInfo = (*mut structs::nsAtom, structs::CSSPseudoElementType);
type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;

impl ComputedValuesInner {
Expand Down Expand Up @@ -220,7 +220,7 @@ impl ComputedValuesInner {
pres_context: bindings::RawGeckoPresContextBorrowed,
parent: ParentStyleContextInfo,
pseudo_ty: structs::CSSPseudoElementType,
pseudo_tag: *mut structs::nsIAtom
pseudo_tag: *mut structs::nsAtom
) -> Arc<ComputedValues> {
let arc = unsafe {
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
Expand Down Expand Up @@ -3456,15 +3456,15 @@ fn static_assert() {

pub fn clone_will_change(&self) -> longhands::will_change::computed_value::T {
use properties::longhands::will_change::computed_value::T;
use gecko_bindings::structs::nsIAtom;
use gecko_bindings::structs::nsAtom;
use values::CustomIdent;

if self.gecko.mWillChange.len() == 0 {
T::Auto
} else {
T::AnimateableFeatures(
self.gecko.mWillChange.iter().map(|gecko_atom| {
CustomIdent((gecko_atom.mRawPtr as *mut nsIAtom).into())
CustomIdent((gecko_atom.mRawPtr as *mut nsAtom).into())
}).collect()
)
}
Expand Down
20 changes: 10 additions & 10 deletions ports/geckolib/glue.rs
Expand Up @@ -80,7 +80,7 @@ use style::gecko_bindings::structs;
use style::gecko_bindings::structs::{CSSPseudoElementType, CompositeOperation};
use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets};
use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleContextStrong, RustString};
use style::gecko_bindings::structs::{ServoStyleSheet, SheetParsingMode, nsIAtom, nsCSSPropertyID};
use style::gecko_bindings::structs::{ServoStyleSheet, SheetParsingMode, nsAtom, nsCSSPropertyID};
use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
use style::gecko_bindings::structs::IterationCompositeOperation;
Expand Down Expand Up @@ -1589,12 +1589,12 @@ pub extern "C" fn Servo_Keyframe_SetStyle(keyframe: RawServoKeyframeBorrowed,
}

#[no_mangle]
pub extern "C" fn Servo_KeyframesRule_GetName(rule: RawServoKeyframesRuleBorrowed) -> *mut nsIAtom {
pub extern "C" fn Servo_KeyframesRule_GetName(rule: RawServoKeyframesRuleBorrowed) -> *mut nsAtom {
read_locked_arc(rule, |rule: &KeyframesRule| rule.name.as_atom().as_ptr())
}

#[no_mangle]
pub extern "C" fn Servo_KeyframesRule_SetName(rule: RawServoKeyframesRuleBorrowed, name: *mut nsIAtom) {
pub extern "C" fn Servo_KeyframesRule_SetName(rule: RawServoKeyframesRuleBorrowed, name: *mut nsAtom) {
write_locked_arc(rule, |rule: &mut KeyframesRule| {
rule.name = KeyframesName::Ident(CustomIdent(unsafe { Atom::from_addrefed(name) }));
})
Expand Down Expand Up @@ -1665,14 +1665,14 @@ pub extern "C" fn Servo_MediaRule_GetMedia(rule: RawServoMediaRuleBorrowed) -> R
}

#[no_mangle]
pub extern "C" fn Servo_NamespaceRule_GetPrefix(rule: RawServoNamespaceRuleBorrowed) -> *mut nsIAtom {
pub extern "C" fn Servo_NamespaceRule_GetPrefix(rule: RawServoNamespaceRuleBorrowed) -> *mut nsAtom {
read_locked_arc(rule, |rule: &NamespaceRule| {
rule.prefix.as_ref().unwrap_or(&atom!("")).as_ptr()
})
}

#[no_mangle]
pub extern "C" fn Servo_NamespaceRule_GetURI(rule: RawServoNamespaceRuleBorrowed) -> *mut nsIAtom {
pub extern "C" fn Servo_NamespaceRule_GetURI(rule: RawServoNamespaceRuleBorrowed) -> *mut nsAtom {
read_locked_arc(rule, |rule: &NamespaceRule| rule.url.0.as_ptr())
}

Expand Down Expand Up @@ -1726,7 +1726,7 @@ pub extern "C" fn Servo_FontFeatureValuesRule_GetValueText(rule: RawServoFontFea

#[no_mangle]
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoStyleContextBorrowedOrNull,
pseudo_tag: *mut nsIAtom,
pseudo_tag: *mut nsAtom,
raw_data: RawServoStyleSetBorrowed)
-> ServoStyleContextStrong {
let global_style_data = &*GLOBAL_STYLE_DATA;
Expand Down Expand Up @@ -1981,7 +1981,7 @@ fn get_pseudo_style(
#[no_mangle]
pub extern "C" fn Servo_ComputedValues_Inherit(
raw_data: RawServoStyleSetBorrowed,
pseudo_tag: *mut nsIAtom,
pseudo_tag: *mut nsAtom,
parent_style_context: ServoStyleContextBorrowedOrNull,
target: structs::InheritTarget
) -> ServoStyleContextStrong {
Expand Down Expand Up @@ -2662,7 +2662,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(declarations:
property:
nsCSSPropertyID,
value:
*mut nsIAtom) {
*mut nsAtom) {
use style::properties::{PropertyDeclaration, LonghandId};
use style::properties::longhands::_x_lang::computed_value::T as Lang;

Expand Down Expand Up @@ -3821,7 +3821,7 @@ pub extern "C" fn Servo_StyleSet_GetFontFaceRules(raw_data: RawServoStyleSetBorr

#[no_mangle]
pub extern "C" fn Servo_StyleSet_GetCounterStyleRule(raw_data: RawServoStyleSetBorrowed,
name: *mut nsIAtom) -> *mut nsCSSCounterStyleRule {
name: *mut nsAtom) -> *mut nsCSSCounterStyleRule {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();

unsafe {
Expand Down Expand Up @@ -3925,7 +3925,7 @@ pub extern "C" fn Servo_UACache_AddSizeOf(
pub extern "C" fn Servo_StyleSet_MightHaveAttributeDependency(
raw_data: RawServoStyleSetBorrowed,
element: RawGeckoElementBorrowed,
local_name: *mut nsIAtom,
local_name: *mut nsAtom,
) -> bool {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let element = GeckoElement(element);
Expand Down

0 comments on commit 7628c12

Please sign in to comment.