Backed out 9 changesets (bug 1656107) for frequent assertion failures on layout/style/nsComputedDOMStyle.cpp CLOSED TREE

Backed out changeset 2d9843871809 (bug 1656107)
Backed out changeset 87031ccf6c8e (bug 1656107)
Backed out changeset 1e06017a213c (bug 1656107)
Backed out changeset b51bae240379 (bug 1656107)
Backed out changeset 8d98b76de39a (bug 1656107)
Backed out changeset 0f4ea8cdd34a (bug 1656107)
Backed out changeset 95eeff5318e5 (bug 1656107)
Backed out changeset 469fa7a429c2 (bug 1656107)
Backed out changeset ec3d7e825bc9 (bug 1656107)
This commit is contained in:
Bogdan Tara 2020-12-17 22:19:09 +02:00
parent 1ec41e129a
commit 0e0311351e
8 changed files with 60 additions and 44 deletions

View File

@ -13,7 +13,6 @@
#include "TextUpdater.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/Element.h"
#include "mozilla/PresShell.h"
#include "mozilla/Telemetry.h"
@ -767,10 +766,11 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
continue;
}
BrowsingContext* bc = childDoc->DocumentNode()->GetBrowsingContext();
if (bc && !bc->IsCached() && bc->GetEmbedderElement()) {
Accessible* outerDocAcc =
mDocument->GetAccessible(bc->GetEmbedderElement());
nsIContent* ownerContent =
mDocument->DocumentNode()->FindContentForSubDocument(
childDoc->DocumentNode());
if (ownerContent) {
Accessible* outerDocAcc = mDocument->GetAccessible(ownerContent);
if (outerDocAcc && outerDocAcc->AppendChild(childDoc)) {
if (mDocument->AppendChildDocument(childDoc)) {
newChildDocs.AppendElement(std::move(mHangingChildDocuments[idx]));

View File

@ -6724,6 +6724,22 @@ Document* Document::GetSubDocumentFor(nsIContent* aContent) const {
return nullptr;
}
Element* Document::FindContentForSubDocument(Document* aDocument) const {
NS_ENSURE_TRUE(aDocument, nullptr);
if (!mSubDocuments) {
return nullptr;
}
for (auto iter = mSubDocuments->Iter(); !iter.Done(); iter.Next()) {
auto entry = static_cast<SubDocMapEntry*>(iter.Get());
if (entry->mSubDocument == aDocument) {
return entry->mKey;
}
}
return nullptr;
}
bool Document::IsNodeOfType(uint32_t aFlags) const { return false; }
Element* Document::GetRootElement() const {
@ -7508,17 +7524,15 @@ void Document::DispatchContentLoadedEvents() {
// target_frame is the [i]frame element that will be used as the
// target for the event. It's the [i]frame whose content is done
// loading.
nsCOMPtr<Element> target_frame;
nsCOMPtr<EventTarget> target_frame;
if (BrowsingContext* bc = GetBrowsingContext()) {
if (!bc->IsCached()) {
target_frame = bc->GetEmbedderElement();
}
if (mParentDocument) {
target_frame = mParentDocument->FindContentForSubDocument(this);
}
if (target_frame && target_frame->IsInComposedDoc()) {
nsCOMPtr<Document> parent = target_frame->OwnerDoc();
while (parent) {
if (target_frame) {
nsCOMPtr<Document> parent = mParentDocument;
do {
RefPtr<Event> event;
if (parent) {
IgnoredErrorResult ignored;
@ -7549,7 +7563,7 @@ void Document::DispatchContentLoadedEvents() {
}
parent = parent->GetInProcessParentDocument();
}
} while (parent);
}
// If the document has a manifest attribute, fire a MozApplicationManifest
@ -14483,10 +14497,7 @@ bool Document::ApplyFullscreen(UniquePtr<FullscreenRequest> aRequest) {
break;
}
Document* parent = child->GetInProcessParentDocument();
BrowsingContext* bc = child->GetBrowsingContext();
Element* element =
bc && !bc->IsCached() ? bc->GetEmbedderElement() : nullptr;
Element* element = parent->FindContentForSubDocument(child);
if (!element) {
// We've reached the root.No more changes need to be made
// to the top layer stacks of documents further up the tree.

View File

@ -1254,6 +1254,11 @@ class Document : public nsINode,
*/
Document* GetSubDocumentFor(nsIContent* aContent) const;
/**
* Find the content node for which aDocument is a sub document.
*/
Element* FindContentForSubDocument(Document* aDocument) const;
/**
* Return the doctype for this document.
*/

View File

@ -2320,8 +2320,9 @@ nsINode* nsContentUtils::GetCrossDocParentNode(nsINode* aChild) {
return parent;
}
BrowsingContext* bc = aChild->AsDocument()->GetBrowsingContext();
return bc && !bc->IsCached() ? bc->GetEmbedderElement() : nullptr;
Document* doc = aChild->AsDocument();
Document* parentDoc = doc->GetInProcessParentDocument();
return parentDoc ? parentDoc->FindContentForSubDocument(doc) : nullptr;
}
nsINode* nsContentUtils::GetNearestInProcessCrossDocParentNode(

View File

@ -5123,6 +5123,9 @@ void nsGlobalWindowOuter::FocusOuter(CallerType aCallerType) {
return;
}
// Don't look for a presshell if we're a root chrome window that's got
// about:blank loaded. We don't want to focus our widget in that case.
// XXXbz should we really be checking for IsInitialDocument() instead?
RefPtr<BrowsingContext> parent;
BrowsingContext* bc = GetBrowsingContext();
if (bc) {
@ -5145,10 +5148,13 @@ void nsGlobalWindowOuter::FocusOuter(CallerType aCallerType) {
}
return;
}
if (!bc->IsCached()) {
if (Element* frame = bc->GetEmbedderElement()) {
nsContentUtils::RequestFrameFocus(*frame, canFocus, aCallerType);
}
nsCOMPtr<Document> parentdoc = parent->GetDocument();
if (!parentdoc) {
return;
}
if (Element* frame = parentdoc->FindContentForSubDocument(mDoc)) {
nsContentUtils::RequestFrameFocus(*frame, canFocus, aCallerType);
}
return;
}

View File

@ -4501,15 +4501,12 @@ void EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent,
// content associated with our subdocument.
EnsureDocument(mPresContext);
if (Document* parentDoc = mDocument->GetInProcessParentDocument()) {
if (RefPtr<BrowsingContext> bc = mDocument->GetBrowsingContext()) {
if (!bc->IsCached()) {
if (nsCOMPtr<nsIContent> docContent = bc->GetEmbedderElement()) {
if (PresShell* parentPresShell = parentDoc->GetPresShell()) {
RefPtr<EventStateManager> parentESM =
parentPresShell->GetPresContext()->EventStateManager();
parentESM->NotifyMouseOver(aMouseEvent, docContent);
}
}
if (nsCOMPtr<nsIContent> docContent =
parentDoc->FindContentForSubDocument(mDocument)) {
if (PresShell* parentPresShell = parentDoc->GetPresShell()) {
RefPtr<EventStateManager> parentESM =
parentPresShell->GetPresContext()->EventStateManager();
parentESM->NotifyMouseOver(aMouseEvent, docContent);
}
}
}

View File

@ -680,8 +680,8 @@ nsresult nsPresContext::Init(nsDeviceContext* aDeviceContext) {
// XXX the document can change in AttachPresShell, does this work?
dom::BrowsingContext* browsingContext = mDocument->GetBrowsingContext();
if (browsingContext && !browsingContext->IsTop()) {
MOZ_ASSERT(!browsingContext->IsCached());
Element* containingElement = browsingContext->GetEmbedderElement();
Element* containingElement =
parent->FindContentForSubDocument(mDocument);
if (!containingElement->IsXULElement() ||
!containingElement->HasAttr(kNameSpaceID_None,
nsGkAtoms::forceOwnRefreshDriver)) {

View File

@ -821,16 +821,12 @@ bool nsComputedDOMStyle::NeedsToFlushStyle(nsCSSPropertyID aPropID) const {
// If parent document is there, also needs to check if there is some change
// that needs to flush this document (e.g. size change for iframe).
while (doc->StyleOrLayoutObservablyDependsOnParentDocumentLayout()) {
if (BrowsingContext* bc = doc->GetBrowsingContext()) {
if (Element* element = bc->GetEmbedderElement()) {
MOZ_ASSERT(!bc->IsCached());
if (ElementNeedsRestyle(element, nullptr, mayNeedToFlushLayout)) {
return true;
}
}
Document* parentDocument = doc->GetInProcessParentDocument();
Element* element = parentDocument->FindContentForSubDocument(doc);
if (ElementNeedsRestyle(element, nullptr, mayNeedToFlushLayout)) {
return true;
}
doc = doc->GetInProcessParentDocument();
doc = parentDocument;
}
return false;