Bug 1399546: Add an API to know if an element is it's document body element. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Sep 2017 22:54:59 +0200
changeset 433224 f6de9a593c3c3913b483a6606dbcb493369eb3f6
parent 433223 cd3a11354b72de2b9001c2ad83b6f1b7663fd4a0
child 433225 c710d47517a28487160978de88f76e586fafd449
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1399546
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1399546: Add an API to know if an element is it's document body element. r=heycam MozReview-Commit-ID: 8mtd4CsoSlU
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -845,16 +845,23 @@ Gecko_FillAllMaskLists(nsStyleImageLayer
 }
 
 RawGeckoElementBorrowedOrNull
 Gecko_GetBody(RawGeckoPresContextBorrowed aPresContext)
 {
   return aPresContext->Document()->GetBodyElement();
 }
 
+bool
+Gecko_IsDocumentBody(RawGeckoElementBorrowed aElement)
+{
+  nsIDocument* doc = aElement->GetUncomposedDoc();
+  return doc && doc->GetBodyElement() == aElement;
+}
+
 nscolor
 Gecko_GetLookAndFeelSystemColor(int32_t aId,
                                 RawGeckoPresContextBorrowed aPresContext)
 {
   bool useStandinsForNativeColors = aPresContext && !aPresContext->IsChrome();
   nscolor result;
   LookAndFeel::ColorID colorId = static_cast<LookAndFeel::ColorID>(aId);
   MutexAutoLock guard(*sServoWidgetLock);
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -627,16 +627,17 @@ NS_DECL_FFI_REFCOUNTING(nsCSSFontFaceRul
 // Counter style rule
 // Creates and returns a new (already-addrefed) nsCSSCounterStyleRule object.
 nsCSSCounterStyleRule* Gecko_CSSCounterStyle_Create(nsIAtom* name);
 nsCSSCounterStyleRule* Gecko_CSSCounterStyle_Clone(const nsCSSCounterStyleRule* rule);
 void Gecko_CSSCounterStyle_GetCssText(const nsCSSCounterStyleRule* rule, nsAString* result);
 NS_DECL_FFI_REFCOUNTING(nsCSSCounterStyleRule, CSSCounterStyleRule);
 
 RawGeckoElementBorrowedOrNull Gecko_GetBody(RawGeckoPresContextBorrowed pres_context);
+bool Gecko_IsDocumentBody(RawGeckoElementBorrowed element);
 
 // We use an int32_t here instead of a LookAndFeel::ColorID
 // because forward-declaring a nested enum/struct is impossible
 nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
                                         RawGeckoPresContextBorrowed pres_context);
 
 bool Gecko_MatchStringArgPseudo(RawGeckoElementBorrowed element,
                                 mozilla::CSSPseudoClassType type,