| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if (node->isPseudoElement() || node->isTextNode()) | 301 if (node->isPseudoElement() || node->isTextNode()) |
| 302 node = node->parentOrShadowHostNode(); | 302 node = node->parentOrShadowHostNode(); |
| 303 node = ancestorInThisScope(node); | 303 node = ancestorInThisScope(node); |
| 304 | 304 |
| 305 // Prune duplicate entries. A pseduo ::before content above its parent | 305 // Prune duplicate entries. A pseduo ::before content above its parent |
| 306 // node should only result in a single entry. | 306 // node should only result in a single entry. |
| 307 if (node == lastNode) | 307 if (node == lastNode) |
| 308 continue; | 308 continue; |
| 309 | 309 |
| 310 if (node && node->isElementNode()) { | 310 if (node && node->isElementNode()) { |
| 311 elements.append(toElement(node)); | 311 elements.push_back(toElement(node)); |
| 312 lastNode = node; | 312 lastNode = node; |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 if (rootNode().isDocumentNode()) { | 316 if (rootNode().isDocumentNode()) { |
| 317 if (Element* rootElement = toDocument(rootNode()).documentElement()) { | 317 if (Element* rootElement = toDocument(rootNode()).documentElement()) { |
| 318 if (elements.isEmpty() || elements.back() != rootElement) | 318 if (elements.isEmpty() || elements.back() != rootElement) |
| 319 elements.append(rootElement); | 319 elements.push_back(rootElement); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 return elements; | 323 return elements; |
| 324 } | 324 } |
| 325 | 325 |
| 326 HeapVector<Member<Element>> TreeScope::elementsFromPoint(int x, int y) const { | 326 HeapVector<Member<Element>> TreeScope::elementsFromPoint(int x, int y) const { |
| 327 Document& document = rootNode().document(); | 327 Document& document = rootNode().document(); |
| 328 IntPoint hitPoint(x, y); | 328 IntPoint hitPoint(x, y); |
| 329 if (!pointWithScrollAndZoomIfPossible(document, hitPoint)) | 329 if (!pointWithScrollAndZoomIfPossible(document, hitPoint)) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 } | 441 } |
| 442 | 442 |
| 443 unsigned short TreeScope::comparePosition(const TreeScope& otherScope) const { | 443 unsigned short TreeScope::comparePosition(const TreeScope& otherScope) const { |
| 444 if (otherScope == this) | 444 if (otherScope == this) |
| 445 return Node::kDocumentPositionEquivalent; | 445 return Node::kDocumentPositionEquivalent; |
| 446 | 446 |
| 447 HeapVector<Member<const TreeScope>, 16> chain1; | 447 HeapVector<Member<const TreeScope>, 16> chain1; |
| 448 HeapVector<Member<const TreeScope>, 16> chain2; | 448 HeapVector<Member<const TreeScope>, 16> chain2; |
| 449 const TreeScope* current; | 449 const TreeScope* current; |
| 450 for (current = this; current; current = current->parentTreeScope()) | 450 for (current = this; current; current = current->parentTreeScope()) |
| 451 chain1.append(current); | 451 chain1.push_back(current); |
| 452 for (current = &otherScope; current; current = current->parentTreeScope()) | 452 for (current = &otherScope; current; current = current->parentTreeScope()) |
| 453 chain2.append(current); | 453 chain2.push_back(current); |
| 454 | 454 |
| 455 unsigned index1 = chain1.size(); | 455 unsigned index1 = chain1.size(); |
| 456 unsigned index2 = chain2.size(); | 456 unsigned index2 = chain2.size(); |
| 457 if (chain1[index1 - 1] != chain2[index2 - 1]) | 457 if (chain1[index1 - 1] != chain2[index2 - 1]) |
| 458 return Node::kDocumentPositionDisconnected | | 458 return Node::kDocumentPositionDisconnected | |
| 459 Node::kDocumentPositionImplementationSpecific; | 459 Node::kDocumentPositionImplementationSpecific; |
| 460 | 460 |
| 461 for (unsigned i = std::min(index1, index2); i; --i) { | 461 for (unsigned i = std::min(index1, index2); i; --i) { |
| 462 const TreeScope* child1 = chain1[--index1]; | 462 const TreeScope* child1 = chain1[--index1]; |
| 463 const TreeScope* child2 = chain2[--index2]; | 463 const TreeScope* child2 = chain2[--index2]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 485 ? Node::kDocumentPositionFollowing | | 485 ? Node::kDocumentPositionFollowing | |
| 486 Node::kDocumentPositionContainedBy | 486 Node::kDocumentPositionContainedBy |
| 487 : Node::kDocumentPositionPreceding | | 487 : Node::kDocumentPositionPreceding | |
| 488 Node::kDocumentPositionContains; | 488 Node::kDocumentPositionContains; |
| 489 } | 489 } |
| 490 | 490 |
| 491 const TreeScope* TreeScope::commonAncestorTreeScope( | 491 const TreeScope* TreeScope::commonAncestorTreeScope( |
| 492 const TreeScope& other) const { | 492 const TreeScope& other) const { |
| 493 HeapVector<Member<const TreeScope>, 16> thisChain; | 493 HeapVector<Member<const TreeScope>, 16> thisChain; |
| 494 for (const TreeScope* tree = this; tree; tree = tree->parentTreeScope()) | 494 for (const TreeScope* tree = this; tree; tree = tree->parentTreeScope()) |
| 495 thisChain.append(tree); | 495 thisChain.push_back(tree); |
| 496 | 496 |
| 497 HeapVector<Member<const TreeScope>, 16> otherChain; | 497 HeapVector<Member<const TreeScope>, 16> otherChain; |
| 498 for (const TreeScope* tree = &other; tree; tree = tree->parentTreeScope()) | 498 for (const TreeScope* tree = &other; tree; tree = tree->parentTreeScope()) |
| 499 otherChain.append(tree); | 499 otherChain.push_back(tree); |
| 500 | 500 |
| 501 // Keep popping out the last elements of these chains until a mismatched pair | 501 // Keep popping out the last elements of these chains until a mismatched pair |
| 502 // is found. If |this| and |other| belong to different documents, null will be | 502 // is found. If |this| and |other| belong to different documents, null will be |
| 503 // returned. | 503 // returned. |
| 504 const TreeScope* lastAncestor = nullptr; | 504 const TreeScope* lastAncestor = nullptr; |
| 505 while (!thisChain.isEmpty() && !otherChain.isEmpty() && | 505 while (!thisChain.isEmpty() && !otherChain.isEmpty() && |
| 506 thisChain.back() == otherChain.back()) { | 506 thisChain.back() == otherChain.back()) { |
| 507 lastAncestor = thisChain.back(); | 507 lastAncestor = thisChain.back(); |
| 508 thisChain.pop_back(); | 508 thisChain.pop_back(); |
| 509 otherChain.pop_back(); | 509 otherChain.pop_back(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 visitor->trace(m_parentTreeScope); | 562 visitor->trace(m_parentTreeScope); |
| 563 visitor->trace(m_idTargetObserverRegistry); | 563 visitor->trace(m_idTargetObserverRegistry); |
| 564 visitor->trace(m_selection); | 564 visitor->trace(m_selection); |
| 565 visitor->trace(m_elementsById); | 565 visitor->trace(m_elementsById); |
| 566 visitor->trace(m_imageMapsByName); | 566 visitor->trace(m_imageMapsByName); |
| 567 visitor->trace(m_scopedStyleResolver); | 567 visitor->trace(m_scopedStyleResolver); |
| 568 visitor->trace(m_radioButtonGroupScope); | 568 visitor->trace(m_radioButtonGroupScope); |
| 569 } | 569 } |
| 570 | 570 |
| 571 } // namespace blink | 571 } // namespace blink |
| OLD | NEW |