From aeb2b8b0981d98b1158ebf2afb8e40707b041a03 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 24 Jul 2017 10:40:58 -0400 Subject: [PATCH 1/2] stylo: Read mName as a raw nsIAtom* from NodeInfoInner. --- components/style/gecko/wrapper.rs | 2 +- components/style/gecko_string_cache/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index c8028acaee2..1c0208c1c40 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1665,7 +1665,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { fn get_local_name(&self) -> &WeakAtom { unsafe { - WeakAtom::new(self.as_node().node_info().mInner.mName.raw::()) + WeakAtom::new(self.as_node().node_info().mInner.mName) } } diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs index 0adf5c09da1..fed06fbeec5 100644 --- a/components/style/gecko_string_cache/mod.rs +++ b/components/style/gecko_string_cache/mod.rs @@ -94,7 +94,7 @@ unsafe impl Sync for WeakAtom {} impl WeakAtom { /// Construct a `WeakAtom` from a raw `nsIAtom`. #[inline] - pub unsafe fn new<'a>(atom: *mut nsIAtom) -> &'a mut Self { + pub unsafe fn new<'a>(atom: *const nsIAtom) -> &'a mut Self { &mut *(atom as *mut WeakAtom) } From 0e80710ee71d66026c9d45323d1cd19280012c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 24 Jul 2017 22:04:16 +0200 Subject: [PATCH 2/2] style: Update NodeInfo bindings. --- .../style/gecko/generated/structs_debug.rs | 39 ++++++++++++++----- .../style/gecko/generated/structs_release.rs | 39 ++++++++++++++----- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index 5a6c073d0a1..bcdae124f1f 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -4206,19 +4206,21 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] - #[derive(Debug)] + #[derive(Debug, Copy)] pub struct NodeInfo_NodeInfoInner { - pub mName: root::nsCOMPtr, - pub mPrefix: root::nsCOMPtr, + pub mName: *const root::nsIAtom, + pub mPrefix: *mut root::nsIAtom, pub mNamespaceID: i32, pub mNodeType: u16, pub mNameString: *const root::nsAString, - pub mExtraName: root::nsCOMPtr, + pub mExtraName: *mut root::nsIAtom, + pub mHash: root::PLHashNumber, + pub mHashInitialized: bool, } #[test] fn bindgen_test_layout_NodeInfo_NodeInfoInner() { assert_eq!(::std::mem::size_of::() , - 40usize , concat ! ( + 48usize , concat ! ( "Size of: " , stringify ! ( NodeInfo_NodeInfoInner ) )); assert_eq! (::std::mem::align_of::() , @@ -4267,6 +4269,23 @@ pub mod root { "Alignment of field: " , stringify ! ( NodeInfo_NodeInfoInner ) , "::" , stringify ! ( mExtraName ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const NodeInfo_NodeInfoInner ) ) . + mHash as * const _ as usize } , 40usize , concat ! + ( + "Alignment of field: " , stringify ! ( + NodeInfo_NodeInfoInner ) , "::" , stringify ! ( + mHash ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const NodeInfo_NodeInfoInner ) ) . + mHashInitialized as * const _ as usize } , 44usize + , concat ! ( + "Alignment of field: " , stringify ! ( + NodeInfo_NodeInfoInner ) , "::" , stringify ! ( + mHashInitialized ) )); + } + impl Clone for NodeInfo_NodeInfoInner { + fn clone(&self) -> Self { *self } } extern "C" { #[link_name = @@ -4276,7 +4295,7 @@ pub mod root { } #[test] fn bindgen_test_layout_NodeInfo() { - assert_eq!(::std::mem::size_of::() , 120usize , + assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( "Size of: " , stringify ! ( NodeInfo ) )); assert_eq! (::std::mem::align_of::() , 8usize , @@ -4304,22 +4323,22 @@ pub mod root { , "::" , stringify ! ( mInner ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mOwnerManager - as * const _ as usize } , 64usize , concat ! ( + as * const _ as usize } , 72usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mOwnerManager ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mQualifiedName - as * const _ as usize } , 72usize , concat ! ( + as * const _ as usize } , 80usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mQualifiedName ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mNodeName as * - const _ as usize } , 88usize , concat ! ( + const _ as usize } , 96usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mNodeName ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mLocalName as - * const _ as usize } , 104usize , concat ! ( + * const _ as usize } , 112usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mLocalName ) )); } diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index 1bd450faae8..1b3a5654dd4 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -4097,19 +4097,21 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] - #[derive(Debug)] + #[derive(Debug, Copy)] pub struct NodeInfo_NodeInfoInner { - pub mName: root::nsCOMPtr, - pub mPrefix: root::nsCOMPtr, + pub mName: *const root::nsIAtom, + pub mPrefix: *mut root::nsIAtom, pub mNamespaceID: i32, pub mNodeType: u16, pub mNameString: *const root::nsAString, - pub mExtraName: root::nsCOMPtr, + pub mExtraName: *mut root::nsIAtom, + pub mHash: root::PLHashNumber, + pub mHashInitialized: bool, } #[test] fn bindgen_test_layout_NodeInfo_NodeInfoInner() { assert_eq!(::std::mem::size_of::() , - 40usize , concat ! ( + 48usize , concat ! ( "Size of: " , stringify ! ( NodeInfo_NodeInfoInner ) )); assert_eq! (::std::mem::align_of::() , @@ -4158,6 +4160,23 @@ pub mod root { "Alignment of field: " , stringify ! ( NodeInfo_NodeInfoInner ) , "::" , stringify ! ( mExtraName ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const NodeInfo_NodeInfoInner ) ) . + mHash as * const _ as usize } , 40usize , concat ! + ( + "Alignment of field: " , stringify ! ( + NodeInfo_NodeInfoInner ) , "::" , stringify ! ( + mHash ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const NodeInfo_NodeInfoInner ) ) . + mHashInitialized as * const _ as usize } , 44usize + , concat ! ( + "Alignment of field: " , stringify ! ( + NodeInfo_NodeInfoInner ) , "::" , stringify ! ( + mHashInitialized ) )); + } + impl Clone for NodeInfo_NodeInfoInner { + fn clone(&self) -> Self { *self } } extern "C" { #[link_name = @@ -4167,7 +4186,7 @@ pub mod root { } #[test] fn bindgen_test_layout_NodeInfo() { - assert_eq!(::std::mem::size_of::() , 112usize , + assert_eq!(::std::mem::size_of::() , 120usize , concat ! ( "Size of: " , stringify ! ( NodeInfo ) )); assert_eq! (::std::mem::align_of::() , 8usize , @@ -4190,22 +4209,22 @@ pub mod root { , "::" , stringify ! ( mInner ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mOwnerManager - as * const _ as usize } , 56usize , concat ! ( + as * const _ as usize } , 64usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mOwnerManager ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mQualifiedName - as * const _ as usize } , 64usize , concat ! ( + as * const _ as usize } , 72usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mQualifiedName ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mNodeName as * - const _ as usize } , 80usize , concat ! ( + const _ as usize } , 88usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mNodeName ) )); assert_eq! (unsafe { & ( * ( 0 as * const NodeInfo ) ) . mLocalName as - * const _ as usize } , 96usize , concat ! ( + * const _ as usize } , 104usize , concat ! ( "Alignment of field: " , stringify ! ( NodeInfo ) , "::" , stringify ! ( mLocalName ) )); }