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

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: 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 Element* TreeScope::getElementById(const AtomicString& elementId) const 145 Element* TreeScope::getElementById(const AtomicString& elementId) const
146 { 146 {
147 if (elementId.isEmpty()) 147 if (elementId.isEmpty())
148 return 0; 148 return 0;
149 if (!m_elementsById) 149 if (!m_elementsById)
150 return 0; 150 return 0;
151 return m_elementsById->getElementById(elementId.impl(), this); 151 return m_elementsById->getElementById(elementId.impl(), this);
152 } 152 }
153 153
154 const Vector<Element*>* TreeScope::getAllElementsById(const AtomicString& elemen tId) const
155 {
156 if (elementId.isEmpty())
157 return 0;
158 if (!m_elementsById)
159 return 0;
160 return m_elementsById->getAllElementsById(elementId.impl(), this);
161 }
162
154 void TreeScope::addElementById(const AtomicString& elementId, Element* element) 163 void TreeScope::addElementById(const AtomicString& elementId, Element* element)
155 { 164 {
156 if (!m_elementsById) 165 if (!m_elementsById)
157 m_elementsById = adoptPtr(new DocumentOrderedMap); 166 m_elementsById = adoptPtr(new DocumentOrderedMap);
158 m_elementsById->add(elementId.impl(), element); 167 m_elementsById->add(elementId.impl(), element);
159 m_idTargetObserverRegistry->notifyObservers(elementId); 168 m_idTargetObserverRegistry->notifyObservers(elementId);
160 } 169 }
161 170
162 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen t) 171 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen t)
163 { 172 {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 result = element; 502 result = element;
494 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) { 503 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) {
495 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) 504 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key))
496 result = shadowResult; 505 result = shadowResult;
497 } 506 }
498 } 507 }
499 return result; 508 return result;
500 } 509 }
501 510
502 } // namespace WebCore 511 } // 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