diff options
author | Nicolas Pena <npm@chromium.org> | 2018-01-03 16:30:43 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-04 20:47:03 +0000 |
commit | 492ad362da4953ddcbd5c12a6517aabd1f513454 (patch) | |
tree | 6a1d024ce57ee376b50b3561b003e435f137cbc1 /fpdfsdk/pwl/cpwl_edit_impl.cpp | |
parent | c560a8c11a6f8ee239e570db8c022ae0fd2a4db5 (diff) | |
download | pdfium-492ad362da4953ddcbd5c12a6517aabd1f513454.tar.xz |
Remove unneeded vector implementations from cpwl_edit_impl
Change-Id: I98f3f1773b570dc525618ada997425000e1e4c58
Reviewed-on: https://pdfium-review.googlesource.com/22191
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl/cpwl_edit_impl.cpp')
-rw-r--r-- | fpdfsdk/pwl/cpwl_edit_impl.cpp | 93 |
1 files changed, 20 insertions, 73 deletions
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp index 1b324dc2fc..a2a7b1dddf 100644 --- a/fpdfsdk/pwl/cpwl_edit_impl.cpp +++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp @@ -175,35 +175,38 @@ CPWL_EditImpl_Refresh::CPWL_EditImpl_Refresh() {} CPWL_EditImpl_Refresh::~CPWL_EditImpl_Refresh() {} void CPWL_EditImpl_Refresh::BeginRefresh() { - m_RefreshRects.Clear(); + m_RefreshRects.clear(); m_OldLineRects = std::move(m_NewLineRects); } void CPWL_EditImpl_Refresh::Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect) { - m_NewLineRects.Add(linerange, rect); + m_NewLineRects.emplace_back(CPWL_EditImpl_LineRect(linerange, rect)); } void CPWL_EditImpl_Refresh::NoAnalyse() { - { - for (int32_t i = 0, sz = m_OldLineRects.GetSize(); i < sz; i++) - if (CPWL_EditImpl_LineRect* pOldRect = m_OldLineRects.GetAt(i)) - m_RefreshRects.Add(pOldRect->m_rcLine); - } + for (const auto& lineRect : m_OldLineRects) + Add(lineRect.m_rcLine); - { - for (int32_t i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++) - if (CPWL_EditImpl_LineRect* pNewRect = m_NewLineRects.GetAt(i)) - m_RefreshRects.Add(pNewRect->m_rcLine); - } + for (const auto& lineRect : m_NewLineRects) + Add(lineRect.m_rcLine); } -const CPWL_EditImpl_RectArray* CPWL_EditImpl_Refresh::GetRefreshRects() const { +std::vector<CFX_FloatRect>* CPWL_EditImpl_Refresh::GetRefreshRects() { return &m_RefreshRects; } void CPWL_EditImpl_Refresh::EndRefresh() { - m_RefreshRects.Clear(); + m_RefreshRects.clear(); +} + +void CPWL_EditImpl_Refresh::Add(const CFX_FloatRect& new_rect) { + // Check for overlapped area. + for (const auto& rect : m_RefreshRects) { + if (rect.Contains(new_rect)) + return; + } + m_RefreshRects.emplace_back(CFX_FloatRect(new_rect)); } CPWL_EditImpl_Undo::CPWL_EditImpl_Undo() @@ -1137,10 +1140,9 @@ void CPWL_EditImpl::Refresh() { if (!m_bNotifyFlag) { AutoRestorer<bool> restorer(&m_bNotifyFlag); m_bNotifyFlag = true; - if (const CPWL_EditImpl_RectArray* pRects = - m_Refresh.GetRefreshRects()) { - for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) - m_pNotify->InvalidateRect(pRects->GetAt(i)); + if (std::vector<CFX_FloatRect>* pRects = m_Refresh.GetRefreshRects()) { + for (auto& rect : *pRects) + m_pNotify->InvalidateRect(&rect); } } } @@ -1867,33 +1869,6 @@ ByteString CPWL_EditImpl::GetPDFWordString(int32_t nFontIndex, return sWord; } -CPWL_EditImpl_LineRectArray::CPWL_EditImpl_LineRectArray() {} - -CPWL_EditImpl_LineRectArray::~CPWL_EditImpl_LineRectArray() {} - -void CPWL_EditImpl_LineRectArray::operator=( - CPWL_EditImpl_LineRectArray&& that) { - m_LineRects = std::move(that.m_LineRects); -} - -void CPWL_EditImpl_LineRectArray::Add(const CPVT_WordRange& wrLine, - const CFX_FloatRect& rcLine) { - m_LineRects.push_back( - pdfium::MakeUnique<CPWL_EditImpl_LineRect>(wrLine, rcLine)); -} - -int32_t CPWL_EditImpl_LineRectArray::GetSize() const { - return pdfium::CollectionSize<int32_t>(m_LineRects); -} - -CPWL_EditImpl_LineRect* CPWL_EditImpl_LineRectArray::GetAt( - int32_t nIndex) const { - if (nIndex < 0 || nIndex >= GetSize()) - return nullptr; - - return m_LineRects[nIndex].get(); -} - CPWL_EditImpl_Select::CPWL_EditImpl_Select() {} CPWL_EditImpl_Select::CPWL_EditImpl_Select(const CPVT_WordRange& range) { @@ -1922,31 +1897,3 @@ void CPWL_EditImpl_Select::SetEndPos(const CPVT_WordPlace& end) { bool CPWL_EditImpl_Select::IsEmpty() const { return BeginPos == EndPos; } - -CPWL_EditImpl_RectArray::CPWL_EditImpl_RectArray() {} - -CPWL_EditImpl_RectArray::~CPWL_EditImpl_RectArray() {} - -void CPWL_EditImpl_RectArray::Clear() { - m_Rects.clear(); -} - -void CPWL_EditImpl_RectArray::Add(const CFX_FloatRect& rect) { - // check for overlapped area - for (const auto& pRect : m_Rects) { - if (pRect && pRect->Contains(rect)) - return; - } - m_Rects.push_back(pdfium::MakeUnique<CFX_FloatRect>(rect)); -} - -int32_t CPWL_EditImpl_RectArray::GetSize() const { - return pdfium::CollectionSize<int32_t>(m_Rects); -} - -CFX_FloatRect* CPWL_EditImpl_RectArray::GetAt(int32_t nIndex) const { - if (nIndex < 0 || nIndex >= GetSize()) - return nullptr; - - return m_Rects[nIndex].get(); -} |