Skip to content

Commit

Permalink
Bug 1335863 - Inline Gecko_IsHTMLElementInHTMLDocument. r=emilio
Browse files Browse the repository at this point in the history
  • Loading branch information
bholley committed Feb 2, 2017
1 parent ae88d22 commit e78f240
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions components/style/build_gecko.rs
Expand Up @@ -235,6 +235,7 @@ mod bindings {
.include(add_include("mozilla/Keyframe.h"))
.include(add_include("mozilla/ServoElementSnapshot.h"))
.include(add_include("mozilla/dom/Element.h"))
.include(add_include("mozilla/dom/NameSpaceConstants.h"))
.include(add_include("mozilla/ServoBindings.h"))
.include(add_include("nsMediaFeatures.h"))
.include(add_include("nsMediaList.h"))
Expand All @@ -258,6 +259,7 @@ mod bindings {
"BORDER_COLOR_.*",
"BORDER_STYLE_.*",
"mozilla::SERVO_PREF_.*",
"kNameSpaceID_.*",
];
let whitelist = [
"RawGecko.*",
Expand Down
14 changes: 10 additions & 4 deletions components/style/gecko/wrapper.rs
Expand Up @@ -25,12 +25,12 @@ use gecko::snapshot_helpers;
use gecko_bindings::bindings;
use gecko_bindings::bindings::{Gecko_DropStyleChildrenIterator, Gecko_MaybeCreateStyleChildrenIterator};
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetLastChild, Gecko_GetNextStyleChild};
use gecko_bindings::bindings::{Gecko_GetServoDeclarationBlock, Gecko_IsHTMLElementInHTMLDocument};
use gecko_bindings::bindings::{Gecko_IsLink, Gecko_IsRootElement, Gecko_MatchesElement};
use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink, Gecko_Namespace};
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use gecko_bindings::bindings::Gecko_ClassOrClassList;
use gecko_bindings::bindings::Gecko_GetAnimationRule;
use gecko_bindings::bindings::Gecko_GetServoDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetStyleContext;
use gecko_bindings::structs;
use gecko_bindings::structs::{RawGeckoElement, RawGeckoNode};
Expand Down Expand Up @@ -88,6 +88,11 @@ impl<'ln> GeckoNode<'ln> {
unsafe { &*self.0.mNodeInfo.mRawPtr }
}

fn owner_doc(&self) -> &structs::nsIDocument {
debug_assert!(!self.node_info().mDocument.is_null());
unsafe { &*self.node_info().mDocument }
}

fn first_child(&self) -> Option<GeckoNode<'ln>> {
unsafe { self.0.mFirstChild.as_ref().map(GeckoNode::from_content) }
}
Expand Down Expand Up @@ -565,9 +570,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
}

fn is_html_element_in_html_document(&self) -> bool {
unsafe {
Gecko_IsHTMLElementInHTMLDocument(self.0)
}
let node = self.as_node();
let node_info = node.node_info();
node_info.mInner.mNamespaceID == (structs::root::kNameSpaceID_XHTML as i32) &&
node.owner_doc().mType == structs::root::nsIDocument_Type::eHTML
}
}

Expand Down

0 comments on commit e78f240

Please sign in to comment.