| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) | 476 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) |
| 477 , m_hasViewportUnits(false) | 477 , m_hasViewportUnits(false) |
| 478 , m_styleRecalcElementCounter(0) | 478 , m_styleRecalcElementCounter(0) |
| 479 , m_parserSyncPolicy(AllowAsynchronousParsing) | 479 , m_parserSyncPolicy(AllowAsynchronousParsing) |
| 480 { | 480 { |
| 481 if (m_frame) { | 481 if (m_frame) { |
| 482 ASSERT(m_frame->page()); | 482 ASSERT(m_frame->page()); |
| 483 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 483 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
| 484 | 484 |
| 485 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 485 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
| 486 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
| 487 } else if (m_importsController) { |
| 488 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr); |
| 489 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
| 490 } else { |
| 491 m_fetcher = ResourceFetcher::create(nullptr); |
| 486 } | 492 } |
| 487 | 493 |
| 488 if (!m_fetcher) | |
| 489 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr); | |
| 490 static_cast<FrameFetchContext&>(m_fetcher->context()).setDocument(this); | |
| 491 | |
| 492 // We depend on the url getting immediately set in subframes, but we | 494 // We depend on the url getting immediately set in subframes, but we |
| 493 // also depend on the url NOT getting immediately set in opened windows. | 495 // also depend on the url NOT getting immediately set in opened windows. |
| 494 // See fast/dom/early-frame-url.html | 496 // See fast/dom/early-frame-url.html |
| 495 // and fast/dom/location-new-window-no-crash.html, respectively. | 497 // and fast/dom/location-new-window-no-crash.html, respectively. |
| 496 // FIXME: Can/should we unify this behavior? | 498 // FIXME: Can/should we unify this behavior? |
| 497 if (initializer.shouldSetURL()) | 499 if (initializer.shouldSetURL()) |
| 498 setURL(initializer.url()); | 500 setURL(initializer.url()); |
| 499 | 501 |
| 500 initSecurityContext(initializer); | 502 initSecurityContext(initializer); |
| 501 initDNSPrefetch(); | 503 initDNSPrefetch(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 525 #endif | 527 #endif |
| 526 } | 528 } |
| 527 | 529 |
| 528 Document::~Document() | 530 Document::~Document() |
| 529 { | 531 { |
| 530 ASSERT(!layoutView()); | 532 ASSERT(!layoutView()); |
| 531 ASSERT(!parentTreeScope()); | 533 ASSERT(!parentTreeScope()); |
| 532 #if !ENABLE(OILPAN) | 534 #if !ENABLE(OILPAN) |
| 533 ASSERT(m_ranges.isEmpty()); | 535 ASSERT(m_ranges.isEmpty()); |
| 534 ASSERT(!hasGuardRefCount()); | 536 ASSERT(!hasGuardRefCount()); |
| 537 ASSERT(!m_importsController); |
| 535 // With Oilpan, either the document outlives the visibility observers | 538 // With Oilpan, either the document outlives the visibility observers |
| 536 // or the visibility observers and the document die in the same GC round. | 539 // or the visibility observers and the document die in the same GC round. |
| 537 // When they die in the same GC round, the list of visibility observers | 540 // When they die in the same GC round, the list of visibility observers |
| 538 // will not be empty on Document destruction. | 541 // will not be empty on Document destruction. |
| 539 ASSERT(m_visibilityObservers.isEmpty()); | 542 ASSERT(m_visibilityObservers.isEmpty()); |
| 540 | 543 |
| 541 if (m_templateDocument) | 544 if (m_templateDocument) |
| 542 m_templateDocument->m_templateDocumentHost = nullptr; // balanced in ens
ureTemplateDocument(). | 545 m_templateDocument->m_templateDocumentHost = nullptr; // balanced in ens
ureTemplateDocument(). |
| 543 | 546 |
| 544 m_scriptRunner.clear(); | 547 m_scriptRunner.clear(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 559 detachParser(); | 562 detachParser(); |
| 560 #endif | 563 #endif |
| 561 | 564 |
| 562 if (this == &axObjectCacheOwner()) | 565 if (this == &axObjectCacheOwner()) |
| 563 clearAXObjectCache(); | 566 clearAXObjectCache(); |
| 564 | 567 |
| 565 #if !ENABLE(OILPAN) | 568 #if !ENABLE(OILPAN) |
| 566 if (m_styleSheetList) | 569 if (m_styleSheetList) |
| 567 m_styleSheetList->detachFromDocument(); | 570 m_styleSheetList->detachFromDocument(); |
| 568 | 571 |
| 569 if (m_importsController) | |
| 570 HTMLImportsController::removeFrom(*this); | |
| 571 | |
| 572 m_timeline->detachFromDocument(); | 572 m_timeline->detachFromDocument(); |
| 573 | 573 |
| 574 // We need to destroy CSSFontSelector before destroying m_fetcher. | 574 // We need to destroy CSSFontSelector before destroying m_fetcher. |
| 575 m_styleEngine->detachFromDocument(); | 575 m_styleEngine->detachFromDocument(); |
| 576 | 576 |
| 577 if (m_elemSheet) | 577 if (m_elemSheet) |
| 578 m_elemSheet->clearOwnerNode(); | 578 m_elemSheet->clearOwnerNode(); |
| 579 | 579 |
| 580 // It's possible for multiple Documents to end up referencing the same Resou
rceFetcher (e.g., SVGImages | |
| 581 // load the initial empty document and the SVGDocument with the same Documen
tLoader). | |
| 582 FrameFetchContext& context = static_cast<FrameFetchContext&>(m_fetcher->cont
ext()); | |
| 583 if (context.document() == this) | |
| 584 context.setDocument(nullptr); | |
| 585 m_fetcher.clear(); | |
| 586 | |
| 587 // We must call clearRareData() here since a Document class inherits TreeSco
pe | 580 // We must call clearRareData() here since a Document class inherits TreeSco
pe |
| 588 // as well as Node. See a comment on TreeScope.h for the reason. | 581 // as well as Node. See a comment on TreeScope.h for the reason. |
| 589 if (hasRareData()) | 582 if (hasRareData()) |
| 590 clearRareData(); | 583 clearRareData(); |
| 591 | 584 |
| 592 ASSERT(m_listsInvalidatedAtDocument.isEmpty()); | 585 ASSERT(m_listsInvalidatedAtDocument.isEmpty()); |
| 593 | 586 |
| 594 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); ++i) | 587 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); ++i) |
| 595 ASSERT(!m_nodeListCounts[i]); | 588 ASSERT(!m_nodeListCounts[i]); |
| 596 | 589 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 616 m_titleElement = nullptr; | 609 m_titleElement = nullptr; |
| 617 m_documentElement = nullptr; | 610 m_documentElement = nullptr; |
| 618 m_contextFeatures = ContextFeatures::defaultSwitch(); | 611 m_contextFeatures = ContextFeatures::defaultSwitch(); |
| 619 m_userActionElements.documentDidRemoveLastRef(); | 612 m_userActionElements.documentDidRemoveLastRef(); |
| 620 m_associatedFormControls.clear(); | 613 m_associatedFormControls.clear(); |
| 621 | 614 |
| 622 detachParser(); | 615 detachParser(); |
| 623 | 616 |
| 624 m_registrationContext.clear(); | 617 m_registrationContext.clear(); |
| 625 | 618 |
| 626 if (m_importsController) | |
| 627 HTMLImportsController::removeFrom(*this); | |
| 628 | |
| 629 // removeDetachedChildren() doesn't always unregister IDs, | 619 // removeDetachedChildren() doesn't always unregister IDs, |
| 630 // so tear down scope information upfront to avoid having stale references i
n the map. | 620 // so tear down scope information upfront to avoid having stale references i
n the map. |
| 631 destroyTreeScopeData(); | 621 destroyTreeScopeData(); |
| 632 | 622 |
| 633 removeDetachedChildren(); | 623 removeDetachedChildren(); |
| 634 | 624 |
| 635 // removeDetachedChildren() can access FormController. | 625 // removeDetachedChildren() can access FormController. |
| 636 m_formController.clear(); | 626 m_formController.clear(); |
| 637 | 627 |
| 638 m_markers->clear(); | 628 m_markers->clear(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 { | 817 { |
| 828 if (!m_customElementMicrotaskRunQueue) | 818 if (!m_customElementMicrotaskRunQueue) |
| 829 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat
e(); | 819 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat
e(); |
| 830 return m_customElementMicrotaskRunQueue.get(); | 820 return m_customElementMicrotaskRunQueue.get(); |
| 831 } | 821 } |
| 832 | 822 |
| 833 void Document::setImportsController(HTMLImportsController* controller) | 823 void Document::setImportsController(HTMLImportsController* controller) |
| 834 { | 824 { |
| 835 ASSERT(!m_importsController || !controller); | 825 ASSERT(!m_importsController || !controller); |
| 836 m_importsController = controller; | 826 m_importsController = controller; |
| 827 if (!m_importsController) |
| 828 m_fetcher->clearContext(); |
| 837 } | 829 } |
| 838 | 830 |
| 839 HTMLImportLoader* Document::importLoader() const | 831 HTMLImportLoader* Document::importLoader() const |
| 840 { | 832 { |
| 841 if (!m_importsController) | 833 if (!m_importsController) |
| 842 return 0; | 834 return 0; |
| 843 return m_importsController->loaderFor(*this); | 835 return m_importsController->loaderFor(*this); |
| 844 } | 836 } |
| 845 | 837 |
| 846 bool Document::haveImportsLoaded() const | 838 bool Document::haveImportsLoaded() const |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 if (this == &axObjectCacheOwner()) | 2145 if (this == &axObjectCacheOwner()) |
| 2154 clearAXObjectCache(); | 2146 clearAXObjectCache(); |
| 2155 | 2147 |
| 2156 m_layoutView = nullptr; | 2148 m_layoutView = nullptr; |
| 2157 ContainerNode::detach(context); | 2149 ContainerNode::detach(context); |
| 2158 | 2150 |
| 2159 styleEngine().didDetach(); | 2151 styleEngine().didDetach(); |
| 2160 | 2152 |
| 2161 frameHost()->eventHandlerRegistry().documentDetached(*this); | 2153 frameHost()->eventHandlerRegistry().documentDetached(*this); |
| 2162 | 2154 |
| 2155 // If this Document is associated with a live DocumentLoader, the |
| 2156 // DocumentLoader will take care of clearing the FetchContext. Deferring |
| 2157 // to the DocumentLoader when possible also prevents prematurely clearing |
| 2158 // the context in the case where multiple Documents end up associated with |
| 2159 // a single DocumentLoader (e.g., navigating to a javascript: url). |
| 2160 if (!loader()) |
| 2161 m_fetcher->clearContext(); |
| 2162 // If this document is the master for an HTMLImportsController, sever that |
| 2163 // relationship. This ensures that we don't leave import loads in flight, |
| 2164 // thinking they should have access to a valid frame when they don't. |
| 2165 if (m_importsController) |
| 2166 HTMLImportsController::removeFrom(*this); |
| 2167 |
| 2163 // This is required, as our LocalFrame might delete itself as soon as it det
aches | 2168 // This is required, as our LocalFrame might delete itself as soon as it det
aches |
| 2164 // us. However, this violates Node::detach() semantics, as it's never | 2169 // us. However, this violates Node::detach() semantics, as it's never |
| 2165 // possible to re-attach. Eventually Document::detach() should be renamed, | 2170 // possible to re-attach. Eventually Document::detach() should be renamed, |
| 2166 // or this setting of the frame to 0 could be made explicit in each of the | 2171 // or this setting of the frame to 0 could be made explicit in each of the |
| 2167 // callers of Document::detach(). | 2172 // callers of Document::detach(). |
| 2168 m_frame = nullptr; | 2173 m_frame = nullptr; |
| 2169 | 2174 |
| 2170 if (m_mediaQueryMatcher) | 2175 if (m_mediaQueryMatcher) |
| 2171 m_mediaQueryMatcher->documentDetached(); | 2176 m_mediaQueryMatcher->documentDetached(); |
| 2172 | 2177 |
| (...skipping 3584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5757 #ifndef NDEBUG | 5762 #ifndef NDEBUG |
| 5758 using namespace blink; | 5763 using namespace blink; |
| 5759 void showLiveDocumentInstances() | 5764 void showLiveDocumentInstances() |
| 5760 { | 5765 { |
| 5761 WeakDocumentSet& set = liveDocumentSet(); | 5766 WeakDocumentSet& set = liveDocumentSet(); |
| 5762 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5767 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5763 for (Document* document : set) | 5768 for (Document* document : set) |
| 5764 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5769 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
| 5765 } | 5770 } |
| 5766 #endif | 5771 #endif |
| OLD | NEW |