Bug 1596317 - Use CallState for SubDocEnumFunc. r=smaug

`true` -> `CallState::Continue`
`false` -> `CallState::Stop`

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2019-12-19 04:16:10 +00:00
Родитель 634fee0f48
Коммит 9e4bf031ae
12 изменённых файлов: 99 добавлений и 84 удалений

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

@ -765,7 +765,7 @@ void ExternalResourceMap::EnumerateResources(SubDocEnumFunc aCallback,
}
for (auto& doc : docs) {
if (!aCallback(*doc, aData)) {
if (aCallback(*doc, aData) == CallState::Stop) {
return;
}
}
@ -9979,9 +9979,9 @@ void Document::FlushExternalResources(FlushType aType) {
}
EnumerateExternalResources(
[](Document& aDoc, void* aData) -> bool {
[](Document& aDoc, void* aData) -> CallState {
aDoc.FlushPendingNotifications(*static_cast<FlushType*>(aData));
return true;
return CallState::Continue;
},
&aType);
}
@ -10223,7 +10223,7 @@ void Document::EnumerateSubDocuments(SubDocEnumFunc aCallback, void* aData) {
}
}
for (auto& subdoc : subdocs) {
if (!aCallback(*subdoc, aData)) {
if (aCallback(*subdoc, aData) == CallState::Stop) {
break;
}
}
@ -10708,10 +10708,10 @@ void Document::DispatchPageTransition(EventTarget* aDispatchTarget,
nullptr);
}
static bool NotifyPageShow(Document& aDocument, void* aData) {
static CallState NotifyPageShow(Document& aDocument, void* aData) {
const bool* aPersistedPtr = static_cast<const bool*>(aData);
aDocument.OnPageShow(*aPersistedPtr, nullptr);
return true;
return CallState::Continue;
}
void Document::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget,
@ -10774,10 +10774,10 @@ void Document::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget,
}
}
static bool NotifyPageHide(Document& aDocument, void* aData) {
static CallState NotifyPageHide(Document& aDocument, void* aData) {
const bool* aPersistedPtr = static_cast<const bool*>(aData);
aDocument.OnPageHide(*aPersistedPtr, nullptr);
return true;
return CallState::Continue;
}
static void DispatchFullscreenChange(Document& aDocument, nsINode* aTarget) {
@ -11190,9 +11190,10 @@ void Document::GetReadyState(nsAString& aReadyState) const {
}
}
static bool SuppressEventHandlingInDocument(Document& aDocument, void* aData) {
static CallState SuppressEventHandlingInDocument(Document& aDocument,
void* aData) {
aDocument.SuppressEventHandling(*static_cast<uint32_t*>(aData));
return true;
return CallState::Continue;
}
void Document::SuppressEventHandling(uint32_t aIncrease) {
@ -11528,7 +11529,8 @@ class nsDelayedEventDispatcher : public Runnable {
nsTArray<nsCOMPtr<Document>> mDocuments;
};
static bool GetAndUnsuppressSubDocuments(Document& aDocument, void* aData) {
static CallState GetAndUnsuppressSubDocuments(Document& aDocument,
void* aData) {
if (aDocument.EventHandlingSuppressed() > 0) {
aDocument.DecreaseEventSuppression();
aDocument.ScriptLoader()->RemoveExecuteBlocker();
@ -11538,7 +11540,7 @@ static bool GetAndUnsuppressSubDocuments(Document& aDocument, void* aData) {
docs->AppendElement(&aDocument);
aDocument.EnumerateSubDocuments(GetAndUnsuppressSubDocuments, aData);
return true;
return CallState::Continue;
}
void Document::UnsuppressEventHandlingAndFireEvents(bool aFireEvents) {
@ -11608,7 +11610,7 @@ void Document::SetSuppressedEventListener(EventListener* aListener) {
[](Document& aDocument, void* aData) {
aDocument.SetSuppressedEventListener(
static_cast<EventListener*>(aData));
return true;
return CallState::Continue;
},
aListener);
}
@ -12160,12 +12162,12 @@ mozilla::dom::ImageTracker* Document::ImageTracker() {
return mImageTracker;
}
static bool AllSubDocumentPluginEnum(Document& aDocument, void* userArg) {
static CallState AllSubDocumentPluginEnum(Document& aDocument, void* userArg) {
nsTArray<nsIObjectLoadingContent*>* plugins =
reinterpret_cast<nsTArray<nsIObjectLoadingContent*>*>(userArg);
MOZ_ASSERT(plugins);
aDocument.GetPlugins(*plugins);
return true;
return CallState::Continue;
}
void Document::GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) {
@ -12963,12 +12965,12 @@ void Document::AsyncExitFullscreen(Document* aDoc) {
}
}
static bool CountFullscreenSubDocuments(Document& aDoc, void* aData) {
static CallState CountFullscreenSubDocuments(Document& aDoc, void* aData) {
if (aDoc.FullscreenStackTop()) {
uint32_t* count = static_cast<uint32_t*>(aData);
(*count)++;
}
return true;
return CallState::Continue;
}
static uint32_t CountFullscreenSubDocuments(Document& aDoc) {
@ -12986,14 +12988,19 @@ bool Document::IsFullscreenLeaf() {
return CountFullscreenSubDocuments(*this) == 0;
}
bool GetFullscreenLeaf(Document& aDoc, void* aData) {
static bool GetFullscreenLeaf(Document& aDoc, void* aData) {
if (aDoc.IsFullscreenLeaf()) {
Document** result = static_cast<Document**>(aData);
*result = &aDoc;
return false;
}
if (aDoc.FullscreenStackTop()) {
aDoc.EnumerateSubDocuments(GetFullscreenLeaf, aData);
aDoc.EnumerateSubDocuments(
[](Document& aDocument, void* aData) {
return GetFullscreenLeaf(aDocument, aData) ? CallState::Continue
: CallState::Stop;
},
aData);
}
return true;
}
@ -13016,7 +13023,7 @@ static Document* GetFullscreenLeaf(Document* aDoc) {
return leaf;
}
static bool ResetFullscreen(Document& aDocument, void* aData) {
static CallState ResetFullscreen(Document& aDocument, void* aData) {
if (Element* fsElement = aDocument.FullscreenStackTop()) {
NS_ASSERTION(CountFullscreenSubDocuments(aDocument) <= 1,
"Should have at most 1 fullscreen subdocument.");
@ -13025,7 +13032,7 @@ static bool ResetFullscreen(Document& aDocument, void* aData) {
DispatchFullscreenChange(aDocument, fsElement);
aDocument.EnumerateSubDocuments(ResetFullscreen, nullptr);
}
return true;
return CallState::Continue;
}
// Since Document::ExitFullscreenInDocTree() could be called from
@ -14496,9 +14503,9 @@ void Document::ReportUseCounters() {
doc->ReportUseCounters();
}
EnumerateExternalResources(
[](Document& aDoc, void*) -> bool {
[](Document& aDoc, void*) -> CallState {
aDoc.ReportUseCounters();
return true;
return CallState::Continue;
},
nullptr);
}
@ -14655,9 +14662,10 @@ void Document::NotifyIntersectionObservers() {
}
}
static bool NotifyLayerManagerRecreatedCallback(Document& aDocument, void*) {
static CallState NotifyLayerManagerRecreatedCallback(Document& aDocument,
void*) {
aDocument.NotifyLayerManagerRecreated();
return true;
return CallState::Continue;
}
void Document::NotifyLayerManagerRecreated() {
@ -14747,7 +14755,8 @@ already_AddRefed<Element> Document::CreateHTMLElement(nsAtom* aTag) {
return element.forget();
}
bool MarkDocumentTreeToBeInSyncOperation(Document& aDoc, void* aData) {
static CallState MarkDocumentTreeToBeInSyncOperation(Document& aDoc,
void* aData) {
auto* documents = static_cast<nsTArray<nsCOMPtr<Document>>*>(aData);
aDoc.SetIsInSyncOperation(true);
if (nsCOMPtr<nsPIDOMWindowInner> window = aDoc.GetInnerWindow()) {
@ -14755,7 +14764,7 @@ bool MarkDocumentTreeToBeInSyncOperation(Document& aDoc, void* aData) {
}
documents->AppendElement(&aDoc);
aDoc.EnumerateSubDocuments(MarkDocumentTreeToBeInSyncOperation, aData);
return true;
return CallState::Continue;
}
nsAutoSyncOperation::nsAutoSyncOperation(Document* aDoc) {

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

@ -48,6 +48,7 @@
#include "nsClassHashtable.h"
#include "ReferrerInfo.h"
#include "mozilla/Attributes.h"
#include "mozilla/CallState.h"
#include "mozilla/CORSMode.h"
#include "mozilla/dom/ContentBlockingLog.h"
#include "mozilla/dom/DispatcherTrait.h"
@ -288,7 +289,7 @@ class DocHeaderData {
};
class ExternalResourceMap {
typedef bool (*SubDocEnumFunc)(Document& aDocument, void* aData);
typedef CallState (*SubDocEnumFunc)(Document& aDocument, void* aData);
public:
/**
@ -2570,10 +2571,11 @@ class Document : public nsINode,
/**
* Enumerate all subdocuments.
* The enumerator callback should return true to continue enumerating, or
* false to stop. This will never get passed a null aDocument.
* The enumerator callback should return CallState::Continue to continue
* enumerating, or CallState::Stop to stop. This will never get passed a null
* aDocument.
*/
typedef bool (*SubDocEnumFunc)(Document&, void* aData);
typedef CallState (*SubDocEnumFunc)(Document&, void* aData);
void EnumerateSubDocuments(SubDocEnumFunc aCallback, void* aData);
/**
@ -2885,8 +2887,9 @@ class Document : public nsINode,
/**
* Enumerate the external resource documents associated with this document.
* The enumerator callback should return true to continue enumerating, or
* false to stop. This callback will never get passed a null aDocument.
* The enumerator callback should return CallState::Continue to continue
* enumerating, or CallState::Stop to stop. This callback will never get
* passed a null aDocument.
*/
void EnumerateExternalResources(SubDocEnumFunc aCallback, void* aData);

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

@ -6742,10 +6742,10 @@ void nsGlobalWindowOuter::ActivateOrDeactivate(bool aActivate) {
}
}
static bool NotifyDocumentTree(Document& aDocument, void*) {
static CallState NotifyDocumentTree(Document& aDocument, void*) {
aDocument.EnumerateSubDocuments(NotifyDocumentTree, nullptr);
aDocument.UpdateDocumentStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE, true);
return true;
return CallState::Continue;
}
void nsGlobalWindowOuter::SetActive(bool aActive) {

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

@ -6325,7 +6325,7 @@ nsIFrame* PresShell::EventHandler::GetNearestFrameContainingPresShell(
return frame;
}
static bool FlushThrottledStyles(Document& aDocument, void* aData) {
static CallState FlushThrottledStyles(Document& aDocument, void* aData) {
PresShell* presShell = aDocument.GetPresShell();
if (presShell && presShell->IsVisible()) {
if (nsPresContext* presContext = presShell->GetPresContext()) {
@ -6334,7 +6334,7 @@ static bool FlushThrottledStyles(Document& aDocument, void* aData) {
}
aDocument.EnumerateSubDocuments(FlushThrottledStyles, nullptr);
return true;
return CallState::Continue;
}
bool PresShell::CanDispatchEvent(const WidgetGUIEvent* aEvent) const {
@ -8836,11 +8836,11 @@ static void FreezeElement(nsISupports* aSupports, void* /* unused */) {
}
}
static bool FreezeSubDocument(Document& aDocument, void*) {
static CallState FreezeSubDocument(Document& aDocument, void*) {
if (PresShell* presShell = aDocument.GetPresShell()) {
presShell->Freeze();
}
return true;
return CallState::Continue;
}
void PresShell::Freeze() {
@ -8906,11 +8906,11 @@ static void ThawElement(nsISupports* aSupports, void* aShell) {
}
}
static bool ThawSubDocument(Document& aDocument, void* aData) {
static CallState ThawSubDocument(Document& aDocument, void* aData) {
if (PresShell* presShell = aDocument.GetPresShell()) {
presShell->Thaw();
}
return true;
return CallState::Continue;
}
void PresShell::Thaw() {
@ -10395,11 +10395,12 @@ void PresShell::QueryIsActive() {
}
// Helper for propagating mIsActive changes to external resources
static bool SetExternalResourceIsActive(Document& aDocument, void* aClosure) {
static CallState SetExternalResourceIsActive(Document& aDocument,
void* aClosure) {
if (PresShell* presShell = aDocument.GetPresShell()) {
presShell->SetIsActive(*static_cast<bool*>(aClosure));
}
return true;
return CallState::Continue;
}
static void SetPluginIsActive(nsISupports* aSupports, void* aClosure) {
@ -11194,11 +11195,11 @@ PresShell::EventHandler::HandlingTimeAccumulator::~HandlingTimeAccumulator() {
}
}
static bool EndPaintHelper(Document& aDocument, void* aData) {
static CallState EndPaintHelper(Document& aDocument, void* aData) {
if (PresShell* presShell = aDocument.GetPresShell()) {
presShell->EndPaint();
}
return true;
return CallState::Continue;
}
void PresShell::EndPaint() {

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

@ -519,11 +519,11 @@ class AutoPrintEventDispatcher {
}
}
static bool CollectDocuments(Document& aDocument, void* aData) {
static CallState CollectDocuments(Document& aDocument, void* aData) {
static_cast<nsTArray<nsCOMPtr<Document>>*>(aData)->AppendElement(
&aDocument);
aDocument.EnumerateSubDocuments(CollectDocuments, aData);
return true;
return CallState::Continue;
}
nsCOMPtr<Document> mTop;
@ -2661,12 +2661,12 @@ void nsDocumentViewer::PropagateToPresContextsHelper(CallChildFunc aChildFunc,
if (mDocument) {
mDocument->EnumerateExternalResources(
[](Document& aDoc, void* aClosure) -> bool {
[](Document& aDoc, void* aClosure) -> CallState {
auto* closure = static_cast<ResourceDocClosure*>(aClosure);
if (nsPresContext* pc = aDoc.GetPresContext()) {
closure->mFunc(pc, closure->mParentClosure);
}
return true;
return CallState::Continue;
},
&resourceDocClosure);
}

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

@ -1400,7 +1400,7 @@ void nsPresContext::UIResolutionChangedSync() {
}
/* static */
bool nsPresContext::UIResolutionChangedSubdocumentCallback(
CallState nsPresContext::UIResolutionChangedSubdocumentCallback(
dom::Document& aDocument, void* aData) {
if (nsPresContext* pc = aDocument.GetPresContext()) {
// For subdocuments, we want to apply the parent's scale, because there
@ -1410,7 +1410,7 @@ bool nsPresContext::UIResolutionChangedSubdocumentCallback(
double scale = *static_cast<double*>(aData);
pc->UIResolutionChangedInternalScale(scale);
}
return true;
return CallState::Continue;
}
static void NotifyTabUIResolutionChanged(nsIRemoteTab* aTab, void* aArg) {
@ -1510,13 +1510,13 @@ void nsPresContext::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
RestyleManager()->PostRebuildAllStyleDataEvent(aExtraHint, aRestyleHint);
}
static bool MediaFeatureValuesChangedAllDocumentsCallback(Document& aDocument,
void* aChange) {
static CallState MediaFeatureValuesChangedAllDocumentsCallback(
Document& aDocument, void* aChange) {
auto* change = static_cast<const MediaFeatureChange*>(aChange);
if (nsPresContext* pc = aDocument.GetPresContext()) {
pc->MediaFeatureValuesChangedAllDocuments(*change);
}
return true;
return CallState::Continue;
}
void nsPresContext::MediaFeatureValuesChangedAllDocuments(
@ -1819,17 +1819,17 @@ void nsPresContext::FireDOMPaintEvent(
static_cast<Event*>(event), this, nullptr);
}
static bool MayHavePaintEventListenerSubdocumentCallback(Document& aDocument,
void* aData) {
static CallState MayHavePaintEventListenerSubdocumentCallback(
Document& aDocument, void* aData) {
bool* result = static_cast<bool*>(aData);
if (nsPresContext* pc = aDocument.GetPresContext()) {
*result = pc->MayHavePaintEventListenerInSubDocument();
// If we found a paint event listener, then we can stop enumerating
// sub documents.
return !*result;
return !*result ? CallState::Continue : CallState::Stop;
}
return true;
return CallState::Continue;
}
static bool MayHavePaintEventListener(nsPIDOMWindowInner* aInnerWindow) {
@ -1989,22 +1989,24 @@ struct NotifyDidPaintSubdocumentCallbackClosure {
TransactionId mTransactionId;
const mozilla::TimeStamp& mTimeStamp;
};
bool nsPresContext::NotifyDidPaintSubdocumentCallback(dom::Document& aDocument,
void* aData) {
/* static */
CallState nsPresContext::NotifyDidPaintSubdocumentCallback(
dom::Document& aDocument, void* aData) {
auto* closure = static_cast<NotifyDidPaintSubdocumentCallbackClosure*>(aData);
if (nsPresContext* pc = aDocument.GetPresContext()) {
pc->NotifyDidPaintForSubtree(closure->mTransactionId, closure->mTimeStamp);
}
return true;
return CallState::Continue;
}
bool nsPresContext::NotifyRevokingDidPaintSubdocumentCallback(
/* static */
CallState nsPresContext::NotifyRevokingDidPaintSubdocumentCallback(
dom::Document& aDocument, void* aData) {
auto* closure = static_cast<NotifyDidPaintSubdocumentCallbackClosure*>(aData);
if (nsPresContext* pc = aDocument.GetPresContext()) {
pc->NotifyRevokingDidPaint(closure->mTransactionId);
}
return true;
return CallState::Continue;
}
class DelayedFireDOMPaintEvent : public Runnable {

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

@ -1060,8 +1060,8 @@ class nsPresContext : public nsISupports,
// aData here is a pointer to a double that holds the CSS to device-pixel
// scale factor from the parent, which will be applied to the subdocument's
// device context instead of retrieving a scale from the widget.
static bool UIResolutionChangedSubdocumentCallback(mozilla::dom::Document&,
void* aData);
static mozilla::CallState UIResolutionChangedSubdocumentCallback(
mozilla::dom::Document&, void* aData);
void SetImgAnimations(nsIContent* aParent, uint16_t aMode);
void SetSMILAnimations(mozilla::dom::Document* aDoc, uint16_t aNewMode,
@ -1077,10 +1077,10 @@ class nsPresContext : public nsISupports,
void UpdateCharSet(NotNull<const Encoding*> aCharSet);
static bool NotifyDidPaintSubdocumentCallback(mozilla::dom::Document&,
void* aData);
static bool NotifyRevokingDidPaintSubdocumentCallback(mozilla::dom::Document&,
void* aData);
static mozilla::CallState NotifyDidPaintSubdocumentCallback(
mozilla::dom::Document&, void* aData);
static mozilla::CallState NotifyRevokingDidPaintSubdocumentCallback(
mozilla::dom::Document&, void* aData);
public:
// Used by the PresShell to force a reflow when some aspect of font info

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

@ -1808,13 +1808,13 @@ void nsRefreshDriver::CancelIdleRunnable(nsIRunnable* aRunnable) {
}
}
static bool ReduceAnimations(Document& aDocument, void* aData) {
static CallState ReduceAnimations(Document& aDocument, void* aData) {
if (aDocument.GetPresContext() &&
aDocument.GetPresContext()->EffectCompositor()->NeedsReducing()) {
aDocument.GetPresContext()->EffectCompositor()->ReduceAnimations();
}
aDocument.EnumerateSubDocuments(ReduceAnimations, nullptr);
return true;
return CallState::Continue;
}
void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {

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

@ -1026,7 +1026,7 @@ static void DestroyDisplayItemDataForFrames(nsIFrame* aFrame) {
}
}
static bool BeginSwapDocShellsForDocument(Document& aDocument, void*) {
static CallState BeginSwapDocShellsForDocument(Document& aDocument, void*) {
if (PresShell* presShell = aDocument.GetPresShell()) {
// Disable painting while the views are detached, see bug 946929.
presShell->SetNeverPainting(true);
@ -1038,7 +1038,7 @@ static bool BeginSwapDocShellsForDocument(Document& aDocument, void*) {
aDocument.EnumerateActivityObservers(nsPluginFrame::BeginSwapDocShells,
nullptr);
aDocument.EnumerateSubDocuments(BeginSwapDocShellsForDocument, nullptr);
return true;
return CallState::Continue;
}
static nsView* BeginSwapDocShellsForViews(nsView* aSibling) {
@ -1099,7 +1099,7 @@ nsresult nsSubDocumentFrame::BeginSwapDocShells(nsIFrame* aOther) {
return NS_OK;
}
static bool EndSwapDocShellsForDocument(Document& aDocument, void*) {
static CallState EndSwapDocShellsForDocument(Document& aDocument, void*) {
// Our docshell and view trees have been updated for the new hierarchy.
// Now also update all nsDeviceContext::mWidget to that of the
// container view in the new hierarchy.
@ -1123,7 +1123,7 @@ static bool EndSwapDocShellsForDocument(Document& aDocument, void*) {
aDocument.EnumerateActivityObservers(nsPluginFrame::EndSwapDocShells,
nullptr);
aDocument.EnumerateSubDocuments(EndSwapDocShellsForDocument, nullptr);
return true;
return CallState::Continue;
}
static void EndSwapDocShellsForViews(nsView* aSibling) {

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

@ -922,7 +922,7 @@ static nsIFrame* GetRootFrameForPainting(nsDisplayListBuilder* aBuilder,
return presShell ? presShell->GetRootFrame() : nullptr;
}
static bool SubDocEnumCb(Document& aDocument, void* aData) {
static CallState SubDocEnumCb(Document& aDocument, void* aData) {
MOZ_ASSERT(aData);
auto* data = static_cast<CbData*>(aData);
@ -935,7 +935,7 @@ static bool SubDocEnumCb(Document& aDocument, void* aData) {
innerDoc->EnumerateSubDocuments(SubDocEnumCb, aData);
}
}
return true;
return CallState::Continue;
}
static void GetModifiedAndFramesWithProps(

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

@ -2924,8 +2924,8 @@ bool nsDisplayList::ComputeVisibilityForSublist(
return anyVisible;
}
static bool TriggerPendingAnimationsOnSubDocuments(Document& aDoc,
void* aReadyTime) {
static CallState TriggerPendingAnimationsOnSubDocuments(Document& aDoc,
void* aReadyTime) {
if (PendingAnimationTracker* tracker = aDoc.GetPendingAnimationTracker()) {
PresShell* presShell = aDoc.GetPresShell();
// If paint-suppression is in effect then we haven't finished painting
@ -2937,7 +2937,7 @@ static bool TriggerPendingAnimationsOnSubDocuments(Document& aDoc,
}
aDoc.EnumerateSubDocuments(TriggerPendingAnimationsOnSubDocuments,
aReadyTime);
return true;
return CallState::Continue;
}
static void TriggerPendingAnimations(Document& aDocument,

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

@ -521,10 +521,10 @@ static nsresult EnsureSettingsHasPrinterNameSet(
#endif
}
static bool DocHasPrintCallbackCanvas(Document& aDoc, void* aData) {
static CallState DocHasPrintCallbackCanvas(Document& aDoc, void* aData) {
Element* root = aDoc.GetRootElement();
if (!root) {
return true;
return CallState::Continue;
}
RefPtr<nsContentList> canvases =
NS_GetContentList(root, kNameSpaceID_XHTML, NS_LITERAL_STRING("canvas"));
@ -536,10 +536,10 @@ static bool DocHasPrintCallbackCanvas(Document& aDoc, void* aData) {
// This subdocument has a print callback. Set result and return false to
// stop iteration.
*static_cast<bool*>(aData) = true;
return false;
return CallState::Stop;
}
}
return true;
return CallState::Continue;
}
static bool AnySubdocHasPrintCallbackCanvas(Document& aDoc) {