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

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: Fix nits Created 6 years, 4 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/Element.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 4533 matching lines...) Expand 10 before | Expand all | Expand 10 after
4544 if (!m_svgExtensions) 4544 if (!m_svgExtensions)
4545 m_svgExtensions = adoptPtrWillBeNoop(new SVGDocumentExtensions(this)); 4545 m_svgExtensions = adoptPtrWillBeNoop(new SVGDocumentExtensions(this));
4546 return *m_svgExtensions; 4546 return *m_svgExtensions;
4547 } 4547 }
4548 4548
4549 bool Document::hasSVGRootNode() const 4549 bool Document::hasSVGRootNode() const
4550 { 4550 {
4551 return isSVGSVGElement(documentElement()); 4551 return isSVGSVGElement(documentElement());
4552 } 4552 }
4553 4553
4554 PassRefPtrWillBeRawPtr<HTMLCollection> Document::ensureCachedCollection(Collecti onType type)
4555 {
4556 return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, ty pe);
4557 }
4558
4559 PassRefPtrWillBeRawPtr<HTMLCollection> Document::images() 4554 PassRefPtrWillBeRawPtr<HTMLCollection> Document::images()
4560 { 4555 {
4561 return ensureCachedCollection(DocImages); 4556 return ensureCachedCollection<HTMLCollection>(DocImages);
4562 } 4557 }
4563 4558
4564 PassRefPtrWillBeRawPtr<HTMLCollection> Document::applets() 4559 PassRefPtrWillBeRawPtr<HTMLCollection> Document::applets()
4565 { 4560 {
4566 return ensureCachedCollection(DocApplets); 4561 return ensureCachedCollection<HTMLCollection>(DocApplets);
4567 } 4562 }
4568 4563
4569 PassRefPtrWillBeRawPtr<HTMLCollection> Document::embeds() 4564 PassRefPtrWillBeRawPtr<HTMLCollection> Document::embeds()
4570 { 4565 {
4571 return ensureCachedCollection(DocEmbeds); 4566 return ensureCachedCollection<HTMLCollection>(DocEmbeds);
4572 } 4567 }
4573 4568
4574 PassRefPtrWillBeRawPtr<HTMLCollection> Document::scripts() 4569 PassRefPtrWillBeRawPtr<HTMLCollection> Document::scripts()
4575 { 4570 {
4576 return ensureCachedCollection(DocScripts); 4571 return ensureCachedCollection<HTMLCollection>(DocScripts);
4577 } 4572 }
4578 4573
4579 PassRefPtrWillBeRawPtr<HTMLCollection> Document::links() 4574 PassRefPtrWillBeRawPtr<HTMLCollection> Document::links()
4580 { 4575 {
4581 return ensureCachedCollection(DocLinks); 4576 return ensureCachedCollection<HTMLCollection>(DocLinks);
4582 } 4577 }
4583 4578
4584 PassRefPtrWillBeRawPtr<HTMLCollection> Document::forms() 4579 PassRefPtrWillBeRawPtr<HTMLCollection> Document::forms()
4585 { 4580 {
4586 return ensureCachedCollection(DocForms); 4581 return ensureCachedCollection<HTMLCollection>(DocForms);
4587 } 4582 }
4588 4583
4589 PassRefPtrWillBeRawPtr<HTMLCollection> Document::anchors() 4584 PassRefPtrWillBeRawPtr<HTMLCollection> Document::anchors()
4590 { 4585 {
4591 return ensureCachedCollection(DocAnchors); 4586 return ensureCachedCollection<HTMLCollection>(DocAnchors);
4592 } 4587 }
4593 4588
4594 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::allForBinding() 4589 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::allForBinding()
4595 { 4590 {
4596 UseCounter::count(*this, UseCounter::DocumentAll); 4591 UseCounter::count(*this, UseCounter::DocumentAll);
4597 return all(); 4592 return all();
4598 } 4593 }
4599 4594
4600 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::all() 4595 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::all()
4601 { 4596 {
4602 return ensureRareData().ensureNodeLists().addCache<HTMLAllCollection>(*this, DocAll); 4597 return ensureCachedCollection<HTMLAllCollection>(DocAll);
4603 } 4598 }
4604 4599
4605 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt ring& name) 4600 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt ring& name)
4606 { 4601 {
4607 return ensureRareData().ensureNodeLists().addCache<WindowNameCollection>(*th is, WindowNamedItems, name); 4602 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name);
4608 } 4603 }
4609 4604
4610 PassRefPtrWillBeRawPtr<HTMLCollection> Document::documentNamedItems(const Atomic String& name) 4605 PassRefPtrWillBeRawPtr<HTMLCollection> Document::documentNamedItems(const Atomic String& name)
4611 { 4606 {
4612 return ensureRareData().ensureNodeLists().addCache<DocumentNameCollection>(* this, DocumentNamedItems, name); 4607 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me);
4613 } 4608 }
4614 4609
4615 void Document::finishedParsing() 4610 void Document::finishedParsing()
4616 { 4611 {
4617 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); 4612 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
4618 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); 4613 ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
4619 setParsing(false); 4614 setParsing(false);
4620 if (!m_documentTiming.domContentLoadedEventStart) 4615 if (!m_documentTiming.domContentLoadedEventStart)
4621 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e(); 4616 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e();
4622 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); 4617 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
5879 using namespace blink; 5874 using namespace blink;
5880 void showLiveDocumentInstances() 5875 void showLiveDocumentInstances()
5881 { 5876 {
5882 WeakDocumentSet& set = liveDocumentSet(); 5877 WeakDocumentSet& set = liveDocumentSet();
5883 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5878 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5884 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5879 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5885 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5880 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5886 } 5881 }
5887 } 5882 }
5888 #endif 5883 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698