| 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, 2013 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
| 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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 else if (renderStyle()->affectedByHover()) | 1091 else if (renderStyle()->affectedByHover()) |
| 1092 setNeedsStyleRecalc(LocalStyleChange); | 1092 setNeedsStyleRecalc(LocalStyleChange); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 if (renderer()->style()->hasAppearance()) | 1095 if (renderer()->style()->hasAppearance()) |
| 1096 RenderTheme::theme().stateChanged(renderer(), HoverControlState); | 1096 RenderTheme::theme().stateChanged(renderer(), HoverControlState); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 PassRefPtrWillBeRawPtr<HTMLCollection> ContainerNode::children() | 1099 PassRefPtrWillBeRawPtr<HTMLCollection> ContainerNode::children() |
| 1100 { | 1100 { |
| 1101 return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, No
deChildren); | 1101 return ensureCachedCollection<HTMLCollection>(NodeChildren); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 unsigned ContainerNode::countChildren() const | 1104 unsigned ContainerNode::countChildren() const |
| 1105 { | 1105 { |
| 1106 unsigned count = 0; | 1106 unsigned count = 0; |
| 1107 Node *n; | 1107 Node *n; |
| 1108 for (n = firstChild(); n; n = n->nextSibling()) | 1108 for (n = firstChild(); n; n = n->nextSibling()) |
| 1109 count++; | 1109 count++; |
| 1110 return count; | 1110 return count; |
| 1111 } | 1111 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 lists->invalidateCaches(attrName); | 1347 lists->invalidateCaches(attrName); |
| 1348 } | 1348 } |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagName(const
AtomicString& localName) | 1351 PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagName(const
AtomicString& localName) |
| 1352 { | 1352 { |
| 1353 if (localName.isNull()) | 1353 if (localName.isNull()) |
| 1354 return nullptr; | 1354 return nullptr; |
| 1355 | 1355 |
| 1356 if (document().isHTMLDocument()) | 1356 if (document().isHTMLDocument()) |
| 1357 return ensureRareData().ensureNodeLists().addCache<HTMLTagCollection>(*t
his, HTMLTagCollectionType, localName); | 1357 return ensureCachedCollection<HTMLTagCollection>(HTMLTagCollectionType,
localName); |
| 1358 return ensureRareData().ensureNodeLists().addCache<TagCollection>(*this, Tag
CollectionType, localName); | 1358 return ensureCachedCollection<TagCollection>(TagCollectionType, localName); |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagNameNS(cons
t AtomicString& namespaceURI, const AtomicString& localName) | 1361 PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagNameNS(cons
t AtomicString& namespaceURI, const AtomicString& localName) |
| 1362 { | 1362 { |
| 1363 if (localName.isNull()) | 1363 if (localName.isNull()) |
| 1364 return nullptr; | 1364 return nullptr; |
| 1365 | 1365 |
| 1366 if (namespaceURI == starAtom) | 1366 if (namespaceURI == starAtom) |
| 1367 return getElementsByTagName(localName); | 1367 return getElementsByTagName(localName); |
| 1368 | 1368 |
| 1369 return ensureRareData().ensureNodeLists().addCache(*this, namespaceURI.isEmp
ty() ? nullAtom : namespaceURI, localName); | 1369 return ensureCachedCollection<TagCollection>(TagCollectionType, namespaceURI
.isEmpty() ? nullAtom : namespaceURI, localName); |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 // Takes an AtomicString in argument because it is common for elements to share
the same name attribute. | 1372 // Takes an AtomicString in argument because it is common for elements to share
the same name attribute. |
| 1373 // Therefore, the NameNodeList factory function expects an AtomicString type. | 1373 // Therefore, the NameNodeList factory function expects an AtomicString type. |
| 1374 PassRefPtrWillBeRawPtr<NameNodeList> ContainerNode::getElementsByName(const Atom
icString& elementName) | 1374 PassRefPtrWillBeRawPtr<NameNodeList> ContainerNode::getElementsByName(const Atom
icString& elementName) |
| 1375 { | 1375 { |
| 1376 return ensureRareData().ensureNodeLists().addCache<NameNodeList>(*this, Name
NodeListType, elementName); | 1376 return ensureCachedCollection<NameNodeList>(NameNodeListType, elementName); |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 // Takes an AtomicString in argument because it is common for elements to share
the same set of class names. | 1379 // Takes an AtomicString in argument because it is common for elements to share
the same set of class names. |
| 1380 // Therefore, the ClassNodeList factory function expects an AtomicString type. | 1380 // Therefore, the ClassNodeList factory function expects an AtomicString type. |
| 1381 PassRefPtrWillBeRawPtr<ClassCollection> ContainerNode::getElementsByClassName(co
nst AtomicString& classNames) | 1381 PassRefPtrWillBeRawPtr<ClassCollection> ContainerNode::getElementsByClassName(co
nst AtomicString& classNames) |
| 1382 { | 1382 { |
| 1383 return ensureRareData().ensureNodeLists().addCache<ClassCollection>(*this, C
lassCollectionType, classNames); | 1383 return ensureCachedCollection<ClassCollection>(ClassCollectionType, classNam
es); |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 PassRefPtrWillBeRawPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicS
tring& name, bool onlyMatchImgElements) | 1386 PassRefPtrWillBeRawPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicS
tring& name, bool onlyMatchImgElements) |
| 1387 { | 1387 { |
| 1388 ASSERT(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); | 1388 ASSERT(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); |
| 1389 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod
eListType; | 1389 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod
eListType; |
| 1390 return ensureRareData().ensureNodeLists().addCache<RadioNodeList>(*this, typ
e, name); | 1390 return ensureCachedCollection<RadioNodeList>(type, name); |
| 1391 } | 1391 } |
| 1392 | 1392 |
| 1393 Element* ContainerNode::getElementById(const AtomicString& id) const | 1393 Element* ContainerNode::getElementById(const AtomicString& id) const |
| 1394 { | 1394 { |
| 1395 if (isInTreeScope()) { | 1395 if (isInTreeScope()) { |
| 1396 // Fast path if we are in a tree scope: call getElementById() on tree sc
ope | 1396 // Fast path if we are in a tree scope: call getElementById() on tree sc
ope |
| 1397 // and check if the matching element is in our subtree. | 1397 // and check if the matching element is in our subtree. |
| 1398 Element* element = treeScope().getElementById(id); | 1398 Element* element = treeScope().getElementById(id); |
| 1399 if (!element) | 1399 if (!element) |
| 1400 return 0; | 1400 return 0; |
| 1401 if (element->isDescendantOf(this)) | 1401 if (element->isDescendantOf(this)) |
| 1402 return element; | 1402 return element; |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 // Fall back to traversing our subtree. In case of duplicate ids, the first
element found will be returned. | 1405 // Fall back to traversing our subtree. In case of duplicate ids, the first
element found will be returned. |
| 1406 for (Element* element = ElementTraversal::firstWithin(*this); element; eleme
nt = ElementTraversal::next(*element, this)) { | 1406 for (Element* element = ElementTraversal::firstWithin(*this); element; eleme
nt = ElementTraversal::next(*element, this)) { |
| 1407 if (element->getIdAttribute() == id) | 1407 if (element->getIdAttribute() == id) |
| 1408 return element; | 1408 return element; |
| 1409 } | 1409 } |
| 1410 return 0; | 1410 return 0; |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 NodeListsNodeData& ContainerNode::ensureNodeLists() |
| 1414 { |
| 1415 return ensureRareData().ensureNodeLists(); |
| 1416 } |
| 1417 |
| 1413 #if ENABLE(ASSERT) | 1418 #if ENABLE(ASSERT) |
| 1414 bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node) | 1419 bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node) |
| 1415 { | 1420 { |
| 1416 if (node->isShadowRoot()) | 1421 if (node->isShadowRoot()) |
| 1417 return true; | 1422 return true; |
| 1418 | 1423 |
| 1419 if (node->isInsertionPoint()) | 1424 if (node->isInsertionPoint()) |
| 1420 return true; | 1425 return true; |
| 1421 | 1426 |
| 1422 if (node->isElementNode() && toElement(node)->shadow()) | 1427 if (node->isElementNode() && toElement(node)->shadow()) |
| 1423 return true; | 1428 return true; |
| 1424 | 1429 |
| 1425 return false; | 1430 return false; |
| 1426 } | 1431 } |
| 1427 #endif | 1432 #endif |
| 1428 | 1433 |
| 1429 } // namespace blink | 1434 } // namespace blink |
| OLD | NEW |