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

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

Issue 774033002: Run Microtasks before dispatching onload (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add rebaseline Created 5 years, 11 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 | « LayoutTests/http/tests/inspector/network/network-initiator-expected.txt ('k') | no next file » | 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "core/dom/DocumentLifecycleObserver.h" 70 #include "core/dom/DocumentLifecycleObserver.h"
71 #include "core/dom/DocumentMarkerController.h" 71 #include "core/dom/DocumentMarkerController.h"
72 #include "core/dom/DocumentType.h" 72 #include "core/dom/DocumentType.h"
73 #include "core/dom/Element.h" 73 #include "core/dom/Element.h"
74 #include "core/dom/ElementDataCache.h" 74 #include "core/dom/ElementDataCache.h"
75 #include "core/dom/ElementRegistrationOptions.h" 75 #include "core/dom/ElementRegistrationOptions.h"
76 #include "core/dom/ElementTraversal.h" 76 #include "core/dom/ElementTraversal.h"
77 #include "core/dom/ExceptionCode.h" 77 #include "core/dom/ExceptionCode.h"
78 #include "core/dom/ExecutionContextTask.h" 78 #include "core/dom/ExecutionContextTask.h"
79 #include "core/dom/MainThreadTaskRunner.h" 79 #include "core/dom/MainThreadTaskRunner.h"
80 #include "core/dom/Microtask.h"
80 #include "core/dom/MutationObserver.h" 81 #include "core/dom/MutationObserver.h"
81 #include "core/dom/NodeChildRemovalTracker.h" 82 #include "core/dom/NodeChildRemovalTracker.h"
82 #include "core/dom/NodeFilter.h" 83 #include "core/dom/NodeFilter.h"
83 #include "core/dom/NodeIterator.h" 84 #include "core/dom/NodeIterator.h"
84 #include "core/dom/NodeRareData.h" 85 #include "core/dom/NodeRareData.h"
85 #include "core/dom/NodeRenderStyle.h" 86 #include "core/dom/NodeRenderStyle.h"
86 #include "core/dom/NodeRenderingTraversal.h" 87 #include "core/dom/NodeRenderingTraversal.h"
87 #include "core/dom/NodeTraversal.h" 88 #include "core/dom/NodeTraversal.h"
88 #include "core/dom/NodeWithIndex.h" 89 #include "core/dom/NodeWithIndex.h"
89 #include "core/dom/ProcessingInstruction.h" 90 #include "core/dom/ProcessingInstruction.h"
(...skipping 4523 matching lines...) Expand 10 before | Expand all | Expand 10 after
4613 PassRefPtrWillBeRawPtr<DocumentNameCollection> Document::documentNamedItems(cons t AtomicString& name) 4614 PassRefPtrWillBeRawPtr<DocumentNameCollection> Document::documentNamedItems(cons t AtomicString& name)
4614 { 4615 {
4615 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me); 4616 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me);
4616 } 4617 }
4617 4618
4618 void Document::finishedParsing() 4619 void Document::finishedParsing()
4619 { 4620 {
4620 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); 4621 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
4621 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); 4622 ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
4622 setParsingState(InDOMContentLoaded); 4623 setParsingState(InDOMContentLoaded);
4624
4625 // FIXME: DOMContentLoaded is dispatched synchronously, but this should be d ispatched in a queued task,
4626 // See https://crbug.com/425790
4623 if (!m_documentTiming.domContentLoadedEventStart) 4627 if (!m_documentTiming.domContentLoadedEventStart)
4624 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e(); 4628 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e();
4625 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); 4629 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
4626 if (!m_documentTiming.domContentLoadedEventEnd) 4630 if (!m_documentTiming.domContentLoadedEventEnd)
4627 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime( ); 4631 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime( );
4628 setParsingState(FinishedParsing); 4632 setParsingState(FinishedParsing);
4629 4633
4630 // The loader's finishedParsing() method may invoke script that causes this object to 4634 // The microtask checkpoint or the loader's finishedParsing() method may inv oke script that causes this object to
4631 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change). 4635 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
4632 // Keep it alive until we are done. 4636 // Keep it alive until we are done.
4633 RefPtrWillBeRawPtr<Document> protect(this); 4637 RefPtrWillBeRawPtr<Document> protect(this);
4634 4638
4639 // Ensure Custom Element callbacks are drained before DOMContentLoaded.
4640 // FIXME: Remove this ad-hoc checkpoint when DOMContentLoaded is dispatched in a
4641 // queued task, which will do a checkpoint anyway. https://crbug.com/425790
4642 Microtask::performCheckpoint();
4643
4635 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) { 4644 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) {
4636 // Don't update the render tree if we haven't requested the main resourc e yet to avoid 4645 // Don't update the render tree if we haven't requested the main resourc e yet to avoid
4637 // adding extra latency. Note that the first render tree update can be e xpensive since it 4646 // adding extra latency. Note that the first render tree update can be e xpensive since it
4638 // triggers the parsing of the default stylesheets which are compiled-in . 4647 // triggers the parsing of the default stylesheets which are compiled-in .
4639 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad(); 4648 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad();
4640 4649
4641 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all 4650 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all
4642 // resource loads are complete. HTMLObjectElements can start loading the ir resources from 4651 // resource loads are complete. HTMLObjectElements can start loading the ir resources from
4643 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object> 4652 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object>
4644 // tag and then reach the end of the document without updating styles, w e might not have yet 4653 // tag and then reach the end of the document without updating styles, w e might not have yet
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
5853 #ifndef NDEBUG 5862 #ifndef NDEBUG
5854 using namespace blink; 5863 using namespace blink;
5855 void showLiveDocumentInstances() 5864 void showLiveDocumentInstances()
5856 { 5865 {
5857 WeakDocumentSet& set = liveDocumentSet(); 5866 WeakDocumentSet& set = liveDocumentSet();
5858 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5867 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5859 for (Document* document : set) 5868 for (Document* document : set)
5860 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5869 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5861 } 5870 }
5862 #endif 5871 #endif
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/inspector/network/network-initiator-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698