Bug 1685828 - Stop calling SVG and MathML enabling helpers every time we check their enabling status. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D101244
This commit is contained in:
Ting-Yu Lin 2021-01-11 03:56:18 +00:00
Родитель c60fdae7a4
Коммит 59be07e5b4
2 изменённых файлов: 9 добавлений и 2 удалений

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

@ -362,6 +362,8 @@ static bool IsSystemOrAddonOrAboutPrincipal(nsIPrincipal* aPrincipal) {
}
bool nsNodeInfoManager::InternalSVGEnabled() {
MOZ_ASSERT(!mSVGEnabled, "Caller should use the cached mSVGEnabled!");
// If the svg.disabled pref. is true, convert all SVG nodes into
// disabled SVG nodes by swapping the namespace.
nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();
@ -396,6 +398,8 @@ bool nsNodeInfoManager::InternalSVGEnabled() {
}
bool nsNodeInfoManager::InternalMathMLEnabled() {
MOZ_ASSERT(!mMathMLEnabled, "Caller should use the cached mMathMLEnabled!");
// If the mathml.disabled pref. is true, convert all MathML nodes into
// disabled MathML nodes by swapping the namespace.
nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance();

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

@ -101,13 +101,16 @@ class nsNodeInfoManager final {
/**
* Returns true if SVG nodes in this document have real SVG semantics.
*/
bool SVGEnabled() { return mSVGEnabled.valueOr(InternalSVGEnabled()); }
bool SVGEnabled() {
return mSVGEnabled.valueOrFrom([this] { return InternalSVGEnabled(); });
}
/**
* Returns true if MathML nodes in this document have real MathML semantics.
*/
bool MathMLEnabled() {
return mMathMLEnabled.valueOr(InternalMathMLEnabled());
return mMathMLEnabled.valueOrFrom(
[this] { return InternalMathMLEnabled(); });
}
mozilla::dom::DOMArena* GetArenaAllocator() { return mArena; }