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

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

Issue 92083002: Add fast path for tag#id selector queries (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix clusterfuzz crash and remove FIXME comment Created 7 years 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) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 Element* TreeScope::getElementById(const AtomicString& elementId) const 144 Element* TreeScope::getElementById(const AtomicString& elementId) const
145 { 145 {
146 if (elementId.isEmpty()) 146 if (elementId.isEmpty())
147 return 0; 147 return 0;
148 if (!m_elementsById) 148 if (!m_elementsById)
149 return 0; 149 return 0;
150 return m_elementsById->getElementById(elementId.impl(), this); 150 return m_elementsById->getElementById(elementId.impl(), this);
151 } 151 }
152 152
153 const Vector<Element*>* TreeScope::getAllElementsById(const AtomicString& elemen tId) const
154 {
155 if (elementId.isEmpty())
156 return 0;
157 if (!m_elementsById)
158 return 0;
esprehn 2013/12/17 18:57:48 Why not return emptyVector? We should just add a s
Inactive 2013/12/17 21:20:24 Done.
159 return m_elementsById->getAllElementsById(elementId.impl(), this);
160 }
161
153 void TreeScope::addElementById(const AtomicString& elementId, Element* element) 162 void TreeScope::addElementById(const AtomicString& elementId, Element* element)
154 { 163 {
155 if (!m_elementsById) 164 if (!m_elementsById)
156 m_elementsById = adoptPtr(new DocumentOrderedMap); 165 m_elementsById = adoptPtr(new DocumentOrderedMap);
157 m_elementsById->add(elementId.impl(), element); 166 m_elementsById->add(elementId.impl(), element);
158 m_idTargetObserverRegistry->notifyObservers(elementId); 167 m_idTargetObserverRegistry->notifyObservers(elementId);
159 } 168 }
160 169
161 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen t) 170 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen t)
162 { 171 {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 result = element; 501 result = element;
493 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) { 502 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) {
494 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) 503 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key))
495 result = shadowResult; 504 result = shadowResult;
496 } 505 }
497 } 506 }
498 return result; 507 return result;
499 } 508 }
500 509
501 } // namespace WebCore 510 } // namespace WebCore
OLDNEW
« Source/core/dom/SelectorQuery.cpp ('K') | « Source/core/dom/TreeScope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698