Bug 1261499 - Make nsContentUtils::AddScriptRunner return void, r=khuey

This commit is contained in:
Ben Tian 2016-05-06 16:09:03 +08:00
Родитель bf94e2fc4e
Коммит 1d3df2ccde
7 изменённых файлов: 16 добавлений и 32 удалений

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

@ -5029,28 +5029,27 @@ nsContentUtils::WarnScriptWasIgnored(nsIDocument* aDocument)
}
/* static */
bool
void
nsContentUtils::AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable)
{
nsCOMPtr<nsIRunnable> 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<nsIRunnable> runnable = aRunnable;
return AddScriptRunner(runnable.forget());
AddScriptRunner(runnable.forget());
}
/* static */

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

@ -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<nsIRunnable> aRunnable);
static bool AddScriptRunner(nsIRunnable* aRunnable);
static void AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable);
static void AddScriptRunner(nsIRunnable* aRunnable);
/**
* Returns true if it's safe to execute content script and false otherwise.

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

@ -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;
}

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

@ -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;

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

@ -159,7 +159,8 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder)
nsCOMPtr<nsIRunnable> 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;
}
}

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

@ -1012,8 +1012,7 @@ nsComboboxControlFrame::RedisplayText(int32_t aIndex)
RefPtr<RedisplayTextEvent> event = new RedisplayTextEvent(this);
mRedisplayTextEvent = event;
if (!nsContentUtils::AddScriptRunner(event))
mRedisplayTextEvent.Forget();
nsContentUtils::AddScriptRunner(event);
}
return rv;
}

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

@ -394,12 +394,7 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& 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;