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

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

Issue 176933013: Pass rootNode by reference when constructing node lists / collections (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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/ClassCollection.cpp ('k') | Source/core/dom/Document.cpp » ('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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 setNeedsStyleRecalc(SubtreeStyleChange); 878 setNeedsStyleRecalc(SubtreeStyleChange);
879 else if (renderStyle()->affectedByHover()) 879 else if (renderStyle()->affectedByHover())
880 setNeedsStyleRecalc(LocalStyleChange); 880 setNeedsStyleRecalc(LocalStyleChange);
881 881
882 if (renderer()->style()->hasAppearance()) 882 if (renderer()->style()->hasAppearance())
883 RenderTheme::theme().stateChanged(renderer(), HoverState); 883 RenderTheme::theme().stateChanged(renderer(), HoverState);
884 } 884 }
885 885
886 PassRefPtr<HTMLCollection> ContainerNode::children() 886 PassRefPtr<HTMLCollection> ContainerNode::children()
887 { 887 {
888 return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(this, Nod eChildren); 888 return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, No deChildren);
889 } 889 }
890 890
891 unsigned ContainerNode::countChildren() const 891 unsigned ContainerNode::countChildren() const
892 { 892 {
893 unsigned count = 0; 893 unsigned count = 0;
894 Node *n; 894 Node *n;
895 for (n = firstChild(); n; n = n->nextSibling()) 895 for (n = firstChild(); n; n = n->nextSibling())
896 count++; 896 count++;
897 return count; 897 return count;
898 } 898 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 993
994 dispatchChildInsertionEvents(child); 994 dispatchChildInsertionEvents(child);
995 } 995 }
996 996
997 PassRefPtr<HTMLCollection> ContainerNode::getElementsByTagName(const AtomicStrin g& localName) 997 PassRefPtr<HTMLCollection> ContainerNode::getElementsByTagName(const AtomicStrin g& localName)
998 { 998 {
999 if (localName.isNull()) 999 if (localName.isNull())
1000 return nullptr; 1000 return nullptr;
1001 1001
1002 if (document().isHTMLDocument()) 1002 if (document().isHTMLDocument())
1003 return ensureRareData().ensureNodeLists().addCache<HTMLTagCollection>(th is, HTMLTagCollectionType, localName); 1003 return ensureRareData().ensureNodeLists().addCache<HTMLTagCollection>(*t his, HTMLTagCollectionType, localName);
1004 return ensureRareData().ensureNodeLists().addCache<TagCollection>(this, TagC ollectionType, localName); 1004 return ensureRareData().ensureNodeLists().addCache<TagCollection>(*this, Tag CollectionType, localName);
1005 } 1005 }
1006 1006
1007 PassRefPtr<HTMLCollection> ContainerNode::getElementsByTagNameNS(const AtomicStr ing& namespaceURI, const AtomicString& localName) 1007 PassRefPtr<HTMLCollection> ContainerNode::getElementsByTagNameNS(const AtomicStr ing& namespaceURI, const AtomicString& localName)
1008 { 1008 {
1009 if (localName.isNull()) 1009 if (localName.isNull())
1010 return nullptr; 1010 return nullptr;
1011 1011
1012 if (namespaceURI == starAtom) 1012 if (namespaceURI == starAtom)
1013 return getElementsByTagName(localName); 1013 return getElementsByTagName(localName);
1014 1014
1015 return ensureRareData().ensureNodeLists().addCache(this, namespaceURI.isEmpt y() ? nullAtom : namespaceURI, localName); 1015 return ensureRareData().ensureNodeLists().addCache(*this, namespaceURI.isEmp ty() ? nullAtom : namespaceURI, localName);
1016 } 1016 }
1017 1017
1018 // Takes an AtomicString in argument because it is common for elements to share the same name attribute. 1018 // Takes an AtomicString in argument because it is common for elements to share the same name attribute.
1019 // Therefore, the NameNodeList factory function expects an AtomicString type. 1019 // Therefore, the NameNodeList factory function expects an AtomicString type.
1020 PassRefPtr<NodeList> ContainerNode::getElementsByName(const AtomicString& elemen tName) 1020 PassRefPtr<NodeList> ContainerNode::getElementsByName(const AtomicString& elemen tName)
1021 { 1021 {
1022 return ensureRareData().ensureNodeLists().addCache<NameNodeList>(this, NameN odeListType, elementName); 1022 return ensureRareData().ensureNodeLists().addCache<NameNodeList>(*this, Name NodeListType, elementName);
1023 } 1023 }
1024 1024
1025 // Takes an AtomicString in argument because it is common for elements to share the same set of class names. 1025 // Takes an AtomicString in argument because it is common for elements to share the same set of class names.
1026 // Therefore, the ClassNodeList factory function expects an AtomicString type. 1026 // Therefore, the ClassNodeList factory function expects an AtomicString type.
1027 PassRefPtr<HTMLCollection> ContainerNode::getElementsByClassName(const AtomicStr ing& classNames) 1027 PassRefPtr<HTMLCollection> ContainerNode::getElementsByClassName(const AtomicStr ing& classNames)
1028 { 1028 {
1029 return ensureRareData().ensureNodeLists().addCache<ClassCollection>(this, Cl assCollectionType, classNames); 1029 return ensureRareData().ensureNodeLists().addCache<ClassCollection>(*this, C lassCollectionType, classNames);
1030 } 1030 }
1031 1031
1032 PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name, bool onlyMatchImgElements) 1032 PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name, bool onlyMatchImgElements)
1033 { 1033 {
1034 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag)); 1034 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag));
1035 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod eListType; 1035 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod eListType;
1036 return ensureRareData().ensureNodeLists().addCache<RadioNodeList>(this, type , name); 1036 return ensureRareData().ensureNodeLists().addCache<RadioNodeList>(*this, typ e, name);
1037 } 1037 }
1038 1038
1039 #ifndef NDEBUG 1039 #ifndef NDEBUG
1040 bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node) 1040 bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node)
1041 { 1041 {
1042 if (node->isShadowRoot()) 1042 if (node->isShadowRoot())
1043 return true; 1043 return true;
1044 1044
1045 if (node->isInsertionPoint()) 1045 if (node->isInsertionPoint())
1046 return true; 1046 return true;
1047 1047
1048 if (node->isElementNode() && toElement(node)->shadow()) 1048 if (node->isElementNode() && toElement(node)->shadow())
1049 return true; 1049 return true;
1050 1050
1051 return false; 1051 return false;
1052 } 1052 }
1053 #endif 1053 #endif
1054 1054
1055 } // namespace WebCore 1055 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ClassCollection.cpp ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698