summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2018-01-03 16:30:43 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-04 20:47:03 +0000
commit492ad362da4953ddcbd5c12a6517aabd1f513454 (patch)
tree6a1d024ce57ee376b50b3561b003e435f137cbc1 /fpdfsdk
parentc560a8c11a6f8ee239e570db8c022ae0fd2a4db5 (diff)
downloadpdfium-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')
-rw-r--r--fpdfsdk/pwl/cpwl_edit_impl.cpp93
-rw-r--r--fpdfsdk/pwl/cpwl_edit_impl.h40
2 files changed, 26 insertions, 107 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();
-}
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h
index 387f6e700d..e0d8324a4c 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.h
+++ b/fpdfsdk/pwl/cpwl_edit_impl.h
@@ -38,36 +38,6 @@ struct CPWL_EditImpl_LineRect {
CFX_FloatRect m_rcLine;
};
-class CPWL_EditImpl_LineRectArray {
- public:
- CPWL_EditImpl_LineRectArray();
- ~CPWL_EditImpl_LineRectArray();
-
- void operator=(CPWL_EditImpl_LineRectArray&& rects);
- void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine);
-
- int32_t GetSize() const;
- CPWL_EditImpl_LineRect* GetAt(int32_t nIndex) const;
-
- private:
- std::vector<std::unique_ptr<CPWL_EditImpl_LineRect>> m_LineRects;
-};
-
-class CPWL_EditImpl_RectArray {
- public:
- CPWL_EditImpl_RectArray();
- ~CPWL_EditImpl_RectArray();
-
- void Clear();
- void Add(const CFX_FloatRect& rect);
-
- int32_t GetSize() const;
- CFX_FloatRect* GetAt(int32_t nIndex) const;
-
- private:
- std::vector<std::unique_ptr<CFX_FloatRect>> m_Rects;
-};
-
class CPWL_EditImpl_Refresh {
public:
CPWL_EditImpl_Refresh();
@@ -76,13 +46,15 @@ class CPWL_EditImpl_Refresh {
void BeginRefresh();
void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect);
void NoAnalyse();
- const CPWL_EditImpl_RectArray* GetRefreshRects() const;
+ std::vector<CFX_FloatRect>* GetRefreshRects();
void EndRefresh();
private:
- CPWL_EditImpl_LineRectArray m_NewLineRects;
- CPWL_EditImpl_LineRectArray m_OldLineRects;
- CPWL_EditImpl_RectArray m_RefreshRects;
+ void Add(const CFX_FloatRect& new_rect);
+
+ std::vector<CPWL_EditImpl_LineRect> m_NewLineRects;
+ std::vector<CPWL_EditImpl_LineRect> m_OldLineRects;
+ std::vector<CFX_FloatRect> m_RefreshRects;
};
class CPWL_EditImpl_Select {