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

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

Issue 2903203002: Reorganize the maintenance and usage of TextIterator::last_text_node_ (Closed)
Patch Set: Thu May 25 16:01:04 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 | 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 fdec28a114c081bbf6fbcf5dc206bb08ae0c450a..489642687d7b86e3dddb16802484768b24200071 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -587,6 +587,7 @@ bool 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_ = ToText(node_);
offset_ = text_node_ == start_container_ ? start_offset_ : 0;
@@ -594,8 +595,6 @@ bool TextIteratorAlgorithm<Strategy>::HandleTextNode() {
first_letter_text_ = nullptr;
LayoutText* layout_object = text_node_->GetLayoutObject();
-
- last_text_node_ = text_node_;
String str = layout_object->GetText();
// handle pre-formatted text
@@ -706,8 +705,7 @@ void TextIteratorAlgorithm<Strategy>::HandleTextBox() {
!layout_object->Style()->IsCollapsibleWhiteSpace(
text_state_.LastCharacter()) &&
text_state_.LastCharacter()) {
- if (last_text_node_ == text_node_ && run_start > 0 &&
- str[run_start - 1] == ' ') {
+ if (run_start > 0 && str[run_start - 1] == ' ') {
unsigned space_run_start = run_start - 1;
while (space_run_start > 0 && str[space_run_start - 1] == ' ')
--space_run_start;
@@ -887,19 +885,20 @@ bool TextIteratorAlgorithm<Strategy>::HandleReplacedElement() {
return true;
}
+ DCHECK_EQ(last_text_node_, text_node_);
if (behavior_.CollapseTrailingSpace()) {
- if (last_text_node_) {
- String str = last_text_node_->GetLayoutObject()->GetText();
+ if (text_node_) {
+ String str = text_node_->GetLayoutObject()->GetText();
if (last_text_node_ended_with_collapsed_space_ && offset_ > 0 &&
str[offset_ - 1] == ' ') {
SpliceBuffer(kSpaceCharacter, Strategy::Parent(*last_text_node_),
- last_text_node_, 1, 1);
+ text_node_, 1, 1);
return false;
}
}
} else if (last_text_node_ended_with_collapsed_space_) {
SpliceBuffer(kSpaceCharacter, Strategy::Parent(*last_text_node_),
- last_text_node_, 1, 1);
+ text_node_, 1, 1);
return false;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698