| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/editing/EditingUtilities.h" | 5 #include "core/editing/EditingUtilities.h" |
| 6 | 6 |
| 7 #include "core/dom/StaticNodeList.h" | 7 #include "core/dom/StaticNodeList.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 EXPECT_EQ(0, previousGraphemeBoundaryOf(node, 3)); | 543 EXPECT_EQ(0, previousGraphemeBoundaryOf(node, 3)); |
| 544 EXPECT_EQ(3, nextGraphemeBoundaryOf(node, 0)); | 544 EXPECT_EQ(3, nextGraphemeBoundaryOf(node, 0)); |
| 545 EXPECT_EQ(4, nextGraphemeBoundaryOf(node, 3)); | 545 EXPECT_EQ(4, nextGraphemeBoundaryOf(node, 3)); |
| 546 setBodyContent("<p id='target'>a‍👦b</p>"); // ZWJ x EBG | 546 setBodyContent("<p id='target'>a‍👦b</p>"); // ZWJ x EBG |
| 547 node = document().getElementById("target")->firstChild(); | 547 node = document().getElementById("target")->firstChild(); |
| 548 EXPECT_EQ(4, previousGraphemeBoundaryOf(node, 5)); | 548 EXPECT_EQ(4, previousGraphemeBoundaryOf(node, 5)); |
| 549 EXPECT_EQ(0, previousGraphemeBoundaryOf(node, 4)); | 549 EXPECT_EQ(0, previousGraphemeBoundaryOf(node, 4)); |
| 550 EXPECT_EQ(4, nextGraphemeBoundaryOf(node, 0)); | 550 EXPECT_EQ(4, nextGraphemeBoundaryOf(node, 0)); |
| 551 EXPECT_EQ(5, nextGraphemeBoundaryOf(node, 4)); | 551 EXPECT_EQ(5, nextGraphemeBoundaryOf(node, 4)); |
| 552 | 552 |
| 553 // Not only Glue_After_ZWJ or EBG but also other emoji shouldn't break |
| 554 // before ZWJ. |
| 555 // U+1F5FA(WORLD MAP) doesn't have either Glue_After_Zwj or EBG but has |
| 556 // Emoji property. |
| 557 setBodyContent("<p id='target'>‍🗺</p>"); |
| 558 node = document().getElementById("target")->firstChild(); |
| 559 EXPECT_EQ(0, previousGraphemeBoundaryOf(node, 3)); |
| 560 EXPECT_EQ(3, nextGraphemeBoundaryOf(node, 0)); |
| 561 |
| 553 // GB999: Otherwise break everywhere. | 562 // GB999: Otherwise break everywhere. |
| 554 // Breaks between Hangul syllable except for GB6, GB7, GB8. | 563 // Breaks between Hangul syllable except for GB6, GB7, GB8. |
| 555 setBodyContent("<p id='target'>" + L + T + "</p>"); | 564 setBodyContent("<p id='target'>" + L + T + "</p>"); |
| 556 node = document().getElementById("target")->firstChild(); | 565 node = document().getElementById("target")->firstChild(); |
| 557 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 2)); | 566 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 2)); |
| 558 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); | 567 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); |
| 559 setBodyContent("<p id='target'>" + V + L + "</p>"); | 568 setBodyContent("<p id='target'>" + V + L + "</p>"); |
| 560 node = document().getElementById("target")->firstChild(); | 569 node = document().getElementById("target")->firstChild(); |
| 561 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 2)); | 570 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 2)); |
| 562 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); | 571 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 3)); | 628 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 3)); |
| 620 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); | 629 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); |
| 621 // U+1F5FA(WORLD MAP) doesn't have either E_Base or EBG property. | 630 // U+1F5FA(WORLD MAP) doesn't have either E_Base or EBG property. |
| 622 setBodyContent("<p id='target'>🗺🏻</p>"); | 631 setBodyContent("<p id='target'>🗺🏻</p>"); |
| 623 node = document().getElementById("target")->firstChild(); | 632 node = document().getElementById("target")->firstChild(); |
| 624 EXPECT_EQ(2, previousGraphemeBoundaryOf(node, 4)); | 633 EXPECT_EQ(2, previousGraphemeBoundaryOf(node, 4)); |
| 625 EXPECT_EQ(2, nextGraphemeBoundaryOf(node, 0)); | 634 EXPECT_EQ(2, nextGraphemeBoundaryOf(node, 0)); |
| 626 | 635 |
| 627 // For GB11, if trailing character is not Glue_After_Zwj or EBG, break happe
ns after ZWJ. | 636 // For GB11, if trailing character is not Glue_After_Zwj or EBG, break happe
ns after ZWJ. |
| 628 // U+1F5FA(WORLD MAP) doesn't have either Glue_After_Zwj or EBG. | 637 // U+1F5FA(WORLD MAP) doesn't have either Glue_After_Zwj or EBG. |
| 629 setBodyContent("<p id='target'>‍🗺</p>"); | 638 setBodyContent("<p id='target'>‍a</p>"); |
| 630 node = document().getElementById("target")->firstChild(); | 639 node = document().getElementById("target")->firstChild(); |
| 631 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 3)); | 640 EXPECT_EQ(1, previousGraphemeBoundaryOf(node, 2)); |
| 632 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); | 641 EXPECT_EQ(1, nextGraphemeBoundaryOf(node, 0)); |
| 633 } | 642 } |
| 634 | 643 |
| 635 TEST_F(EditingUtilitiesTest, previousPositionOf_Backspace) | 644 TEST_F(EditingUtilitiesTest, previousPositionOf_Backspace) |
| 636 { | 645 { |
| 637 // BMP characters. Only one code point should be deleted. | 646 // BMP characters. Only one code point should be deleted. |
| 638 setBodyContent("<p id='target'>abc</p>"); | 647 setBodyContent("<p id='target'>abc</p>"); |
| 639 Node* node = document().getElementById("target")->firstChild(); | 648 Node* node = document().getElementById("target")->firstChild(); |
| 640 EXPECT_EQ(Position(node, 2), previousPositionOf(Position(node, 3), PositionM
oveType::BackwardDeletion)); | 649 EXPECT_EQ(Position(node, 2), previousPositionOf(Position(node, 3), PositionM
oveType::BackwardDeletion)); |
| 641 EXPECT_EQ(Position(node, 1), previousPositionOf(Position(node, 2), PositionM
oveType::BackwardDeletion)); | 650 EXPECT_EQ(Position(node, 1), previousPositionOf(Position(node, 2), PositionM
oveType::BackwardDeletion)); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 | 733 |
| 725 // Edge case: specify middle of surrogate pairs. | 734 // Edge case: specify middle of surrogate pairs. |
| 726 setBodyContent("<p id='target'>👁👁👁</p>"); | 735 setBodyContent("<p id='target'>👁👁👁</p>"); |
| 727 node = document().getElementById("target")->firstChild(); | 736 node = document().getElementById("target")->firstChild(); |
| 728 EXPECT_EQ(Position(node, 4), previousPositionOf(Position(node, 5), PositionM
oveType::BackwardDeletion)); | 737 EXPECT_EQ(Position(node, 4), previousPositionOf(Position(node, 5), PositionM
oveType::BackwardDeletion)); |
| 729 EXPECT_EQ(Position(node, 2), previousPositionOf(Position(node, 3), PositionM
oveType::BackwardDeletion)); | 738 EXPECT_EQ(Position(node, 2), previousPositionOf(Position(node, 3), PositionM
oveType::BackwardDeletion)); |
| 730 EXPECT_EQ(Position(node, 0), previousPositionOf(Position(node, 1), PositionM
oveType::BackwardDeletion)); | 739 EXPECT_EQ(Position(node, 0), previousPositionOf(Position(node, 1), PositionM
oveType::BackwardDeletion)); |
| 731 } | 740 } |
| 732 | 741 |
| 733 } // namespace blink | 742 } // namespace blink |
| OLD | NEW |