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

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

Issue 2912283002: Use remembered progress to handle replaced elements in TextIterator (Closed)
Patch Set: Created 3 years, 7 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/TextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
index 91854edb51ac8d4315f1d4670636dd0fb757c83b..4eb832d698d84df717682a199e7285a2ceb62201 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -145,6 +145,7 @@ bool IsRenderedAsTable(const Node* node) {
} // namespace
+// TODO(xiaochengh): Most members should be initialized in-place, not here.
template <typename Strategy>
TextIteratorAlgorithm<Strategy>::TextIteratorAlgorithm(
const PositionTemplate<Strategy>& start,
@@ -155,6 +156,7 @@ TextIteratorAlgorithm<Strategy>::TextIteratorAlgorithm(
end_container_(nullptr),
end_offset_(0),
needs_another_newline_(false),
+ needs_handle_replaced_element_(false),
last_text_node_(nullptr),
behavior_(AdjustBehaviorFlags<Strategy>(behavior)),
should_stop_(false),
@@ -284,6 +286,12 @@ bool TextIteratorAlgorithm<Strategy>::HandleRememberedProgress() {
// way, we can also remove the return values of HandleReplaceElement() and
// HandleNonTextNode(), and make the control flow cleaner.
+ if (needs_handle_replaced_element_) {
+ HandleReplacedElement();
+ if (text_state_.PositionNode())
+ return true;
+ }
+
// Try to emit more text runs if we are handling a text node.
return text_node_handler_.HandleRemainingTextRuns();
}
@@ -516,6 +524,8 @@ bool TextIteratorAlgorithm<Strategy>::SupportsAltText(Node* node) {
template <typename Strategy>
bool TextIteratorAlgorithm<Strategy>::HandleReplacedElement() {
+ needs_handle_replaced_element_ = false;
+
if (fully_clipped_stack_.Top())
return false;
@@ -533,8 +543,10 @@ bool TextIteratorAlgorithm<Strategy>::HandleReplacedElement() {
DCHECK_EQ(last_text_node_, text_node_handler_.GetNode());
if (last_text_node_) {
if (text_node_handler_.FixLeadingWhiteSpaceForReplacedElement(
- Strategy::Parent(*last_text_node_)))
- return false;
+ Strategy::Parent(*last_text_node_))) {
+ needs_handle_replaced_element_ = true;
+ return true;
+ }
}
if (EntersTextControls() && layout_object->IsTextControl()) {

Powered by Google App Engine
This is Rietveld 408576698