| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 #if !ENABLE(OILPAN) | 126 #if !ENABLE(OILPAN) |
| 127 void TreeScope::destroyTreeScopeData() | 127 void TreeScope::destroyTreeScopeData() |
| 128 { | 128 { |
| 129 m_elementsById.clear(); | 129 m_elementsById.clear(); |
| 130 m_imageMapsByName.clear(); | 130 m_imageMapsByName.clear(); |
| 131 m_labelsByForAttribute.clear(); | 131 m_labelsByForAttribute.clear(); |
| 132 } | 132 } |
| 133 #endif | 133 #endif |
| 134 | 134 |
| 135 void TreeScope::setDocument(Document& document) |
| 136 { |
| 137 m_document = &document; |
| 138 } |
| 139 |
| 135 void TreeScope::setParentTreeScope(TreeScope& newParentScope) | 140 void TreeScope::setParentTreeScope(TreeScope& newParentScope) |
| 136 { | 141 { |
| 137 // A document node cannot be re-parented. | 142 // A document node cannot be re-parented. |
| 138 ASSERT(!rootNode().isDocumentNode()); | 143 ASSERT(!rootNode().isDocumentNode()); |
| 139 | 144 |
| 140 #if !ENABLE(OILPAN) | 145 #if !ENABLE(OILPAN) |
| 141 newParentScope.guardRef(); | 146 newParentScope.guardRef(); |
| 142 if (m_parentTreeScope) | 147 if (m_parentTreeScope) |
| 143 m_parentTreeScope->guardDeref(); | 148 m_parentTreeScope->guardDeref(); |
| 144 #endif | 149 #endif |
| 145 m_parentTreeScope = &newParentScope; | 150 m_parentTreeScope = &newParentScope; |
| 146 setDocument(newParentScope.document()); | 151 setDocument(newParentScope.document()); |
| 147 } | 152 } |
| 148 | 153 |
| 154 ScopedStyleResolver* TreeScope::scopedStyleResolver() const |
| 155 { |
| 156 return m_scopedStyleResolver.get(); |
| 157 } |
| 158 |
| 149 ScopedStyleResolver& TreeScope::ensureScopedStyleResolver() | 159 ScopedStyleResolver& TreeScope::ensureScopedStyleResolver() |
| 150 { | 160 { |
| 151 RELEASE_ASSERT(this); | 161 RELEASE_ASSERT(this); |
| 152 if (!m_scopedStyleResolver) | 162 if (!m_scopedStyleResolver) |
| 153 m_scopedStyleResolver = ScopedStyleResolver::create(*this); | 163 m_scopedStyleResolver = ScopedStyleResolver::create(*this); |
| 154 return *m_scopedStyleResolver; | 164 return *m_scopedStyleResolver; |
| 155 } | 165 } |
| 156 | 166 |
| 157 void TreeScope::clearScopedStyleResolver() | 167 void TreeScope::clearScopedStyleResolver() |
| 158 { | 168 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 187 } | 197 } |
| 188 | 198 |
| 189 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen
t) | 199 void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen
t) |
| 190 { | 200 { |
| 191 if (!m_elementsById) | 201 if (!m_elementsById) |
| 192 return; | 202 return; |
| 193 m_elementsById->remove(elementId, element); | 203 m_elementsById->remove(elementId, element); |
| 194 m_idTargetObserverRegistry->notifyObservers(elementId); | 204 m_idTargetObserverRegistry->notifyObservers(elementId); |
| 195 } | 205 } |
| 196 | 206 |
| 207 Document& TreeScope::document() const |
| 208 { |
| 209 ASSERT(m_document); |
| 210 return *m_document; |
| 211 } |
| 212 |
| 197 Node* TreeScope::ancestorInThisScope(Node* node) const | 213 Node* TreeScope::ancestorInThisScope(Node* node) const |
| 198 { | 214 { |
| 199 while (node) { | 215 while (node) { |
| 200 if (node->treeScope() == this) | 216 if (node->treeScope() == this) |
| 201 return node; | 217 return node; |
| 202 if (!node->isInShadowTree()) | 218 if (!node->isInShadowTree()) |
| 203 return 0; | 219 return 0; |
| 204 | 220 |
| 205 node = node->shadowHost(); | 221 node = node->shadowHost(); |
| 206 } | 222 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 ASSERT(this); | 428 ASSERT(this); |
| 413 ASSERT(!node.isDocumentNode()); | 429 ASSERT(!node.isDocumentNode()); |
| 414 #if !ENABLE(OILPAN) | 430 #if !ENABLE(OILPAN) |
| 415 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun); | 431 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun); |
| 416 #endif | 432 #endif |
| 417 TreeScopeAdopter adopter(node, *this); | 433 TreeScopeAdopter adopter(node, *this); |
| 418 if (adopter.needsScopeChange()) | 434 if (adopter.needsScopeChange()) |
| 419 adopter.execute(); | 435 adopter.execute(); |
| 420 } | 436 } |
| 421 | 437 |
| 438 IdTargetObserverRegistry& TreeScope::idTargetObserverRegistry() const |
| 439 { |
| 440 return *m_idTargetObserverRegistry.get(); |
| 441 } |
| 442 |
| 422 Element* TreeScope::adjustedFocusedElement() const | 443 Element* TreeScope::adjustedFocusedElement() const |
| 423 { | 444 { |
| 424 Document& document = rootNode().document(); | 445 Document& document = rootNode().document(); |
| 425 Element* element = document.focusedElement(); | 446 Element* element = document.focusedElement(); |
| 426 if (!element && document.page()) | 447 if (!element && document.page()) |
| 427 element = document.page()->focusController().focusedFrameOwnerElement(*d
ocument.frame()); | 448 element = document.page()->focusController().focusedFrameOwnerElement(*d
ocument.frame()); |
| 428 if (!element) | 449 if (!element) |
| 429 return 0; | 450 return 0; |
| 430 | 451 |
| 431 OwnPtrWillBeRawPtr<EventPath> eventPath = adoptPtrWillBeNoop(new EventPath(*
element)); | 452 OwnPtrWillBeRawPtr<EventPath> eventPath = adoptPtrWillBeNoop(new EventPath(*
element)); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 visitor->trace(m_parentTreeScope); | 595 visitor->trace(m_parentTreeScope); |
| 575 visitor->trace(m_idTargetObserverRegistry); | 596 visitor->trace(m_idTargetObserverRegistry); |
| 576 visitor->trace(m_selection); | 597 visitor->trace(m_selection); |
| 577 visitor->trace(m_elementsById); | 598 visitor->trace(m_elementsById); |
| 578 visitor->trace(m_imageMapsByName); | 599 visitor->trace(m_imageMapsByName); |
| 579 visitor->trace(m_labelsByForAttribute); | 600 visitor->trace(m_labelsByForAttribute); |
| 580 visitor->trace(m_scopedStyleResolver); | 601 visitor->trace(m_scopedStyleResolver); |
| 581 } | 602 } |
| 582 | 603 |
| 583 } // namespace blink | 604 } // namespace blink |
| OLD | NEW |