Chromium Code Reviews| 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 { |