From d13f24c08debb293e794ba5a66dd449adf4bc2c8 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 19 Sep 2017 11:11:00 -0400 Subject: Invert flag to CFDE_TextEditEngine::Iterator::IsEOF This CL changes the IsEOF flag to match the semantics of the FindNextBreakPos flag. Change-Id: I1a8aba91171baeacf80bdea4b9468d6093599c90 Reviewed-on: https://pdfium-review.googlesource.com/14291 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fde/cfde_texteditengine.cpp | 20 ++++++++++---------- xfa/fde/cfde_texteditengine.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp index 0c64e39aeb..a28aeb5f6c 100644 --- a/xfa/fde/cfde_texteditengine.cpp +++ b/xfa/fde/cfde_texteditengine.cpp @@ -840,12 +840,12 @@ void CFDE_TextEditEngine::RebuildPieces() { contents_bounding_box_ = CFX_RectF(); auto iter = pdfium::MakeUnique(this); - while (!iter->IsEOF(true)) { + while (!iter->IsEOF(false)) { iter->Next(false); CFX_BreakType break_status = text_break_.AppendChar( password_mode_ ? password_alias_ : iter->GetChar()); - if (iter->IsEOF(true) && CFX_BreakTypeNoneOrPiece(break_status)) + if (iter->IsEOF(false) && CFX_BreakTypeNoneOrPiece(break_status)) break_status = text_break_.EndBreak(CFX_BreakType::Paragraph); if (CFX_BreakTypeNoneOrPiece(break_status)) @@ -1019,19 +1019,19 @@ int32_t CFDE_TextEditEngine::Iterator::GetAt() const { return current_position_; } -bool CFDE_TextEditEngine::Iterator::IsEOF(bool bTail) const { - return bTail ? current_position_ > -1 && +bool CFDE_TextEditEngine::Iterator::IsEOF(bool bPrev) const { + return bPrev ? current_position_ == -1 + : current_position_ > -1 && static_cast(current_position_) == - engine_->GetLength() - : current_position_ == -1; + engine_->GetLength(); } void CFDE_TextEditEngine::Iterator::FindNextBreakPos(bool bPrev) { - if (IsEOF(!bPrev)) + if (IsEOF(bPrev)) return; WordBreakProperty ePreType = WordBreakProperty::kNone; - if (!IsEOF(bPrev)) { + if (!IsEOF(!bPrev)) { Next(!bPrev); ePreType = GetWordBreakProperty(GetChar()); Next(bPrev); @@ -1045,7 +1045,7 @@ void CFDE_TextEditEngine::Iterator::FindNextBreakPos(bool bPrev) { WordBreakProperty eNextType = GetWordBreakProperty(GetChar()); bool wBreak = CheckStateChangeForWordBreak(eCurType, eNextType); if (wBreak) { - if (IsEOF(!bPrev)) { + if (IsEOF(bPrev)) { Next(!bPrev); return; } @@ -1080,5 +1080,5 @@ void CFDE_TextEditEngine::Iterator::FindNextBreakPos(bool bPrev) { ePreType = eCurType; eCurType = eNextType; bFirst = false; - } while (!IsEOF(!bPrev)); + } while (!IsEOF(bPrev)); } diff --git a/xfa/fde/cfde_texteditengine.h b/xfa/fde/cfde_texteditengine.h index 40f12e5f76..fc5a5fb490 100644 --- a/xfa/fde/cfde_texteditengine.h +++ b/xfa/fde/cfde_texteditengine.h @@ -47,7 +47,7 @@ class CFDE_TextEditEngine { void SetAt(int32_t nIndex); int32_t GetAt() const; void FindNextBreakPos(bool bPrev); - bool IsEOF(bool bTail) const; + bool IsEOF(bool bPrev) const; private: CFX_UnownedPtr engine_; -- cgit v1.2.3