Commit fbb37ade authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Add overloaded GetSelectionTextFromBody() to simplify code.

This change adds an overloaded GetSelectionTextFromBody() function in
EditingTestBase. It returns text of Selection().GetSelectionInDOMTree().
This can simplify the test code and improve code health.
Signed-off-by: default avatarZhuoyu Qian <zhuoyu.qian@samsung.com>
Change-Id: I5548e4f168176a0e9921d2c4798fdf9126661b75
Reviewed-on: https://chromium-review.googlesource.com/1000655Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549135}
parent 18fb38eb
...@@ -121,7 +121,7 @@ TEST_F(ApplyBlockElementCommandTest, InsertPlaceHolderAtDisconnectedPosition) { ...@@ -121,7 +121,7 @@ TEST_F(ApplyBlockElementCommandTest, InsertPlaceHolderAtDisconnectedPosition) {
EXPECT_FALSE(command->Apply()); EXPECT_FALSE(command->Apply());
EXPECT_EQ( EXPECT_EQ(
"<pre>|<input></pre><input class=\"input\" style=\"position:absolute\">", "<pre>|<input></pre><input class=\"input\" style=\"position:absolute\">",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
} // namespace blink } // namespace blink
...@@ -93,6 +93,6 @@ TEST_F(ApplyStyleCommandTest, FontSizeDeltaWithSpanElement) { ...@@ -93,6 +93,6 @@ TEST_F(ApplyStyleCommandTest, FontSizeDeltaWithSpanElement) {
InputEvent::InputType::kNone) InputEvent::InputType::kNone)
->Apply(); ->Apply();
EXPECT_EQ("<div contenteditable><div></div><span>^a|</span></div>", EXPECT_EQ("<div contenteditable><div></div><span>^a|</span></div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
} // namespace blink } // namespace blink
...@@ -72,8 +72,7 @@ TEST_F(DeleteSelectionCommandTest, ForwardDeleteWithFirstLetter) { ...@@ -72,8 +72,7 @@ TEST_F(DeleteSelectionCommandTest, ForwardDeleteWithFirstLetter) {
.SetSanitizeMarkup(true) .SetSanitizeMarkup(true)
.Build()); .Build());
EXPECT_TRUE(command.Apply()) << "the delete command should have succeeded"; EXPECT_TRUE(command.Apply()) << "the delete command should have succeeded";
EXPECT_EQ("<p contenteditable>a|c</p>", EXPECT_EQ("<p contenteditable>a|c</p>", GetSelectionTextFromBody());
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree()));
} }
} // namespace blink } // namespace blink
...@@ -65,7 +65,7 @@ TEST_F(InsertListCommandTest, UnlistifyParagraphCrashOnVisuallyEmptyParagraph) { ...@@ -65,7 +65,7 @@ TEST_F(InsertListCommandTest, UnlistifyParagraphCrashOnVisuallyEmptyParagraph) {
"<dl><ul>" "<dl><ul>"
"|<textarea style=\"float:left;\"></textarea>" "|<textarea style=\"float:left;\"></textarea>"
"</ul></dl>", "</ul></dl>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// Refer https://crbug.com/798176 // Refer https://crbug.com/798176
...@@ -91,7 +91,7 @@ TEST_F(InsertListCommandTest, CleanupNodeSameAsDestinationNode) { ...@@ -91,7 +91,7 @@ TEST_F(InsertListCommandTest, CleanupNodeSameAsDestinationNode) {
"<ul><li><br></li></ul>" "<ul><li><br></li></ul>"
"</col></colgroup></table>" "</col></colgroup></table>"
"<button></button>", "<button></button>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
TEST_F(InsertListCommandTest, InsertListOnEmptyHiddenElements) { TEST_F(InsertListCommandTest, InsertListOnEmptyHiddenElements) {
...@@ -108,7 +108,7 @@ TEST_F(InsertListCommandTest, InsertListOnEmptyHiddenElements) { ...@@ -108,7 +108,7 @@ TEST_F(InsertListCommandTest, InsertListOnEmptyHiddenElements) {
"<button>" "<button>"
"|<ul><li><br></li></ul>" "|<ul><li><br></li></ul>"
"</button>", "</button>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// Refer https://crbug.com/797520 // Refer https://crbug.com/797520
...@@ -128,6 +128,6 @@ TEST_F(InsertListCommandTest, InsertListWithCollapsedVisibility) { ...@@ -128,6 +128,6 @@ TEST_F(InsertListCommandTest, InsertListWithCollapsedVisibility) {
"<dl>" "<dl>"
"<ol></ol><ul>^a|</ul>" "<ol></ol><ul>^a|</ul>"
"</dl>", "</dl>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
} }
...@@ -29,7 +29,7 @@ TEST_F(InsertParagraphSeparatorCommandTest, ...@@ -29,7 +29,7 @@ TEST_F(InsertParagraphSeparatorCommandTest,
"<table contenteditable>" "<table contenteditable>"
" <colgroup style=\"-webkit-appearance:radio;\">|<br></colgroup>" " <colgroup style=\"-webkit-appearance:radio;\">|<br></colgroup>"
"</table>", "</table>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// http://crbug.com/777378 // http://crbug.com/777378
...@@ -52,7 +52,7 @@ TEST_F(InsertParagraphSeparatorCommandTest, ...@@ -52,7 +52,7 @@ TEST_F(InsertParagraphSeparatorCommandTest,
" <col>" " <col>"
" </colgroup>" " </colgroup>"
"</table>", "</table>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
} // namespace blink } // namespace blink
...@@ -39,7 +39,7 @@ TEST_F(InsertTextCommandTest, InsertChar) { ...@@ -39,7 +39,7 @@ TEST_F(InsertTextCommandTest, InsertChar) {
SetSelectionTextToBody("<p contenteditable><span>\ta|c</span></p>")); SetSelectionTextToBody("<p contenteditable><span>\ta|c</span></p>"));
GetDocument().execCommand("insertText", false, "B", ASSERT_NO_EXCEPTION); GetDocument().execCommand("insertText", false, "B", ASSERT_NO_EXCEPTION);
EXPECT_EQ("<p contenteditable><span>\taB|c</span></p>", EXPECT_EQ("<p contenteditable><span>\taB|c</span></p>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())) GetSelectionTextFromBody())
<< "We should not split Text node"; << "We should not split Text node";
} }
...@@ -54,7 +54,7 @@ TEST_F(InsertTextCommandTest, InsertCharToWhiteSpacePre) { ...@@ -54,7 +54,7 @@ TEST_F(InsertTextCommandTest, InsertCharToWhiteSpacePre) {
"B|" "B|"
"<span style=\"white-space:pre\">c</span>" "<span style=\"white-space:pre\">c</span>"
"</p>", "</p>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())) GetSelectionTextFromBody())
<< "This is a just record current behavior. We should not split SPAN."; << "This is a just record current behavior. We should not split SPAN.";
} }
...@@ -64,7 +64,7 @@ TEST_F(InsertTextCommandTest, InsertSpace) { ...@@ -64,7 +64,7 @@ TEST_F(InsertTextCommandTest, InsertSpace) {
SetSelectionTextToBody("<p contenteditable><span>\ta|c</span></p>")); SetSelectionTextToBody("<p contenteditable><span>\ta|c</span></p>"));
GetDocument().execCommand("insertText", false, " ", ASSERT_NO_EXCEPTION); GetDocument().execCommand("insertText", false, " ", ASSERT_NO_EXCEPTION);
EXPECT_EQ("<p contenteditable><span>\ta\xC2\xA0 |c</span></p>", EXPECT_EQ("<p contenteditable><span>\ta\xC2\xA0 |c</span></p>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())) GetSelectionTextFromBody())
<< "We should insert U+0020 without splitting SPAN"; << "We should insert U+0020 without splitting SPAN";
} }
...@@ -78,7 +78,7 @@ TEST_F(InsertTextCommandTest, InsertSpaceToWhiteSpacePre) { ...@@ -78,7 +78,7 @@ TEST_F(InsertTextCommandTest, InsertSpaceToWhiteSpacePre) {
"<span style=\"white-space:pre\">\ta</span>" "<span style=\"white-space:pre\">\ta</span>"
"\xC2\xA0\xC2\xA0|" "\xC2\xA0\xC2\xA0|"
"<span style=\"white-space:pre\">c</span></p>", "<span style=\"white-space:pre\">c</span></p>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())) GetSelectionTextFromBody())
<< "We should insert U+0020 without splitting SPAN"; << "We should insert U+0020 without splitting SPAN";
} }
...@@ -91,7 +91,7 @@ TEST_F(InsertTextCommandTest, InsertTab) { ...@@ -91,7 +91,7 @@ TEST_F(InsertTextCommandTest, InsertTab) {
"<p contenteditable>" "<p contenteditable>"
"<span>\ta<span style=\"white-space:pre\">\t|</span>c</span>" "<span>\ta<span style=\"white-space:pre\">\t|</span>c</span>"
"</p>", "</p>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// http://crbug.com/741826 // http://crbug.com/741826
...@@ -101,7 +101,7 @@ TEST_F(InsertTextCommandTest, InsertTabToWhiteSpacePre) { ...@@ -101,7 +101,7 @@ TEST_F(InsertTextCommandTest, InsertTabToWhiteSpacePre) {
GetDocument().execCommand("insertText", false, "\t", ASSERT_NO_EXCEPTION); GetDocument().execCommand("insertText", false, "\t", ASSERT_NO_EXCEPTION);
EXPECT_EQ( EXPECT_EQ(
"<p contenteditable><span style=\"white-space:pre\">\ta\t|c</span></p>", "<p contenteditable><span style=\"white-space:pre\">\ta\t|c</span></p>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// http://crbug.com/752860 // http://crbug.com/752860
...@@ -112,7 +112,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) { ...@@ -112,7 +112,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) {
// The space after "qux" should have been converted to a no-break space // The space after "qux" should have been converted to a no-break space
// (U+00A0) to prevent it from being collapsed. // (U+00A0) to prevent it from being collapsed.
EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>", EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable>qux^ bar|<p>baz</p>")); SetSelectionTextToBody("<div contenteditable>qux^ bar|<p>baz</p>"));
...@@ -120,7 +120,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) { ...@@ -120,7 +120,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) {
// The newly-inserted space should have been converted to a no-break space // The newly-inserted space should have been converted to a no-break space
// (U+00A0) to prevent it from being collapsed. // (U+00A0) to prevent it from being collapsed.
EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>", EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable>qux^bar| <p>baz</p>")); SetSelectionTextToBody("<div contenteditable>qux^bar| <p>baz</p>"));
...@@ -128,7 +128,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) { ...@@ -128,7 +128,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) {
// The space after "bar" was already being collapsed before the edit. It // The space after "bar" was already being collapsed before the edit. It
// should not have been converted to a no-break space. // should not have been converted to a no-break space.
EXPECT_EQ("<div contenteditable>qux|<p>baz</p></div>", EXPECT_EQ("<div contenteditable>qux|<p>baz</p></div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable>qux^bar |<p>baz</p>")); SetSelectionTextToBody("<div contenteditable>qux^bar |<p>baz</p>"));
...@@ -136,7 +136,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) { ...@@ -136,7 +136,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) {
// The newly-inserted space should have been converted to a no-break space // The newly-inserted space should have been converted to a no-break space
// (U+00A0) to prevent it from being collapsed. // (U+00A0) to prevent it from being collapsed.
EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>", EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable>qux\t^bar|<p>baz</p>")); SetSelectionTextToBody("<div contenteditable>qux\t^bar|<p>baz</p>"));
...@@ -144,7 +144,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) { ...@@ -144,7 +144,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupBeforeParagraph) {
// The tab should have been converted to a no-break space (U+00A0) to prevent // The tab should have been converted to a no-break space (U+00A0) to prevent
// it from being collapsed. // it from being collapsed.
EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>", EXPECT_EQ("<div contenteditable>qux\xC2\xA0|<p>baz</p></div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) { TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) {
...@@ -154,7 +154,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) { ...@@ -154,7 +154,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) {
// The space before "qux" should have been converted to a no-break space // The space before "qux" should have been converted to a no-break space
// (U+00A0) to prevent it from being collapsed. // (U+00A0) to prevent it from being collapsed.
EXPECT_EQ("<div contenteditable><p>baz</p>|\xC2\xA0qux</div>", EXPECT_EQ("<div contenteditable><p>baz</p>|\xC2\xA0qux</div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable><p>baz</p>^bar |qux")); SetSelectionTextToBody("<div contenteditable><p>baz</p>^bar |qux"));
...@@ -162,7 +162,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) { ...@@ -162,7 +162,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) {
// The newly-inserted space should have been converted to a no-break space // The newly-inserted space should have been converted to a no-break space
// (U+00A0) to prevent it from being collapsed. // (U+00A0) to prevent it from being collapsed.
EXPECT_EQ("<div contenteditable><p>baz</p>\xC2\xA0|qux</div>", EXPECT_EQ("<div contenteditable><p>baz</p>\xC2\xA0|qux</div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable><p>baz</p> ^bar|qux")); SetSelectionTextToBody("<div contenteditable><p>baz</p> ^bar|qux"));
...@@ -170,7 +170,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) { ...@@ -170,7 +170,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) {
// The space before "bar" was already being collapsed before the edit. It // The space before "bar" was already being collapsed before the edit. It
// should not have been converted to a no-break space. // should not have been converted to a no-break space.
EXPECT_EQ("<div contenteditable><p>baz</p>|qux</div>", EXPECT_EQ("<div contenteditable><p>baz</p>|qux</div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable><p>baz</p>^ bar|qux")); SetSelectionTextToBody("<div contenteditable><p>baz</p>^ bar|qux"));
...@@ -178,7 +178,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) { ...@@ -178,7 +178,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) {
// The newly-inserted space should have been converted to a no-break space // The newly-inserted space should have been converted to a no-break space
// (U+00A0) to prevent it from being collapsed. // (U+00A0) to prevent it from being collapsed.
EXPECT_EQ("<div contenteditable><p>baz</p>\xC2\xA0|qux</div>", EXPECT_EQ("<div contenteditable><p>baz</p>\xC2\xA0|qux</div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<div contenteditable><p>baz</p>^bar|\tqux")); SetSelectionTextToBody("<div contenteditable><p>baz</p>^bar|\tqux"));
...@@ -186,7 +186,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) { ...@@ -186,7 +186,7 @@ TEST_F(InsertTextCommandTest, WhitespaceFixupAfterParagraph) {
// The tab should have been converted to a no-break space (U+00A0) to prevent // The tab should have been converted to a no-break space (U+00A0) to prevent
// it from being collapsed. // it from being collapsed.
EXPECT_EQ("<div contenteditable><p>baz</p>|\xC2\xA0qux</div>", EXPECT_EQ("<div contenteditable><p>baz</p>|\xC2\xA0qux</div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// http://crbug.com/779376 // http://crbug.com/779376
...@@ -212,7 +212,7 @@ TEST_F(InsertTextCommandTest, NoVisibleSelectionAfterDeletingSelection) { ...@@ -212,7 +212,7 @@ TEST_F(InsertTextCommandTest, NoVisibleSelectionAfterDeletingSelection) {
" <navi></navi>" " <navi></navi>"
" ^</strike></ruby>" " ^</strike></ruby>"
"|</div>", "|</div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// http://crbug.com/778901 // http://crbug.com/778901
...@@ -277,7 +277,7 @@ TEST_F(InsertTextCommandTest, AnchorElementWithBlockCrash) { ...@@ -277,7 +277,7 @@ TEST_F(InsertTextCommandTest, AnchorElementWithBlockCrash) {
"<i style=\"display: block;\">" "<i style=\"display: block;\">"
"<a href=\"www\" style=\"display: block;\">a</a>" "<a href=\"www\" style=\"display: block;\">a</a>"
"</i>|", "</i>|",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
} // namespace blink } // namespace blink
...@@ -171,8 +171,7 @@ TEST_F(ReplaceSelectionCommandTest, TrailingNonVisibleTextCrash) { ...@@ -171,8 +171,7 @@ TEST_F(ReplaceSelectionCommandTest, TrailingNonVisibleTextCrash) {
// Crash should not occur on applying ReplaceSelectionCommand // Crash should not occur on applying ReplaceSelectionCommand
EXPECT_FALSE(command->Apply()); EXPECT_FALSE(command->Apply());
EXPECT_EQ("<div>bar</div>|<br>", EXPECT_EQ("<div>bar</div>|<br>", GetSelectionTextFromBody());
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree()));
} }
// This is a regression test for https://crbug.com/796840 // This is a regression test for https://crbug.com/796840
...@@ -185,8 +184,7 @@ TEST_F(ReplaceSelectionCommandTest, CrashWithNoSelection) { ...@@ -185,8 +184,7 @@ TEST_F(ReplaceSelectionCommandTest, CrashWithNoSelection) {
// Crash should not occur on applying ReplaceSelectionCommand // Crash should not occur on applying ReplaceSelectionCommand
EXPECT_FALSE(command->Apply()); EXPECT_FALSE(command->Apply());
EXPECT_EQ("<div></div>", EXPECT_EQ("<div></div>", GetSelectionTextFromBody());
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree()));
} }
} // namespace blink } // namespace blink
...@@ -65,7 +65,7 @@ TEST_F(TypingCommandTest, ...@@ -65,7 +65,7 @@ TEST_F(TypingCommandTest,
GetDocument(), " ", 0, GetDocument(), " ", 0,
TypingCommand::TextCompositionType::kTextCompositionUpdate, true); TypingCommand::TextCompositionType::kTextCompositionUpdate, true);
EXPECT_EQ("<div contenteditable>^<h1></h1>|</div>", EXPECT_EQ("<div contenteditable>^<h1></h1>|</div>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
// crbug.com/794397 // crbug.com/794397
...@@ -90,7 +90,7 @@ TEST_F(TypingCommandTest, ForwardDeleteInvalidatesSelection) { ...@@ -90,7 +90,7 @@ TEST_F(TypingCommandTest, ForwardDeleteInvalidatesSelection) {
"</table>\n" "</table>\n"
"<svg></svg>" "<svg></svg>"
"</q>", "</q>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); GetSelectionTextFromBody());
} }
} // namespace blink } // namespace blink
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/range.h" #include "third_party/blink/renderer/core/dom/range.h"
#include "third_party/blink/renderer/core/dom/text.h" #include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/position.h" #include "third_party/blink/renderer/core/editing/position.h"
#include "third_party/blink/renderer/core/editing/selection_template.h" #include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/testing/selection_sample.h" #include "third_party/blink/renderer/core/editing/testing/selection_sample.h"
...@@ -71,6 +72,10 @@ std::string EditingTestBase::GetSelectionTextFromBody( ...@@ -71,6 +72,10 @@ std::string EditingTestBase::GetSelectionTextFromBody(
return SelectionSample::GetSelectionText(*GetDocument().body(), selection); return SelectionSample::GetSelectionText(*GetDocument().body(), selection);
} }
std::string EditingTestBase::GetSelectionTextFromBody() const {
return GetSelectionTextFromBody(Selection().GetSelectionInDOMTree());
}
std::string EditingTestBase::GetSelectionTextInFlatTreeFromBody( std::string EditingTestBase::GetSelectionTextInFlatTreeFromBody(
const SelectionInFlatTree& selection) const { const SelectionInFlatTree& selection) const {
return SelectionSample::GetSelectionTextInFlatTree(*GetDocument().body(), return SelectionSample::GetSelectionTextInFlatTree(*GetDocument().body(),
......
...@@ -58,6 +58,8 @@ class EditingTestBase : public PageTestBase { ...@@ -58,6 +58,8 @@ class EditingTestBase : public PageTestBase {
// |SelectionInDOMTree|. // |SelectionInDOMTree|.
std::string GetSelectionTextFromBody(const SelectionInDOMTree&) const; std::string GetSelectionTextFromBody(const SelectionInDOMTree&) const;
std::string GetSelectionTextFromBody() const;
// Returns selection text for child nodes of BODY with specified // Returns selection text for child nodes of BODY with specified
// |SelectionInFlatTree|. // |SelectionInFlatTree|.
std::string GetSelectionTextInFlatTreeFromBody( std::string GetSelectionTextInFlatTreeFromBody(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment