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

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

Issue 2913673004: Change how iteration range is passed to TextIteratorTextNodeHandler (Closed)
Patch Set: Thu Jun 1 08:33:52 PDT 2017 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 | « no previous file | third_party/WebKit/Source/core/editing/iterators/TextIteratorTextNodeHandler.h » ('j') | 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 7f81c73f6ec912684c74103b2a24906b4fb0120e..8bd538efe7c5c47ebf83a7adb6655e0580765be7 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -188,9 +188,6 @@ TextIteratorAlgorithm<Strategy>::TextIteratorAlgorithm(
Node* const end_container = end.ComputeContainerNode();
const int end_offset = end.ComputeOffsetInContainerNode();
- text_node_handler_.Initialize(start_container, start_offset, end_container,
- end_offset);
-
// Remember the range - this does not change.
start_container_ = start_container;
start_offset_ = start_offset;
@@ -484,8 +481,23 @@ void TextIteratorAlgorithm<Strategy>::HandleTextNode() {
DCHECK_NE(last_text_node_, node_)
<< "We should never call HandleTextNode on the same node twice";
- last_text_node_ = ToText(node_);
- text_node_handler_.HandleTextNode(ToText(node_));
+ Text* text = ToText(node_);
+ last_text_node_ = text;
+
+ // TODO(editing-dev): Introduce a |DOMOffsetRange| class so that we can pass
+ // an offset range with unbounded endpoint(s) in an easy but still clear way.
+ if (node_ != start_container_) {
+ if (node_ != end_container_)
+ text_node_handler_.HandleTextNodeWhole(text);
+ else
+ text_node_handler_.HandleTextNodeEndAt(text, end_offset_);
+ return;
+ }
+ if (node_ != end_container_) {
+ text_node_handler_.HandleTextNodeStartFrom(text, start_offset_);
+ return;
+ }
+ text_node_handler_.HandleTextNodeInRange(text, start_offset_, end_offset_);
}
template <typename Strategy>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/iterators/TextIteratorTextNodeHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698