| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 void TreeScope::ClearScopedStyleResolver() { | 117 void TreeScope::ClearScopedStyleResolver() { |
| 118 scoped_style_resolver_.Clear(); | 118 scoped_style_resolver_.Clear(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 Element* TreeScope::getElementById(const AtomicString& element_id) const { | 121 Element* TreeScope::getElementById(const AtomicString& element_id) const { |
| 122 if (element_id.IsEmpty()) | 122 if (element_id.IsEmpty()) |
| 123 return nullptr; | 123 return nullptr; |
| 124 if (!elements_by_id_) | 124 if (!elements_by_id_) |
| 125 return nullptr; | 125 return nullptr; |
| 126 return elements_by_id_->GetElementById(element_id, this); | 126 return elements_by_id_->GetElementById(element_id, *this); |
| 127 } | 127 } |
| 128 | 128 |
| 129 const HeapVector<Member<Element>>& TreeScope::GetAllElementsById( | 129 const HeapVector<Member<Element>>& TreeScope::GetAllElementsById( |
| 130 const AtomicString& element_id) const { | 130 const AtomicString& element_id) const { |
| 131 DEFINE_STATIC_LOCAL(HeapVector<Member<Element>>, empty_vector, | 131 DEFINE_STATIC_LOCAL(HeapVector<Member<Element>>, empty_vector, |
| 132 (new HeapVector<Member<Element>>)); | 132 (new HeapVector<Member<Element>>)); |
| 133 if (element_id.IsEmpty()) | 133 if (element_id.IsEmpty()) |
| 134 return empty_vector; | 134 return empty_vector; |
| 135 if (!elements_by_id_) | 135 if (!elements_by_id_) |
| 136 return empty_vector; | 136 return empty_vector; |
| 137 return elements_by_id_->GetAllElementsById(element_id, this); | 137 return elements_by_id_->GetAllElementsById(element_id, *this); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void TreeScope::AddElementById(const AtomicString& element_id, | 140 void TreeScope::AddElementById(const AtomicString& element_id, |
| 141 Element* element) { | 141 Element* element) { |
| 142 if (!elements_by_id_) | 142 if (!elements_by_id_) |
| 143 elements_by_id_ = DocumentOrderedMap::Create(); | 143 elements_by_id_ = DocumentOrderedMap::Create(); |
| 144 elements_by_id_->Add(element_id, element); | 144 elements_by_id_->Add(element_id, element); |
| 145 id_target_observer_registry_->NotifyObservers(element_id); | 145 id_target_observer_registry_->NotifyObservers(element_id); |
| 146 } | 146 } |
| 147 | 147 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 | 186 |
| 187 HTMLMapElement* TreeScope::GetImageMap(const String& url) const { | 187 HTMLMapElement* TreeScope::GetImageMap(const String& url) const { |
| 188 if (url.IsNull()) | 188 if (url.IsNull()) |
| 189 return nullptr; | 189 return nullptr; |
| 190 if (!image_maps_by_name_) | 190 if (!image_maps_by_name_) |
| 191 return nullptr; | 191 return nullptr; |
| 192 size_t hash_pos = url.find('#'); | 192 size_t hash_pos = url.find('#'); |
| 193 String name = hash_pos == kNotFound ? url : url.Substring(hash_pos + 1); | 193 String name = hash_pos == kNotFound ? url : url.Substring(hash_pos + 1); |
| 194 return toHTMLMapElement( | 194 return toHTMLMapElement( |
| 195 image_maps_by_name_->GetElementByMapName(AtomicString(name), this)); | 195 image_maps_by_name_->GetElementByMapName(AtomicString(name), *this)); |
| 196 } | 196 } |
| 197 | 197 |
| 198 static bool PointWithScrollAndZoomIfPossible(const Document& document, | 198 static bool PointWithScrollAndZoomIfPossible(const Document& document, |
| 199 IntPoint& point) { | 199 IntPoint& point) { |
| 200 LocalFrame* frame = document.GetFrame(); | 200 LocalFrame* frame = document.GetFrame(); |
| 201 if (!frame) | 201 if (!frame) |
| 202 return false; | 202 return false; |
| 203 FrameView* frame_view = frame->View(); | 203 FrameView* frame_view = frame->View(); |
| 204 if (!frame_view) | 204 if (!frame_view) |
| 205 return false; | 205 return false; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 if (child == child1) | 446 if (child == child1) |
| 447 return Node::kDocumentPositionFollowing; | 447 return Node::kDocumentPositionFollowing; |
| 448 } | 448 } |
| 449 | 449 |
| 450 return Node::kDocumentPositionPreceding; | 450 return Node::kDocumentPositionPreceding; |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 | 453 |
| 454 // There was no difference between the two parent chains, i.e., one was a | 454 // There was no difference between the two parent chains, i.e., one was a |
| 455 // subset of the other. The shorter chain is the ancestor. | 455 // subset of the other. The shorter chain is the ancestor. |
| 456 return index1 < index2 | 456 return index1 < index2 ? Node::kDocumentPositionFollowing | |
| 457 ? Node::kDocumentPositionFollowing | | 457 Node::kDocumentPositionContainedBy |
| 458 Node::kDocumentPositionContainedBy | 458 : Node::kDocumentPositionPreceding | |
| 459 : Node::kDocumentPositionPreceding | | 459 Node::kDocumentPositionContains; |
| 460 Node::kDocumentPositionContains; | |
| 461 } | 460 } |
| 462 | 461 |
| 463 const TreeScope* TreeScope::CommonAncestorTreeScope( | 462 const TreeScope* TreeScope::CommonAncestorTreeScope( |
| 464 const TreeScope& other) const { | 463 const TreeScope& other) const { |
| 465 HeapVector<Member<const TreeScope>, 16> this_chain; | 464 HeapVector<Member<const TreeScope>, 16> this_chain; |
| 466 for (const TreeScope* tree = this; tree; tree = tree->ParentTreeScope()) | 465 for (const TreeScope* tree = this; tree; tree = tree->ParentTreeScope()) |
| 467 this_chain.push_back(tree); | 466 this_chain.push_back(tree); |
| 468 | 467 |
| 469 HeapVector<Member<const TreeScope>, 16> other_chain; | 468 HeapVector<Member<const TreeScope>, 16> other_chain; |
| 470 for (const TreeScope* tree = &other; tree; tree = tree->ParentTreeScope()) | 469 for (const TreeScope* tree = &other; tree; tree = tree->ParentTreeScope()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 visitor->Trace(id_target_observer_registry_); | 535 visitor->Trace(id_target_observer_registry_); |
| 537 visitor->Trace(selection_); | 536 visitor->Trace(selection_); |
| 538 visitor->Trace(elements_by_id_); | 537 visitor->Trace(elements_by_id_); |
| 539 visitor->Trace(image_maps_by_name_); | 538 visitor->Trace(image_maps_by_name_); |
| 540 visitor->Trace(scoped_style_resolver_); | 539 visitor->Trace(scoped_style_resolver_); |
| 541 visitor->Trace(radio_button_group_scope_); | 540 visitor->Trace(radio_button_group_scope_); |
| 542 visitor->Trace(svg_tree_scoped_resources_); | 541 visitor->Trace(svg_tree_scoped_resources_); |
| 543 } | 542 } |
| 544 | 543 |
| 545 } // namespace blink | 544 } // namespace blink |
| OLD | NEW |