| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fde/cfx_wordbreak.h" | 7 #include "xfa/fde/cfx_wordbreak.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "third_party/base/ptr_util.h" |
| 11 #include "xfa/fde/cfx_chariter.h" | 12 #include "xfa/fde/cfx_chariter.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 enum FX_WordBreakProp { | 16 enum FX_WordBreakProp { |
| 16 FX_WordBreakProp_None = 0, | 17 FX_WordBreakProp_None = 0, |
| 17 FX_WordBreakProp_CR, | 18 FX_WordBreakProp_CR, |
| 18 FX_WordBreakProp_LF, | 19 FX_WordBreakProp_LF, |
| 19 FX_WordBreakProp_NewLine, | 20 FX_WordBreakProp_NewLine, |
| 20 FX_WordBreakProp_Extend, | 21 FX_WordBreakProp_Extend, |
| (...skipping 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2781 CFX_WordBreak::CFX_WordBreak() {} | 2782 CFX_WordBreak::CFX_WordBreak() {} |
| 2782 | 2783 |
| 2783 CFX_WordBreak::~CFX_WordBreak() {} | 2784 CFX_WordBreak::~CFX_WordBreak() {} |
| 2784 | 2785 |
| 2785 void CFX_WordBreak::Attach(IFX_CharIter* pIter) { | 2786 void CFX_WordBreak::Attach(IFX_CharIter* pIter) { |
| 2786 ASSERT(pIter); | 2787 ASSERT(pIter); |
| 2787 m_pCurIter.reset(pIter); | 2788 m_pCurIter.reset(pIter); |
| 2788 } | 2789 } |
| 2789 | 2790 |
| 2790 void CFX_WordBreak::Attach(const CFX_WideString& wsText) { | 2791 void CFX_WordBreak::Attach(const CFX_WideString& wsText) { |
| 2791 m_pCurIter.reset(new CFX_CharIter(wsText)); | 2792 m_pCurIter = pdfium::MakeUnique<CFX_CharIter>(wsText); |
| 2792 } | 2793 } |
| 2793 | 2794 |
| 2794 bool CFX_WordBreak::Next(bool bPrev) { | 2795 bool CFX_WordBreak::Next(bool bPrev) { |
| 2795 std::unique_ptr<IFX_CharIter> pIter( | 2796 std::unique_ptr<IFX_CharIter> pIter( |
| 2796 (bPrev ? m_pPreIter : m_pCurIter)->Clone()); | 2797 (bPrev ? m_pPreIter : m_pCurIter)->Clone()); |
| 2797 if (pIter->IsEOF(!bPrev)) | 2798 if (pIter->IsEOF(!bPrev)) |
| 2798 return false; | 2799 return false; |
| 2799 | 2800 |
| 2800 pIter->Next(bPrev); | 2801 pIter->Next(bPrev); |
| 2801 if (!FindNextBreakPos(pIter.get(), bPrev, true)) | 2802 if (!FindNextBreakPos(pIter.get(), bPrev, true)) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 return true; | 2937 return true; |
| 2937 } | 2938 } |
| 2938 } | 2939 } |
| 2939 } | 2940 } |
| 2940 ePreType = eCurType; | 2941 ePreType = eCurType; |
| 2941 eCurType = eNextType; | 2942 eCurType = eNextType; |
| 2942 bFirst = false; | 2943 bFirst = false; |
| 2943 } while (!pIter->IsEOF(!bPrev)); | 2944 } while (!pIter->IsEOF(!bPrev)); |
| 2944 return true; | 2945 return true; |
| 2945 } | 2946 } |
| OLD | NEW |