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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
index 3134ba15cf30b9e2211bf171e9a6c0de4697f363..0587b2dbf673f1a95299a32a01f4fe995805d344 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
@@ -40,9 +40,9 @@ struct DOMTree : NodeTraversal {
using TextIteratorType = TextIterator;
};
-struct ComposedTree : ComposedTreeTraversal {
- using PositionType = PositionInComposedTree;
- using TextIteratorType = TextIteratorInComposedTree;
+struct FlatTree : FlatTreeTraversal {
+ using PositionType = PositionInFlatTree;
+ using TextIteratorType = TextIteratorInFlatTree;
};
class TextIteratorTest : public EditingTestBase {
@@ -115,7 +115,7 @@ TEST_F(TextIteratorTest, BasicIteration)
static const char* input = "<p>Hello, \ntext</p><p>iterator.</p>";
setBodyContent(input);
EXPECT_EQ("[Hello, ][text][\n][\n][iterator.]", iterate<DOMTree>());
- EXPECT_EQ("[Hello, ][text][\n][\n][iterator.]", iterate<ComposedTree>());
+ EXPECT_EQ("[Hello, ][text][\n][\n][iterator.]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, IgnoreAltTextInTextControls)
@@ -123,7 +123,7 @@ TEST_F(TextIteratorTest, IgnoreAltTextInTextControls)
static const char* input = "<p>Hello <input type='text' value='value'>!</p>";
setBodyContent(input);
EXPECT_EQ("[Hello ][][!]", iterate<DOMTree>(TextIteratorEmitsImageAltText));
- EXPECT_EQ("[Hello ][][\n][value][\n][!]", iterate<ComposedTree>(TextIteratorEmitsImageAltText));
+ EXPECT_EQ("[Hello ][][\n][value][\n][!]", iterate<FlatTree>(TextIteratorEmitsImageAltText));
}
TEST_F(TextIteratorTest, DisplayAltTextInImageControls)
@@ -131,7 +131,7 @@ TEST_F(TextIteratorTest, DisplayAltTextInImageControls)
static const char* input = "<p>Hello <input type='image' alt='alt'>!</p>";
setBodyContent(input);
EXPECT_EQ("[Hello ][alt][!]", iterate<DOMTree>(TextIteratorEmitsImageAltText));
- EXPECT_EQ("[Hello ][alt][!]", iterate<ComposedTree>(TextIteratorEmitsImageAltText));
+ EXPECT_EQ("[Hello ][alt][!]", iterate<FlatTree>(TextIteratorEmitsImageAltText));
}
TEST_F(TextIteratorTest, NotEnteringTextControls)
@@ -139,7 +139,7 @@ TEST_F(TextIteratorTest, NotEnteringTextControls)
static const char* input = "<p>Hello <input type='text' value='input'>!</p>";
setBodyContent(input);
EXPECT_EQ("[Hello ][][!]", iterate<DOMTree>());
- EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<ComposedTree>());
+ EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, EnteringTextControlsWithOption)
@@ -147,7 +147,7 @@ TEST_F(TextIteratorTest, EnteringTextControlsWithOption)
static const char* input = "<p>Hello <input type='text' value='input'>!</p>";
setBodyContent(input);
EXPECT_EQ("[Hello ][\n][input][!]", iterate<DOMTree>(TextIteratorEntersTextControls));
- EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<ComposedTree>(TextIteratorEntersTextControls));
+ EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<FlatTree>(TextIteratorEntersTextControls));
}
TEST_F(TextIteratorTest, EnteringTextControlsWithOptionComplex)
@@ -155,7 +155,7 @@ TEST_F(TextIteratorTest, EnteringTextControlsWithOptionComplex)
static const char* input = "<input type='text' value='Beginning of range'><div><div><input type='text' value='Under DOM nodes'></div></div><input type='text' value='End of range'>";
setBodyContent(input);
EXPECT_EQ("[\n][Beginning of range][\n][Under DOM nodes][\n][End of range]", iterate<DOMTree>(TextIteratorEntersTextControls));
- EXPECT_EQ("[][\n][Beginning of range][\n][][\n][Under DOM nodes][\n][][\n][End of range]", iterate<ComposedTree>(TextIteratorEntersTextControls));
+ EXPECT_EQ("[][\n][Beginning of range][\n][][\n][Under DOM nodes][\n][][\n][End of range]", iterate<FlatTree>(TextIteratorEntersTextControls));
}
TEST_F(TextIteratorTest, NotEnteringTextControlHostingShadowTreeEvenWithOption)
@@ -168,7 +168,7 @@ TEST_F(TextIteratorTest, NotEnteringTextControlHostingShadowTreeEvenWithOption)
createShadowRootForElementWithIDAndSetInnerHTML(document(), "input", shadowContent);
// FIXME: Why is an empty string emitted here?
EXPECT_EQ("[Hello, ][][ iterator.]", iterate<DOMTree>());
- EXPECT_EQ("[Hello, ][][shadow][ iterator.]", iterate<ComposedTree>());
+ EXPECT_EQ("[Hello, ][][shadow][ iterator.]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, NotEnteringShadowTree)
@@ -179,7 +179,7 @@ TEST_F(TextIteratorTest, NotEnteringShadowTree)
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
// TextIterator doesn't emit "text" since its layoutObject is not created. The shadow tree is ignored.
EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>());
- EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<ComposedTree>());
+ EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, NotEnteringShadowTreeWithMultipleShadowTrees)
@@ -191,7 +191,7 @@ TEST_F(TextIteratorTest, NotEnteringShadowTreeWithMultipleShadowTrees)
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent1);
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent2);
EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>());
- EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<ComposedTree>());
+ EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, NotEnteringShadowTreeWithNestedShadowTrees)
@@ -203,7 +203,7 @@ TEST_F(TextIteratorTest, NotEnteringShadowTreeWithNestedShadowTrees)
RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = createShadowRootForElementWithIDAndSetInnerHTML(document(), "host-in-document", shadowContent1);
createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host-in-shadow", shadowContent2);
EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>());
- EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<ComposedTree>());
+ EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, NotEnteringShadowTreeWithContentInsertionPoint)
@@ -214,7 +214,7 @@ TEST_F(TextIteratorTest, NotEnteringShadowTreeWithContentInsertionPoint)
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
// In this case a layoutObject for "text" is created, so it shows up here.
EXPECT_EQ("[Hello, ][text][ iterator.]", iterate<DOMTree>());
- EXPECT_EQ("[Hello, ][shadow ][text][ iterator.]", iterate<ComposedTree>());
+ EXPECT_EQ("[Hello, ][shadow ][text][ iterator.]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, EnteringShadowTreeWithOption)
@@ -225,7 +225,7 @@ TEST_F(TextIteratorTest, EnteringShadowTreeWithOption)
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
// TextIterator emits "shadow" since TextIteratorEntersOpenShadowRoots is specified.
EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots));
- EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<ComposedTree>(TextIteratorEntersOpenShadowRoots));
+ EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<FlatTree>(TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, EnteringShadowTreeWithMultipleShadowTreesWithOption)
@@ -238,7 +238,7 @@ TEST_F(TextIteratorTest, EnteringShadowTreeWithMultipleShadowTreesWithOption)
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent2);
// The first isn't emitted because a layoutObject for the first is not created.
EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots));
- EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<ComposedTree>(TextIteratorEntersOpenShadowRoots));
+ EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<FlatTree>(TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, EnteringShadowTreeWithNestedShadowTreesWithOption)
@@ -250,7 +250,7 @@ TEST_F(TextIteratorTest, EnteringShadowTreeWithNestedShadowTreesWithOption)
RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = createShadowRootForElementWithIDAndSetInnerHTML(document(), "host-in-document", shadowContent1);
createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host-in-shadow", shadowContent2);
EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots));
- EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<ComposedTree>(TextIteratorEntersOpenShadowRoots));
+ EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<FlatTree>(TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, EnteringShadowTreeWithContentInsertionPointWithOption)
@@ -263,7 +263,7 @@ TEST_F(TextIteratorTest, EnteringShadowTreeWithContentInsertionPointWithOption)
setBodyContent(bodyContent);
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
EXPECT_EQ("[Hello, ][ shadow][text][ iterator.]", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots));
- EXPECT_EQ("[Hello, ][text][ shadow][ iterator.]", iterate<ComposedTree>(TextIteratorEntersOpenShadowRoots));
+ EXPECT_EQ("[Hello, ][text][ shadow][ iterator.]", iterate<FlatTree>(TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, StartingAtNodeInShadowRoot)
@@ -278,9 +278,9 @@ TEST_F(TextIteratorTest, StartingAtNodeInShadowRoot)
Position end(outerDiv, PositionAnchorType::AfterChildren);
EXPECT_EQ("[ shadow][text][ iterator.]", iteratePartial<DOMTree>(start, end, TextIteratorEntersOpenShadowRoots));
- PositionInComposedTree startInComposedTree(spanInShadow, PositionAnchorType::BeforeChildren);
- PositionInComposedTree endInComposedTree(outerDiv, PositionAnchorType::AfterChildren);
- EXPECT_EQ("[text][ shadow][ iterator.]", iteratePartial<ComposedTree>(startInComposedTree, endInComposedTree, TextIteratorEntersOpenShadowRoots));
+ PositionInFlatTree startInFlatTree(spanInShadow, PositionAnchorType::BeforeChildren);
+ PositionInFlatTree endInFlatTree(outerDiv, PositionAnchorType::AfterChildren);
+ EXPECT_EQ("[text][ shadow][ iterator.]", iteratePartial<FlatTree>(startInFlatTree, endInFlatTree, TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, FinishingAtNodeInShadowRoot)
@@ -295,9 +295,9 @@ TEST_F(TextIteratorTest, FinishingAtNodeInShadowRoot)
Position end(spanInShadow, PositionAnchorType::AfterChildren);
EXPECT_EQ("[Hello, ][ shadow]", iteratePartial<DOMTree>(start, end, TextIteratorEntersOpenShadowRoots));
- PositionInComposedTree startInComposedTree(outerDiv, PositionAnchorType::BeforeChildren);
- PositionInComposedTree endInComposedTree(spanInShadow, PositionAnchorType::AfterChildren);
- EXPECT_EQ("[Hello, ][text][ shadow]", iteratePartial<ComposedTree>(startInComposedTree, endInComposedTree, TextIteratorEntersOpenShadowRoots));
+ PositionInFlatTree startInFlatTree(outerDiv, PositionAnchorType::BeforeChildren);
+ PositionInFlatTree endInFlatTree(spanInShadow, PositionAnchorType::AfterChildren);
+ EXPECT_EQ("[Hello, ][text][ shadow]", iteratePartial<FlatTree>(startInFlatTree, endInFlatTree, TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, FullyClipsContents)
@@ -308,7 +308,7 @@ TEST_F(TextIteratorTest, FullyClipsContents)
"</div>";
setBodyContent(bodyContent);
EXPECT_EQ("", iterate<DOMTree>());
- EXPECT_EQ("", iterate<ComposedTree>());
+ EXPECT_EQ("", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, IgnoresContainerClip)
@@ -322,7 +322,7 @@ TEST_F(TextIteratorTest, IgnoresContainerClip)
"</div>";
setBodyContent(bodyContent);
EXPECT_EQ("[but I am!]", iterate<DOMTree>());
- EXPECT_EQ("[but I am!]", iterate<ComposedTree>());
+ EXPECT_EQ("[but I am!]", iterate<FlatTree>());
}
TEST_F(TextIteratorTest, FullyClippedContentsDistributed)
@@ -339,7 +339,7 @@ TEST_F(TextIteratorTest, FullyClippedContentsDistributed)
createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
// FIXME: The text below is actually invisible but TextIterator currently thinks it's visible.
EXPECT_EQ("[\n][Am I visible?]", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots));
- EXPECT_EQ("", iterate<ComposedTree>(TextIteratorEntersOpenShadowRoots));
+ EXPECT_EQ("", iterate<FlatTree>(TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, IgnoresContainersClipDistributed)
@@ -357,7 +357,7 @@ TEST_F(TextIteratorTest, IgnoresContainersClipDistributed)
// FIXME: The text below is actually visible but TextIterator currently thinks it's invisible.
// [\n][Nobody can find me!]
EXPECT_EQ("", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots));
- EXPECT_EQ("[Nobody can find me!]", iterate<ComposedTree>(TextIteratorEntersOpenShadowRoots));
+ EXPECT_EQ("[Nobody can find me!]", iterate<FlatTree>(TextIteratorEntersOpenShadowRoots));
}
TEST_F(TextIteratorTest, EmitsReplacementCharForInput)
@@ -370,7 +370,7 @@ TEST_F(TextIteratorTest, EmitsReplacementCharForInput)
"</div>";
setBodyContent(bodyContent);
EXPECT_EQ("[Before][\xEF\xBF\xBC][After]", iterate<DOMTree>(TextIteratorEmitsObjectReplacementCharacter));
- EXPECT_EQ("[Before][\xEF\xBF\xBC][After]", iterate<ComposedTree>(TextIteratorEmitsObjectReplacementCharacter));
+ EXPECT_EQ("[Before][\xEF\xBF\xBC][After]", iterate<FlatTree>(TextIteratorEmitsObjectReplacementCharacter));
}
TEST_F(TextIteratorTest, RangeLengthWithReplacedElements)
@@ -391,7 +391,7 @@ TEST_F(TextIteratorTest, WhitespaceCollapseForReplacedElements)
static const char* bodyContent = "<span>Some text </span> <input type='button' value='Button text'/><span>Some more text</span>";
setBodyContent(bodyContent);
EXPECT_EQ("[Some text ][][Some more text]", iterate<DOMTree>(TextIteratorCollapseTrailingSpace));
- EXPECT_EQ("[Some text ][][Button text][Some more text]", iterate<ComposedTree>(TextIteratorCollapseTrailingSpace));
+ EXPECT_EQ("[Some text ][][Button text][Some more text]", iterate<FlatTree>(TextIteratorCollapseTrailingSpace));
}
TEST_F(TextIteratorTest, copyTextTo)
@@ -418,8 +418,8 @@ TEST_F(TextIteratorTest, copyTextTo)
iter1.copyTextTo(&output1, 1, 2);
EXPECT_EQ("onetwo", String(output1.data(), output1.size())) << String::format(message, 1, "onetwo").utf8().data();
- EphemeralRangeTemplate<EditingInComposedTreeStrategy> range2(EphemeralRangeTemplate<EditingInComposedTreeStrategy>::rangeOfContents(*host));
- TextIteratorAlgorithm<EditingInComposedTreeStrategy> iter2(range2.startPosition(), range2.endPosition());
+ EphemeralRangeTemplate<EditingInFlatTreeStrategy> range2(EphemeralRangeTemplate<EditingInFlatTreeStrategy>::rangeOfContents(*host));
+ TextIteratorAlgorithm<EditingInFlatTreeStrategy> iter2(range2.startPosition(), range2.endPosition());
ForwardsTextBuffer output2;
iter2.copyTextTo(&output2, 0, 3);
EXPECT_EQ("thr", String(output2.data(), output2.size())) << String::format(message, 2, "thr").utf8().data();
@@ -466,8 +466,8 @@ TEST_F(TextIteratorTest, characterAt)
EXPECT_EQ('w', iter1.characterAt(1)) << message1;
EXPECT_EQ('o', iter1.characterAt(2)) << message1;
- EphemeralRangeTemplate<EditingInComposedTreeStrategy> range2(EphemeralRangeTemplate<EditingInComposedTreeStrategy>::rangeOfContents(*host));
- TextIteratorAlgorithm<EditingInComposedTreeStrategy> iter2(range2.startPosition(), range2.endPosition());
+ EphemeralRangeTemplate<EditingInFlatTreeStrategy> range2(EphemeralRangeTemplate<EditingInFlatTreeStrategy>::rangeOfContents(*host));
+ TextIteratorAlgorithm<EditingInFlatTreeStrategy> iter2(range2.startPosition(), range2.endPosition());
const char* message2 = "|iter2| should emit 'three ', 'two', ' ', 'one' and ' zero'.";
EXPECT_EQ('t', iter2.characterAt(0)) << message2;
EXPECT_EQ('h', iter2.characterAt(1)) << message2;

Powered by Google App Engine
This is Rietveld 408576698