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

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

Issue 2649923012: Avoid reporting space as NBSP in TextInputState. (Closed)
Patch Set: Code review comments Created 3 years, 11 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.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp
index 06262fb3c1c295ddda943d6406850f37a6f6d2fe..ca82e93a0e52cb13a1958be627c814ab611b11e8 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp
@@ -31,7 +31,7 @@
namespace blink {
-TextIteratorTextState::TextIteratorTextState(bool emitsOriginalText)
+TextIteratorTextState::TextIteratorTextState(TextIteratorBehaviorFlags behavior)
: m_textLength(0),
m_singleCharacterBuffer(0),
m_positionNode(nullptr),
@@ -39,7 +39,8 @@ TextIteratorTextState::TextIteratorTextState(bool emitsOriginalText)
m_positionEndOffset(0),
m_hasEmitted(false),
m_lastCharacter(0),
- m_emitsOriginalText(emitsOriginalText),
+ m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText),
+ m_emitsSpaceForNbsp(behavior & TextIteratorEmitsSpaceForNbsp),
m_textStartOffset(0) {}
UChar TextIteratorTextState::characterAt(unsigned index) const {
@@ -149,6 +150,8 @@ void TextIteratorTextState::emitText(Node* textNode,
DCHECK(textNode);
m_text =
m_emitsOriginalText ? layoutObject->originalText() : layoutObject->text();
+ if (m_emitsSpaceForNbsp)
+ m_text.replace(noBreakSpaceCharacter, spaceCharacter);
DCHECK(!m_text.isEmpty());
DCHECK_LE(0, textStartOffset);
DCHECK_LT(textStartOffset, static_cast<int>(m_text.length()));

Powered by Google App Engine
This is Rietveld 408576698