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

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

Issue 2911373003: Wrap code into TextIterator::HandleRememberedProgress (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
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/TextIterator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2368499c400e69dd5e1be50b64b2d69bc7656057..cec2ddf26489fa9718873113f558296223ec65ae 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -254,18 +254,8 @@ bool TextIteratorAlgorithm<Strategy>::IsInsideAtomicInlineElement() const {
}
template <typename Strategy>
-void TextIteratorAlgorithm<Strategy>::Advance() {
- if (should_stop_)
- return;
-
- if (node_)
- DCHECK(!node_->GetDocument().NeedsLayoutTreeUpdate()) << node_;
-
- text_state_.ResetRunInformation();
-
- // TODO(xiaochengh): Wrap the following code into HandleRememberedProgress().
-
- // handle remembered node that needed a newline after the text node's newline
+bool TextIteratorAlgorithm<Strategy>::HandleRememberedProgress() {
+ // Handle remembered node that needed a newline after the text node's newline
if (needs_another_newline_) {
// Emit the extra newline, and position it *inside* m_node, after m_node's
// contents, in case it's a block, in the same way that we position the
@@ -277,10 +267,30 @@ void TextIteratorAlgorithm<Strategy>::Advance() {
Node* base_node = last_child ? last_child : node_.Get();
SpliceBuffer('\n', Strategy::Parent(*base_node), base_node, 1, 1);
needs_another_newline_ = false;
- return;
+ return true;
}
- if (text_node_handler_.HandleRemainingTextRuns())
+ // TODO(xiaochengh): When multiple text runs should be emitted from a replaced
+ // element or non-text node, we should handle it directly from here, instead
+ // of going into the main iteration of Advance() for multiple times. In this
+ // way, we can also remove the return values of HandleReplaceElement() and
+ // HandleNonTextNode(), and make the control flow cleaner.
+
+ // Try to emit more text runs if we are handling a text node.
+ return text_node_handler_.HandleRemainingTextRuns();
+}
+
+template <typename Strategy>
+void TextIteratorAlgorithm<Strategy>::Advance() {
+ if (should_stop_)
+ return;
+
+ if (node_)
+ DCHECK(!node_->GetDocument().NeedsLayoutTreeUpdate()) << node_;
+
+ text_state_.ResetRunInformation();
+
+ if (HandleRememberedProgress())
return;
while (node_ && (node_ != past_end_node_ || shadow_depth_ > 0)) {
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/TextIterator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698