From 0d164f894472b364b0673471eda49b5d4f209c96 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 9 Jan 2017 07:28:13 -0800 Subject: Remove CFX_ArrayTemplate from CPWL_Wnd. Review-Url: https://codereview.chromium.org/2619673002 --- fpdfsdk/pdfwindow/PWL_Wnd.cpp | 49 ++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp index c9dc89c07e..d3b3b9b754 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -5,11 +5,13 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include +#include #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" #include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" static std::map& GetPWLTimeMap() { // Leak the object at shutdown. @@ -111,8 +113,8 @@ class CPWL_MsgControl { ~CPWL_MsgControl() { Default(); } void Default() { - m_aMousePath.RemoveAll(); - m_aKeyboardPath.RemoveAll(); + m_aMousePath.clear(); + m_aKeyboardPath.clear(); m_pMainMouseWnd = nullptr; m_pMainKeyboardWnd = nullptr; } @@ -126,14 +128,7 @@ class CPWL_MsgControl { } bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { - if (pWnd) { - for (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++) { - if (m_aMousePath.GetAt(i) == pWnd) - return true; - } - } - - return false; + return pWnd && pdfium::ContainsValue(m_aMousePath, pWnd); } bool IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const { @@ -141,50 +136,38 @@ class CPWL_MsgControl { } bool IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { - if (pWnd) { - for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++) { - if (m_aKeyboardPath.GetAt(i) == pWnd) - return true; - } - } - - return false; + return pWnd && pdfium::ContainsValue(m_aKeyboardPath, pWnd); } void SetFocus(CPWL_Wnd* pWnd) { - m_aKeyboardPath.RemoveAll(); - + m_aKeyboardPath.clear(); if (pWnd) { m_pMainKeyboardWnd = pWnd; - CPWL_Wnd* pParent = pWnd; while (pParent) { - m_aKeyboardPath.Add(pParent); + m_aKeyboardPath.push_back(pParent); pParent = pParent->GetParentWindow(); } - pWnd->OnSetFocus(); } } void KillFocus() { - if (m_aKeyboardPath.GetSize() > 0) - if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) + if (!m_aKeyboardPath.empty()) + if (CPWL_Wnd* pWnd = m_aKeyboardPath[0]) pWnd->OnKillFocus(); m_pMainKeyboardWnd = nullptr; - m_aKeyboardPath.RemoveAll(); + m_aKeyboardPath.clear(); } void SetCapture(CPWL_Wnd* pWnd) { - m_aMousePath.RemoveAll(); - + m_aMousePath.clear(); if (pWnd) { m_pMainMouseWnd = pWnd; - CPWL_Wnd* pParent = pWnd; while (pParent) { - m_aMousePath.Add(pParent); + m_aMousePath.push_back(pParent); pParent = pParent->GetParentWindow(); } } @@ -192,12 +175,12 @@ class CPWL_MsgControl { void ReleaseCapture() { m_pMainMouseWnd = nullptr; - m_aMousePath.RemoveAll(); + m_aMousePath.clear(); } private: - CFX_ArrayTemplate m_aMousePath; - CFX_ArrayTemplate m_aKeyboardPath; + std::vector m_aMousePath; + std::vector m_aKeyboardPath; CPWL_Wnd* m_pCreatedWnd; CPWL_Wnd* m_pMainMouseWnd; CPWL_Wnd* m_pMainKeyboardWnd; -- cgit v1.2.3