From 1d3df2ccde81264de1c550348e0405eafe99acac Mon Sep 17 00:00:00 2001 From: Ben Tian Date: Fri, 6 May 2016 16:09:03 +0800 Subject: [PATCH] Bug 1261499 - Make nsContentUtils::AddScriptRunner return void, r=khuey --- dom/base/nsContentUtils.cpp | 15 +++++++-------- dom/base/nsContentUtils.h | 5 ++--- dom/base/nsDocument.cpp | 10 +--------- dom/html/nsTextEditorState.cpp | 5 ++--- dom/plugins/base/nsPluginInstanceOwner.cpp | 3 ++- layout/forms/nsComboboxControlFrame.cpp | 3 +-- layout/forms/nsTextControlFrame.cpp | 7 +------ 7 files changed, 16 insertions(+), 32 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index a11dcb8ea98b..317a47481610 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5029,28 +5029,27 @@ nsContentUtils::WarnScriptWasIgnored(nsIDocument* aDocument) } /* static */ -bool +void nsContentUtils::AddScriptRunner(already_AddRefed aRunnable) { nsCOMPtr runnable = aRunnable; if (!runnable) { - return false; + return; } if (sScriptBlockerCount) { - return sBlockedScriptRunners->AppendElement(runnable.forget()) != nullptr; + sBlockedScriptRunners->AppendElement(runnable.forget()); + return; } - - runnable->Run(); - return true; + runnable->Run(); } /* static */ -bool +void nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) { nsCOMPtr runnable = aRunnable; - return AddScriptRunner(runnable.forget()); + AddScriptRunner(runnable.forget()); } /* static */ diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 890287ac8fba..2359acc66497 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1606,10 +1606,9 @@ public: * scripts. Passing null is allowed and results in nothing * happening. It is also allowed to pass an object that * has not yet been AddRefed. - * @return false on out of memory, true otherwise. */ - static bool AddScriptRunner(already_AddRefed aRunnable); - static bool AddScriptRunner(nsIRunnable* aRunnable); + static void AddScriptRunner(already_AddRefed aRunnable); + static void AddScriptRunner(nsIRunnable* aRunnable); /** * Returns true if it's safe to execute content script and false otherwise. diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 89a11b8a1c54..ffe5aa7d447d 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -9082,16 +9082,8 @@ nsDocument::BlockOnload() // block onload only when there are no script blockers. ++mAsyncOnloadBlockCount; if (mAsyncOnloadBlockCount == 1) { - bool success = nsContentUtils::AddScriptRunner( + nsContentUtils::AddScriptRunner( NewRunnableMethod(this, &nsDocument::AsyncBlockOnload)); - - // The script runner shouldn't fail to add. But if somebody broke - // something and it does, we'll thrash at 100% cpu forever. The best - // response is just to ignore the onload blocking request. See bug 579535. - if (!success) { - NS_WARNING("Disaster! Onload blocking script runner failed to add - expect bad things!"); - mAsyncOnloadBlockCount = 0; - } } return; } diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index 7bbb15f00a3e..e560dfe1a981 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -1196,9 +1196,8 @@ nsTextEditorState::BindToFrame(nsTextControlFrame* aFrame) // otherwise, inherit the content node's direction } - if (!nsContentUtils::AddScriptRunner( - new PrepareEditorEvent(*this, content, currentValue))) - return NS_ERROR_OUT_OF_MEMORY; + nsContentUtils::AddScriptRunner( + new PrepareEditorEvent(*this, content, currentValue)); } return NS_OK; diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 4207cbc5c187..13ecbb4f1897 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -159,7 +159,8 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder) nsCOMPtr event = new AsyncPaintWaitEvent(content, false); // Run this event as soon as it's safe to do so, since listeners need to // receive it immediately - mWaitingForPaint = nsContentUtils::AddScriptRunner(event); + nsContentUtils::AddScriptRunner(event); + mWaitingForPaint = true; } } diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 47a29946ed61..1f74c70fc5e9 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -1012,8 +1012,7 @@ nsComboboxControlFrame::RedisplayText(int32_t aIndex) RefPtr event = new RedisplayTextEvent(this); mRedisplayTextEvent = event; - if (!nsContentUtils::AddScriptRunner(event)) - mRedisplayTextEvent.Forget(); + nsContentUtils::AddScriptRunner(event); } return rv; } diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 7ca99e44eca8..f5f1a5d8a69a 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -394,12 +394,7 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray& aElements) } initializer = new EditorInitializer(this); Properties().Set(TextControlInitializer(),initializer); - if (!nsContentUtils::AddScriptRunner(initializer)) { - initializer->Revoke(); // paranoia - Properties().Delete(TextControlInitializer()); - delete initializer; - return NS_ERROR_OUT_OF_MEMORY; - } + nsContentUtils::AddScriptRunner(initializer); } return NS_OK;