Auto merge of #11784 - heycam:atom, r=bholley

Look at nsIAtom.mHash directly rather than call Gecko_HashAtom.

<!-- Please describe your changes on the following line: -->

We hash Gecko-backed atoms pretty often.  Using bindgen to access to the stored hash in nsIAtom helps with perf a little.

r? @bholley

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11784)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-21 16:33:44 -05:00 committed by GitHub
commit bc5a52b328
7 changed files with 9 additions and 10 deletions

View file

@ -35,6 +35,7 @@ use structs::nscolor;
use structs::nsFont;
use structs::FontFamilyList;
use structs::FontFamilyType;
use structs::nsIAtom;
use heapsize::HeapSizeOf;
unsafe impl Send for nsStyleFont {}
unsafe impl Sync for nsStyleFont {}
@ -121,7 +122,6 @@ unsafe impl Send for nsStyleGradientStop {}
unsafe impl Sync for nsStyleGradientStop {}
impl HeapSizeOf for nsStyleGradientStop { fn heap_size_of_children(&self) -> usize { 0 } }
pub enum nsIAtom { }
pub enum nsINode { }
pub type RawGeckoNode = nsINode;
pub enum nsIPrincipal { }

View file

@ -52,7 +52,7 @@ done
# Other mapped types.
for TYPE in SheetParsingMode nsMainThreadPtrHandle nsMainThreadPtrHolder nscolor nsFont \
FontFamilyList FontFamilyType
FontFamilyList FontFamilyType nsIAtom
do
MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-blacklist-type $TYPE "
MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-raw-line 'use structs::$TYPE;' "

View file

@ -10,9 +10,9 @@ use env_logger;
use euclid::Size2D;
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
use gecko_bindings::bindings::{RawServoStyleSet, RawServoStyleSheet, ServoComputedValues, ServoNodeData};
use gecko_bindings::bindings::{ThreadSafePrincipalHolder, ThreadSafeURIHolder, nsIAtom};
use gecko_bindings::bindings::{ThreadSafePrincipalHolder, ThreadSafeURIHolder};
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
use gecko_bindings::structs::SheetParsingMode;
use gecko_bindings::structs::{SheetParsingMode, nsIAtom};
use properties::GeckoComputedValues;
use selector_impl::{GeckoSelectorImpl, PseudoElement, SharedStyleContext, Stylesheet};
use std::marker::PhantomData;

View file

@ -1,4 +1,4 @@
use gecko_bindings::bindings::nsIAtom;
use gecko_bindings::structs::nsIAtom;
use Atom;

View file

@ -10,9 +10,8 @@ use gecko_bindings::bindings::Gecko_AddRefAtom;
use gecko_bindings::bindings::Gecko_AtomEqualsUTF8IgnoreCase;
use gecko_bindings::bindings::Gecko_Atomize;
use gecko_bindings::bindings::Gecko_GetAtomAsUTF16;
use gecko_bindings::bindings::Gecko_HashAtom;
use gecko_bindings::bindings::Gecko_ReleaseAtom;
use gecko_bindings::bindings::nsIAtom;
use gecko_bindings::structs::nsIAtom;
use heapsize::HeapSizeOf;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::borrow::Cow;
@ -100,7 +99,7 @@ unsafe impl Sync for Atom {}
impl Atom {
pub fn get_hash(&self) -> u32 {
unsafe {
Gecko_HashAtom(self.0)
(*self.0).mHash
}
}

View file

@ -24,7 +24,7 @@ with open(objdir_path + "/dist/include/nsGkAtomList.h") as f:
atoms = [line_to_atom(line) for line in lines]
with open("atom_macro.rs", "w") as f:
f.write("use gecko_bindings::bindings::nsIAtom;\n\n")
f.write("use gecko_bindings::structs::nsIAtom;\n\n")
f.write("use Atom;\n\n")
f.write("pub fn unsafe_atom_from_static(ptr: *mut nsIAtom) -> Atom { unsafe { Atom::from_static(ptr) } }\n\n")
for atom in atoms:

View file

@ -9,7 +9,6 @@ use gecko_bindings::bindings::Gecko_ClassOrClassList;
use gecko_bindings::bindings::Gecko_GetElementId;
use gecko_bindings::bindings::Gecko_GetNodeData;
use gecko_bindings::bindings::ServoNodeData;
use gecko_bindings::bindings::nsIAtom;
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetAttrAsUTF8, Gecko_GetDocumentElement};
use gecko_bindings::bindings::{Gecko_GetFirstChild, Gecko_GetFirstChildElement};
use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetLastChildElement};
@ -21,6 +20,7 @@ use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink};
#[allow(unused_imports)] // Used in commented-out code.
use gecko_bindings::bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsElement, Gecko_SetNodeData};
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
use gecko_bindings::structs::nsIAtom;
use libc::uintptr_t;
use properties::GeckoComputedValues;
use selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PrivateStyleData};