Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 901663005: Revert r189385 "Remove LifecycleContext" and r189391, r189530, r189456 that block it (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "core/css/resolver/StyleResolverStats.h" 59 #include "core/css/resolver/StyleResolverStats.h"
60 #include "core/dom/AXObjectCache.h" 60 #include "core/dom/AXObjectCache.h"
61 #include "core/dom/AddConsoleMessageTask.h" 61 #include "core/dom/AddConsoleMessageTask.h"
62 #include "core/dom/Attr.h" 62 #include "core/dom/Attr.h"
63 #include "core/dom/CDATASection.h" 63 #include "core/dom/CDATASection.h"
64 #include "core/dom/ClientRect.h" 64 #include "core/dom/ClientRect.h"
65 #include "core/dom/Comment.h" 65 #include "core/dom/Comment.h"
66 #include "core/dom/ContextFeatures.h" 66 #include "core/dom/ContextFeatures.h"
67 #include "core/dom/DOMImplementation.h" 67 #include "core/dom/DOMImplementation.h"
68 #include "core/dom/DocumentFragment.h" 68 #include "core/dom/DocumentFragment.h"
69 #include "core/dom/DocumentLifecycleNotifier.h"
69 #include "core/dom/DocumentLifecycleObserver.h" 70 #include "core/dom/DocumentLifecycleObserver.h"
70 #include "core/dom/DocumentMarkerController.h" 71 #include "core/dom/DocumentMarkerController.h"
71 #include "core/dom/DocumentType.h" 72 #include "core/dom/DocumentType.h"
72 #include "core/dom/Element.h" 73 #include "core/dom/Element.h"
73 #include "core/dom/ElementDataCache.h" 74 #include "core/dom/ElementDataCache.h"
74 #include "core/dom/ElementRegistrationOptions.h" 75 #include "core/dom/ElementRegistrationOptions.h"
75 #include "core/dom/ElementTraversal.h" 76 #include "core/dom/ElementTraversal.h"
76 #include "core/dom/ExceptionCode.h" 77 #include "core/dom/ExceptionCode.h"
77 #include "core/dom/ExecutionContextTask.h" 78 #include "core/dom/ExecutionContextTask.h"
78 #include "core/dom/MainThreadTaskRunner.h" 79 #include "core/dom/MainThreadTaskRunner.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 396
396 void DocumentVisibilityObserver::setObservedDocument(Document& document) 397 void DocumentVisibilityObserver::setObservedDocument(Document& document)
397 { 398 {
398 unregisterObserver(); 399 unregisterObserver();
399 registerObserver(document); 400 registerObserver(document);
400 } 401 }
401 402
402 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) 403 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses)
403 : ContainerNode(0, CreateDocument) 404 : ContainerNode(0, CreateDocument)
404 , TreeScope(*this) 405 , TreeScope(*this)
405 , DocumentLifecycleNotifier(this)
406 , m_hasNodesWithPlaceholderStyle(false) 406 , m_hasNodesWithPlaceholderStyle(false)
407 , m_evaluateMediaQueriesOnStyleRecalc(false) 407 , m_evaluateMediaQueriesOnStyleRecalc(false)
408 , m_pendingSheetLayout(NoLayoutWithPendingSheets) 408 , m_pendingSheetLayout(NoLayoutWithPendingSheets)
409 , m_frame(initializer.frame()) 409 , m_frame(initializer.frame())
410 , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0) 410 , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0)
411 , m_importsController(initializer.importsController()) 411 , m_importsController(initializer.importsController())
412 , m_activeParserCount(0) 412 , m_activeParserCount(0)
413 , m_contextFeatures(ContextFeatures::defaultSwitch()) 413 , m_contextFeatures(ContextFeatures::defaultSwitch())
414 , m_wellFormed(false) 414 , m_wellFormed(false)
415 , m_printing(false) 415 , m_printing(false)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 635
636 // FIXME: consider using ActiveDOMObject. 636 // FIXME: consider using ActiveDOMObject.
637 if (m_scriptedAnimationController) 637 if (m_scriptedAnimationController)
638 m_scriptedAnimationController->clearDocumentPointer(); 638 m_scriptedAnimationController->clearDocumentPointer();
639 m_scriptedAnimationController.clear(); 639 m_scriptedAnimationController.clear();
640 640
641 if (svgExtensions()) 641 if (svgExtensions())
642 accessSVGExtensions().pauseAnimations(); 642 accessSVGExtensions().pauseAnimations();
643 643
644 m_lifecycle.advanceTo(DocumentLifecycle::Disposed); 644 m_lifecycle.advanceTo(DocumentLifecycle::Disposed);
645 DocumentLifecycleNotifier::notifyDocumentWasDisposed(); 645 lifecycleNotifier().notifyDocumentWasDisposed();
646 } 646 }
647 #endif 647 #endif
648 648
649 SelectorQueryCache& Document::selectorQueryCache() 649 SelectorQueryCache& Document::selectorQueryCache()
650 { 650 {
651 if (!m_selectorQueryCache) 651 if (!m_selectorQueryCache)
652 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); 652 m_selectorQueryCache = adoptPtr(new SelectorQueryCache());
653 return *m_selectorQueryCache; 653 return *m_selectorQueryCache;
654 } 654 }
655 655
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 // This is required, as our LocalFrame might delete itself as soon as it det aches 2175 // This is required, as our LocalFrame might delete itself as soon as it det aches
2176 // us. However, this violates Node::detach() semantics, as it's never 2176 // us. However, this violates Node::detach() semantics, as it's never
2177 // possible to re-attach. Eventually Document::detach() should be renamed, 2177 // possible to re-attach. Eventually Document::detach() should be renamed,
2178 // or this setting of the frame to 0 could be made explicit in each of the 2178 // or this setting of the frame to 0 could be made explicit in each of the
2179 // callers of Document::detach(). 2179 // callers of Document::detach().
2180 m_frame = nullptr; 2180 m_frame = nullptr;
2181 2181
2182 if (m_mediaQueryMatcher) 2182 if (m_mediaQueryMatcher)
2183 m_mediaQueryMatcher->documentDetached(); 2183 m_mediaQueryMatcher->documentDetached();
2184 2184
2185 DocumentLifecycleNotifier::notifyDocumentWasDetached(); 2185 lifecycleNotifier().notifyDocumentWasDetached();
2186 m_lifecycle.advanceTo(DocumentLifecycle::Stopped); 2186 m_lifecycle.advanceTo(DocumentLifecycle::Stopped);
2187 2187
2188 // FIXME: Currently we call notifyContextDestroyed() only in 2188 // FIXME: Currently we call notifyContextDestroyed() only in
2189 // Document::detach(), which means that we don't call 2189 // Document::detach(), which means that we don't call
2190 // notifyContextDestroyed() for a document that doesn't get detached. 2190 // notifyContextDestroyed() for a document that doesn't get detached.
2191 // If such a document has any observer, the observer won't get 2191 // If such a document has any observer, the observer won't get
2192 // a contextDestroyed() notification. This can happen for a document 2192 // a contextDestroyed() notification. This can happen for a document
2193 // created by DOMImplementation::createDocument(). 2193 // created by DOMImplementation::createDocument().
2194 DocumentLifecycleNotifier::notifyContextDestroyed(); 2194 LifecycleContext<Document>::notifyContextDestroyed();
2195 ExecutionContext::notifyContextDestroyed(); 2195 ExecutionContext::notifyContextDestroyed();
2196 } 2196 }
2197 2197
2198 void Document::prepareForDestruction() 2198 void Document::prepareForDestruction()
2199 { 2199 {
2200 m_markers->prepareForDestruction(); 2200 m_markers->prepareForDestruction();
2201 disconnectDescendantFrames(); 2201 disconnectDescendantFrames();
2202 2202
2203 // The process of disconnecting descendant frames could have already detache d us. 2203 // The process of disconnecting descendant frames could have already detache d us.
2204 if (!isActive()) 2204 if (!isActive())
(...skipping 3246 matching lines...) Expand 10 before | Expand all | Expand 10 after
5451 5451
5452 frame()->page()->chrome().client().didAssociateFormControls(associatedFormCo ntrols, frame()); 5452 frame()->page()->chrome().client().didAssociateFormControls(associatedFormCo ntrols, frame());
5453 m_associatedFormControls.clear(); 5453 m_associatedFormControls.clear();
5454 } 5454 }
5455 5455
5456 float Document::devicePixelRatio() const 5456 float Document::devicePixelRatio() const
5457 { 5457 {
5458 return m_frame ? m_frame->devicePixelRatio() : 1.0; 5458 return m_frame ? m_frame->devicePixelRatio() : 1.0;
5459 } 5459 }
5460 5460
5461 PassOwnPtr<LifecycleNotifier<Document>> Document::createLifecycleNotifier()
5462 {
5463 return DocumentLifecycleNotifier::create(this);
5464 }
5465
5466 DocumentLifecycleNotifier& Document::lifecycleNotifier()
5467 {
5468 return static_cast<DocumentLifecycleNotifier&>(LifecycleContext<Document>::l ifecycleNotifier());
5469 }
5470
5461 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda teMode) 5471 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda teMode)
5462 { 5472 {
5463 // If we're in document teardown, then we don't need this notification of ou r sheet's removal. 5473 // If we're in document teardown, then we don't need this notification of ou r sheet's removal.
5464 // styleResolverChanged() is needed even when the document is inactive so th at 5474 // styleResolverChanged() is needed even when the document is inactive so th at
5465 // imported docuements (which is inactive) notifies the change to the master document. 5475 // imported docuements (which is inactive) notifies the change to the master document.
5466 if (isActive()) 5476 if (isActive())
5467 styleEngine()->modifiedStyleSheet(sheet); 5477 styleEngine()->modifiedStyleSheet(sheet);
5468 styleResolverChanged(updateMode); 5478 styleResolverChanged(updateMode);
5469 } 5479 }
5470 5480
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
5747 visitor->trace(m_svgExtensions); 5757 visitor->trace(m_svgExtensions);
5748 visitor->trace(m_timeline); 5758 visitor->trace(m_timeline);
5749 visitor->trace(m_compositorPendingAnimations); 5759 visitor->trace(m_compositorPendingAnimations);
5750 visitor->trace(m_contextDocument); 5760 visitor->trace(m_contextDocument);
5751 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5761 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5752 DocumentSupplementable::trace(visitor); 5762 DocumentSupplementable::trace(visitor);
5753 #endif 5763 #endif
5754 TreeScope::trace(visitor); 5764 TreeScope::trace(visitor);
5755 ContainerNode::trace(visitor); 5765 ContainerNode::trace(visitor);
5756 ExecutionContext::trace(visitor); 5766 ExecutionContext::trace(visitor);
5757 DocumentLifecycleNotifier::trace(visitor); 5767 LifecycleContext<Document>::trace(visitor);
5758 } 5768 }
5759 5769
5760 } // namespace blink 5770 } // namespace blink
5761 5771
5762 #ifndef NDEBUG 5772 #ifndef NDEBUG
5763 using namespace blink; 5773 using namespace blink;
5764 void showLiveDocumentInstances() 5774 void showLiveDocumentInstances()
5765 { 5775 {
5766 WeakDocumentSet& set = liveDocumentSet(); 5776 WeakDocumentSet& set = liveDocumentSet();
5767 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5777 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5768 for (Document* document : set) 5778 for (Document* document : set)
5769 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5779 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5770 } 5780 }
5771 #endif 5781 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698