Bug 1425759: Make Shadow DOM Stylo-only. r?smaug
I don't plan to fix this stuff up on the old style system.
MozReview-Commit-ID: E7Ayatwsw4E
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1470,16 +1470,17 @@ nsIDocument::nsIDocument()
mHasScrollLinkedEffect(false),
mFrameRequestCallbacksScheduled(false),
mIsTopLevelContentDocument(false),
mIsContentDocument(false),
mDidCallBeginLoad(false),
mBufferingCSPViolations(false),
mAllowPaymentRequest(false),
mEncodingMenuDisabled(false),
+ mIsShadowDOMEnabled(false),
mIsSVGGlyphsDocument(false),
mAllowUnsafeHTML(false),
mIsScopedStyleEnabled(eScopedStyle_Unknown),
mCompatMode(eCompatibility_FullStandards),
mReadyState(ReadyState::READYSTATE_UNINITIALIZED),
mStyleBackendType(StyleBackendType::None),
#ifdef MOZILLA_INTERNAL_API
mVisibilityState(dom::VisibilityState::Hidden),
@@ -1513,20 +1514,16 @@ nsIDocument::nsIDocument()
mServoRestyleRootDirtyBits(0),
mThrowOnDynamicMarkupInsertionCounter(0),
mIgnoreOpensDuringUnloadCounter(0)
{
SetIsInDocument();
for (auto& cnt : mIncCounters) {
cnt = 0;
}
-
- // Set this when document is created and value stays the same for the lifetime
- // of the document.
- mIsShadowDOMEnabled = nsContentUtils::IsShadowDOMEnabled();
}
nsDocument::nsDocument(const char* aContentType)
: nsIDocument()
, mSubDocuments(nullptr)
, mFlashClassification(FlashClassification::Unclassified)
, mHeaderData(nullptr)
, mIsGoingAway(false)
@@ -2161,16 +2158,24 @@ nsDocument::Init()
// mNodeInfo keeps NodeInfoManager alive!
mNodeInfo = mNodeInfoManager->GetDocumentNodeInfo();
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_OUT_OF_MEMORY);
MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_NODE,
"Bad NodeType in aNodeInfo");
NS_ASSERTION(OwnerDoc() == this, "Our nodeinfo is busted!");
+ UpdateStyleBackendType();
+
+ // Set this when document is initialized and value stays the same for the
+ // lifetime of the document.
+ mIsShadowDOMEnabled =
+ mStyleBackendType == StyleBackendType::Servo &&
+ nsContentUtils::IsShadowDOMEnabled();
+
// If after creation the owner js global is not set for a document
// we use the default compartment for this document, instead of creating
// wrapper in some random compartment when the document is exposed to js
// via some events.
nsCOMPtr<nsIGlobalObject> global = xpc::NativeGlobal(xpc::PrivilegedJunkScope());
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
mScopeObject = do_GetWeakReference(global);
MOZ_ASSERT(mScopeObject);
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -1398,20 +1398,18 @@ public:
/**
* Get this document's CSSLoader. This is guaranteed to not return null.
*/
mozilla::css::Loader* CSSLoader() const {
return mCSSLoader;
}
mozilla::StyleBackendType GetStyleBackendType() const {
- if (mStyleBackendType == mozilla::StyleBackendType::None) {
- const_cast<nsIDocument*>(this)->UpdateStyleBackendType();
- }
- MOZ_ASSERT(mStyleBackendType != mozilla::StyleBackendType::None);
+ MOZ_ASSERT(mStyleBackendType != mozilla::StyleBackendType::None,
+ "Not initialized yet");
return mStyleBackendType;
}
/**
* Documents generally decide their style backend type themselves, and
* this is only used for XBL documents to set their style backend type to
* their bounding document's.
*/