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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h

Issue 2914313002: Manage DOM and string offsets separately in TextIteratorTextState (Closed)
Patch Set: Fri Jun 2 10:34:55 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
Index: third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h
index f81bb8fed902e50b89d21c3fbbd61b9589dc192d..64dbf2f519a1c2bd2c7102129d8b3c0fcf3d49b7 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h
@@ -44,12 +44,16 @@ class CORE_EXPORT TextIteratorTextState
explicit TextIteratorTextState(const TextIteratorBehavior&);
~TextIteratorTextState() {}
+ // Return properties of the current text.
int length() const { return text_length_; }
UChar CharacterAt(unsigned index) const;
String Substring(unsigned position, unsigned length) const;
void AppendTextToStringBuilder(StringBuilder&,
unsigned position = 0,
unsigned max_length = UINT_MAX) const;
+ void AppendTextTo(ForwardsTextBuffer* output,
+ unsigned position,
+ unsigned length_to_append) const;
void SpliceBuffer(UChar,
Node* text_node,
@@ -62,35 +66,36 @@ class CORE_EXPORT TextIteratorTextState
int text_end_offset);
void EmitAltText(Node*);
void UpdateForReplacedElement(Node* base_node);
+
+ // Return position of the current text.
void FlushPositionOffsets() const;
int PositionStartOffset() const { return position_start_offset_; }
int PositionEndOffset() const { return position_end_offset_; }
Node* PositionNode() const { return position_node_; }
+
bool HasEmitted() const { return has_emitted_; }
UChar LastCharacter() const { return last_character_; }
- int TextStartOffset() const { return text_start_offset_; }
void ResetRunInformation() {
position_node_ = nullptr;
text_length_ = 0;
}
- void AppendTextTo(ForwardsTextBuffer* output,
- unsigned position,
- unsigned length_to_append) const;
-
DECLARE_TRACE();
private:
int text_length_ = 0;
- String text_;
// Used for whitespace characters that aren't in the DOM, so we can point at
// them.
- // If non-zero, overrides m_text.
+ // If non-zero, overrides |text_|.
UChar single_character_buffer_ = 0;
- // The current text and its position, in the form to be returned from the
- // iterator.
+ // The current text when |single_character_buffer_| is zero, in which case it
+ // is |text_.Substring(text_start_offset_, text_length_)|.
+ String text_;
+ int text_start_offset_ = 0;
+
+ // Position of the current text, in the form to be returned from the iterator.
Member<Node> position_node_;
mutable Member<Node> position_offset_base_node_;
mutable int position_start_offset_ = 0;
@@ -103,10 +108,6 @@ class CORE_EXPORT TextIteratorTextState
const TextIteratorBehavior behavior_;
- // Stores the length of :first-letter when we are at the remaining text.
- // Equals to 0 in all other cases.
- int text_start_offset_ = 0;
-
DISALLOW_COPY_AND_ASSIGN(TextIteratorTextState);
};

Powered by Google App Engine
This is Rietveld 408576698