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 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 , m_frame(initializer.frame()) | 446 , m_frame(initializer.frame()) |
447 , m_domWindow(m_frame ? m_frame->domWindow() : 0) | 447 , m_domWindow(m_frame ? m_frame->domWindow() : 0) |
448 , m_importsController(initializer.importsController()) | 448 , m_importsController(initializer.importsController()) |
449 , m_activeParserCount(0) | 449 , m_activeParserCount(0) |
450 , m_contextFeatures(ContextFeatures::defaultSwitch()) | 450 , m_contextFeatures(ContextFeatures::defaultSwitch()) |
451 , m_wellFormed(false) | 451 , m_wellFormed(false) |
452 , m_printing(false) | 452 , m_printing(false) |
453 , m_paginatedForScreen(false) | 453 , m_paginatedForScreen(false) |
454 , m_compatibilityMode(NoQuirksMode) | 454 , m_compatibilityMode(NoQuirksMode) |
455 , m_compatibilityModeLocked(false) | 455 , m_compatibilityModeLocked(false) |
| 456 , m_hasFiredDOMContentLoadedEvent(false) |
| 457 , m_dispatchDOMContentLoadedTimer(this, &Document::dispatchDOMContentLoadedT
imerFired) |
456 , m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWa
itingForResourcesTimerFired) | 458 , m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWa
itingForResourcesTimerFired) |
457 , m_hasAutofocused(false) | 459 , m_hasAutofocused(false) |
458 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) | 460 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) |
459 , m_domTreeVersion(++s_globalTreeVersion) | 461 , m_domTreeVersion(++s_globalTreeVersion) |
460 , m_listenerTypes(0) | 462 , m_listenerTypes(0) |
461 , m_mutationObserverTypes(0) | 463 , m_mutationObserverTypes(0) |
462 , m_visitedLinkState(VisitedLinkState::create(*this)) | 464 , m_visitedLinkState(VisitedLinkState::create(*this)) |
463 , m_visuallyOrdered(false) | 465 , m_visuallyOrdered(false) |
464 , m_readyState(Complete) | 466 , m_readyState(Complete) |
465 , m_isParsing(false) | 467 , m_isParsing(false) |
(...skipping 4136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4602 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt
ring& name) | 4604 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt
ring& name) |
4603 { | 4605 { |
4604 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name); | 4606 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name); |
4605 } | 4607 } |
4606 | 4608 |
4607 PassRefPtrWillBeRawPtr<DocumentNameCollection> Document::documentNamedItems(cons
t AtomicString& name) | 4609 PassRefPtrWillBeRawPtr<DocumentNameCollection> Document::documentNamedItems(cons
t AtomicString& name) |
4608 { | 4610 { |
4609 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na
me); | 4611 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na
me); |
4610 } | 4612 } |
4611 | 4613 |
4612 void Document::finishedParsing() | 4614 void Document::dispatchDOMContentLoadedTimerFired(Timer<Document>*) |
4613 { | 4615 { |
4614 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); | |
4615 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); | |
4616 setParsing(false); | |
4617 if (!m_documentTiming.domContentLoadedEventStart) | 4616 if (!m_documentTiming.domContentLoadedEventStart) |
4618 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim
e(); | 4617 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim
e(); |
4619 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); | 4618 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); |
4620 if (!m_documentTiming.domContentLoadedEventEnd) | 4619 if (!m_documentTiming.domContentLoadedEventEnd) |
4621 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime(
); | 4620 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime(
); |
4622 | 4621 |
| 4622 m_hasFiredDOMContentLoadedEvent = true; |
| 4623 |
| 4624 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) { |
| 4625 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma
rkDOMContent", "data", InspectorMarkLoadEvent::data(frame.get())); |
| 4626 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. |
| 4627 InspectorInstrumentation::domContentLoadedEventFired(frame.get()); |
| 4628 |
| 4629 frame->loader().checkLoadComplete(); |
| 4630 } |
| 4631 } |
| 4632 |
| 4633 // FIXME: Document should be a DocumentParserClient and this should be replaced
with its notifyParserStopped() callback |
| 4634 void Document::finishedParsing() |
| 4635 { |
| 4636 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); |
| 4637 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); |
| 4638 setParsing(false); |
| 4639 m_dispatchDOMContentLoadedTimer.startOneShot(0, FROM_HERE); |
| 4640 |
4623 // The loader's finishedParsing() method may invoke script that causes this
object to | 4641 // The loader's finishedParsing() method may invoke script that causes this
object to |
4624 // be dereferenced (when this document is in an iframe and the onload causes
the iframe's src to change). | 4642 // be dereferenced (when this document is in an iframe and the onload causes
the iframe's src to change). |
4625 // Keep it alive until we are done. | 4643 // Keep it alive until we are done. |
4626 RefPtrWillBeRawPtr<Document> protect(this); | 4644 RefPtrWillBeRawPtr<Document> protect(this); |
4627 | 4645 |
4628 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) { | 4646 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) { |
4629 // Don't update the render tree if we haven't requested the main resourc
e yet to avoid | 4647 // Don't update the render tree if we haven't requested the main resourc
e yet to avoid |
4630 // adding extra latency. Note that the first render tree update can be e
xpensive since it | 4648 // adding extra latency. Note that the first render tree update can be e
xpensive since it |
4631 // triggers the parsing of the default stylesheets which are compiled-in
. | 4649 // triggers the parsing of the default stylesheets which are compiled-in
. |
4632 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin
e()->committedFirstRealDocumentLoad(); | 4650 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin
e()->committedFirstRealDocumentLoad(); |
4633 | 4651 |
4634 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all | 4652 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all |
4635 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from | 4653 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from |
4636 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> | 4654 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> |
4637 // tag and then reach the end of the document without updating styles, w
e might not have yet | 4655 // tag and then reach the end of the document without updating styles, w
e might not have yet |
4638 // started the resource load and might fire the window load event too ea
rly. To avoid this | 4656 // started the resource load and might fire the window load event too ea
rly. To avoid this |
4639 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). | 4657 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). |
4640 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. | 4658 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. |
4641 if (mainResourceWasAlreadyRequested) | 4659 if (mainResourceWasAlreadyRequested) |
4642 updateRenderTreeIfNeeded(); | 4660 updateRenderTreeIfNeeded(); |
4643 | 4661 |
4644 frame->loader().finishedParsing(); | 4662 frame->loader().finishedParsing(); |
4645 | |
4646 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma
rkDOMContent", "data", InspectorMarkLoadEvent::data(frame.get())); | |
4647 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. | |
4648 InspectorInstrumentation::domContentLoadedEventFired(frame.get()); | |
4649 } | 4663 } |
4650 | 4664 |
4651 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes | 4665 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes |
4652 // so that dynamically inserted content can also benefit from sharing optimi
zations. | 4666 // so that dynamically inserted content can also benefit from sharing optimi
zations. |
4653 // Note that we don't refresh the timer on cache access since that could lea
d to huge caches being kept | 4667 // Note that we don't refresh the timer on cache access since that could lea
d to huge caches being kept |
4654 // alive indefinitely by something innocuous like JS setting .innerHTML repe
atedly on a timer. | 4668 // alive indefinitely by something innocuous like JS setting .innerHTML repe
atedly on a timer. |
4655 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE); | 4669 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE); |
4656 | 4670 |
4657 // Parser should have picked up all preloads by now | 4671 // Parser should have picked up all preloads by now |
4658 m_fetcher->clearPreloads(); | 4672 m_fetcher->clearPreloads(); |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5823 #ifndef NDEBUG | 5837 #ifndef NDEBUG |
5824 using namespace blink; | 5838 using namespace blink; |
5825 void showLiveDocumentInstances() | 5839 void showLiveDocumentInstances() |
5826 { | 5840 { |
5827 WeakDocumentSet& set = liveDocumentSet(); | 5841 WeakDocumentSet& set = liveDocumentSet(); |
5828 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5842 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5829 for (Document* document : set) | 5843 for (Document* document : set) |
5830 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5844 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5831 } | 5845 } |
5832 #endif | 5846 #endif |
OLD | NEW |