OLD | NEW |
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 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 return ensureRareData().ensureNodeLists().addCache<ClassCollection>(*this, C
lassCollectionType, classNames); | 1160 return ensureRareData().ensureNodeLists().addCache<ClassCollection>(*this, C
lassCollectionType, classNames); |
1161 } | 1161 } |
1162 | 1162 |
1163 PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name,
bool onlyMatchImgElements) | 1163 PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name,
bool onlyMatchImgElements) |
1164 { | 1164 { |
1165 ASSERT(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); | 1165 ASSERT(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); |
1166 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod
eListType; | 1166 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod
eListType; |
1167 return ensureRareData().ensureNodeLists().addCache<RadioNodeList>(*this, typ
e, name); | 1167 return ensureRareData().ensureNodeLists().addCache<RadioNodeList>(*this, typ
e, name); |
1168 } | 1168 } |
1169 | 1169 |
| 1170 Element* ContainerNode::getElementById(const AtomicString& id) const |
| 1171 { |
| 1172 if (isInTreeScope()) { |
| 1173 // Fast path if we are in a tree scope: call getElementById() on tree sc
ope |
| 1174 // and check if the matching element is in our subtree. |
| 1175 Element* element = treeScope().getElementById(id); |
| 1176 if (!element) |
| 1177 return 0; |
| 1178 if (element->isDescendantOf(this)) |
| 1179 return element; |
| 1180 } |
| 1181 |
| 1182 // Fall back to traversing our subtree. In case of duplicate ids, the first
element found will be returned. |
| 1183 for (Element* element = ElementTraversal::firstWithin(*this); element; eleme
nt = ElementTraversal::next(*element, this)) { |
| 1184 if (element->getIdAttribute() == id) |
| 1185 return element; |
| 1186 } |
| 1187 return 0; |
| 1188 } |
| 1189 |
1170 #ifndef NDEBUG | 1190 #ifndef NDEBUG |
1171 bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node) | 1191 bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node) |
1172 { | 1192 { |
1173 if (node->isShadowRoot()) | 1193 if (node->isShadowRoot()) |
1174 return true; | 1194 return true; |
1175 | 1195 |
1176 if (node->isInsertionPoint()) | 1196 if (node->isInsertionPoint()) |
1177 return true; | 1197 return true; |
1178 | 1198 |
1179 if (node->isElementNode() && toElement(node)->shadow()) | 1199 if (node->isElementNode() && toElement(node)->shadow()) |
1180 return true; | 1200 return true; |
1181 | 1201 |
1182 return false; | 1202 return false; |
1183 } | 1203 } |
1184 #endif | 1204 #endif |
1185 | 1205 |
1186 } // namespace WebCore | 1206 } // namespace WebCore |
OLD | NEW |