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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2688473005: Replace Document::postTask with WebTaskRunner::postTask (Closed)
Patch Set: remove extra null-check: context on addConsoleMessage is now persistent 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 379
380 return element.document().frame() && rootEditableElement(element); 380 return element.document().frame() && rootEditableElement(element);
381 } 381 }
382 382
383 uint64_t Document::s_globalTreeVersion = 0; 383 uint64_t Document::s_globalTreeVersion = 0;
384 384
385 static bool s_threadedParsingEnabledForTesting = true; 385 static bool s_threadedParsingEnabledForTesting = true;
386 386
387 // This doesn't work with non-Document ExecutionContext. 387 // This doesn't work with non-Document ExecutionContext.
388 static void runAutofocusTask(ExecutionContext* context) { 388 static void runAutofocusTask(ExecutionContext* context) {
389 // Document lifecycle check is done in Element::focus()
390 if (!context)
391 return;
392
389 Document* document = toDocument(context); 393 Document* document = toDocument(context);
390 if (Element* element = document->autofocusElement()) { 394 if (Element* element = document->autofocusElement()) {
391 document->setAutofocusElement(0); 395 document->setAutofocusElement(0);
392 element->focus(); 396 element->focus();
393 } 397 }
394 } 398 }
395 399
396 static void recordLoadReasonToHistogram(WouldLoadReason reason) { 400 static void recordLoadReasonToHistogram(WouldLoadReason reason) {
397 DEFINE_STATIC_LOCAL( 401 DEFINE_STATIC_LOCAL(
398 EnumerationHistogram, unseenFrameHistogram, 402 EnumerationHistogram, unseenFrameHistogram,
(...skipping 5316 matching lines...) Expand 10 before | Expand all | Expand 10 after
5715 5719
5716 static void runAddConsoleMessageTask(MessageSource source, 5720 static void runAddConsoleMessageTask(MessageSource source,
5717 MessageLevel level, 5721 MessageLevel level,
5718 const String& message, 5722 const String& message,
5719 ExecutionContext* context) { 5723 ExecutionContext* context) {
5720 context->addConsoleMessage(ConsoleMessage::create(source, level, message)); 5724 context->addConsoleMessage(ConsoleMessage::create(source, level, message));
5721 } 5725 }
5722 5726
5723 void Document::addConsoleMessage(ConsoleMessage* consoleMessage) { 5727 void Document::addConsoleMessage(ConsoleMessage* consoleMessage) {
5724 if (!isContextThread()) { 5728 if (!isContextThread()) {
5725 postTask(TaskType::Unthrottled, BLINK_FROM_HERE, 5729 TaskRunnerHelper::get(TaskType::Unthrottled, this)
5726 createCrossThreadTask( 5730 ->postTask(
5727 &runAddConsoleMessageTask, consoleMessage->source(), 5731 BLINK_FROM_HERE,
5728 consoleMessage->level(), consoleMessage->message())); 5732 crossThreadBind(&runAddConsoleMessageTask, consoleMessage->source(),
5733 consoleMessage->level(), consoleMessage->message(),
5734 wrapCrossThreadPersistent(this)));
5729 return; 5735 return;
5730 } 5736 }
5731 5737
5732 if (!m_frame) 5738 if (!m_frame)
5733 return; 5739 return;
5734 5740
5735 if (consoleMessage->location()->isUnknown()) { 5741 if (consoleMessage->location()->isUnknown()) {
5736 // TODO(dgozman): capture correct location at call places instead. 5742 // TODO(dgozman): capture correct location at call places instead.
5737 unsigned lineNumber = 0; 5743 unsigned lineNumber = 0;
5738 if (!isInDocumentWrite() && scriptableDocumentParser()) { 5744 if (!isInDocumentWrite() && scriptableDocumentParser()) {
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
6305 void Document::setAutofocusElement(Element* element) { 6311 void Document::setAutofocusElement(Element* element) {
6306 if (!element) { 6312 if (!element) {
6307 m_autofocusElement = nullptr; 6313 m_autofocusElement = nullptr;
6308 return; 6314 return;
6309 } 6315 }
6310 if (m_hasAutofocused) 6316 if (m_hasAutofocused)
6311 return; 6317 return;
6312 m_hasAutofocused = true; 6318 m_hasAutofocused = true;
6313 DCHECK(!m_autofocusElement); 6319 DCHECK(!m_autofocusElement);
6314 m_autofocusElement = element; 6320 m_autofocusElement = element;
6315 postTask(TaskType::UserInteraction, BLINK_FROM_HERE, 6321 TaskRunnerHelper::get(TaskType::UserInteraction, this)
6316 createSameThreadTask(&runAutofocusTask)); 6322 ->postTask(BLINK_FROM_HERE,
6323 WTF::bind(&runAutofocusTask, wrapWeakPersistent(this)));
6317 } 6324 }
6318 6325
6319 Element* Document::activeElement() const { 6326 Element* Document::activeElement() const {
6320 if (Element* element = adjustedFocusedElement()) 6327 if (Element* element = adjustedFocusedElement())
6321 return element; 6328 return element;
6322 return body(); 6329 return body();
6323 } 6330 }
6324 6331
6325 bool Document::hasFocus() const { 6332 bool Document::hasFocus() const {
6326 return page() && page()->focusController().isDocumentFocused(*this); 6333 return page() && page()->focusController().isDocumentFocused(*this);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
6580 } 6587 }
6581 6588
6582 void showLiveDocumentInstances() { 6589 void showLiveDocumentInstances() {
6583 WeakDocumentSet& set = liveDocumentSet(); 6590 WeakDocumentSet& set = liveDocumentSet();
6584 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6591 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6585 for (blink::Document* document : set) 6592 for (blink::Document* document : set)
6586 fprintf(stderr, "- Document %p URL: %s\n", document, 6593 fprintf(stderr, "- Document %p URL: %s\n", document,
6587 document->url().getString().utf8().data()); 6594 document->url().getString().utf8().data());
6588 } 6595 }
6589 #endif 6596 #endif
OLDNEW
« 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