зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1827856 - Speed up GetClosestAnonymousSubtreeRoot for UA widgets. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D175353
This commit is contained in:
Родитель
11349941a9
Коммит
339529a536
|
@ -61,6 +61,11 @@ ShadowRoot::ShadowRoot(Element* aElement, ShadowRootMode aMode,
|
|||
mSlotAssignment(aSlotAssignment),
|
||||
mIsDetailsShadowTree(aElement->IsHTMLElement(nsGkAtoms::details)),
|
||||
mIsAvailableToElementInternals(false) {
|
||||
// nsINode.h relies on this.
|
||||
MOZ_ASSERT(static_cast<nsINode*>(this) == reinterpret_cast<nsINode*>(this));
|
||||
MOZ_ASSERT(static_cast<nsIContent*>(this) ==
|
||||
reinterpret_cast<nsIContent*>(this));
|
||||
|
||||
SetHost(aElement);
|
||||
|
||||
// Nodes in a shadow tree should never store a value
|
||||
|
|
|
@ -1410,9 +1410,15 @@ class nsINode : public mozilla::dom::EventTarget {
|
|||
*/
|
||||
nsIContent* GetClosestNativeAnonymousSubtreeRoot() const {
|
||||
if (!IsInNativeAnonymousSubtree()) {
|
||||
MOZ_ASSERT(!HasBeenInUAWidget(), "UA widget implies anonymous");
|
||||
return nullptr;
|
||||
}
|
||||
MOZ_ASSERT(IsContent(), "How did non-content end up in NAC?");
|
||||
if (HasBeenInUAWidget()) {
|
||||
// reinterpret_cast because in this header we don't know ShadowRoot is an
|
||||
// nsIContent. ShadowRoot constructor asserts this is correct.
|
||||
return reinterpret_cast<nsIContent*>(GetContainingShadow());
|
||||
}
|
||||
for (const nsINode* node = this; node; node = node->GetParentNode()) {
|
||||
if (node->IsRootOfNativeAnonymousSubtree()) {
|
||||
return const_cast<nsINode*>(node)->AsContent();
|
||||
|
|
Загрузка…
Ссылка в новой задаче