Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2764783004: Add DocumentMarker::createTextMatchMarker() (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/markers/DocumentMarker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/InputMethodController.h" 5 #include "core/editing/InputMethodController.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/Range.h" 10 #include "core/dom/Range.h"
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 } 1515 }
1516 1516
1517 TEST_F(InputMethodControllerTest, 1517 TEST_F(InputMethodControllerTest,
1518 Marker_WhitespaceFixupAroundMarkerNotContainingSpace) { 1518 Marker_WhitespaceFixupAroundMarkerNotContainingSpace) {
1519 Element* div = insertHTMLElement( 1519 Element* div = insertHTMLElement(
1520 "<div id='sample' contenteditable>Initial text blah</div>", "sample"); 1520 "<div id='sample' contenteditable>Initial text blah</div>", "sample");
1521 1521
1522 // Add marker under "text" (use TextMatch since Composition markers don't 1522 // Add marker under "text" (use TextMatch since Composition markers don't
1523 // persist across editing operations) 1523 // persist across editing operations)
1524 EphemeralRange markerRange = PlainTextRange(8, 12).createRange(*div); 1524 EphemeralRange markerRange = PlainTextRange(8, 12).createRange(*div);
1525 document().markers().addMarker(markerRange.startPosition(), 1525 document().markers().addTextMatchMarker(markerRange, false);
1526 markerRange.endPosition(),
1527 DocumentMarker::TextMatch);
1528 // Delete "Initial" 1526 // Delete "Initial"
1529 Vector<CompositionUnderline> emptyUnderlines; 1527 Vector<CompositionUnderline> emptyUnderlines;
1530 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7); 1528 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
1531 controller().commitText(String(""), emptyUnderlines, 0); 1529 controller().commitText(String(""), emptyUnderlines, 0);
1532 1530
1533 // Delete "blah" 1531 // Delete "blah"
1534 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10); 1532 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10);
1535 controller().commitText(String(""), emptyUnderlines, 0); 1533 controller().commitText(String(""), emptyUnderlines, 0);
1536 1534
1537 // Check that the marker is still attached to "text" and doesn't include 1535 // Check that the marker is still attached to "text" and doesn't include
1538 // either space around it 1536 // either space around it
1539 EXPECT_EQ(1u, document().markers().markersFor(div->firstChild()).size()); 1537 EXPECT_EQ(1u, document().markers().markersFor(div->firstChild()).size());
1540 EXPECT_STREQ( 1538 EXPECT_STREQ(
1541 "text", 1539 "text",
1542 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1540 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1543 } 1541 }
1544 1542
1545 // TODO(rlanday): The behavior tested in the following DocumentMarker tests is 1543 // TODO(rlanday): The behavior tested in the following DocumentMarker tests is
1546 // going to be changed so markers are not split when text they contain is 1544 // going to be changed so markers are not split when text they contain is
1547 // deleted 1545 // deleted
1548 1546
1549 TEST_F(InputMethodControllerTest, 1547 TEST_F(InputMethodControllerTest,
1550 Marker_WhitespaceFixupAroundMarkerBeginningWithSpace) { 1548 Marker_WhitespaceFixupAroundMarkerBeginningWithSpace) {
1551 Element* div = insertHTMLElement( 1549 Element* div = insertHTMLElement(
1552 "<div id='sample' contenteditable>Initial text blah</div>", "sample"); 1550 "<div id='sample' contenteditable>Initial text blah</div>", "sample");
1553 1551
1554 // Add marker under " text" (use TextMatch since Composition markers don't 1552 // Add marker under " text" (use TextMatch since Composition markers don't
1555 // persist across editing operations) 1553 // persist across editing operations)
1556 EphemeralRange markerRange = PlainTextRange(7, 12).createRange(*div); 1554 EphemeralRange markerRange = PlainTextRange(7, 12).createRange(*div);
1557 document().markers().addMarker(markerRange.startPosition(), 1555 document().markers().addTextMatchMarker(markerRange, false);
1558 markerRange.endPosition(), 1556
1559 DocumentMarker::TextMatch);
1560 // Delete "Initial" 1557 // Delete "Initial"
1561 Vector<CompositionUnderline> emptyUnderlines; 1558 Vector<CompositionUnderline> emptyUnderlines;
1562 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7); 1559 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
1563 controller().commitText(String(""), emptyUnderlines, 0); 1560 controller().commitText(String(""), emptyUnderlines, 0);
1564 1561
1565 // Delete "blah" 1562 // Delete "blah"
1566 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10); 1563 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10);
1567 controller().commitText(String(""), emptyUnderlines, 0); 1564 controller().commitText(String(""), emptyUnderlines, 0);
1568 1565
1569 // Check that the marker is still attached to " text" and includes the space 1566 // Check that the marker is still attached to " text" and includes the space
1570 // before "text" but not the space after 1567 // before "text" but not the space after
1571 EXPECT_EQ(1u, document().markers().markers().size()); 1568 EXPECT_EQ(1u, document().markers().markers().size());
1572 ASSERT_STREQ( 1569 ASSERT_STREQ(
1573 "\xC2\xA0text", 1570 "\xC2\xA0text",
1574 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1571 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1575 } 1572 }
1576 1573
1577 TEST_F(InputMethodControllerTest, 1574 TEST_F(InputMethodControllerTest,
1578 Marker_WhitespaceFixupAroundMarkerEndingWithSpace) { 1575 Marker_WhitespaceFixupAroundMarkerEndingWithSpace) {
1579 Element* div = insertHTMLElement( 1576 Element* div = insertHTMLElement(
1580 "<div id='sample' contenteditable>Initial text blah</div>", "sample"); 1577 "<div id='sample' contenteditable>Initial text blah</div>", "sample");
1581 1578
1582 // Add marker under "text " (use TextMatch since Composition markers don't 1579 // Add marker under "text " (use TextMatch since Composition markers don't
1583 // persist across editing operations) 1580 // persist across editing operations)
1584 EphemeralRange markerRange = PlainTextRange(8, 13).createRange(*div); 1581 EphemeralRange markerRange = PlainTextRange(8, 13).createRange(*div);
1585 document().markers().addMarker(markerRange.startPosition(), 1582 document().markers().addTextMatchMarker(markerRange, false);
1586 markerRange.endPosition(), 1583
1587 DocumentMarker::TextMatch);
1588 // Delete "Initial" 1584 // Delete "Initial"
1589 Vector<CompositionUnderline> emptyUnderlines; 1585 Vector<CompositionUnderline> emptyUnderlines;
1590 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7); 1586 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
1591 controller().commitText(String(""), emptyUnderlines, 0); 1587 controller().commitText(String(""), emptyUnderlines, 0);
1592 1588
1593 // Delete "blah" 1589 // Delete "blah"
1594 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10); 1590 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10);
1595 controller().commitText(String(""), emptyUnderlines, 0); 1591 controller().commitText(String(""), emptyUnderlines, 0);
1596 1592
1597 // Check that the marker is still attached to "text " and includes the space 1593 // Check that the marker is still attached to "text " and includes the space
1598 // after "text" but not the space before 1594 // after "text" but not the space before
1599 EXPECT_EQ(1u, document().markers().markers().size()); 1595 EXPECT_EQ(1u, document().markers().markers().size());
1600 ASSERT_STREQ( 1596 ASSERT_STREQ(
1601 "text\xC2\xA0", 1597 "text\xC2\xA0",
1602 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1598 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1603 } 1599 }
1604 1600
1605 TEST_F(InputMethodControllerTest, 1601 TEST_F(InputMethodControllerTest,
1606 Marker_WhitespaceFixupAroundMarkerBeginningAndEndingWithSpaces) { 1602 Marker_WhitespaceFixupAroundMarkerBeginningAndEndingWithSpaces) {
1607 Element* div = insertHTMLElement( 1603 Element* div = insertHTMLElement(
1608 "<div id='sample' contenteditable>Initial text blah</div>", "sample"); 1604 "<div id='sample' contenteditable>Initial text blah</div>", "sample");
1609 1605
1610 // Add marker under " text " (use TextMatch since Composition markers don't 1606 // Add marker under " text " (use TextMatch since Composition markers don't
1611 // persist across editing operations) 1607 // persist across editing operations)
1612 EphemeralRange markerRange = PlainTextRange(7, 13).createRange(*div); 1608 EphemeralRange markerRange = PlainTextRange(7, 13).createRange(*div);
1613 document().markers().addMarker(markerRange.startPosition(), 1609 document().markers().addTextMatchMarker(markerRange, false);
1614 markerRange.endPosition(),
1615 DocumentMarker::TextMatch);
1616 1610
1617 // Delete "Initial" 1611 // Delete "Initial"
1618 Vector<CompositionUnderline> emptyUnderlines; 1612 Vector<CompositionUnderline> emptyUnderlines;
1619 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7); 1613 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
1620 controller().commitText(String(""), emptyUnderlines, 0); 1614 controller().commitText(String(""), emptyUnderlines, 0);
1621 1615
1622 // Delete "blah" 1616 // Delete "blah"
1623 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10); 1617 controller().setCompositionFromExistingText(emptyUnderlines, 6, 10);
1624 controller().commitText(String(""), emptyUnderlines, 0); 1618 controller().commitText(String(""), emptyUnderlines, 0);
1625 1619
1626 // Check that the marker is still attached to " text " and includes both the 1620 // Check that the marker is still attached to " text " and includes both the
1627 // space before "text" and the space after 1621 // space before "text" and the space after
1628 EXPECT_EQ(1u, document().markers().markers().size()); 1622 EXPECT_EQ(1u, document().markers().markers().size());
1629 ASSERT_STREQ( 1623 ASSERT_STREQ(
1630 "\xC2\xA0text\xC2\xA0", 1624 "\xC2\xA0text\xC2\xA0",
1631 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1625 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1632 } 1626 }
1633 1627
1634 TEST_F(InputMethodControllerTest, Marker_ReplaceStartOfMarker) { 1628 TEST_F(InputMethodControllerTest, Marker_ReplaceStartOfMarker) {
1635 Element* div = insertHTMLElement( 1629 Element* div = insertHTMLElement(
1636 "<div id='sample' contenteditable>Initial text</div>", "sample"); 1630 "<div id='sample' contenteditable>Initial text</div>", "sample");
1637 1631
1638 // Add marker under "Initial text" 1632 // Add marker under "Initial text"
1639 EphemeralRange markerRange = PlainTextRange(0, 12).createRange(*div); 1633 EphemeralRange markerRange = PlainTextRange(0, 12).createRange(*div);
1640 document().markers().addMarker(markerRange.startPosition(), 1634 document().markers().addTextMatchMarker(markerRange, false);
1641 markerRange.endPosition(),
1642 DocumentMarker::TextMatch);
1643 1635
1644 // Replace "Initial" with "Original" 1636 // Replace "Initial" with "Original"
1645 Vector<CompositionUnderline> emptyUnderlines; 1637 Vector<CompositionUnderline> emptyUnderlines;
1646 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7); 1638 controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
1647 controller().commitText(String("Original"), emptyUnderlines, 0); 1639 controller().commitText(String("Original"), emptyUnderlines, 0);
1648 1640
1649 // Verify marker is under "Original text" 1641 // Verify marker is under "Original text"
1650 EXPECT_EQ(1u, document().markers().markers().size()); 1642 EXPECT_EQ(1u, document().markers().markers().size());
1651 ASSERT_STREQ( 1643 ASSERT_STREQ(
1652 "Original text", 1644 "Original text",
1653 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1645 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1654 } 1646 }
1655 1647
1656 TEST_F(InputMethodControllerTest, Marker_ReplaceTextContainsStartOfMarker) { 1648 TEST_F(InputMethodControllerTest, Marker_ReplaceTextContainsStartOfMarker) {
1657 Element* div = insertHTMLElement( 1649 Element* div = insertHTMLElement(
1658 "<div id='sample' contenteditable>This is some initial text</div>", 1650 "<div id='sample' contenteditable>This is some initial text</div>",
1659 "sample"); 1651 "sample");
1660 1652
1661 // Add marker under "initial text" 1653 // Add marker under "initial text"
1662 EphemeralRange markerRange = PlainTextRange(13, 25).createRange(*div); 1654 EphemeralRange markerRange = PlainTextRange(13, 25).createRange(*div);
1663 document().markers().addMarker(markerRange.startPosition(), 1655 document().markers().addTextMatchMarker(markerRange, false);
1664 markerRange.endPosition(),
1665 DocumentMarker::TextMatch);
1666 1656
1667 // Replace "some initial" with "boring" 1657 // Replace "some initial" with "boring"
1668 Vector<CompositionUnderline> emptyUnderlines; 1658 Vector<CompositionUnderline> emptyUnderlines;
1669 controller().setCompositionFromExistingText(emptyUnderlines, 8, 20); 1659 controller().setCompositionFromExistingText(emptyUnderlines, 8, 20);
1670 controller().commitText(String("boring"), emptyUnderlines, 0); 1660 controller().commitText(String("boring"), emptyUnderlines, 0);
1671 1661
1672 // Verify marker is under " text" 1662 // Verify marker is under " text"
1673 EXPECT_EQ(1u, document().markers().markers().size()); 1663 EXPECT_EQ(1u, document().markers().markers().size());
1674 EXPECT_STREQ( 1664 EXPECT_STREQ(
1675 " text", 1665 " text",
1676 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1666 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1677 } 1667 }
1678 1668
1679 TEST_F(InputMethodControllerTest, Marker_ReplaceEndOfMarker) { 1669 TEST_F(InputMethodControllerTest, Marker_ReplaceEndOfMarker) {
1680 Element* div = insertHTMLElement( 1670 Element* div = insertHTMLElement(
1681 "<div id='sample' contenteditable>Initial text</div>", "sample"); 1671 "<div id='sample' contenteditable>Initial text</div>", "sample");
1682 1672
1683 // Add marker under "Initial text" 1673 // Add marker under "Initial text"
1684 EphemeralRange markerRange = PlainTextRange(0, 12).createRange(*div); 1674 EphemeralRange markerRange = PlainTextRange(0, 12).createRange(*div);
1685 document().markers().addMarker(markerRange.startPosition(), 1675 document().markers().addTextMatchMarker(markerRange, false);
1686 markerRange.endPosition(),
1687 DocumentMarker::TextMatch);
1688 1676
1689 // Replace "text" with "string" 1677 // Replace "text" with "string"
1690 Vector<CompositionUnderline> emptyUnderlines; 1678 Vector<CompositionUnderline> emptyUnderlines;
1691 controller().setCompositionFromExistingText(emptyUnderlines, 8, 12); 1679 controller().setCompositionFromExistingText(emptyUnderlines, 8, 12);
1692 controller().commitText(String("string"), emptyUnderlines, 0); 1680 controller().commitText(String("string"), emptyUnderlines, 0);
1693 1681
1694 // Verify marker is under "Initial string" 1682 // Verify marker is under "Initial string"
1695 EXPECT_EQ(1u, document().markers().markers().size()); 1683 EXPECT_EQ(1u, document().markers().markers().size());
1696 ASSERT_STREQ( 1684 ASSERT_STREQ(
1697 "Initial string", 1685 "Initial string",
1698 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1686 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1699 } 1687 }
1700 1688
1701 TEST_F(InputMethodControllerTest, Marker_ReplaceTextContainsEndOfMarker) { 1689 TEST_F(InputMethodControllerTest, Marker_ReplaceTextContainsEndOfMarker) {
1702 Element* div = insertHTMLElement( 1690 Element* div = insertHTMLElement(
1703 "<div id='sample' contenteditable>This is some initial text</div>", 1691 "<div id='sample' contenteditable>This is some initial text</div>",
1704 "sample"); 1692 "sample");
1705 1693
1706 // Add marker under "some initial" 1694 // Add marker under "some initial"
1707 EphemeralRange markerRange = PlainTextRange(8, 20).createRange(*div); 1695 EphemeralRange markerRange = PlainTextRange(8, 20).createRange(*div);
1708 document().markers().addMarker(markerRange.startPosition(), 1696 document().markers().addTextMatchMarker(markerRange, false);
1709 markerRange.endPosition(),
1710 DocumentMarker::TextMatch);
1711 1697
1712 // Replace "initial text" with "content" 1698 // Replace "initial text" with "content"
1713 Vector<CompositionUnderline> emptyUnderlines; 1699 Vector<CompositionUnderline> emptyUnderlines;
1714 controller().setCompositionFromExistingText(emptyUnderlines, 13, 25); 1700 controller().setCompositionFromExistingText(emptyUnderlines, 13, 25);
1715 controller().commitText(String("content"), emptyUnderlines, 0); 1701 controller().commitText(String("content"), emptyUnderlines, 0);
1716 1702
1717 EXPECT_STREQ("This is some content", div->innerHTML().utf8().data()); 1703 EXPECT_STREQ("This is some content", div->innerHTML().utf8().data());
1718 1704
1719 // Verify marker is under "some " 1705 // Verify marker is under "some "
1720 EXPECT_EQ(1u, document().markers().markers().size()); 1706 EXPECT_EQ(1u, document().markers().markers().size());
1721 EXPECT_STREQ( 1707 EXPECT_STREQ(
1722 "some ", 1708 "some ",
1723 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1709 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1724 } 1710 }
1725 1711
1726 TEST_F(InputMethodControllerTest, Marker_ReplaceEntireMarker) { 1712 TEST_F(InputMethodControllerTest, Marker_ReplaceEntireMarker) {
1727 Element* div = insertHTMLElement( 1713 Element* div = insertHTMLElement(
1728 "<div id='sample' contenteditable>Initial text</div>", "sample"); 1714 "<div id='sample' contenteditable>Initial text</div>", "sample");
1729 1715
1730 // Add marker under "text" 1716 // Add marker under "text"
1731 EphemeralRange markerRange = PlainTextRange(8, 12).createRange(*div); 1717 EphemeralRange markerRange = PlainTextRange(8, 12).createRange(*div);
1732 document().markers().addMarker(markerRange.startPosition(), 1718 document().markers().addTextMatchMarker(markerRange, false);
1733 markerRange.endPosition(),
1734 DocumentMarker::TextMatch);
1735 1719
1736 // Replace "text" with "string" 1720 // Replace "text" with "string"
1737 Vector<CompositionUnderline> emptyUnderlines; 1721 Vector<CompositionUnderline> emptyUnderlines;
1738 controller().setCompositionFromExistingText(emptyUnderlines, 8, 12); 1722 controller().setCompositionFromExistingText(emptyUnderlines, 8, 12);
1739 controller().commitText(String("string"), emptyUnderlines, 0); 1723 controller().commitText(String("string"), emptyUnderlines, 0);
1740 1724
1741 // Verify marker is under "string" 1725 // Verify marker is under "string"
1742 EXPECT_EQ(1u, document().markers().markers().size()); 1726 EXPECT_EQ(1u, document().markers().markers().size());
1743 ASSERT_STREQ( 1727 ASSERT_STREQ(
1744 "string", 1728 "string",
1745 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data()); 1729 getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
1746 } 1730 }
1747 1731
1748 TEST_F(InputMethodControllerTest, Marker_ReplaceTextWithMarkerAtBeginning) { 1732 TEST_F(InputMethodControllerTest, Marker_ReplaceTextWithMarkerAtBeginning) {
1749 Element* div = insertHTMLElement( 1733 Element* div = insertHTMLElement(
1750 "<div id='sample' contenteditable>Initial text</div>", "sample"); 1734 "<div id='sample' contenteditable>Initial text</div>", "sample");
1751 1735
1752 // Add marker under "Initial" 1736 // Add marker under "Initial"
1753 EphemeralRange markerRange = PlainTextRange(0, 7).createRange(*div); 1737 EphemeralRange markerRange = PlainTextRange(0, 7).createRange(*div);
1754 document().markers().addMarker(markerRange.startPosition(), 1738 document().markers().addTextMatchMarker(markerRange, false);
1755 markerRange.endPosition(),
1756 DocumentMarker::TextMatch);
1757 1739
1758 EXPECT_EQ(1u, document().markers().markers().size()); 1740 EXPECT_EQ(1u, document().markers().markers().size());
1759 1741
1760 // Replace "Initial text" with "New string" 1742 // Replace "Initial text" with "New string"
1761 Vector<CompositionUnderline> emptyUnderlines; 1743 Vector<CompositionUnderline> emptyUnderlines;
1762 controller().setCompositionFromExistingText(emptyUnderlines, 0, 12); 1744 controller().setCompositionFromExistingText(emptyUnderlines, 0, 12);
1763 controller().commitText(String("New string"), emptyUnderlines, 0); 1745 controller().commitText(String("New string"), emptyUnderlines, 0);
1764 1746
1765 // Verify marker was removed 1747 // Verify marker was removed
1766 EXPECT_EQ(0u, document().markers().markers().size()); 1748 EXPECT_EQ(0u, document().markers().markers().size());
1767 } 1749 }
1768 1750
1769 TEST_F(InputMethodControllerTest, Marker_ReplaceTextWithMarkerAtEnd) { 1751 TEST_F(InputMethodControllerTest, Marker_ReplaceTextWithMarkerAtEnd) {
1770 Element* div = insertHTMLElement( 1752 Element* div = insertHTMLElement(
1771 "<div id='sample' contenteditable>Initial text</div>", "sample"); 1753 "<div id='sample' contenteditable>Initial text</div>", "sample");
1772 1754
1773 // Add marker under "text" 1755 // Add marker under "text"
1774 EphemeralRange markerRange = PlainTextRange(8, 12).createRange(*div); 1756 EphemeralRange markerRange = PlainTextRange(8, 12).createRange(*div);
1775 document().markers().addMarker(markerRange.startPosition(), 1757 document().markers().addTextMatchMarker(markerRange, false);
1776 markerRange.endPosition(),
1777 DocumentMarker::TextMatch);
1778 1758
1779 EXPECT_EQ(1u, document().markers().markers().size()); 1759 EXPECT_EQ(1u, document().markers().markers().size());
1780 1760
1781 // Replace "Initial text" with "New string" 1761 // Replace "Initial text" with "New string"
1782 Vector<CompositionUnderline> emptyUnderlines; 1762 Vector<CompositionUnderline> emptyUnderlines;
1783 controller().setCompositionFromExistingText(emptyUnderlines, 0, 12); 1763 controller().setCompositionFromExistingText(emptyUnderlines, 0, 12);
1784 controller().commitText(String("New string"), emptyUnderlines, 0); 1764 controller().commitText(String("New string"), emptyUnderlines, 0);
1785 1765
1786 // Verify marker was removed 1766 // Verify marker was removed
1787 EXPECT_EQ(0u, document().markers().markers().size()); 1767 EXPECT_EQ(0u, document().markers().markers().size());
1788 } 1768 }
1789 1769
1790 } // namespace blink 1770 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/markers/DocumentMarker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698