Chromium Code Reviews| Index: fpdfsdk/fxedit/fxet_edit.cpp |
| diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp |
| index fb219ca16ca18604836df0755b24b75ee1e7e63d..16395961c1219a50f432779f21c421a3c966bcbf 100644 |
| --- a/fpdfsdk/fxedit/fxet_edit.cpp |
| +++ b/fpdfsdk/fxedit/fxet_edit.cpp |
| @@ -769,8 +769,7 @@ void CFXEU_Clear::Undo() { |
| if (m_pEdit) { |
| m_pEdit->SelectNone(); |
| m_pEdit->SetCaret(m_wrSel.BeginPos); |
| - m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, nullptr, nullptr, |
| - FALSE, TRUE); |
| + m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, FALSE, TRUE); |
| m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
| } |
| } |
| @@ -779,21 +778,12 @@ CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, |
| const CPVT_WordPlace& wpOldPlace, |
| const CPVT_WordPlace& wpNewPlace, |
| const CFX_WideString& swText, |
| - int32_t charset, |
| - const CPVT_SecProps* pSecProps, |
| - const CPVT_WordProps* pWordProps) |
| + int32_t charset) |
| : m_pEdit(pEdit), |
| m_wpOld(wpOldPlace), |
| m_wpNew(wpNewPlace), |
| m_swText(swText), |
| - m_nCharset(charset), |
| - m_SecProps(), |
| - m_WordProps() { |
| - if (pSecProps) |
| - m_SecProps = *pSecProps; |
| - if (pWordProps) |
| - m_WordProps = *pWordProps; |
| -} |
| + m_nCharset(charset) {} |
| CFXEU_InsertText::~CFXEU_InsertText() {} |
| @@ -801,8 +791,7 @@ void CFXEU_InsertText::Redo() { |
| if (m_pEdit && IsLast()) { |
| m_pEdit->SelectNone(); |
| m_pEdit->SetCaret(m_wpOld); |
| - m_pEdit->InsertText(m_swText.c_str(), m_nCharset, &m_SecProps, &m_WordProps, |
|
Lei Zhang
2016/07/13 19:35:15
Can you help convince me this is safe to remove?
dsinclair
2016/07/14 14:16:53
CFXEU_InsertText is created in CFX_Edit::InsertTex
|
| - FALSE, TRUE); |
| + m_pEdit->InsertText(m_swText.c_str(), m_nCharset, FALSE, TRUE); |
| } |
| } |
| @@ -1503,11 +1492,10 @@ IPVT_FontMap* CFX_Edit::GetFontMap() { |
| return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; |
| } |
| -void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect, FX_BOOL bPaint) { |
| +void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { |
| m_pVT->SetPlateRect(rect); |
| m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); |
| - if (bPaint) |
| - Paint(); |
| + Paint(); |
| } |
| void CFX_Edit::SetAlignmentH(int32_t nFormat, FX_BOOL bPaint) { |
| @@ -1528,28 +1516,19 @@ void CFX_Edit::SetPasswordChar(uint16_t wSubWord, FX_BOOL bPaint) { |
| Paint(); |
| } |
| -void CFX_Edit::SetLimitChar(int32_t nLimitChar, FX_BOOL bPaint) { |
| +void CFX_Edit::SetLimitChar(int32_t nLimitChar) { |
| m_pVT->SetLimitChar(nLimitChar); |
| - if (bPaint) |
| - Paint(); |
| + Paint(); |
| } |
| -void CFX_Edit::SetCharArray(int32_t nCharArray, FX_BOOL bPaint) { |
| +void CFX_Edit::SetCharArray(int32_t nCharArray) { |
| m_pVT->SetCharArray(nCharArray); |
| - if (bPaint) |
| - Paint(); |
| + Paint(); |
| } |
| -void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint) { |
| +void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace) { |
| m_pVT->SetCharSpace(fCharSpace); |
| - if (bPaint) |
| - Paint(); |
| -} |
| - |
| -void CFX_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint) { |
| - m_pVT->SetHorzScale(nHorzScale); |
| - if (bPaint) |
| - Paint(); |
| + Paint(); |
| } |
| void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine, FX_BOOL bPaint) { |
| @@ -1564,22 +1543,15 @@ void CFX_Edit::SetAutoReturn(FX_BOOL bAuto, FX_BOOL bPaint) { |
| Paint(); |
| } |
| -void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint) { |
| - m_pVT->SetLineLeading(fLineLeading); |
| - if (bPaint) |
| - Paint(); |
| -} |
| - |
| void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto, FX_BOOL bPaint) { |
| m_pVT->SetAutoFontSize(bAuto); |
| if (bPaint) |
| Paint(); |
| } |
| -void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint) { |
| +void CFX_Edit::SetFontSize(FX_FLOAT fFontSize) { |
| m_pVT->SetFontSize(fFontSize); |
| - if (bPaint) |
| - Paint(); |
| + Paint(); |
| } |
| void CFX_Edit::SetAutoScroll(FX_BOOL bAuto, FX_BOOL bPaint) { |
| @@ -1622,8 +1594,7 @@ void CFX_Edit::SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { |
| if (m_SelState.IsExist()) { |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_SelState.BeginPos, m_SelState.EndPos); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretInfo(); |
| } else { |
| ScrollToCaret(); |
| @@ -1762,22 +1733,18 @@ CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange& wr1, |
| return wrRet; |
| } |
| -void CFX_Edit::SetText(const FX_WCHAR* text, |
| - int32_t charset, |
| - const CPVT_SecProps* pSecProps, |
| - const CPVT_WordProps* pWordProps) { |
| - SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); |
| +void CFX_Edit::SetText(const FX_WCHAR* text) { |
| + Empty(); |
| + DoInsertText(CPVT_WordPlace(0, 0, -1), text, DEFAULT_CHARSET); |
| + Paint(); |
| } |
| -FX_BOOL CFX_Edit::InsertWord(uint16_t word, |
| - int32_t charset, |
| - const CPVT_WordProps* pWordProps) { |
| - return InsertWord(word, charset, pWordProps, TRUE, TRUE); |
| +FX_BOOL CFX_Edit::InsertWord(uint16_t word, int32_t charset) { |
| + return InsertWord(word, charset, nullptr, TRUE, TRUE); |
| } |
| -FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps, |
| - const CPVT_WordProps* pWordProps) { |
| - return InsertReturn(pSecProps, pWordProps, TRUE, TRUE); |
| +FX_BOOL CFX_Edit::InsertReturn() { |
| + return InsertReturn(nullptr, nullptr, TRUE, TRUE); |
| } |
| FX_BOOL CFX_Edit::Backspace() { |
| @@ -1792,11 +1759,8 @@ FX_BOOL CFX_Edit::Clear() { |
| return Clear(TRUE, TRUE); |
| } |
| -FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, |
| - int32_t charset, |
| - const CPVT_SecProps* pSecProps, |
| - const CPVT_WordProps* pWordProps) { |
| - return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE); |
| +FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset) { |
| + return InsertText(text, charset, TRUE, TRUE); |
| } |
| FX_FLOAT CFX_Edit::GetFontSize() const { |
| @@ -1864,7 +1828,7 @@ void CFX_Edit::Paint() { |
| if (m_pVT->IsValid()) { |
| RearrangeAll(); |
| ScrollToCaret(); |
| - Refresh(RP_NOANALYSE); |
| + Refresh(); |
| SetCaretOrigin(); |
| SetCaretInfo(); |
| } |
| @@ -1911,8 +1875,7 @@ void CFX_Edit::SelectAll() { |
| SetCaret(m_SelState.EndPos); |
| ScrollToCaret(); |
| - CPVT_WordRange wrVisible = GetVisibleWordRange(); |
| - Refresh(RP_OPTIONAL, &wrVisible); |
| + Refresh(); |
| SetCaretInfo(); |
| } |
| } |
| @@ -1920,9 +1883,8 @@ void CFX_Edit::SelectAll() { |
| void CFX_Edit::SelectNone() { |
| if (m_pVT->IsValid()) { |
| if (m_SelState.IsExist()) { |
| - CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); |
| m_SelState.Default(); |
| - Refresh(RP_OPTIONAL, &wrTemp); |
| + Refresh(); |
| } |
| } |
| } |
| @@ -2015,7 +1977,7 @@ void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { |
| if (m_pVT->IsValid()) { |
| if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { |
| m_ptScrollPos.x = fx; |
| - Refresh(RP_NOANALYSE); |
| + Refresh(); |
| } |
| } |
| } |
| @@ -2027,7 +1989,7 @@ void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { |
| if (m_pVT->IsValid()) { |
| if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { |
| m_ptScrollPos.y = fy; |
| - Refresh(RP_NOANALYSE); |
| + Refresh(); |
| if (m_pNotify) { |
| if (!m_bNotifyFlag) { |
| @@ -2134,9 +2096,7 @@ void CFX_Edit::ScrollToCaret() { |
| } |
| } |
| -void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, |
| - const CPVT_WordRange* pRange1, |
| - const CPVT_WordRange* pRange2) { |
| +void CFX_Edit::Refresh() { |
| if (m_bEnableRefresh && m_pVT->IsValid()) { |
| m_Refresh.BeginRefresh(); |
| RefreshPushLineRects(GetVisibleWordRange()); |
| @@ -2356,8 +2316,7 @@ void CFX_Edit::OnMouseMove(const CFX_FloatPoint& point, |
| m_SelState.SetEndPos(m_wpCaret); |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretOrigin(); |
| SetCaretInfo(); |
| } |
| @@ -2376,8 +2335,7 @@ void CFX_Edit::OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) { |
| if (m_wpOldCaret != m_wpCaret) { |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretInfo(); |
| } |
| } else { |
| @@ -2401,8 +2359,7 @@ void CFX_Edit::OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) { |
| if (m_wpOldCaret != m_wpCaret) { |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretInfo(); |
| } |
| } else { |
| @@ -2430,8 +2387,7 @@ void CFX_Edit::OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) { |
| if (m_wpOldCaret != m_wpCaret) { |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretInfo(); |
| } |
| } else { |
| @@ -2475,8 +2431,7 @@ void CFX_Edit::OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) { |
| if (m_wpOldCaret != m_wpCaret) { |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretInfo(); |
| } |
| } else { |
| @@ -2518,8 +2473,7 @@ void CFX_Edit::OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) { |
| m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretInfo(); |
| } else { |
| if (m_SelState.IsExist()) { |
| @@ -2559,8 +2513,7 @@ void CFX_Edit::OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) { |
| m_SelState.Set(m_wpOldCaret, m_wpCaret); |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
| - Refresh(RP_OPTIONAL, &wr); |
| + Refresh(); |
| SetCaretInfo(); |
| } else { |
| if (m_SelState.IsExist()) { |
| @@ -2586,18 +2539,6 @@ void CFX_Edit::OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) { |
| } |
| } |
| -void CFX_Edit::SetText(const FX_WCHAR* text, |
| - int32_t charset, |
| - const CPVT_SecProps* pSecProps, |
| - const CPVT_WordProps* pWordProps, |
| - FX_BOOL bAddUndo, |
| - FX_BOOL bPaint) { |
| - Empty(); |
| - DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps); |
| - if (bPaint) |
| - Paint(); |
| -} |
| - |
| FX_BOOL CFX_Edit::InsertWord(uint16_t word, |
| int32_t charset, |
| const CPVT_WordProps* pWordProps, |
| @@ -2653,8 +2594,7 @@ FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps, |
| if (bPaint) { |
| RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); |
| ScrollToCaret(); |
| - CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); |
| - Refresh(RP_ANALYSE, &wr); |
| + Refresh(); |
| SetCaretOrigin(); |
| SetCaretInfo(); |
| } |
| @@ -2703,20 +2643,7 @@ FX_BOOL CFX_Edit::Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
| if (bPaint) { |
| RearrangePart(CPVT_WordRange(m_wpCaret, m_wpOldCaret)); |
| ScrollToCaret(); |
| - |
| - CPVT_WordRange wr; |
| - if (m_wpCaret.SecCmp(m_wpOldCaret) != 0) |
| - wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret), |
| - GetVisibleWordRange().EndPos); |
| - else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0) |
| - wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret), |
| - m_pVT->GetSectionEndPlace(m_wpCaret)); |
| - else |
| - wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret), |
| - m_pVT->GetSectionEndPlace(m_wpCaret)); |
| - |
| - Refresh(RP_ANALYSE, &wr); |
| - |
| + Refresh(); |
| SetCaretOrigin(); |
| SetCaretInfo(); |
| } |
| @@ -2766,20 +2693,7 @@ FX_BOOL CFX_Edit::Delete(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
| if (bPaint) { |
| RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); |
| ScrollToCaret(); |
| - |
| - CPVT_WordRange wr; |
| - if (bSecEnd) |
| - wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret), |
| - GetVisibleWordRange().EndPos); |
| - else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0) |
| - wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret), |
| - m_pVT->GetSectionEndPlace(m_wpCaret)); |
| - else |
| - wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret), |
| - m_pVT->GetSectionEndPlace(m_wpCaret)); |
| - |
| - Refresh(RP_ANALYSE, &wr); |
| - |
| + Refresh(); |
| SetCaretOrigin(); |
| SetCaretInfo(); |
| } |
| @@ -2823,10 +2737,7 @@ FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
| if (bPaint) { |
| RearrangePart(range); |
| ScrollToCaret(); |
| - |
| - CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); |
| - Refresh(RP_ANALYSE, &wr); |
| - |
| + Refresh(); |
| SetCaretOrigin(); |
| SetCaretInfo(); |
| } |
| @@ -2839,21 +2750,19 @@ FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
| FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, |
| int32_t charset, |
| - const CPVT_SecProps* pSecProps, |
| - const CPVT_WordProps* pWordProps, |
| FX_BOOL bAddUndo, |
| FX_BOOL bPaint) { |
| if (IsTextOverflow()) |
| return FALSE; |
| m_pVT->UpdateWordPlace(m_wpCaret); |
| - SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps)); |
| + SetCaret(DoInsertText(m_wpCaret, text, charset)); |
| m_SelState.Set(m_wpCaret, m_wpCaret); |
| if (m_wpCaret != m_wpOldCaret) { |
| if (bAddUndo && m_bEnableUndo) { |
| - AddEditUndoItem(new CFXEU_InsertText(this, m_wpOldCaret, m_wpCaret, text, |
| - charset, pSecProps, pWordProps)); |
| + AddEditUndoItem( |
| + new CFXEU_InsertText(this, m_wpOldCaret, m_wpCaret, text, charset)); |
| } |
| if (bPaint) |
| @@ -2872,14 +2781,7 @@ void CFX_Edit::PaintInsertText(const CPVT_WordPlace& wpOld, |
| if (m_pVT->IsValid()) { |
| RearrangePart(CPVT_WordRange(wpOld, wpNew)); |
| ScrollToCaret(); |
| - |
| - CPVT_WordRange wr; |
| - if (m_wpCaret.LineCmp(wpOld) != 0) |
| - wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld), |
| - m_pVT->GetSectionEndPlace(wpNew)); |
| - else |
| - wr = CPVT_WordRange(wpOld, m_pVT->GetSectionEndPlace(wpNew)); |
| - Refresh(RP_ANALYSE, &wr); |
| + Refresh(); |
| SetCaretOrigin(); |
| SetCaretInfo(); |
| } |
| @@ -3045,9 +2947,7 @@ FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const { |
| CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, |
| const FX_WCHAR* text, |
| - int32_t charset, |
| - const CPVT_SecProps* pSecProps, |
| - const CPVT_WordProps* pWordProps) { |
| + int32_t charset) { |
| CPVT_WordPlace wp = place; |
| if (m_pVT->IsValid()) { |
| @@ -3057,12 +2957,12 @@ CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, |
| uint16_t word = sText[i]; |
| switch (word) { |
| case 0x0D: |
| - wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); |
| + wp = m_pVT->InsertSection(wp, nullptr, nullptr); |
| if (sText[i + 1] == 0x0A) |
| i++; |
| break; |
| case 0x0A: |
| - wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); |
| + wp = m_pVT->InsertSection(wp, nullptr, nullptr); |
| if (sText[i + 1] == 0x0D) |
| i++; |
| break; |
| @@ -3070,7 +2970,7 @@ CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, |
| word = 0x20; |
| default: |
| wp = m_pVT->InsertWord(wp, word, GetCharSetFromUnicode(word, charset), |
| - pWordProps); |
| + nullptr); |
| break; |
| } |
| } |