Skip to content

Commit

Permalink
Rename nsIDocument to mozilla::dom::Document.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emilio committed Jan 6, 2019
1 parent 274845f commit a454f62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion components/style/element_state.rs
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions components/style/gecko/data.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -152,7 +151,7 @@ impl PerDocumentStyleData {
//
// Should we just force XBL Stylists to be NoQuirks?
let quirks_mode =
unsafe { (*device.pres_context().mDocument.raw::<nsIDocument>()).mCompatMode };
unsafe { (*device.pres_context().mDocument.mRawPtr).mCompatMode };

PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
stylist: Stylist::new(device, quirks_mode.into()),
Expand Down Expand Up @@ -198,7 +197,7 @@ impl PerDocumentStyleDataImpl {
.device()
.pres_context()
.mDocument
.raw::<nsIDocument>();
.mRawPtr;
unsafe { bindings::Gecko_VisitedStylesEnabled(doc) }
}

Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko/media_queries.rs
Expand Up @@ -162,8 +162,8 @@ impl Device {

/// Gets the document pointer.
#[inline]
pub fn document(&self) -> *mut structs::nsIDocument {
self.pres_context().mDocument.raw::<structs::nsIDocument>()
pub fn document(&self) -> *mut structs::Document {
self.pres_context().mDocument.mRawPtr
}

/// Recreates the default computed values.
Expand Down
12 changes: 6 additions & 6 deletions components/style/gecko/wrapper.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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>;
Expand All @@ -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]
Expand Down Expand Up @@ -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::<structs::nsIDocument>()
.mRawPtr
}

fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
Expand Down

0 comments on commit a454f62

Please sign in to comment.