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

Unified Diff: third_party/WebKit/Source/core/editing/state_machines/ForwardGraphemeBoundaryStateMachine.cpp

Issue 1867793003: Do not use U+0000 as the invalid code point. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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/state_machines/ForwardGraphemeBoundaryStateMachine.cpp
diff --git a/third_party/WebKit/Source/core/editing/state_machines/ForwardGraphemeBoundaryStateMachine.cpp b/third_party/WebKit/Source/core/editing/state_machines/ForwardGraphemeBoundaryStateMachine.cpp
index 1caa4b8bb58a72aa49236cf7420a714963388d37..88c08051d656cc3e9dfa2bed77db0cc3c567e690 100644
--- a/third_party/WebKit/Source/core/editing/state_machines/ForwardGraphemeBoundaryStateMachine.cpp
+++ b/third_party/WebKit/Source/core/editing/state_machines/ForwardGraphemeBoundaryStateMachine.cpp
@@ -11,6 +11,9 @@
#include <ostream> // NOLINT
namespace blink {
+namespace {
+const UChar32 kInvalidCodePoint = WTF::Unicode::kMaxCodepoint + 1;
+} // namespace
#define FOR_EACH_FORWARD_GRAPHEME_BOUNDARY_STATE(V) \
/* Counting preceding regional indicators. This is initial state. */ \
@@ -49,14 +52,15 @@ std::ostream& operator<<(std::ostream& os,
}
ForwardGraphemeBoundaryStateMachine::ForwardGraphemeBoundaryStateMachine()
- : m_internalState(InternalState::CountRIS)
+ : m_prevCodePoint(kInvalidCodePoint),
+ m_internalState(InternalState::CountRIS)
{
}
TextSegmentationMachineState
ForwardGraphemeBoundaryStateMachine::feedPrecedingCodeUnit(UChar codeUnit)
{
- DCHECK_EQ(m_prevCodePoint, 0);
+ DCHECK_EQ(m_prevCodePoint, kInvalidCodePoint);
DCHECK_EQ(m_boundaryOffset, 0);
switch (m_internalState) {
case InternalState::CountRIS:
@@ -106,7 +110,7 @@ ForwardGraphemeBoundaryStateMachine::feedFollowingCodeUnit(UChar codeUnit)
<< " is returned. InternalState: " << m_internalState;
return finish();
case InternalState::StartForward:
- DCHECK_EQ(m_prevCodePoint, 0);
+ DCHECK_EQ(m_prevCodePoint, kInvalidCodePoint);
DCHECK_EQ(m_boundaryOffset, 0);
DCHECK_EQ(m_pendingCodeUnit, 0);
if (U16_IS_TRAIL(codeUnit)) {
@@ -123,7 +127,7 @@ ForwardGraphemeBoundaryStateMachine::feedFollowingCodeUnit(UChar codeUnit)
m_boundaryOffset = 1;
return moveToNextState(InternalState::Search);
case InternalState::StartForwardWaitTrailSurrgate:
- DCHECK_EQ(m_prevCodePoint, 0);
+ DCHECK_EQ(m_prevCodePoint, kInvalidCodePoint);
DCHECK_EQ(m_boundaryOffset, 0);
DCHECK_NE(m_pendingCodeUnit, 0);
if (U16_IS_TRAIL(codeUnit)) {
@@ -137,7 +141,7 @@ ForwardGraphemeBoundaryStateMachine::feedFollowingCodeUnit(UChar codeUnit)
m_boundaryOffset = 1;
return finish();
case InternalState::Search:
- DCHECK_NE(m_prevCodePoint, 0);
+ DCHECK_NE(m_prevCodePoint, kInvalidCodePoint);
DCHECK_NE(m_boundaryOffset, 0);
DCHECK_EQ(m_pendingCodeUnit, 0);
if (U16_IS_LEAD(codeUnit)) {
@@ -152,7 +156,7 @@ ForwardGraphemeBoundaryStateMachine::feedFollowingCodeUnit(UChar codeUnit)
m_boundaryOffset += 1;
return staySameState();
case InternalState::SearchWaitTrailSurrogate:
- DCHECK_NE(m_prevCodePoint, 0);
+ DCHECK_NE(m_prevCodePoint, kInvalidCodePoint);
DCHECK_NE(m_boundaryOffset, 0);
DCHECK_NE(m_pendingCodeUnit, 0);
if (!U16_IS_TRAIL(codeUnit))
@@ -214,7 +218,7 @@ void ForwardGraphemeBoundaryStateMachine::reset()
m_pendingCodeUnit = 0;
m_boundaryOffset = 0;
m_precedingRISCount = 0;
- m_prevCodePoint = 0;
+ m_prevCodePoint = kInvalidCodePoint;
m_internalState = InternalState::CountRIS;
}

Powered by Google App Engine
This is Rietveld 408576698