Backed out changeset a911e7cbb478 (bug 1646498) for open-features-negative-innerwidth-innerheight.html failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2021-01-26 22:40:15 +02:00
Родитель 3f8e34cb34
Коммит d8c3aca81c
4 изменённых файлов: 73 добавлений и 76 удалений

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

@ -7,14 +7,16 @@
#ifndef dom_base_AutoSuppressEventHandlingAndSuspend_h #ifndef dom_base_AutoSuppressEventHandlingAndSuspend_h
#define dom_base_AutoSuppressEventHandlingAndSuspend_h #define dom_base_AutoSuppressEventHandlingAndSuspend_h
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/BrowsingContextGroup.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsPIDOMWindow.h" #include "nsPIDOMWindow.h"
#include "nsTArray.h" #include "nsTArray.h"
namespace mozilla::dom { namespace mozilla::dom {
class BrowsingContext;
class BrowsingContextGroup;
/** /**
* Suppresses event handling and suspends the active inner window for all * Suppresses event handling and suspends the active inner window for all
* in-process documents in a BrowsingContextGroup. This should be used while * in-process documents in a BrowsingContextGroup. This should be used while
@ -23,20 +25,16 @@ namespace mozilla::dom {
* group. * group.
*/ */
class MOZ_RAII AutoSuppressEventHandlingAndSuspend class MOZ_RAII AutoSuppressEventHandlingAndSuspend {
: private AutoWalkBrowsingContextGroup {
public: public:
explicit AutoSuppressEventHandlingAndSuspend(BrowsingContextGroup* aGroup) { explicit AutoSuppressEventHandlingAndSuspend(BrowsingContextGroup* aGroup);
if (aGroup) { ~AutoSuppressEventHandlingAndSuspend();
SuppressBrowsingContextGroup(aGroup);
}
}
~AutoSuppressEventHandlingAndSuspend() { UnsuppressDocuments(); } private:
void SuppressBrowsingContext(BrowsingContext* aBC);
protected: AutoTArray<RefPtr<Document>, 16> mDocuments;
void SuppressDocument(Document* aDocument) override; AutoTArray<nsCOMPtr<nsPIDOMWindowInner>, 16> mWindows;
void UnsuppressDocument(Document* aDocument) override;
}; };
} // namespace mozilla::dom } // namespace mozilla::dom

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

@ -15627,32 +15627,38 @@ already_AddRefed<Element> Document::CreateHTMLElement(nsAtom* aTag) {
return element.forget(); return element.forget();
} }
void AutoWalkBrowsingContextGroup::SuppressBrowsingContextGroup( static CallState MarkDocumentTreeToBeInSyncOperation(
BrowsingContextGroup* aGroup) { Document& aDoc, nsTArray<RefPtr<Document>>& aDocuments) {
for (const auto& bc : aGroup->Toplevels()) { aDoc.SetIsInSyncOperation(true);
bc->PreOrderWalk([&](BrowsingContext* aBC) { if (nsCOMPtr<nsPIDOMWindowInner> window = aDoc.GetInnerWindow()) {
if (nsCOMPtr<nsPIDOMWindowOuter> win = aBC->GetDOMWindow()) { window->TimeoutManager().BeginSyncOperation();
if (RefPtr<Document> doc = win->GetExtantDoc()) {
SuppressDocument(doc);
mDocuments.AppendElement(doc);
}
}
});
} }
aDocuments.AppendElement(&aDoc);
auto recurse = [&aDocuments](Document& aSubDoc) {
return MarkDocumentTreeToBeInSyncOperation(aSubDoc, aDocuments);
};
aDoc.EnumerateSubDocuments(recurse);
return CallState::Continue;
} }
nsAutoSyncOperation::nsAutoSyncOperation(Document* aDoc, nsAutoSyncOperation::nsAutoSyncOperation(Document* aDoc,
SyncOperationBehavior aSyncBehavior) SyncOperationBehavior aSyncBehavior)
: mSyncBehavior(aSyncBehavior) { : mSyncBehavior(aSyncBehavior) {
mMicroTaskLevel = 0; mMicroTaskLevel = 0;
if (CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get()) { CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
if (ccjs) {
mMicroTaskLevel = ccjs->MicroTaskLevel(); mMicroTaskLevel = ccjs->MicroTaskLevel();
ccjs->SetMicroTaskLevel(0); ccjs->SetMicroTaskLevel(0);
} }
if (aDoc) { if (aDoc) {
if (auto* bcg = aDoc->GetDocGroup()->GetBrowsingContextGroup()) { if (nsPIDOMWindowOuter* win = aDoc->GetWindow()) {
SuppressBrowsingContextGroup(bcg); if (nsCOMPtr<nsPIDOMWindowOuter> top = win->GetInProcessTop()) {
if (RefPtr<Document> doc = top->GetExtantDoc()) {
MarkDocumentTreeToBeInSyncOperation(*doc, mDocuments);
} }
}
}
mBrowsingContext = aDoc->GetBrowsingContext(); mBrowsingContext = aDoc->GetBrowsingContext();
if (mBrowsingContext && if (mBrowsingContext &&
mSyncBehavior == SyncOperationBehavior::eSuspendInput && mSyncBehavior == SyncOperationBehavior::eSuspendInput &&
@ -15662,26 +15668,18 @@ nsAutoSyncOperation::nsAutoSyncOperation(Document* aDoc,
} }
} }
void nsAutoSyncOperation::SuppressDocument(Document* aDoc) {
if (nsCOMPtr<nsPIDOMWindowInner> win = aDoc->GetInnerWindow()) {
win->TimeoutManager().BeginSyncOperation();
}
aDoc->SetIsInSyncOperation(true);
}
void nsAutoSyncOperation::UnsuppressDocument(Document* aDoc) {
if (nsCOMPtr<nsPIDOMWindowInner> win = aDoc->GetInnerWindow()) {
win->TimeoutManager().EndSyncOperation();
}
aDoc->SetIsInSyncOperation(false);
}
nsAutoSyncOperation::~nsAutoSyncOperation() { nsAutoSyncOperation::~nsAutoSyncOperation() {
UnsuppressDocuments(); for (RefPtr<Document>& doc : mDocuments) {
if (nsCOMPtr<nsPIDOMWindowInner> window = doc->GetInnerWindow()) {
window->TimeoutManager().EndSyncOperation();
}
doc->SetIsInSyncOperation(false);
}
CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get(); CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
if (ccjs) { if (ccjs) {
ccjs->SetMicroTaskLevel(mMicroTaskLevel); ccjs->SetMicroTaskLevel(mMicroTaskLevel);
} }
if (mBrowsingContext && if (mBrowsingContext &&
mSyncBehavior == SyncOperationBehavior::eSuspendInput && mSyncBehavior == SyncOperationBehavior::eSuspendInput &&
InputTaskManager::CanSuspendInputEvent()) { InputTaskManager::CanSuspendInputEvent()) {

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

@ -5228,33 +5228,14 @@ class MOZ_STACK_CLASS mozAutoSubtreeModified {
enum class SyncOperationBehavior { eSuspendInput, eAllowInput }; enum class SyncOperationBehavior { eSuspendInput, eAllowInput };
class AutoWalkBrowsingContextGroup { class MOZ_STACK_CLASS nsAutoSyncOperation {
public:
virtual ~AutoWalkBrowsingContextGroup() = default;
protected:
void SuppressBrowsingContextGroup(BrowsingContextGroup* aGroup);
void UnsuppressDocuments() {
for (const auto& doc : mDocuments) {
UnsuppressDocument(doc);
}
}
virtual void SuppressDocument(Document* aDocument) = 0;
virtual void UnsuppressDocument(Document* aDocument) = 0;
AutoTArray<RefPtr<Document>, 16> mDocuments;
};
class MOZ_RAII nsAutoSyncOperation : private AutoWalkBrowsingContextGroup {
public: public:
explicit nsAutoSyncOperation(Document* aDocument, explicit nsAutoSyncOperation(Document* aDocument,
SyncOperationBehavior aSyncBehavior); SyncOperationBehavior aSyncBehavior);
~nsAutoSyncOperation(); ~nsAutoSyncOperation();
protected:
void SuppressDocument(Document* aDocument) override;
void UnsuppressDocument(Document* aDocument) override;
private: private:
nsTArray<RefPtr<Document>> mDocuments;
uint32_t mMicroTaskLevel; uint32_t mMicroTaskLevel;
const SyncOperationBehavior mSyncBehavior; const SyncOperationBehavior mSyncBehavior;
RefPtr<BrowsingContext> mBrowsingContext; RefPtr<BrowsingContext> mBrowsingContext;

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

@ -676,7 +676,19 @@ class SameOriginCheckerImpl final : public nsIChannelEventSink,
} // namespace } // namespace
void AutoSuppressEventHandlingAndSuspend::SuppressDocument(Document* aDoc) { AutoSuppressEventHandlingAndSuspend::AutoSuppressEventHandlingAndSuspend(
BrowsingContextGroup* aGroup) {
for (const auto& bc : aGroup->Toplevels()) {
SuppressBrowsingContext(bc);
}
}
void AutoSuppressEventHandlingAndSuspend::SuppressBrowsingContext(
BrowsingContext* aBC) {
if (nsCOMPtr<nsPIDOMWindowOuter> win = aBC->GetDOMWindow()) {
if (RefPtr<Document> doc = win->GetExtantDoc()) {
mDocuments.AppendElement(doc);
mWindows.AppendElement(win->GetCurrentInnerWindow());
// Note: Document::SuppressEventHandling will also automatically suppress // Note: Document::SuppressEventHandling will also automatically suppress
// event handling for any in-process sub-documents. However, since we need // event handling for any in-process sub-documents. However, since we need
// to deal with cases where remote BrowsingContexts may be interleaved // to deal with cases where remote BrowsingContexts may be interleaved
@ -684,15 +696,23 @@ void AutoSuppressEventHandlingAndSuspend::SuppressDocument(Document* aDoc) {
// This may be slightly redundant in some cases, but since event handling // This may be slightly redundant in some cases, but since event handling
// suppressions maintain a count of current blockers, it does not cause // suppressions maintain a count of current blockers, it does not cause
// any problems. // any problems.
aDoc->SuppressEventHandling(); doc->SuppressEventHandling();
aDoc->GetInnerWindow()->Suspend(); win->GetCurrentInnerWindow()->Suspend();
}
}
for (const auto& bc : aBC->Children()) {
SuppressBrowsingContext(bc);
}
} }
void AutoSuppressEventHandlingAndSuspend::UnsuppressDocument(Document* aDoc) { AutoSuppressEventHandlingAndSuspend::~AutoSuppressEventHandlingAndSuspend() {
if (nsCOMPtr<nsPIDOMWindowInner> win = aDoc->GetInnerWindow()) { for (const auto& win : mWindows) {
win->Resume(); win->Resume();
} }
aDoc->UnsuppressEventHandlingAndFireEvents(true); for (const auto& doc : mDocuments) {
doc->UnsuppressEventHandlingAndFireEvents(true);
}
} }
/** /**