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 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) | 473 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) |
| 474 , m_hasViewportUnits(false) | 474 , m_hasViewportUnits(false) |
| 475 , m_styleRecalcElementCounter(0) | 475 , m_styleRecalcElementCounter(0) |
| 476 , m_parserSyncPolicy(AllowAsynchronousParsing) | 476 , m_parserSyncPolicy(AllowAsynchronousParsing) |
| 477 { | 477 { |
| 478 if (m_frame) { | 478 if (m_frame) { |
| 479 ASSERT(m_frame->page()); | 479 ASSERT(m_frame->page()); |
| 480 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 480 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
| 481 | 481 |
| 482 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 482 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
| 483 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | |
| 484 } else if (m_importsController) { | |
| 485 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr); | |
| 486 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | |
| 487 } else { | |
| 488 m_fetcher = ResourceFetcher::create(nullptr); | |
| 483 } | 489 } |
| 484 | 490 |
| 485 if (!m_fetcher) | |
| 486 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr); | |
| 487 static_cast<FrameFetchContext&>(m_fetcher->context()).setDocument(this); | |
| 488 | |
| 489 // We depend on the url getting immediately set in subframes, but we | 491 // We depend on the url getting immediately set in subframes, but we |
| 490 // also depend on the url NOT getting immediately set in opened windows. | 492 // also depend on the url NOT getting immediately set in opened windows. |
| 491 // See fast/dom/early-frame-url.html | 493 // See fast/dom/early-frame-url.html |
| 492 // and fast/dom/location-new-window-no-crash.html, respectively. | 494 // and fast/dom/location-new-window-no-crash.html, respectively. |
| 493 // FIXME: Can/should we unify this behavior? | 495 // FIXME: Can/should we unify this behavior? |
| 494 if (initializer.shouldSetURL()) | 496 if (initializer.shouldSetURL()) |
| 495 setURL(initializer.url()); | 497 setURL(initializer.url()); |
| 496 | 498 |
| 497 initSecurityContext(initializer); | 499 initSecurityContext(initializer); |
| 498 initDNSPrefetch(); | 500 initDNSPrefetch(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 567 HTMLImportsController::removeFrom(*this); | 569 HTMLImportsController::removeFrom(*this); |
| 568 | 570 |
| 569 m_timeline->detachFromDocument(); | 571 m_timeline->detachFromDocument(); |
| 570 | 572 |
| 571 // We need to destroy CSSFontSelector before destroying m_fetcher. | 573 // We need to destroy CSSFontSelector before destroying m_fetcher. |
| 572 m_styleEngine->detachFromDocument(); | 574 m_styleEngine->detachFromDocument(); |
| 573 | 575 |
| 574 if (m_elemSheet) | 576 if (m_elemSheet) |
| 575 m_elemSheet->clearOwnerNode(); | 577 m_elemSheet->clearOwnerNode(); |
| 576 | 578 |
| 577 // It's possible for multiple Documents to end up referencing the same Resou rceFetcher (e.g., SVGImages | |
| 578 // load the initial empty document and the SVGDocument with the same Documen tLoader). | |
| 579 FrameFetchContext& context = static_cast<FrameFetchContext&>(m_fetcher->cont ext()); | |
| 580 if (context.document() == this) | |
| 581 context.setDocument(nullptr); | |
| 582 m_fetcher.clear(); | |
| 583 | |
| 584 // We must call clearRareData() here since a Document class inherits TreeSco pe | 579 // We must call clearRareData() here since a Document class inherits TreeSco pe |
| 585 // as well as Node. See a comment on TreeScope.h for the reason. | 580 // as well as Node. See a comment on TreeScope.h for the reason. |
| 586 if (hasRareData()) | 581 if (hasRareData()) |
| 587 clearRareData(); | 582 clearRareData(); |
| 588 | 583 |
| 589 ASSERT(m_listsInvalidatedAtDocument.isEmpty()); | 584 ASSERT(m_listsInvalidatedAtDocument.isEmpty()); |
| 590 | 585 |
| 591 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); ++i) | 586 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); ++i) |
| 592 ASSERT(!m_nodeListCounts[i]); | 587 ASSERT(!m_nodeListCounts[i]); |
| 593 | 588 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 613 m_titleElement = nullptr; | 608 m_titleElement = nullptr; |
| 614 m_documentElement = nullptr; | 609 m_documentElement = nullptr; |
| 615 m_contextFeatures = ContextFeatures::defaultSwitch(); | 610 m_contextFeatures = ContextFeatures::defaultSwitch(); |
| 616 m_userActionElements.documentDidRemoveLastRef(); | 611 m_userActionElements.documentDidRemoveLastRef(); |
| 617 m_associatedFormControls.clear(); | 612 m_associatedFormControls.clear(); |
| 618 | 613 |
| 619 detachParser(); | 614 detachParser(); |
| 620 | 615 |
| 621 m_registrationContext.clear(); | 616 m_registrationContext.clear(); |
| 622 | 617 |
| 623 if (m_importsController) | 618 if (m_importsController) |
|
sof
2015/03/26 08:23:30
The lack of this sync removal (and dispose) on the
| |
| 624 HTMLImportsController::removeFrom(*this); | 619 HTMLImportsController::removeFrom(*this); |
| 625 | 620 |
| 626 // removeDetachedChildren() doesn't always unregister IDs, | 621 // removeDetachedChildren() doesn't always unregister IDs, |
| 627 // so tear down scope information upfront to avoid having stale references i n the map. | 622 // so tear down scope information upfront to avoid having stale references i n the map. |
| 628 destroyTreeScopeData(); | 623 destroyTreeScopeData(); |
| 629 | 624 |
| 630 removeDetachedChildren(); | 625 removeDetachedChildren(); |
| 631 | 626 |
| 632 // removeDetachedChildren() can access FormController. | 627 // removeDetachedChildren() can access FormController. |
| 633 m_formController.clear(); | 628 m_formController.clear(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 { | 824 { |
| 830 if (!m_customElementMicrotaskRunQueue) | 825 if (!m_customElementMicrotaskRunQueue) |
| 831 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat e(); | 826 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat e(); |
| 832 return m_customElementMicrotaskRunQueue.get(); | 827 return m_customElementMicrotaskRunQueue.get(); |
| 833 } | 828 } |
| 834 | 829 |
| 835 void Document::setImportsController(HTMLImportsController* controller) | 830 void Document::setImportsController(HTMLImportsController* controller) |
| 836 { | 831 { |
| 837 ASSERT(!m_importsController || !controller); | 832 ASSERT(!m_importsController || !controller); |
| 838 m_importsController = controller; | 833 m_importsController = controller; |
| 834 if (!m_importsController) | |
| 835 m_fetcher->clearContext(); | |
| 839 } | 836 } |
| 840 | 837 |
| 841 HTMLImportLoader* Document::importLoader() const | 838 HTMLImportLoader* Document::importLoader() const |
| 842 { | 839 { |
| 843 if (!m_importsController) | 840 if (!m_importsController) |
| 844 return 0; | 841 return 0; |
| 845 return m_importsController->loaderFor(*this); | 842 return m_importsController->loaderFor(*this); |
| 846 } | 843 } |
| 847 | 844 |
| 848 bool Document::haveImportsLoaded() const | 845 bool Document::haveImportsLoaded() const |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2133 | 2130 |
| 2134 } | 2131 } |
| 2135 | 2132 |
| 2136 m_layoutView = 0; | 2133 m_layoutView = 0; |
| 2137 ContainerNode::detach(context); | 2134 ContainerNode::detach(context); |
| 2138 | 2135 |
| 2139 styleEngine().didDetach(); | 2136 styleEngine().didDetach(); |
| 2140 | 2137 |
| 2141 frameHost()->eventHandlerRegistry().documentDetached(*this); | 2138 frameHost()->eventHandlerRegistry().documentDetached(*this); |
| 2142 | 2139 |
| 2140 // If this Document is associated with a live DocumentLoader, the | |
| 2141 // DocumentLoader will take care of clearing the FetchContext. Deferring | |
| 2142 // to the DocumentLoader when possible also prevents prematurely clearing | |
| 2143 // the context in the case where multiple Documents end up associated with | |
| 2144 // a single DocumentLoader (e.g., navigating to a javascript: url). | |
| 2145 if (!loader()) | |
| 2146 m_fetcher->clearContext(); | |
| 2147 else if (m_importsController) | |
|
haraken
2015/03/27 11:01:33
Why is this 'else if', not 'if'?
Nate Chapin
2015/04/02 20:22:06
It should be if(). I was experimented and forgot t
| |
| 2148 HTMLImportsController::removeFrom(*this); | |
| 2149 | |
| 2143 // This is required, as our LocalFrame might delete itself as soon as it det aches | 2150 // This is required, as our LocalFrame might delete itself as soon as it det aches |
| 2144 // us. However, this violates Node::detach() semantics, as it's never | 2151 // us. However, this violates Node::detach() semantics, as it's never |
| 2145 // possible to re-attach. Eventually Document::detach() should be renamed, | 2152 // possible to re-attach. Eventually Document::detach() should be renamed, |
| 2146 // or this setting of the frame to 0 could be made explicit in each of the | 2153 // or this setting of the frame to 0 could be made explicit in each of the |
| 2147 // callers of Document::detach(). | 2154 // callers of Document::detach(). |
| 2148 m_frame = nullptr; | 2155 m_frame = nullptr; |
| 2149 | 2156 |
| 2150 if (m_mediaQueryMatcher) | 2157 if (m_mediaQueryMatcher) |
| 2151 m_mediaQueryMatcher->documentDetached(); | 2158 m_mediaQueryMatcher->documentDetached(); |
| 2152 | 2159 |
| (...skipping 3598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5751 #ifndef NDEBUG | 5758 #ifndef NDEBUG |
| 5752 using namespace blink; | 5759 using namespace blink; |
| 5753 void showLiveDocumentInstances() | 5760 void showLiveDocumentInstances() |
| 5754 { | 5761 { |
| 5755 WeakDocumentSet& set = liveDocumentSet(); | 5762 WeakDocumentSet& set = liveDocumentSet(); |
| 5756 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5763 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5757 for (Document* document : set) | 5764 for (Document* document : set) |
| 5758 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); | 5765 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); |
| 5759 } | 5766 } |
| 5760 #endif | 5767 #endif |
| OLD | NEW |