summaryrefslogtreecommitdiff
path: root/xfa/fde/cfde_texteditengine.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-18 16:21:03 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-18 20:35:25 +0000
commit5278cebc468e6975f217d0c016501a554d10fd97 (patch)
tree5e92b047e2bdd2c0b58a50f71e4445c001eff0d0 /xfa/fde/cfde_texteditengine.cpp
parent91c2f7cdcf8545d764a8b6543b42f0819f8d4ad3 (diff)
downloadpdfium-5278cebc468e6975f217d0c016501a554d10fd97.tar.xz
Cleanup word break properties
This CL attempts to clarify the contents of the gs_FX_WordBreak_Table and adds static_asserts that each entry in the WordBreakProperty table has the value we expect. Change-Id: I33c1f12a9e18240b01969be9902204eba5074eb7 Reviewed-on: https://pdfium-review.googlesource.com/13430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fde/cfde_texteditengine.cpp')
-rw-r--r--xfa/fde/cfde_texteditengine.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp
index 999380b401..8075ea7a98 100644
--- a/xfa/fde/cfde_texteditengine.cpp
+++ b/xfa/fde/cfde_texteditengine.cpp
@@ -18,22 +18,6 @@ constexpr size_t kMaxEditOperations = 128;
constexpr size_t kGapSize = 128;
constexpr size_t kPageWidthMax = 0xffff;
-enum class WordBreakProperty {
- kNone = 0,
- kCR,
- kLF,
- kNewLine,
- kExtend,
- kFormat,
- kKataKana,
- kALetter,
- kMidLetter,
- kMidNum,
- kMidNumLet,
- kNumeric,
- kExtendNumLet,
-};
-
class InsertOperation : public CFDE_TextEditEngine::Operation {
public:
InsertOperation(CFDE_TextEditEngine* engine,
@@ -110,6 +94,14 @@ class ReplaceOperation : public CFDE_TextEditEngine::Operation {
DeleteOperation delete_op_;
};
+bool CheckStateChangeForWordBreak(WordBreakProperty from,
+ WordBreakProperty to) {
+ ASSERT(static_cast<int>(from) < 13);
+
+ return !!(gs_FX_WordBreak_Table[static_cast<int>(from)] &
+ static_cast<uint16_t>(1 << static_cast<int>(to)));
+}
+
WordBreakProperty GetWordBreakProperty(wchar_t wcCodePoint) {
uint8_t dwProperty = gs_FX_WordBreak_CodePointProperties[wcCodePoint >> 1];
return static_cast<WordBreakProperty>((wcCodePoint & 1) ? (dwProperty & 0x0F)
@@ -1043,8 +1035,7 @@ void CFDE_TextEditEngine::Iterator::FindNextBreakPos(bool bPrev) {
Next(bPrev);
WordBreakProperty eNextType = GetWordBreakProperty(GetChar());
- uint16_t wBreak = gs_FX_WordBreak_Table[static_cast<int>(eCurType)] &
- ((uint16_t)(1 << static_cast<int>(eNextType)));
+ bool wBreak = CheckStateChangeForWordBreak(eCurType, eNextType);
if (wBreak) {
if (IsEOF(!bPrev)) {
Next(!bPrev);