| 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 adjustedTarget = ancestor; | 400 adjustedTarget = ancestor; |
| 401 if (this == ancestor->treeScope()) | 401 if (this == ancestor->treeScope()) |
| 402 return const_cast<Element*>(adjustedTarget); | 402 return const_cast<Element*>(adjustedTarget); |
| 403 } | 403 } |
| 404 return nullptr; | 404 return nullptr; |
| 405 } | 405 } |
| 406 | 406 |
| 407 unsigned short TreeScope::comparePosition(const TreeScope& otherScope) const | 407 unsigned short TreeScope::comparePosition(const TreeScope& otherScope) const |
| 408 { | 408 { |
| 409 if (otherScope == this) | 409 if (otherScope == this) |
| 410 return Node::DOCUMENT_POSITION_EQUIVALENT; | 410 return Node::kDocumentPositionEquivalent; |
| 411 | 411 |
| 412 HeapVector<Member<const TreeScope>, 16> chain1; | 412 HeapVector<Member<const TreeScope>, 16> chain1; |
| 413 HeapVector<Member<const TreeScope>, 16> chain2; | 413 HeapVector<Member<const TreeScope>, 16> chain2; |
| 414 const TreeScope* current; | 414 const TreeScope* current; |
| 415 for (current = this; current; current = current->parentTreeScope()) | 415 for (current = this; current; current = current->parentTreeScope()) |
| 416 chain1.append(current); | 416 chain1.append(current); |
| 417 for (current = &otherScope; current; current = current->parentTreeScope()) | 417 for (current = &otherScope; current; current = current->parentTreeScope()) |
| 418 chain2.append(current); | 418 chain2.append(current); |
| 419 | 419 |
| 420 unsigned index1 = chain1.size(); | 420 unsigned index1 = chain1.size(); |
| 421 unsigned index2 = chain2.size(); | 421 unsigned index2 = chain2.size(); |
| 422 if (chain1[index1 - 1] != chain2[index2 - 1]) | 422 if (chain1[index1 - 1] != chain2[index2 - 1]) |
| 423 return Node::DOCUMENT_POSITION_DISCONNECTED | Node::DOCUMENT_POSITION_IM
PLEMENTATION_SPECIFIC; | 423 return Node::kDocumentPositionDisconnected | Node::kDocumentPositionImpl
ementationSpecific; |
| 424 | 424 |
| 425 for (unsigned i = std::min(index1, index2); i; --i) { | 425 for (unsigned i = std::min(index1, index2); i; --i) { |
| 426 const TreeScope* child1 = chain1[--index1]; | 426 const TreeScope* child1 = chain1[--index1]; |
| 427 const TreeScope* child2 = chain2[--index2]; | 427 const TreeScope* child2 = chain2[--index2]; |
| 428 if (child1 != child2) { | 428 if (child1 != child2) { |
| 429 Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode(); | 429 Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode(); |
| 430 Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode(); | 430 Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode(); |
| 431 if (shadowHost1 != shadowHost2) | 431 if (shadowHost1 != shadowHost2) |
| 432 return shadowHost1->compareDocumentPosition(shadowHost2, Node::T
reatShadowTreesAsDisconnected); | 432 return shadowHost1->compareDocumentPosition(shadowHost2, Node::T
reatShadowTreesAsDisconnected); |
| 433 | 433 |
| 434 for (const ShadowRoot* child = toShadowRoot(child2->rootNode()).olde
rShadowRoot(); child; child = child->olderShadowRoot()) { | 434 for (const ShadowRoot* child = toShadowRoot(child2->rootNode()).olde
rShadowRoot(); child; child = child->olderShadowRoot()) { |
| 435 if (child == child1) | 435 if (child == child1) |
| 436 return Node::DOCUMENT_POSITION_FOLLOWING; | 436 return Node::kDocumentPositionFollowing; |
| 437 } | 437 } |
| 438 | 438 |
| 439 return Node::DOCUMENT_POSITION_PRECEDING; | 439 return Node::kDocumentPositionPreceding; |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 | 442 |
| 443 // There was no difference between the two parent chains, i.e., one was a su
bset of the other. The shorter | 443 // There was no difference between the two parent chains, i.e., one was a su
bset of the other. The shorter |
| 444 // chain is the ancestor. | 444 // chain is the ancestor. |
| 445 return index1 < index2 ? | 445 return index1 < index2 ? |
| 446 Node::DOCUMENT_POSITION_FOLLOWING | Node::DOCUMENT_POSITION_CONTAINED_BY
: | 446 Node::kDocumentPositionFollowing | Node::kDocumentPositionContainedBy : |
| 447 Node::DOCUMENT_POSITION_PRECEDING | Node::DOCUMENT_POSITION_CONTAINS; | 447 Node::kDocumentPositionPreceding | Node::kDocumentPositionContains; |
| 448 } | 448 } |
| 449 | 449 |
| 450 const TreeScope* TreeScope::commonAncestorTreeScope(const TreeScope& other) cons
t | 450 const TreeScope* TreeScope::commonAncestorTreeScope(const TreeScope& other) cons
t |
| 451 { | 451 { |
| 452 HeapVector<Member<const TreeScope>, 16> thisChain; | 452 HeapVector<Member<const TreeScope>, 16> thisChain; |
| 453 for (const TreeScope* tree = this; tree; tree = tree->parentTreeScope()) | 453 for (const TreeScope* tree = this; tree; tree = tree->parentTreeScope()) |
| 454 thisChain.append(tree); | 454 thisChain.append(tree); |
| 455 | 455 |
| 456 HeapVector<Member<const TreeScope>, 16> otherChain; | 456 HeapVector<Member<const TreeScope>, 16> otherChain; |
| 457 for (const TreeScope* tree = &other; tree; tree = tree->parentTreeScope()) | 457 for (const TreeScope* tree = &other; tree; tree = tree->parentTreeScope()) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 visitor->trace(m_parentTreeScope); | 517 visitor->trace(m_parentTreeScope); |
| 518 visitor->trace(m_idTargetObserverRegistry); | 518 visitor->trace(m_idTargetObserverRegistry); |
| 519 visitor->trace(m_selection); | 519 visitor->trace(m_selection); |
| 520 visitor->trace(m_elementsById); | 520 visitor->trace(m_elementsById); |
| 521 visitor->trace(m_imageMapsByName); | 521 visitor->trace(m_imageMapsByName); |
| 522 visitor->trace(m_scopedStyleResolver); | 522 visitor->trace(m_scopedStyleResolver); |
| 523 visitor->trace(m_radioButtonGroupScope); | 523 visitor->trace(m_radioButtonGroupScope); |
| 524 } | 524 } |
| 525 | 525 |
| 526 } // namespace blink | 526 } // namespace blink |
| OLD | NEW |