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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 return 0; | 603 return 0; |
604 | 604 |
605 return domWindow()->location(); | 605 return domWindow()->location(); |
606 } | 606 } |
607 | 607 |
608 void Document::childrenChanged(const ChildrenChange& change) | 608 void Document::childrenChanged(const ChildrenChange& change) |
609 { | 609 { |
610 ContainerNode::childrenChanged(change); | 610 ContainerNode::childrenChanged(change); |
611 m_documentElement = ElementTraversal::firstWithin(*this); | 611 m_documentElement = ElementTraversal::firstWithin(*this); |
612 | 612 |
| 613 // For non-HTML documents the willInsertBody notification won't happen |
| 614 // so we resume as soon as we have a document element. Even for XHTML |
| 615 // documents there may never be a <body> (since the parser won't always |
| 616 // insert one), so we resume here too. That does mean XHTML documents make |
| 617 // frames when there's only a <head>, but such documents are pretty rare. |
| 618 if (m_documentElement && !isHTMLDocument()) |
| 619 beginLifecycleUpdatesIfRenderingReady(); |
| 620 |
613 // Installs the viewport scrolling callback (the "applyScroll" in Scroll | 621 // Installs the viewport scrolling callback (the "applyScroll" in Scroll |
614 // Customization lingo) on the documentElement. This callback is | 622 // Customization lingo) on the documentElement. This callback is |
615 // responsible for viewport related scroll actions like top controls | 623 // responsible for viewport related scroll actions like top controls |
616 // movement and overscroll glow as well as actually scrolling the root | 624 // movement and overscroll glow as well as actually scrolling the root |
617 // viewport. | 625 // viewport. |
618 updateViewportApplyScroll(m_documentElement); | 626 updateViewportApplyScroll(m_documentElement); |
619 } | 627 } |
620 | 628 |
621 AtomicString Document::convertLocalName(const AtomicString& name) | 629 AtomicString Document::convertLocalName(const AtomicString& name) |
622 { | 630 { |
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 HTMLElement* oldBody = body(); | 2496 HTMLElement* oldBody = body(); |
2489 if (oldBody == newBody) | 2497 if (oldBody == newBody) |
2490 return; | 2498 return; |
2491 | 2499 |
2492 if (oldBody) | 2500 if (oldBody) |
2493 documentElement()->replaceChild(newBody, oldBody, exceptionState); | 2501 documentElement()->replaceChild(newBody, oldBody, exceptionState); |
2494 else | 2502 else |
2495 documentElement()->appendChild(newBody, exceptionState); | 2503 documentElement()->appendChild(newBody, exceptionState); |
2496 } | 2504 } |
2497 | 2505 |
| 2506 void Document::willInsertBody() |
| 2507 { |
| 2508 if (frame()) |
| 2509 frame()->loader().client()->dispatchWillInsertBody(); |
| 2510 // If we get to the <body> try to resume commits since we should have conten
t |
| 2511 // to paint now. |
| 2512 // TODO(esprehn): Is this really optimal? We might start producing frames |
| 2513 // for very little content, should we wait for some heuristic like |
| 2514 // isVisuallyNonEmpty() ? |
| 2515 beginLifecycleUpdatesIfRenderingReady(); |
| 2516 } |
| 2517 |
2498 HTMLHeadElement* Document::head() const | 2518 HTMLHeadElement* Document::head() const |
2499 { | 2519 { |
2500 Node* de = documentElement(); | 2520 Node* de = documentElement(); |
2501 if (!de) | 2521 if (!de) |
2502 return 0; | 2522 return 0; |
2503 | 2523 |
2504 return Traversal<HTMLHeadElement>::firstChild(*de); | 2524 return Traversal<HTMLHeadElement>::firstChild(*de); |
2505 } | 2525 } |
2506 | 2526 |
2507 Element* Document::viewportDefiningElement(const ComputedStyle* rootStyle) const | 2527 Element* Document::viewportDefiningElement(const ComputedStyle* rootStyle) const |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 import->didRemoveAllPendingStylesheet(); | 3028 import->didRemoveAllPendingStylesheet(); |
3009 if (!haveImportsLoaded()) | 3029 if (!haveImportsLoaded()) |
3010 return; | 3030 return; |
3011 didLoadAllScriptBlockingResources(); | 3031 didLoadAllScriptBlockingResources(); |
3012 } | 3032 } |
3013 | 3033 |
3014 void Document::didLoadAllScriptBlockingResources() | 3034 void Document::didLoadAllScriptBlockingResources() |
3015 { | 3035 { |
3016 loadingTaskRunner()->postTask(BLINK_FROM_HERE, m_executeScriptsWaitingForRes
ourcesTask->cancelAndCreate()); | 3036 loadingTaskRunner()->postTask(BLINK_FROM_HERE, m_executeScriptsWaitingForRes
ourcesTask->cancelAndCreate()); |
3017 | 3037 |
3018 if (frame()) | 3038 if (isHTMLDocument() && body()) { |
3019 frame()->loader().client()->didRemoveAllPendingStylesheet(); | 3039 // For HTML if we have no more stylesheets to load and we're past the bo
dy |
| 3040 // tag, we should have something to paint so resume. |
| 3041 beginLifecycleUpdatesIfRenderingReady(); |
| 3042 } else if (!isHTMLDocument() && documentElement()) { |
| 3043 // For non-HTML there is no body so resume as soon as the sheets are loa
ded. |
| 3044 beginLifecycleUpdatesIfRenderingReady(); |
| 3045 } |
3020 | 3046 |
3021 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) | 3047 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) |
3022 view()->processUrlFragment(m_url); | 3048 view()->processUrlFragment(m_url); |
3023 } | 3049 } |
3024 | 3050 |
3025 void Document::executeScriptsWaitingForResources() | 3051 void Document::executeScriptsWaitingForResources() |
3026 { | 3052 { |
3027 if (!isRenderingReady()) | 3053 if (!isRenderingReady()) |
3028 return; | 3054 return; |
3029 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) | 3055 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) |
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4733 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all | 4759 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all |
4734 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from | 4760 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from |
4735 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> | 4761 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> |
4736 // tag and then reach the end of the document without updating styles, w
e might not have yet | 4762 // tag and then reach the end of the document without updating styles, w
e might not have yet |
4737 // started the resource load and might fire the window load event too ea
rly. To avoid this | 4763 // started the resource load and might fire the window load event too ea
rly. To avoid this |
4738 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). | 4764 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). |
4739 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. | 4765 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. |
4740 if (mainResourceWasAlreadyRequested) | 4766 if (mainResourceWasAlreadyRequested) |
4741 updateLayoutTree(); | 4767 updateLayoutTree(); |
4742 | 4768 |
| 4769 beginLifecycleUpdatesIfRenderingReady(); |
| 4770 |
4743 frame->loader().finishedParsing(); | 4771 frame->loader().finishedParsing(); |
4744 | 4772 |
4745 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkDOMContent", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorMarkLoadEvent::data(frame)); | 4773 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkDOMContent", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorMarkLoadEvent::data(frame)); |
4746 InspectorInstrumentation::domContentLoadedEventFired(frame); | 4774 InspectorInstrumentation::domContentLoadedEventFired(frame); |
4747 } | 4775 } |
4748 | 4776 |
4749 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes | 4777 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes |
4750 // so that dynamically inserted content can also benefit from sharing optimi
zations. | 4778 // so that dynamically inserted content can also benefit from sharing optimi
zations. |
4751 // Note that we don't refresh the timer on cache access since that could lea
d to huge caches being kept | 4779 // Note that we don't refresh the timer on cache access since that could lea
d to huge caches being kept |
4752 // alive indefinitely by something innocuous like JS setting .innerHTML repe
atedly on a timer. | 4780 // alive indefinitely by something innocuous like JS setting .innerHTML repe
atedly on a timer. |
4753 m_elementDataCacheClearTimer.startOneShot(10, BLINK_FROM_HERE); | 4781 m_elementDataCacheClearTimer.startOneShot(10, BLINK_FROM_HERE); |
4754 | 4782 |
4755 // Parser should have picked up all preloads by now | 4783 // Parser should have picked up all preloads by now |
4756 m_fetcher->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); | 4784 m_fetcher->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); |
4757 } | 4785 } |
4758 | 4786 |
4759 void Document::elementDataCacheClearTimerFired(Timer<Document>*) | 4787 void Document::elementDataCacheClearTimerFired(Timer<Document>*) |
4760 { | 4788 { |
4761 m_elementDataCache.clear(); | 4789 m_elementDataCache.clear(); |
4762 } | 4790 } |
4763 | 4791 |
| 4792 void Document::beginLifecycleUpdatesIfRenderingReady() |
| 4793 { |
| 4794 if (!isActive()) |
| 4795 return; |
| 4796 if (!isRenderingReady()) |
| 4797 return; |
| 4798 if (LocalFrame* frame = this->frame()) { |
| 4799 // Avoid pumping frames for the initially empty document. |
| 4800 if (!frame->loader().stateMachine()->committedFirstRealDocumentLoad()) |
| 4801 return; |
| 4802 // The compositor will "defer commits" for the main frame until we |
| 4803 // explicitly request them. |
| 4804 if (frame->isMainFrame()) |
| 4805 frame->page()->chromeClient().beginLifecycleUpdates(); |
| 4806 } |
| 4807 } |
| 4808 |
4764 Vector<IconURL> Document::iconURLs(int iconTypesMask) | 4809 Vector<IconURL> Document::iconURLs(int iconTypesMask) |
4765 { | 4810 { |
4766 IconURL firstFavicon; | 4811 IconURL firstFavicon; |
4767 IconURL firstTouchIcon; | 4812 IconURL firstTouchIcon; |
4768 IconURL firstTouchPrecomposedIcon; | 4813 IconURL firstTouchPrecomposedIcon; |
4769 Vector<IconURL> secondaryIcons; | 4814 Vector<IconURL> secondaryIcons; |
4770 | 4815 |
4771 // Start from the last child node so that icons seen later take precedence a
s required by the spec. | 4816 // Start from the last child node so that icons seen later take precedence a
s required by the spec. |
4772 for (HTMLLinkElement* linkElement = head() ? Traversal<HTMLLinkElement>::fir
stChild(*head()) : 0; linkElement; linkElement = Traversal<HTMLLinkElement>::nex
tSibling(*linkElement)) { | 4817 for (HTMLLinkElement* linkElement = head() ? Traversal<HTMLLinkElement>::fir
stChild(*head()) : 0; linkElement; linkElement = Traversal<HTMLLinkElement>::nex
tSibling(*linkElement)) { |
4773 if (!(linkElement->getIconType() & iconTypesMask)) | 4818 if (!(linkElement->getIconType() & iconTypesMask)) |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5905 #ifndef NDEBUG | 5950 #ifndef NDEBUG |
5906 using namespace blink; | 5951 using namespace blink; |
5907 void showLiveDocumentInstances() | 5952 void showLiveDocumentInstances() |
5908 { | 5953 { |
5909 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5954 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5910 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5955 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5911 for (Document* document : set) | 5956 for (Document* document : set) |
5912 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 5957 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
5913 } | 5958 } |
5914 #endif | 5959 #endif |
OLD | NEW |