Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2688473005: Replace Document::postTask with WebTaskRunner::postTask (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 03a65cf6a6ec13f79de3710a15377b2db0ef2274..e6169ac4cc664b80c49ae1e7938272b5309e8216 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -386,6 +386,9 @@ static bool s_threadedParsingEnabledForTesting = true;
// This doesn't work with non-Document ExecutionContext.
static void runAutofocusTask(ExecutionContext* context) {
+ if (!context)
+ return;
+
Document* document = toDocument(context);
if (Element* element = document->autofocusElement()) {
document->setAutofocusElement(0);
@@ -5717,15 +5720,18 @@ static void runAddConsoleMessageTask(MessageSource source,
MessageLevel level,
const String& message,
ExecutionContext* context) {
- context->addConsoleMessage(ConsoleMessage::create(source, level, message));
+ if (context)
+ context->addConsoleMessage(ConsoleMessage::create(source, level, message));
}
void Document::addConsoleMessage(ConsoleMessage* consoleMessage) {
if (!isContextThread()) {
- postTask(TaskType::Unthrottled, BLINK_FROM_HERE,
- createCrossThreadTask(
- &runAddConsoleMessageTask, consoleMessage->source(),
- consoleMessage->level(), consoleMessage->message()));
+ TaskRunnerHelper::get(TaskType::Unthrottled, this)
+ ->postTask(
+ BLINK_FROM_HERE,
+ crossThreadBind(&runAddConsoleMessageTask, consoleMessage->source(),
+ consoleMessage->level(), consoleMessage->message(),
+ wrapCrossThreadWeakPersistent(this)));
haraken 2017/02/13 06:43:51 I guess we should use a strong Persistent here bec
yuryu 2017/02/13 09:14:04 Done.
return;
}
@@ -6312,8 +6318,9 @@ void Document::setAutofocusElement(Element* element) {
m_hasAutofocused = true;
DCHECK(!m_autofocusElement);
m_autofocusElement = element;
- postTask(TaskType::UserInteraction, BLINK_FROM_HERE,
- createSameThreadTask(&runAutofocusTask));
+ TaskRunnerHelper::get(TaskType::UserInteraction, this)
+ ->postTask(BLINK_FROM_HERE,
+ WTF::bind(&runAutofocusTask, wrapWeakPersistent(this)));
haraken 2017/02/13 06:43:52 Ditto.
tzik 2017/02/13 06:56:33 I think this should be weak, since focusing an ele
haraken 2017/02/13 06:58:35 Then we should explicitly check if the document ha
tzik 2017/02/13 08:58:53 We don't need the check, since it's done in Elemen
yuryu 2017/02/13 09:14:04 Do you think it's good to add a comment about it?
yuryu 2017/02/13 09:21:15 Done.
}
Element* Document::activeElement() const {
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698