Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 DCHECK(hasEditableStyle(element)); | 378 DCHECK(hasEditableStyle(element)); |
| 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) { |
|
tzik
2017/02/09 23:50:20
null check for |context| is needed here too.
yuryu
2017/02/13 03:33:22
Done.
| |
| 389 Document* document = toDocument(context); | 389 Document* document = toDocument(context); |
| 390 if (Element* element = document->autofocusElement()) { | 390 if (Element* element = document->autofocusElement()) { |
| 391 document->setAutofocusElement(0); | 391 document->setAutofocusElement(0); |
| 392 element->focus(); | 392 element->focus(); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 static void recordLoadReasonToHistogram(WouldLoadReason reason) { | 396 static void recordLoadReasonToHistogram(WouldLoadReason reason) { |
| 397 DEFINE_STATIC_LOCAL( | 397 DEFINE_STATIC_LOCAL( |
| 398 EnumerationHistogram, unseenFrameHistogram, | 398 EnumerationHistogram, unseenFrameHistogram, |
| (...skipping 5306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5705 | 5705 |
| 5706 ResizeObserverController& Document::ensureResizeObserverController() { | 5706 ResizeObserverController& Document::ensureResizeObserverController() { |
| 5707 if (!m_resizeObserverController) | 5707 if (!m_resizeObserverController) |
| 5708 m_resizeObserverController = new ResizeObserverController(); | 5708 m_resizeObserverController = new ResizeObserverController(); |
| 5709 return *m_resizeObserverController; | 5709 return *m_resizeObserverController; |
| 5710 } | 5710 } |
| 5711 | 5711 |
| 5712 static void runAddConsoleMessageTask(MessageSource source, | 5712 static void runAddConsoleMessageTask(MessageSource source, |
| 5713 MessageLevel level, | 5713 MessageLevel level, |
| 5714 const String& message, | 5714 const String& message, |
| 5715 ExecutionContext* context) { | 5715 ExecutionContext* context) { |
|
tzik
2017/02/09 23:50:19
null check for |context| is needed here, since pos
yuryu
2017/02/13 03:33:22
Done.
| |
| 5716 context->addConsoleMessage(ConsoleMessage::create(source, level, message)); | 5716 context->addConsoleMessage(ConsoleMessage::create(source, level, message)); |
| 5717 } | 5717 } |
| 5718 | 5718 |
| 5719 void Document::addConsoleMessage(ConsoleMessage* consoleMessage) { | 5719 void Document::addConsoleMessage(ConsoleMessage* consoleMessage) { |
| 5720 if (!isContextThread()) { | 5720 if (!isContextThread()) { |
| 5721 postTask(TaskType::Unthrottled, BLINK_FROM_HERE, | 5721 TaskRunnerHelper::get(TaskType::Unthrottled, this) |
| 5722 createCrossThreadTask( | 5722 ->postTask( |
| 5723 &runAddConsoleMessageTask, consoleMessage->source(), | 5723 BLINK_FROM_HERE, |
| 5724 consoleMessage->level(), consoleMessage->message())); | 5724 crossThreadBind(&runAddConsoleMessageTask, consoleMessage->source(), |
| 5725 consoleMessage->level(), consoleMessage->message(), | |
| 5726 wrapCrossThreadWeakPersistent(this))); | |
| 5725 return; | 5727 return; |
| 5726 } | 5728 } |
| 5727 | 5729 |
| 5728 if (!m_frame) | 5730 if (!m_frame) |
| 5729 return; | 5731 return; |
| 5730 | 5732 |
| 5731 if (consoleMessage->location()->isUnknown()) { | 5733 if (consoleMessage->location()->isUnknown()) { |
| 5732 // TODO(dgozman): capture correct location at call places instead. | 5734 // TODO(dgozman): capture correct location at call places instead. |
| 5733 unsigned lineNumber = 0; | 5735 unsigned lineNumber = 0; |
| 5734 if (!isInDocumentWrite() && scriptableDocumentParser()) { | 5736 if (!isInDocumentWrite() && scriptableDocumentParser()) { |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6301 void Document::setAutofocusElement(Element* element) { | 6303 void Document::setAutofocusElement(Element* element) { |
| 6302 if (!element) { | 6304 if (!element) { |
| 6303 m_autofocusElement = nullptr; | 6305 m_autofocusElement = nullptr; |
| 6304 return; | 6306 return; |
| 6305 } | 6307 } |
| 6306 if (m_hasAutofocused) | 6308 if (m_hasAutofocused) |
| 6307 return; | 6309 return; |
| 6308 m_hasAutofocused = true; | 6310 m_hasAutofocused = true; |
| 6309 DCHECK(!m_autofocusElement); | 6311 DCHECK(!m_autofocusElement); |
| 6310 m_autofocusElement = element; | 6312 m_autofocusElement = element; |
| 6311 postTask(TaskType::UserInteraction, BLINK_FROM_HERE, | 6313 TaskRunnerHelper::get(TaskType::UserInteraction, this) |
| 6312 createSameThreadTask(&runAutofocusTask)); | 6314 ->postTask(BLINK_FROM_HERE, |
| 6315 WTF::bind(&runAutofocusTask, wrapWeakPersistent(this))); | |
| 6313 } | 6316 } |
| 6314 | 6317 |
| 6315 Element* Document::activeElement() const { | 6318 Element* Document::activeElement() const { |
| 6316 if (Element* element = adjustedFocusedElement()) | 6319 if (Element* element = adjustedFocusedElement()) |
| 6317 return element; | 6320 return element; |
| 6318 return body(); | 6321 return body(); |
| 6319 } | 6322 } |
| 6320 | 6323 |
| 6321 bool Document::hasFocus() const { | 6324 bool Document::hasFocus() const { |
| 6322 return page() && page()->focusController().isDocumentFocused(*this); | 6325 return page() && page()->focusController().isDocumentFocused(*this); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6576 } | 6579 } |
| 6577 | 6580 |
| 6578 void showLiveDocumentInstances() { | 6581 void showLiveDocumentInstances() { |
| 6579 WeakDocumentSet& set = liveDocumentSet(); | 6582 WeakDocumentSet& set = liveDocumentSet(); |
| 6580 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6583 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6581 for (blink::Document* document : set) | 6584 for (blink::Document* document : set) |
| 6582 fprintf(stderr, "- Document %p URL: %s\n", document, | 6585 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6583 document->url().getString().utf8().data()); | 6586 document->url().getString().utf8().data()); |
| 6584 } | 6587 } |
| 6585 #endif | 6588 #endif |
| OLD | NEW |