From 2a6482c19c5577924f73d100431acceb8c874e04 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 20 Mar 2017 14:51:17 -0400 Subject: Cleanup unchanged values in CFX_TxtBreak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl cleans up some members which are always the same value. Change-Id: Ic3feeb5cd8c8a8c3de5a7d6ec3628d32efc600ef Reviewed-on: https://pdfium-review.googlesource.com/3107 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- xfa/fgas/layout/cfx_break.cpp | 8 +++++-- xfa/fgas/layout/cfx_break.h | 3 ++- xfa/fgas/layout/fgas_rtfbreak.cpp | 6 ------ xfa/fgas/layout/fgas_rtfbreak.h | 2 -- xfa/fgas/layout/fgas_textbreak.cpp | 44 +++++++++----------------------------- xfa/fgas/layout/fgas_textbreak.h | 7 +----- 6 files changed, 19 insertions(+), 51 deletions(-) (limited to 'xfa/fgas/layout') diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp index 8be1d1704a..a8280b1161 100644 --- a/xfa/fgas/layout/cfx_break.cpp +++ b/xfa/fgas/layout/cfx_break.cpp @@ -38,12 +38,16 @@ CFX_Break::CFX_Break(uint32_t dwLayoutStyles) CFX_Break::~CFX_Break() {} +void CFX_Break::Reset() { + m_eCharType = FX_CHARTYPE_Unknown; + m_Line[0].Clear(); + m_Line[1].Clear(); +} + void CFX_Break::SetLayoutStyles(uint32_t dwLayoutStyles) { m_dwLayoutStyles = dwLayoutStyles; m_bSingleLine = (m_dwLayoutStyles & FX_LAYOUTSTYLE_SingleLine) != 0; m_bCombText = (m_dwLayoutStyles & FX_LAYOUTSTYLE_CombText) != 0; - - ResetArabicContext(); } void CFX_Break::SetHorizontalScale(int32_t iScale) { diff --git a/xfa/fgas/layout/cfx_break.h b/xfa/fgas/layout/cfx_break.h index d1bbde0682..631cc5aaa1 100644 --- a/xfa/fgas/layout/cfx_break.h +++ b/xfa/fgas/layout/cfx_break.h @@ -32,6 +32,8 @@ class CFX_Break { public: virtual ~CFX_Break(); + void Reset(); + void SetLayoutStyles(uint32_t dwLayoutStyles); uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; } @@ -49,7 +51,6 @@ class CFX_Break { void SetDefaultChar(wchar_t wch); virtual void SetBreakStatus() = 0; - virtual void ResetArabicContext() {} protected: explicit CFX_Break(uint32_t dwLayoutStyles); diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index f4faf00fca..81fbea0cc6 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -723,12 +723,6 @@ void CFX_RTFBreak::ClearBreakPieces() { m_iReadyLineIndex = -1; } -void CFX_RTFBreak::Reset() { - m_eCharType = FX_CHARTYPE_Unknown; - m_Line[0].Clear(); - m_Line[1].Clear(); -} - int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, FXTEXT_CHARPOS* pCharPos, bool bCharCode) const { diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h index 681dc58455..865b17ffb3 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.h +++ b/xfa/fgas/layout/fgas_rtfbreak.h @@ -60,8 +60,6 @@ class CFX_RTFBreak : public CFX_Break { const CFX_BreakPiece* GetBreakPieceUnstable(int32_t index) const; void ClearBreakPieces(); - void Reset(); - int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, FXTEXT_CHARPOS* pCharPos, bool bCharCode) const; diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 8fc425f631..41091700fb 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -25,13 +25,8 @@ bool IsCtrlCode(wchar_t ch) { CFX_TxtBreak::CFX_TxtBreak() : CFX_Break(FX_LAYOUTSTYLE_None), - m_iArabicContext(1), - m_iCurArabicContext(1), m_iAlignment(CFX_TxtLineAlignment_Left), - m_dwContextCharStyles(0), - m_iCombWidth(360000) { - ResetArabicContext(); -} + m_iCombWidth(360000) {} CFX_TxtBreak::~CFX_TxtBreak() {} @@ -45,7 +40,6 @@ void CFX_TxtBreak::SetAlignment(int32_t iAlignment) { ASSERT(iAlignment >= CFX_TxtLineAlignment_Left && iAlignment <= CFX_TxtLineAlignment_Justified); m_iAlignment = iAlignment; - ResetArabicContext(); } void CFX_TxtBreak::SetCombWidth(float fCombWidth) { @@ -83,15 +77,9 @@ inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; } -void CFX_TxtBreak::ResetArabicContext() { - m_iCurAlignment = m_iAlignment; - m_dwContextCharStyles = m_iAlignment; - m_dwContextCharStyles |= (m_iArabicContext << 8); -} - void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps) { pCurChar->m_dwStatus = CFX_BreakType::None; - pCurChar->m_dwCharStyles = m_dwContextCharStyles; + pCurChar->m_dwCharStyles = m_iAlignment | (1 << 8); } void CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) { @@ -479,7 +467,7 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque& tpos, } int32_t iOffset = m_iLineWidth - iNetWidth; - if (iGapChars > 0 && m_iCurAlignment & CFX_TxtLineAlignment_Justified && + if (iGapChars > 0 && m_iAlignment & CFX_TxtLineAlignment_Justified && dwStatus != CFX_BreakType::Paragraph) { int32_t iStart = -1; for (auto& tpo : tpos) { @@ -504,10 +492,10 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque& tpos, } iStart += ttp.m_iWidth; } - } else if (m_iCurAlignment & CFX_TxtLineAlignment_Center || - m_iCurAlignment & CFX_TxtLineAlignment_Right) { - if (m_iCurAlignment & CFX_TxtLineAlignment_Center && - !(m_iCurAlignment & CFX_TxtLineAlignment_Right)) { + } else if (m_iAlignment & CFX_TxtLineAlignment_Center || + m_iAlignment & CFX_TxtLineAlignment_Right) { + if (m_iAlignment & CFX_TxtLineAlignment_Center && + !(m_iAlignment & CFX_TxtLineAlignment_Right)) { iOffset /= 2; } if (iOffset > 0) { @@ -545,21 +533,18 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) { m_iReadyLineIndex = m_pCurLine == &m_Line[0] ? 0 : 1; CFX_BreakLine* pNextLine = &m_Line[1 - m_iReadyLineIndex]; - bool bAllChars = m_iCurAlignment > CFX_TxtLineAlignment_Right; + bool bAllChars = m_iAlignment > CFX_TxtLineAlignment_Right; if (!EndBreak_SplitLine(pNextLine, bAllChars)) { std::deque tpos; EndBreak_BidiLine(&tpos, dwStatus); - if (m_iCurAlignment > CFX_TxtLineAlignment_Left) + if (m_iAlignment > CFX_TxtLineAlignment_Left) EndBreak_Alignment(tpos, bAllChars, dwStatus); } m_pCurLine = pNextLine; CFX_Char* pTC = GetLastChar(0, false); m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown; - if (dwStatus == CFX_BreakType::Paragraph) { - m_iArabicContext = m_iCurArabicContext = 1; - ResetArabicContext(); - } + return dwStatus; } @@ -719,15 +704,6 @@ void CFX_TxtBreak::ClearBreakPieces() { m_iReadyLineIndex = -1; } -void CFX_TxtBreak::Reset() { - m_eCharType = FX_CHARTYPE_Unknown; - m_iArabicContext = 1; - m_iCurArabicContext = 1; - ResetArabicContext(); - m_Line[0].Clear(); - m_Line[1].Clear(); -} - struct FX_FORMCHAR { uint16_t wch; uint16_t wForm; diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h index 0fe4268a0f..439a7ee15b 100644 --- a/xfa/fgas/layout/fgas_textbreak.h +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -67,7 +67,7 @@ class CFX_TxtBreak : public CFX_Break { int32_t CountBreakPieces() const; const CFX_BreakPiece* GetBreakPiece(int32_t index) const; void ClearBreakPieces(); - void Reset(); + int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun, FXTEXT_CHARPOS* pCharPos, bool bCharCode = false, @@ -88,7 +88,6 @@ class CFX_TxtBreak : public CFX_Break { CFX_Char* GetLastChar(int32_t index, bool bOmitChar = true) const; bool HasTxtLine() const { return m_iReadyLineIndex >= 0; } FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const; - void ResetArabicContext() override; void ResetContextCharStyles(); bool EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars); void EndBreak_BidiLine(std::deque* tpos, CFX_BreakType dwStatus); @@ -103,12 +102,8 @@ class CFX_TxtBreak : public CFX_Break { CFX_BreakLine* pNextLine, bool bAllChars = false); - int32_t m_iArabicContext; - int32_t m_iCurArabicContext; int32_t m_iAlignment; - uint32_t m_dwContextCharStyles; int32_t m_iCombWidth; - int32_t m_iCurAlignment; }; #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ -- cgit v1.2.3