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

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

Issue 465563002: Make onload async (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/loader/FrameLoader.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 r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 , m_isSrcdocDocument(false) 482 , m_isSrcdocDocument(false)
483 , m_isMobileDocument(false) 483 , m_isMobileDocument(false)
484 , m_isTransitionDocument(false) 484 , m_isTransitionDocument(false)
485 , m_renderView(0) 485 , m_renderView(0)
486 #if !ENABLE(OILPAN) 486 #if !ENABLE(OILPAN)
487 , m_weakFactory(this) 487 , m_weakFactory(this)
488 #endif 488 #endif
489 , m_contextDocument(initializer.contextDocument()) 489 , m_contextDocument(initializer.contextDocument())
490 , m_hasFullscreenElementStack(false) 490 , m_hasFullscreenElementStack(false)
491 , m_loadEventDelayCount(0) 491 , m_loadEventDelayCount(0)
492 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) 492 , m_loadEventTimer(this, &Document::loadEventTimerFired)
493 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired) 493 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired)
494 , m_didSetReferrerPolicy(false) 494 , m_didSetReferrerPolicy(false)
495 , m_referrerPolicy(ReferrerPolicyDefault) 495 , m_referrerPolicy(ReferrerPolicyDefault)
496 , m_directionSetOnDocumentElement(false) 496 , m_directionSetOnDocumentElement(false)
497 , m_writingModeSetOnDocumentElement(false) 497 , m_writingModeSetOnDocumentElement(false)
498 , m_writeRecursionIsTooDeep(false) 498 , m_writeRecursionIsTooDeep(false)
499 , m_writeRecursionDepth(0) 499 , m_writeRecursionDepth(0)
500 , m_taskRunner(MainThreadTaskRunner::create(this)) 500 , m_taskRunner(MainThreadTaskRunner::create(this))
501 , m_registrationContext(initializer.registrationContext(this)) 501 , m_registrationContext(initializer.registrationContext(this))
502 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red) 502 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red)
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 } 2502 }
2503 2503
2504 m_frame->loader().checkCompleted(); 2504 m_frame->loader().checkCompleted();
2505 } 2505 }
2506 2506
2507 void Document::implicitClose() 2507 void Document::implicitClose()
2508 { 2508 {
2509 ASSERT(!inStyleRecalc()); 2509 ASSERT(!inStyleRecalc());
2510 2510
2511 bool wasLocationChangePending = frame() && frame()->navigationScheduler().lo cationChangePending(); 2511 bool wasLocationChangePending = frame() && frame()->navigationScheduler().lo cationChangePending();
2512 bool doload = !parsing() && m_parser && !processingLoadEvent() && !wasLocati onChangePending;
2513
2514 // If the load was blocked because of a pending location change and the loca tion change triggers a same document 2512 // If the load was blocked because of a pending location change and the loca tion change triggers a same document
2515 // navigation, don't fire load events after the same document navigation com pletes (unless there's an explicit open). 2513 // navigation, don't fire load events after the same document navigation com pletes (unless there's an explicit open).
2516 m_loadEventProgress = LoadEventTried; 2514 if (parsing() || !m_parser || processingLoadEvent() || wasLocationChangePend ing) {
2515 m_loadEventProgress = LoadEventTried;
2516 return;
2517 }
2517 2518
2518 if (!doload) 2519 m_loadEventProgress = LoadEventScheduled;
2519 return; 2520 m_loadEventTimer.startOneShot(0, FROM_HERE);
2521 }
2520 2522
2523 void Document::loadEventTimerFired(Timer<Document>*)
2524 {
2521 // The call to dispatchWindowLoadEvent can detach the LocalDOMWindow and cau se it (and its 2525 // The call to dispatchWindowLoadEvent can detach the LocalDOMWindow and cau se it (and its
2522 // attached Document) to be destroyed. 2526 // attached Document) to be destroyed.
2523 RefPtrWillBeRawPtr<LocalDOMWindow> protectedWindow(this->domWindow()); 2527 RefPtrWillBeRawPtr<LocalDOMWindow> protectedWindow(this->domWindow());
2524 2528
2525 m_loadEventProgress = LoadEventInProgress; 2529 m_loadEventProgress = LoadEventInProgress;
2526 2530
2527 ScriptableDocumentParser* parser = scriptableDocumentParser(); 2531 ScriptableDocumentParser* parser = scriptableDocumentParser();
2528 m_wellFormed = parser && parser->wellFormed(); 2532 m_wellFormed = parser && parser->wellFormed();
2529 2533
2530 // We have to clear the parser, in case someone document.write()s from the 2534 // We have to clear the parser, in case someone document.write()s from the
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 } else { 2600 } else {
2597 // AXLoadComplete can only be posted on the top document, so if it's a document 2601 // AXLoadComplete can only be posted on the top document, so if it's a document
2598 // in an iframe that just finished loading, post AXLayoutComplet e instead. 2602 // in an iframe that just finished loading, post AXLayoutComplet e instead.
2599 cache->postNotification(renderView(), AXObjectCache::AXLayoutCom plete, true); 2603 cache->postNotification(renderView(), AXObjectCache::AXLayoutCom plete, true);
2600 } 2604 }
2601 } 2605 }
2602 } 2606 }
2603 2607
2604 if (svgExtensions()) 2608 if (svgExtensions())
2605 accessSVGExtensions().startAnimations(); 2609 accessSVGExtensions().startAnimations();
2610
2611 if (frame()) {
2612 if (Frame* parent = frame()->tree().parent())
2613 toLocalFrame(parent)->loader().checkCompleted();
2614 frame()->loader().checkLoadComplete();
2615 }
2606 } 2616 }
2607 2617
2608 bool Document::dispatchBeforeUnloadEvent(Chrome& chrome, bool& didAllowNavigatio n) 2618 bool Document::dispatchBeforeUnloadEvent(Chrome& chrome, bool& didAllowNavigatio n)
2609 { 2619 {
2610 if (!m_domWindow) 2620 if (!m_domWindow)
2611 return true; 2621 return true;
2612 2622
2613 if (!body()) 2623 if (!body())
2614 return true; 2624 return true;
2615 2625
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after
5142 } 5152 }
5143 return 0; 5153 return 0;
5144 } 5154 }
5145 5155
5146 void Document::decrementLoadEventDelayCount() 5156 void Document::decrementLoadEventDelayCount()
5147 { 5157 {
5148 ASSERT(m_loadEventDelayCount); 5158 ASSERT(m_loadEventDelayCount);
5149 --m_loadEventDelayCount; 5159 --m_loadEventDelayCount;
5150 5160
5151 if (!m_loadEventDelayCount) 5161 if (!m_loadEventDelayCount)
5152 checkLoadEventSoon(); 5162 checkLoadEvent();
5153 } 5163 }
5154 5164
5155 void Document::checkLoadEventSoon() 5165 void Document::checkLoadEvent()
5156 { 5166 {
5157 if (frame() && !m_loadEventDelayTimer.isActive()) 5167 if (frame())
5158 m_loadEventDelayTimer.startOneShot(0, FROM_HERE); 5168 frame()->loader().checkCompleted();
5159 } 5169 }
5160 5170
5161 bool Document::isDelayingLoadEvent() 5171 bool Document::isDelayingLoadEvent()
5162 { 5172 {
5163 #if ENABLE(OILPAN) 5173 #if ENABLE(OILPAN)
5164 // Always delay load events until after garbage collection. 5174 // Always delay load events until after garbage collection.
5165 // This way we don't have to explicitly delay load events via 5175 // This way we don't have to explicitly delay load events via
5166 // incrementLoadEventDelayCount and decrementLoadEventDelayCount in 5176 // incrementLoadEventDelayCount and decrementLoadEventDelayCount in
5167 // Node destructors. 5177 // Node destructors.
5168 if (ThreadState::current()->isSweepInProgress()) { 5178 if (ThreadState::current()->isSweepInProgress()) {
5169 if (!m_loadEventDelayCount) 5179 if (!m_loadEventDelayCount)
5170 checkLoadEventSoon(); 5180 checkLoadEvent();
5171 return true; 5181 return true;
5172 } 5182 }
5173 #endif 5183 #endif
5174 return m_loadEventDelayCount; 5184 return m_loadEventDelayCount || m_loadEventTimer.isActive();
5175 }
5176
5177
5178 void Document::loadEventDelayTimerFired(Timer<Document>*)
5179 {
5180 if (frame())
5181 frame()->loader().checkCompleted();
5182 } 5185 }
5183 5186
5184 void Document::loadPluginsSoon() 5187 void Document::loadPluginsSoon()
5185 { 5188 {
5186 // FIXME: Remove this timer once we don't need to compute layout to load plu gins. 5189 // FIXME: Remove this timer once we don't need to compute layout to load plu gins.
5187 if (!m_pluginLoadingTimer.isActive()) 5190 if (!m_pluginLoadingTimer.isActive())
5188 m_pluginLoadingTimer.startOneShot(0, FROM_HERE); 5191 m_pluginLoadingTimer.startOneShot(0, FROM_HERE);
5189 } 5192 }
5190 5193
5191 void Document::pluginLoadingTimerFired(Timer<Document>*) 5194 void Document::pluginLoadingTimerFired(Timer<Document>*)
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
5892 using namespace blink; 5895 using namespace blink;
5893 void showLiveDocumentInstances() 5896 void showLiveDocumentInstances()
5894 { 5897 {
5895 WeakDocumentSet& set = liveDocumentSet(); 5898 WeakDocumentSet& set = liveDocumentSet();
5896 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5899 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5897 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5900 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5898 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5901 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5899 } 5902 }
5900 } 5903 }
5901 #endif 5904 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698