Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/editing/Position.h" | 26 #include "core/editing/Position.h" |
| 27 | 27 |
| 28 #include "core/dom/shadow/ElementShadow.h" | 28 #include "core/dom/shadow/ElementShadow.h" |
| 29 #include "core/editing/EditingUtilities.h" | 29 #include "core/editing/EditingUtilities.h" |
| 30 #include "core/editing/TextAffinity.h" | 30 #include "core/editing/TextAffinity.h" |
| 31 #include "wtf/text/CString.h" | 31 #include "wtf/text/CString.h" |
| 32 #include <stdio.h> | 32 #include <stdio.h> |
| 33 #include <ostream> // NOLINT | |
|
tkent
2016/03/31 07:59:58
please sort headers in the alphabetical order.
BT
yosin_UTC9
2016/03/31 08:31:27
Per discussion offline. We'll commit as is.
Here
| |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 #if ENABLE(ASSERT) | 37 #if ENABLE(ASSERT) |
| 37 static bool canBeAnchorNode(Node* node) | 38 static bool canBeAnchorNode(Node* node) |
| 38 { | 39 { |
| 39 return !node || !node->isPseudoElement(); | 40 return !node || !node->isPseudoElement(); |
| 40 } | 41 } |
| 41 #endif | 42 #endif |
| 42 | 43 |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 void PositionTemplate<Strategy>::showTreeForThisInFlatTree() const | 517 void PositionTemplate<Strategy>::showTreeForThisInFlatTree() const |
| 517 { | 518 { |
| 518 if (!anchorNode()) | 519 if (!anchorNode()) |
| 519 return; | 520 return; |
| 520 anchorNode()->showTreeForThisInFlatTree(); | 521 anchorNode()->showTreeForThisInFlatTree(); |
| 521 showAnchorTypeAndOffset(); | 522 showAnchorTypeAndOffset(); |
| 522 } | 523 } |
| 523 | 524 |
| 524 #endif | 525 #endif |
| 525 | 526 |
| 527 template <typename PositionType> | |
| 528 static std::ostream& printPosition(std::ostream& ostream, const PositionType& po sition) | |
| 529 { | |
| 530 if (position.isNull()) | |
| 531 return ostream << "null"; | |
| 532 ostream << position.anchorNode() << "@"; | |
| 533 if (position.isOffsetInAnchor()) | |
| 534 return ostream << position.offsetInContainerNode(); | |
| 535 return ostream << position.anchorType(); | |
| 536 } | |
| 537 | |
| 538 std::ostream& operator<<(std::ostream& ostream, PositionAnchorType anchorType) | |
| 539 { | |
| 540 switch (anchorType) { | |
| 541 case PositionAnchorType::AfterAnchor: | |
| 542 return ostream << "afterAnchor"; | |
| 543 case PositionAnchorType::AfterChildren: | |
| 544 return ostream << "afterChildren"; | |
| 545 case PositionAnchorType::BeforeAnchor: | |
| 546 return ostream << "beforeAnchor"; | |
| 547 case PositionAnchorType::BeforeChildren: | |
| 548 return ostream << "beforeChildren"; | |
| 549 case PositionAnchorType::OffsetInAnchor: | |
| 550 return ostream << "offsetInAnchor"; | |
| 551 } | |
| 552 NOTREACHED(); | |
| 553 return ostream << "anchorType=" << static_cast<int>(anchorType); | |
| 554 } | |
| 555 | |
| 556 std::ostream& operator<<(std::ostream& ostream, const Position& position) | |
| 557 { | |
| 558 return printPosition(ostream, position); | |
| 559 } | |
| 560 | |
| 561 std::ostream& operator<<(std::ostream& ostream, const PositionInFlatTree& positi on) | |
| 562 { | |
| 563 return printPosition(ostream, position); | |
| 564 } | |
| 565 | |
| 526 template class CORE_TEMPLATE_EXPORT PositionTemplate<EditingStrategy>; | 566 template class CORE_TEMPLATE_EXPORT PositionTemplate<EditingStrategy>; |
| 527 template class CORE_TEMPLATE_EXPORT PositionTemplate<EditingInFlatTreeStrategy>; | 567 template class CORE_TEMPLATE_EXPORT PositionTemplate<EditingInFlatTreeStrategy>; |
| 528 | 568 |
| 529 } // namespace blink | 569 } // namespace blink |
| 530 | 570 |
| 531 #ifndef NDEBUG | 571 #ifndef NDEBUG |
| 532 | 572 |
| 533 void showTree(const blink::Position& pos) | 573 void showTree(const blink::Position& pos) |
| 534 { | 574 { |
| 535 pos.showTreeForThis(); | 575 pos.showTreeForThis(); |
| 536 } | 576 } |
| 537 | 577 |
| 538 void showTree(const blink::Position* pos) | 578 void showTree(const blink::Position* pos) |
| 539 { | 579 { |
| 540 if (pos) | 580 if (pos) |
| 541 pos->showTreeForThis(); | 581 pos->showTreeForThis(); |
| 542 else | 582 else |
| 543 fprintf(stderr, "Cannot showTree for (nil)\n"); | 583 fprintf(stderr, "Cannot showTree for (nil)\n"); |
| 544 } | 584 } |
| 545 | 585 |
| 546 #endif | 586 #endif |
| OLD | NEW |