Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: fpdfsdk/pdfwindow/PWL_Wnd.cpp

Issue 2619673002: Remove CFX_ArrayTemplate from CPWL_Wnd. (Closed)
Patch Set: stray Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <map> 7 #include <map>
8 #include <vector>
8 9
9 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" 10 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h"
10 #include "fpdfsdk/pdfwindow/PWL_Utils.h" 11 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
11 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" 12 #include "fpdfsdk/pdfwindow/PWL_Wnd.h"
12 #include "third_party/base/ptr_util.h" 13 #include "third_party/base/ptr_util.h"
14 #include "third_party/base/stl_util.h"
13 15
14 static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() { 16 static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() {
15 // Leak the object at shutdown. 17 // Leak the object at shutdown.
16 static auto timeMap = new std::map<int32_t, CPWL_Timer*>; 18 static auto timeMap = new std::map<int32_t, CPWL_Timer*>;
17 return *timeMap; 19 return *timeMap;
18 } 20 }
19 21
20 PWL_CREATEPARAM::PWL_CREATEPARAM() 22 PWL_CREATEPARAM::PWL_CREATEPARAM()
21 : rcRectWnd(0, 0, 0, 0), 23 : rcRectWnd(0, 0, 0, 0),
22 pSystemHandler(nullptr), 24 pSystemHandler(nullptr),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 106
105 public: 107 public:
106 explicit CPWL_MsgControl(CPWL_Wnd* pWnd) { 108 explicit CPWL_MsgControl(CPWL_Wnd* pWnd) {
107 m_pCreatedWnd = pWnd; 109 m_pCreatedWnd = pWnd;
108 Default(); 110 Default();
109 } 111 }
110 112
111 ~CPWL_MsgControl() { Default(); } 113 ~CPWL_MsgControl() { Default(); }
112 114
113 void Default() { 115 void Default() {
114 m_aMousePath.RemoveAll(); 116 m_aMousePath.clear();
115 m_aKeyboardPath.RemoveAll(); 117 m_aKeyboardPath.clear();
116 m_pMainMouseWnd = nullptr; 118 m_pMainMouseWnd = nullptr;
117 m_pMainKeyboardWnd = nullptr; 119 m_pMainKeyboardWnd = nullptr;
118 } 120 }
119 121
120 bool IsWndCreated(const CPWL_Wnd* pWnd) const { 122 bool IsWndCreated(const CPWL_Wnd* pWnd) const {
121 return m_pCreatedWnd == pWnd; 123 return m_pCreatedWnd == pWnd;
122 } 124 }
123 125
124 bool IsMainCaptureMouse(const CPWL_Wnd* pWnd) const { 126 bool IsMainCaptureMouse(const CPWL_Wnd* pWnd) const {
125 return pWnd == m_pMainMouseWnd; 127 return pWnd == m_pMainMouseWnd;
126 } 128 }
127 129
128 bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { 130 bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const {
129 if (pWnd) { 131 return pWnd && pdfium::ContainsValue(m_aMousePath, pWnd);
130 for (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++) {
131 if (m_aMousePath.GetAt(i) == pWnd)
132 return true;
133 }
134 }
135
136 return false;
137 } 132 }
138 133
139 bool IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const { 134 bool IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const {
140 return pWnd == m_pMainKeyboardWnd; 135 return pWnd == m_pMainKeyboardWnd;
141 } 136 }
142 137
143 bool IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { 138 bool IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
144 if (pWnd) { 139 return pWnd && pdfium::ContainsValue(m_aKeyboardPath, pWnd);
145 for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++) {
146 if (m_aKeyboardPath.GetAt(i) == pWnd)
147 return true;
148 }
149 }
150
151 return false;
152 } 140 }
153 141
154 void SetFocus(CPWL_Wnd* pWnd) { 142 void SetFocus(CPWL_Wnd* pWnd) {
155 m_aKeyboardPath.RemoveAll(); 143 m_aKeyboardPath.clear();
156
157 if (pWnd) { 144 if (pWnd) {
158 m_pMainKeyboardWnd = pWnd; 145 m_pMainKeyboardWnd = pWnd;
159
160 CPWL_Wnd* pParent = pWnd; 146 CPWL_Wnd* pParent = pWnd;
161 while (pParent) { 147 while (pParent) {
162 m_aKeyboardPath.Add(pParent); 148 m_aKeyboardPath.push_back(pParent);
163 pParent = pParent->GetParentWindow(); 149 pParent = pParent->GetParentWindow();
164 } 150 }
165
166 pWnd->OnSetFocus(); 151 pWnd->OnSetFocus();
167 } 152 }
168 } 153 }
169 154
170 void KillFocus() { 155 void KillFocus() {
171 if (m_aKeyboardPath.GetSize() > 0) 156 if (!m_aKeyboardPath.empty())
172 if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) 157 if (CPWL_Wnd* pWnd = m_aKeyboardPath[0])
173 pWnd->OnKillFocus(); 158 pWnd->OnKillFocus();
174 159
175 m_pMainKeyboardWnd = nullptr; 160 m_pMainKeyboardWnd = nullptr;
176 m_aKeyboardPath.RemoveAll(); 161 m_aKeyboardPath.clear();
177 } 162 }
178 163
179 void SetCapture(CPWL_Wnd* pWnd) { 164 void SetCapture(CPWL_Wnd* pWnd) {
180 m_aMousePath.RemoveAll(); 165 m_aMousePath.clear();
181
182 if (pWnd) { 166 if (pWnd) {
183 m_pMainMouseWnd = pWnd; 167 m_pMainMouseWnd = pWnd;
184
185 CPWL_Wnd* pParent = pWnd; 168 CPWL_Wnd* pParent = pWnd;
186 while (pParent) { 169 while (pParent) {
187 m_aMousePath.Add(pParent); 170 m_aMousePath.push_back(pParent);
188 pParent = pParent->GetParentWindow(); 171 pParent = pParent->GetParentWindow();
189 } 172 }
190 } 173 }
191 } 174 }
192 175
193 void ReleaseCapture() { 176 void ReleaseCapture() {
194 m_pMainMouseWnd = nullptr; 177 m_pMainMouseWnd = nullptr;
195 m_aMousePath.RemoveAll(); 178 m_aMousePath.clear();
196 } 179 }
197 180
198 private: 181 private:
199 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath; 182 std::vector<CPWL_Wnd*> m_aMousePath;
200 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath; 183 std::vector<CPWL_Wnd*> m_aKeyboardPath;
201 CPWL_Wnd* m_pCreatedWnd; 184 CPWL_Wnd* m_pCreatedWnd;
202 CPWL_Wnd* m_pMainMouseWnd; 185 CPWL_Wnd* m_pMainMouseWnd;
203 CPWL_Wnd* m_pMainKeyboardWnd; 186 CPWL_Wnd* m_pMainKeyboardWnd;
204 }; 187 };
205 188
206 CPWL_Wnd::CPWL_Wnd() 189 CPWL_Wnd::CPWL_Wnd()
207 : m_pVScrollBar(nullptr), 190 : m_pVScrollBar(nullptr),
208 m_rcWindow(), 191 m_rcWindow(),
209 m_rcClip(), 192 m_rcClip(),
210 m_bCreated(false), 193 m_bCreated(false),
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 return false; 988 return false;
1006 } 989 }
1007 990
1008 bool CPWL_Wnd::IsALTpressed(uint32_t nFlag) const { 991 bool CPWL_Wnd::IsALTpressed(uint32_t nFlag) const {
1009 if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) { 992 if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
1010 return pSystemHandler->IsALTKeyDown(nFlag); 993 return pSystemHandler->IsALTKeyDown(nFlag);
1011 } 994 }
1012 995
1013 return false; 996 return false;
1014 } 997 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698