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

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

Issue 1883083002: Introduce Node::containingTreeScope(), which asserts that the node's root is a tree scope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renamed Created 4 years, 6 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
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, 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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 DCHECK(isHTMLFormElement(this) || isHTMLFieldSetElement(this)); 1347 DCHECK(isHTMLFormElement(this) || isHTMLFieldSetElement(this));
1348 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod eListType; 1348 CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNod eListType;
1349 return ensureCachedCollection<RadioNodeList>(type, name); 1349 return ensureCachedCollection<RadioNodeList>(type, name);
1350 } 1350 }
1351 1351
1352 Element* ContainerNode::getElementById(const AtomicString& id) const 1352 Element* ContainerNode::getElementById(const AtomicString& id) const
1353 { 1353 {
1354 if (isInTreeScope()) { 1354 if (isInTreeScope()) {
1355 // Fast path if we are in a tree scope: call getElementById() on tree sc ope 1355 // Fast path if we are in a tree scope: call getElementById() on tree sc ope
1356 // and check if the matching element is in our subtree. 1356 // and check if the matching element is in our subtree.
1357 Element* element = treeScope().getElementById(id); 1357 Element* element = containingTreeScope().getElementById(id);
1358 if (!element) 1358 if (!element)
1359 return nullptr; 1359 return nullptr;
1360 if (element->isDescendantOf(this)) 1360 if (element->isDescendantOf(this))
1361 return element; 1361 return element;
1362 } 1362 }
1363 1363
1364 // Fall back to traversing our subtree. In case of duplicate ids, the first element found will be returned. 1364 // Fall back to traversing our subtree. In case of duplicate ids, the first element found will be returned.
1365 for (Element& element : ElementTraversal::descendantsOf(*this)) { 1365 for (Element& element : ElementTraversal::descendantsOf(*this)) {
1366 if (element.getIdAttribute() == id) 1366 if (element.getIdAttribute() == id)
1367 return &element; 1367 return &element;
(...skipping 19 matching lines...) Expand all
1387 return true; 1387 return true;
1388 1388
1389 if (node->isElementNode() && toElement(node)->shadow()) 1389 if (node->isElementNode() && toElement(node)->shadow())
1390 return true; 1390 return true;
1391 1391
1392 return false; 1392 return false;
1393 } 1393 }
1394 #endif 1394 #endif
1395 1395
1396 } // namespace blink 1396 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp ('k') | third_party/WebKit/Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698