| OLD | NEW |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "core/page/Page.h" | 48 #include "core/page/Page.h" |
| 49 #include "core/rendering/HitTestResult.h" | 49 #include "core/rendering/HitTestResult.h" |
| 50 #include "core/rendering/RenderView.h" | 50 #include "core/rendering/RenderView.h" |
| 51 #include "wtf/Vector.h" | 51 #include "wtf/Vector.h" |
| 52 #include "wtf/text/AtomicString.h" | 52 #include "wtf/text/AtomicString.h" |
| 53 | 53 |
| 54 namespace WebCore { | 54 namespace WebCore { |
| 55 | 55 |
| 56 struct SameSizeAsTreeScope { | 56 struct SameSizeAsTreeScope { |
| 57 virtual ~SameSizeAsTreeScope(); | 57 virtual ~SameSizeAsTreeScope(); |
| 58 void* pointers[8]; | 58 void* pointers[9]; |
| 59 int ints[1]; | 59 int ints[1]; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 COMPILE_ASSERT(sizeof(TreeScope) == sizeof(SameSizeAsTreeScope), treescope_shoul
d_stay_small); | 62 COMPILE_ASSERT(sizeof(TreeScope) == sizeof(SameSizeAsTreeScope), treescope_shoul
d_stay_small); |
| 63 | 63 |
| 64 using namespace HTMLNames; | 64 using namespace HTMLNames; |
| 65 | 65 |
| 66 TreeScope::TreeScope(ContainerNode* rootNode, Document* document) | 66 TreeScope::TreeScope(ContainerNode* rootNode, Document* document) |
| 67 : m_rootNode(rootNode) | 67 : m_rootNode(rootNode) |
| 68 , m_documentScope(document) | 68 , m_documentScope(document) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { |
| 164 if (!m_elementsById) | 173 if (!m_elementsById) |
| 165 return; | 174 return; |
| 166 m_elementsById->remove(elementId.impl(), element); | 175 m_elementsById->remove(elementId.impl(), element); |
| 167 m_idTargetObserverRegistry->notifyObservers(elementId); | 176 m_idTargetObserverRegistry->notifyObservers(elementId); |
| 168 } | 177 } |
| 169 | 178 |
| 179 Element* TreeScope::getElementByName(const AtomicString& name) const |
| 180 { |
| 181 if (name.isEmpty()) |
| 182 return 0; |
| 183 if (!m_elementsByName) |
| 184 return 0; |
| 185 return m_elementsByName->getElementByName(name.impl(), this); |
| 186 } |
| 187 |
| 188 void TreeScope::addElementByName(const AtomicString& name, Element* element) |
| 189 { |
| 190 if (!m_elementsByName) |
| 191 m_elementsByName = adoptPtr(new DocumentOrderedMap); |
| 192 m_elementsByName->add(name.impl(), element); |
| 193 } |
| 194 |
| 195 void TreeScope::removeElementByName(const AtomicString& name, Element* element) |
| 196 { |
| 197 if (!m_elementsByName) |
| 198 return; |
| 199 m_elementsByName->remove(name.impl(), element); |
| 200 } |
| 201 |
| 170 Node* TreeScope::ancestorInThisScope(Node* node) const | 202 Node* TreeScope::ancestorInThisScope(Node* node) const |
| 171 { | 203 { |
| 172 while (node) { | 204 while (node) { |
| 173 if (node->treeScope() == this) | 205 if (node->treeScope() == this) |
| 174 return node; | 206 return node; |
| 175 if (!node->isInShadowTree()) | 207 if (!node->isInShadowTree()) |
| 176 return 0; | 208 return 0; |
| 177 | 209 |
| 178 node = node->shadowHost(); | 210 node = node->shadowHost(); |
| 179 } | 211 } |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 result = element; | 535 result = element; |
| 504 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { | 536 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { |
| 505 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) | 537 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) |
| 506 result = shadowResult; | 538 result = shadowResult; |
| 507 } | 539 } |
| 508 } | 540 } |
| 509 return result; | 541 return result; |
| 510 } | 542 } |
| 511 | 543 |
| 512 } // namespace WebCore | 544 } // namespace WebCore |
| OLD | NEW |