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