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

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

Issue 25036004: Add a lifecycle state machine for Document (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 2 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/DocumentLifecycle.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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 if (initializer.shouldSetURL()) 483 if (initializer.shouldSetURL())
484 setURL(initializer.url()); 484 setURL(initializer.url());
485 485
486 initSecurityContext(initializer); 486 initSecurityContext(initializer);
487 initDNSPrefetch(); 487 initDNSPrefetch();
488 488
489 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++) 489 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++)
490 m_nodeListCounts[i] = 0; 490 m_nodeListCounts[i] = 0;
491 491
492 InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter); 492 InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter);
493
494 m_lifecyle.advanceTo(DocumentLifecycle::Inactive);
493 } 495 }
494 496
495 static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, cons t WebCore::QualifiedName& prefixedAttribute, const HTMLFrameOwnerElement* owner) 497 static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, cons t WebCore::QualifiedName& prefixedAttribute, const HTMLFrameOwnerElement* owner)
496 { 498 {
497 if (!owner) 499 if (!owner)
498 return true; 500 return true;
499 do { 501 do {
500 if (!(owner->hasAttribute(attribute) || owner->hasAttribute(prefixedAttr ibute))) 502 if (!(owner->hasAttribute(attribute) || owner->hasAttribute(prefixedAttr ibute)))
501 return false; 503 return false;
502 } while ((owner = owner->document().ownerElement())); 504 } while ((owner = owner->document().ownerElement()));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 m_cssCanvasElements.clear(); 608 m_cssCanvasElements.clear();
607 609
608 // FIXME: consider using ActiveDOMObject. 610 // FIXME: consider using ActiveDOMObject.
609 if (m_scriptedAnimationController) 611 if (m_scriptedAnimationController)
610 m_scriptedAnimationController->clearDocumentPointer(); 612 m_scriptedAnimationController->clearDocumentPointer();
611 m_scriptedAnimationController.clear(); 613 m_scriptedAnimationController.clear();
612 614
613 if (svgExtensions()) 615 if (svgExtensions())
614 accessSVGExtensions()->pauseAnimations(); 616 accessSVGExtensions()->pauseAnimations();
615 617
618 m_lifecyle.advanceTo(DocumentLifecycle::Disposed);
616 lifecycleNotifier()->notifyDocumentWasDisposed(); 619 lifecycleNotifier()->notifyDocumentWasDisposed();
617 } 620 }
618 621
619 SelectorQueryCache* Document::selectorQueryCache() 622 SelectorQueryCache* Document::selectorQueryCache()
620 { 623 {
621 if (!m_selectorQueryCache) 624 if (!m_selectorQueryCache)
622 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); 625 m_selectorQueryCache = adoptPtr(new SelectorQueryCache());
623 return m_selectorQueryCache.get(); 626 return m_selectorQueryCache.get();
624 } 627 }
625 628
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 1978
1976 // Create the rendering tree 1979 // Create the rendering tree
1977 setRenderer(new RenderView(this)); 1980 setRenderer(new RenderView(this));
1978 renderView()->setIsInWindow(true); 1981 renderView()->setIsInWindow(true);
1979 1982
1980 recalcStyle(Force); 1983 recalcStyle(Force);
1981 1984
1982 m_styleResolverThrowawayTimer.startRepeating(60); 1985 m_styleResolverThrowawayTimer.startRepeating(60);
1983 1986
1984 ContainerNode::attach(context); 1987 ContainerNode::attach(context);
1988
1989 m_lifecyle.advanceTo(DocumentLifecycle::Active);
1985 } 1990 }
1986 1991
1987 void Document::detach(const AttachContext& context) 1992 void Document::detach(const AttachContext& context)
1988 { 1993 {
1994 m_lifecyle.advanceTo(DocumentLifecycle::Stopping);
1995
1989 ASSERT(confusingAndOftenMisusedAttached()); 1996 ASSERT(confusingAndOftenMisusedAttached());
1990 1997
1991 if (page()) 1998 if (page())
1992 page()->documentDetached(this); 1999 page()->documentDetached(this);
1993 2000
1994 if (this == topDocument()) 2001 if (this == topDocument())
1995 clearAXObjectCache(); 2002 clearAXObjectCache();
1996 2003
1997 stopActiveDOMObjects(); 2004 stopActiveDOMObjects();
1998 m_eventQueue->close(); 2005 m_eventQueue->close();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 // us. However, this violates Node::detach() semantics, as it's never 2049 // us. However, this violates Node::detach() semantics, as it's never
2043 // possible to re-attach. Eventually Document::detach() should be renamed, 2050 // possible to re-attach. Eventually Document::detach() should be renamed,
2044 // or this setting of the frame to 0 could be made explicit in each of the 2051 // or this setting of the frame to 0 could be made explicit in each of the
2045 // callers of Document::detach(). 2052 // callers of Document::detach().
2046 m_frame = 0; 2053 m_frame = 0;
2047 2054
2048 if (m_mediaQueryMatcher) 2055 if (m_mediaQueryMatcher)
2049 m_mediaQueryMatcher->documentDestroyed(); 2056 m_mediaQueryMatcher->documentDestroyed();
2050 2057
2051 lifecycleNotifier()->notifyDocumentWasDetached(); 2058 lifecycleNotifier()->notifyDocumentWasDetached();
2059 m_lifecyle.advanceTo(DocumentLifecycle::Stopped);
2052 } 2060 }
2053 2061
2054 void Document::prepareForDestruction() 2062 void Document::prepareForDestruction()
2055 { 2063 {
2056 disconnectDescendantFrames(); 2064 disconnectDescendantFrames();
2057 2065
2058 // The process of disconnecting descendant frames could have already 2066 // The process of disconnecting descendant frames could have already
2059 // detached us. 2067 // detached us.
2060 if (!confusingAndOftenMisusedAttached()) 2068 if (!confusingAndOftenMisusedAttached())
2061 return; 2069 return;
(...skipping 3367 matching lines...) Expand 10 before | Expand all | Expand 10 after
5429 { 5437 {
5430 return DocumentLifecycleNotifier::create(this); 5438 return DocumentLifecycleNotifier::create(this);
5431 } 5439 }
5432 5440
5433 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5441 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5434 { 5442 {
5435 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5443 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5436 } 5444 }
5437 5445
5438 } // namespace WebCore 5446 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698