From a454f6233d117135145a7dfcaef0c5df6a25eab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 2 Jan 2019 14:05:23 +0100 Subject: [PATCH] Rename nsIDocument to mozilla::dom::Document. Summary: Really sorry for the size of the patch. It's mostly automatic s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to add the right namespacing and such. Overall it's not a very interesting patch I think. nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and nsIDocumentInlines.h into DocumentInlines.h. I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it. While fixing up some of the bits I also removed some unneeded OwnerDoc() null checks and such, but I didn't do anything riskier than that. Bug: 1517241 Reviewed-by: smaug --- components/style/element_state.rs | 2 +- components/style/gecko/data.rs | 7 +++---- components/style/gecko/media_queries.rs | 4 ++-- components/style/gecko/wrapper.rs | 12 ++++++------ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/components/style/element_state.rs b/components/style/element_state.rs index a646a2a37bf..8165c73ef14 100644 --- a/components/style/element_state.rs +++ b/components/style/element_state.rs @@ -144,7 +144,7 @@ bitflags! { /// Event-based document states. /// /// NB: Is important for this to remain in sync with Gecko's - /// dom/base/nsIDocument.h. + /// dom/base/Document.h. #[derive(MallocSizeOf)] pub struct DocumentState: u64 { /// RTL locale: specific to the XUL localedir attribute diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index d4c976cc2a6..af98f116afb 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -7,8 +7,7 @@ use crate::context::QuirksMode; use crate::dom::TElement; use crate::gecko_bindings::bindings::{self, RawServoStyleSet}; -use crate::gecko_bindings::structs::StyleSheet as DomStyleSheet; -use crate::gecko_bindings::structs::{nsIDocument, StyleSheetInfo}; +use crate::gecko_bindings::structs::{StyleSheet as DomStyleSheet, StyleSheetInfo}; use crate::gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes}; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::invalidation::media_queries::{MediaListKey, ToMediaListKey}; @@ -152,7 +151,7 @@ impl PerDocumentStyleData { // // Should we just force XBL Stylists to be NoQuirks? let quirks_mode = - unsafe { (*device.pres_context().mDocument.raw::()).mCompatMode }; + unsafe { (*device.pres_context().mDocument.mRawPtr).mCompatMode }; PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl { stylist: Stylist::new(device, quirks_mode.into()), @@ -198,7 +197,7 @@ impl PerDocumentStyleDataImpl { .device() .pres_context() .mDocument - .raw::(); + .mRawPtr; unsafe { bindings::Gecko_VisitedStylesEnabled(doc) } } diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index ab3f3a0de80..851422467ce 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -162,8 +162,8 @@ impl Device { /// Gets the document pointer. #[inline] - pub fn document(&self) -> *mut structs::nsIDocument { - self.pres_context().mDocument.raw::() + pub fn document(&self) -> *mut structs::Document { + self.pres_context().mDocument.mRawPtr } /// Recreates the default computed values. diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 1340a005d74..b169ee947fa 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -45,7 +45,7 @@ use crate::gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWThe use crate::gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use crate::gecko_bindings::structs; use crate::gecko_bindings::structs::nsChangeHint; -use crate::gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme; +use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme; use crate::gecko_bindings::structs::nsRestyleHint; use crate::gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel; use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT; @@ -107,9 +107,9 @@ fn elements_with_id<'a, 'le>( } } -/// A simple wrapper over `nsIDocument`. +/// A simple wrapper over `Document`. #[derive(Clone, Copy)] -pub struct GeckoDocument<'ld>(pub &'ld structs::nsIDocument); +pub struct GeckoDocument<'ld>(pub &'ld structs::Document); impl<'ld> TDocument for GeckoDocument<'ld> { type ConcreteNode = GeckoNode<'ld>; @@ -121,7 +121,7 @@ impl<'ld> TDocument for GeckoDocument<'ld> { #[inline] fn is_html_document(&self) -> bool { - self.0.mType == structs::root::nsIDocument_Type::eHTML + self.0.mType == structs::Document_Type::eHTML } #[inline] @@ -1242,11 +1242,11 @@ impl<'le> TElement for GeckoElement<'le> { } fn owner_doc_matches_for_testing(&self, device: &Device) -> bool { - self.as_node().owner_doc().0 as *const structs::nsIDocument == + self.as_node().owner_doc().0 as *const structs::Document == device .pres_context() .mDocument - .raw::() + .mRawPtr } fn style_attribute(&self) -> Option>> {