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

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

Issue 342283005: Make collection caching code more consistent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Stop including NodeListsNodeData.h in ContainerNode.h Created 6 years, 5 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
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 4527 matching lines...) Expand 10 before | Expand all | Expand 10 after
4538 if (!m_svgExtensions) 4538 if (!m_svgExtensions)
4539 m_svgExtensions = adoptPtrWillBeNoop(new SVGDocumentExtensions(this)); 4539 m_svgExtensions = adoptPtrWillBeNoop(new SVGDocumentExtensions(this));
4540 return *m_svgExtensions; 4540 return *m_svgExtensions;
4541 } 4541 }
4542 4542
4543 bool Document::hasSVGRootNode() const 4543 bool Document::hasSVGRootNode() const
4544 { 4544 {
4545 return isSVGSVGElement(documentElement()); 4545 return isSVGSVGElement(documentElement());
4546 } 4546 }
4547 4547
4548 PassRefPtrWillBeRawPtr<HTMLCollection> Document::ensureCachedCollection(Collecti onType type)
4549 {
4550 return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, ty pe);
4551 }
4552
4553 PassRefPtrWillBeRawPtr<HTMLCollection> Document::images() 4548 PassRefPtrWillBeRawPtr<HTMLCollection> Document::images()
4554 { 4549 {
4555 return ensureCachedCollection(DocImages); 4550 return ensureCachedCollection<HTMLCollection>(DocImages);
4556 } 4551 }
4557 4552
4558 PassRefPtrWillBeRawPtr<HTMLCollection> Document::applets() 4553 PassRefPtrWillBeRawPtr<HTMLCollection> Document::applets()
4559 { 4554 {
4560 return ensureCachedCollection(DocApplets); 4555 return ensureCachedCollection<HTMLCollection>(DocApplets);
4561 } 4556 }
4562 4557
4563 PassRefPtrWillBeRawPtr<HTMLCollection> Document::embeds() 4558 PassRefPtrWillBeRawPtr<HTMLCollection> Document::embeds()
4564 { 4559 {
4565 return ensureCachedCollection(DocEmbeds); 4560 return ensureCachedCollection<HTMLCollection>(DocEmbeds);
4566 } 4561 }
4567 4562
4568 PassRefPtrWillBeRawPtr<HTMLCollection> Document::scripts() 4563 PassRefPtrWillBeRawPtr<HTMLCollection> Document::scripts()
4569 { 4564 {
4570 return ensureCachedCollection(DocScripts); 4565 return ensureCachedCollection<HTMLCollection>(DocScripts);
4571 } 4566 }
4572 4567
4573 PassRefPtrWillBeRawPtr<HTMLCollection> Document::links() 4568 PassRefPtrWillBeRawPtr<HTMLCollection> Document::links()
4574 { 4569 {
4575 return ensureCachedCollection(DocLinks); 4570 return ensureCachedCollection<HTMLCollection>(DocLinks);
4576 } 4571 }
4577 4572
4578 PassRefPtrWillBeRawPtr<HTMLCollection> Document::forms() 4573 PassRefPtrWillBeRawPtr<HTMLCollection> Document::forms()
4579 { 4574 {
4580 return ensureCachedCollection(DocForms); 4575 return ensureCachedCollection<HTMLCollection>(DocForms);
4581 } 4576 }
4582 4577
4583 PassRefPtrWillBeRawPtr<HTMLCollection> Document::anchors() 4578 PassRefPtrWillBeRawPtr<HTMLCollection> Document::anchors()
4584 { 4579 {
4585 return ensureCachedCollection(DocAnchors); 4580 return ensureCachedCollection<HTMLCollection>(DocAnchors);
4586 } 4581 }
4587 4582
4588 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::allForBinding() 4583 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::allForBinding()
4589 { 4584 {
4590 UseCounter::count(*this, UseCounter::DocumentAll); 4585 UseCounter::count(*this, UseCounter::DocumentAll);
4591 return all(); 4586 return all();
4592 } 4587 }
4593 4588
4594 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::all() 4589 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::all()
4595 { 4590 {
4596 return ensureRareData().ensureNodeLists().addCache<HTMLAllCollection>(*this, DocAll); 4591 return ensureCachedCollection<HTMLAllCollection>(DocAll);
4597 } 4592 }
4598 4593
4599 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt ring& name) 4594 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt ring& name)
4600 { 4595 {
4601 return ensureRareData().ensureNodeLists().addCache<WindowNameCollection>(*th is, WindowNamedItems, name); 4596 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name);
4602 } 4597 }
4603 4598
4604 PassRefPtrWillBeRawPtr<HTMLCollection> Document::documentNamedItems(const Atomic String& name) 4599 PassRefPtrWillBeRawPtr<HTMLCollection> Document::documentNamedItems(const Atomic String& name)
4605 { 4600 {
4606 return ensureRareData().ensureNodeLists().addCache<DocumentNameCollection>(* this, DocumentNamedItems, name); 4601 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me);
4607 } 4602 }
4608 4603
4609 void Document::finishedParsing() 4604 void Document::finishedParsing()
4610 { 4605 {
4611 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); 4606 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
4612 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); 4607 ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
4613 setParsing(false); 4608 setParsing(false);
4614 if (!m_documentTiming.domContentLoadedEventStart) 4609 if (!m_documentTiming.domContentLoadedEventStart)
4615 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e(); 4610 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e();
4616 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); 4611 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
5887 using namespace blink; 5882 using namespace blink;
5888 void showLiveDocumentInstances() 5883 void showLiveDocumentInstances()
5889 { 5884 {
5890 WeakDocumentSet& set = liveDocumentSet(); 5885 WeakDocumentSet& set = liveDocumentSet();
5891 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5886 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5892 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5887 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5893 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5888 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5894 } 5889 }
5895 } 5890 }
5896 #endif 5891 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698