Bug 1564208 part 2: Use Maybe<bool> to represent lazily-initialized bools for SVG/MathML enabling. r=smaug

This patch shouldn't affect behavior at all -- it's just removing a custom enum
type, in favor of our more standard representation for lazily-initialized bool,
which is Maybe<bool>.

Differential Revision: https://phabricator.services.mozilla.com/D37465

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daniel Holbert 2019-07-09 21:19:41 +00:00
Родитель 37e8ae0939
Коммит d352c376ab
2 изменённых файлов: 7 добавлений и 17 удалений

Просмотреть файл

@ -46,9 +46,7 @@ nsNodeInfoManager::nsNodeInfoManager()
mTextNodeInfo(nullptr),
mCommentNodeInfo(nullptr),
mDocumentNodeInfo(nullptr),
mRecentlyUsedNodeInfos(),
mSVGEnabled(eTriUnset),
mMathMLEnabled(eTriUnset) {
mRecentlyUsedNodeInfos() {
nsLayoutStatics::AddRef();
if (gNodeInfoManagerLeakPRLog)
@ -352,7 +350,7 @@ bool nsNodeInfoManager::InternalSVGEnabled() {
nsIContentPolicy::TYPE_OTHER) &&
(IsSystemOrAddonPrincipal(loadInfo->LoadingPrincipal()) ||
IsSystemOrAddonPrincipal(loadInfo->TriggeringPrincipal()))));
mSVGEnabled = conclusion ? eTriTrue : eTriFalse;
mSVGEnabled = Some(conclusion);
return conclusion;
}
@ -362,7 +360,7 @@ bool nsNodeInfoManager::InternalMathMLEnabled() {
nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();
bool conclusion = ((nsmgr && !nsmgr->mMathMLDisabled) ||
nsContentUtils::IsSystemPrincipal(mPrincipal));
mMathMLEnabled = conclusion ? eTriTrue : eTriFalse;
mMathMLEnabled = Some(conclusion);
return conclusion;
}

Просмотреть файл

@ -100,24 +100,16 @@ class nsNodeInfoManager final {
nsBindingManager* GetBindingManager() const { return mBindingManager; }
enum Tri { eTriUnset = 0, eTriFalse, eTriTrue };
/**
* Returns true if SVG nodes in this document have real SVG semantics.
*/
bool SVGEnabled() {
return mSVGEnabled == eTriTrue
? true
: mSVGEnabled == eTriFalse ? false : InternalSVGEnabled();
}
bool SVGEnabled() { return mSVGEnabled.valueOr(InternalSVGEnabled()); }
/**
* Returns true if MathML nodes in this document have real MathML semantics.
*/
bool MathMLEnabled() {
return mMathMLEnabled == eTriTrue
? true
: mMathMLEnabled == eTriFalse ? false : InternalMathMLEnabled();
return mMathMLEnabled.valueOr(InternalMathMLEnabled());
}
void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const;
@ -171,8 +163,8 @@ class nsNodeInfoManager final {
mDocumentNodeInfo; // WEAK to avoid circular ownership
RefPtr<nsBindingManager> mBindingManager;
NodeInfoCache mRecentlyUsedNodeInfos;
Tri mSVGEnabled;
Tri mMathMLEnabled;
mozilla::Maybe<bool> mSVGEnabled; // Lazily initialized.
mozilla::Maybe<bool> mMathMLEnabled; // Lazily initialized.
};
#endif /* nsNodeInfoManager_h___ */