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

Side by Side Diff: fpdfsdk/cpdfsdk_annothandlermgr.cpp

Issue 2368403002: Watch destruction of widgets around OnAAction() method (Closed)
Patch Set: blown merge Created 4 years, 2 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 | fpdfsdk/cpdfsdk_baannothandler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "fpdfsdk/include/cpdfsdk_annothandlermgr.h" 7 #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h"
8 8
9 #include "core/fpdfdoc/include/cpdf_annot.h" 9 #include "core/fpdfdoc/include/cpdf_annot.h"
10 #include "fpdfsdk/include/cba_annotiterator.h" 10 #include "fpdfsdk/include/cba_annotiterator.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 CFX_RenderDevice* pDevice, 97 CFX_RenderDevice* pDevice,
98 CFX_Matrix* pUser2Device, 98 CFX_Matrix* pUser2Device,
99 bool bDrawAnnots) { 99 bool bDrawAnnots) {
100 ASSERT(pAnnot); 100 ASSERT(pAnnot);
101 GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, 101 GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, pUser2Device,
102 bDrawAnnots); 102 bDrawAnnots);
103 } 103 }
104 104
105 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( 105 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(
106 CPDFSDK_PageView* pPageView, 106 CPDFSDK_PageView* pPageView,
107 CPDFSDK_Annot* pAnnot, 107 CPDFSDK_Annot::ObservedPtr* pAnnot,
108 uint32_t nFlags, 108 uint32_t nFlags,
109 const CFX_FloatPoint& point) { 109 const CFX_FloatPoint& point) {
110 ASSERT(pAnnot); 110 ASSERT(*pAnnot);
111 return GetAnnotHandler(pAnnot)->OnLButtonDown(pPageView, pAnnot, nFlags, 111 return GetAnnotHandler(pAnnot->Get())
112 point); 112 ->OnLButtonDown(pPageView, pAnnot, nFlags, point);
113 } 113 }
114 114
115 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp( 115 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(
116 CPDFSDK_PageView* pPageView, 116 CPDFSDK_PageView* pPageView,
117 CPDFSDK_Annot* pAnnot, 117 CPDFSDK_Annot::ObservedPtr* pAnnot,
118 uint32_t nFlags, 118 uint32_t nFlags,
119 const CFX_FloatPoint& point) { 119 const CFX_FloatPoint& point) {
120 ASSERT(pAnnot); 120 ASSERT(*pAnnot);
121 return GetAnnotHandler(pAnnot)->OnLButtonUp(pPageView, pAnnot, nFlags, point); 121 return GetAnnotHandler(pAnnot->Get())
122 ->OnLButtonUp(pPageView, pAnnot, nFlags, point);
122 } 123 }
123 124
124 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( 125 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(
125 CPDFSDK_PageView* pPageView, 126 CPDFSDK_PageView* pPageView,
126 CPDFSDK_Annot* pAnnot, 127 CPDFSDK_Annot::ObservedPtr* pAnnot,
127 uint32_t nFlags, 128 uint32_t nFlags,
128 const CFX_FloatPoint& point) { 129 const CFX_FloatPoint& point) {
129 ASSERT(pAnnot); 130 ASSERT(*pAnnot);
130 return GetAnnotHandler(pAnnot)->OnLButtonDblClk(pPageView, pAnnot, nFlags, 131 return GetAnnotHandler(pAnnot->Get())
131 point); 132 ->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
132 } 133 }
133 134
134 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove( 135 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(
135 CPDFSDK_PageView* pPageView, 136 CPDFSDK_PageView* pPageView,
136 CPDFSDK_Annot* pAnnot, 137 CPDFSDK_Annot::ObservedPtr* pAnnot,
137 uint32_t nFlags, 138 uint32_t nFlags,
138 const CFX_FloatPoint& point) { 139 const CFX_FloatPoint& point) {
139 ASSERT(pAnnot); 140 ASSERT(*pAnnot);
140 return GetAnnotHandler(pAnnot)->OnMouseMove(pPageView, pAnnot, nFlags, point); 141 return GetAnnotHandler(pAnnot->Get())
142 ->OnMouseMove(pPageView, pAnnot, nFlags, point);
141 } 143 }
142 144
143 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel( 145 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(
144 CPDFSDK_PageView* pPageView, 146 CPDFSDK_PageView* pPageView,
145 CPDFSDK_Annot* pAnnot, 147 CPDFSDK_Annot::ObservedPtr* pAnnot,
146 uint32_t nFlags, 148 uint32_t nFlags,
147 short zDelta, 149 short zDelta,
148 const CFX_FloatPoint& point) { 150 const CFX_FloatPoint& point) {
149 ASSERT(pAnnot); 151 ASSERT(*pAnnot);
150 return GetAnnotHandler(pAnnot)->OnMouseWheel(pPageView, pAnnot, nFlags, 152 return GetAnnotHandler(pAnnot->Get())
151 zDelta, point); 153 ->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
152 } 154 }
153 155
154 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( 156 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(
155 CPDFSDK_PageView* pPageView, 157 CPDFSDK_PageView* pPageView,
156 CPDFSDK_Annot* pAnnot, 158 CPDFSDK_Annot::ObservedPtr* pAnnot,
157 uint32_t nFlags, 159 uint32_t nFlags,
158 const CFX_FloatPoint& point) { 160 const CFX_FloatPoint& point) {
159 ASSERT(pAnnot); 161 ASSERT(*pAnnot);
160 return GetAnnotHandler(pAnnot)->OnRButtonDown(pPageView, pAnnot, nFlags, 162 return GetAnnotHandler(pAnnot->Get())
161 point); 163 ->OnRButtonDown(pPageView, pAnnot, nFlags, point);
162 } 164 }
163 165
164 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp( 166 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(
165 CPDFSDK_PageView* pPageView, 167 CPDFSDK_PageView* pPageView,
166 CPDFSDK_Annot* pAnnot, 168 CPDFSDK_Annot::ObservedPtr* pAnnot,
167 uint32_t nFlags, 169 uint32_t nFlags,
168 const CFX_FloatPoint& point) { 170 const CFX_FloatPoint& point) {
169 ASSERT(pAnnot); 171 ASSERT(*pAnnot);
170 return GetAnnotHandler(pAnnot)->OnRButtonUp(pPageView, pAnnot, nFlags, point); 172 return GetAnnotHandler(pAnnot->Get())
173 ->OnRButtonUp(pPageView, pAnnot, nFlags, point);
171 } 174 }
172 175
173 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, 176 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(
174 CPDFSDK_Annot* pAnnot, 177 CPDFSDK_PageView* pPageView,
175 uint32_t nFlag) { 178 CPDFSDK_Annot::ObservedPtr* pAnnot,
176 ASSERT(pAnnot); 179 uint32_t nFlag) {
177 GetAnnotHandler(pAnnot)->OnMouseEnter(pPageView, pAnnot, nFlag); 180 ASSERT(*pAnnot);
181 GetAnnotHandler(pAnnot->Get())->OnMouseEnter(pPageView, pAnnot, nFlag);
178 } 182 }
179 183
180 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView, 184 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(
181 CPDFSDK_Annot* pAnnot, 185 CPDFSDK_PageView* pPageView,
182 uint32_t nFlag) { 186 CPDFSDK_Annot::ObservedPtr* pAnnot,
183 ASSERT(pAnnot); 187 uint32_t nFlag) {
184 GetAnnotHandler(pAnnot)->OnMouseExit(pPageView, pAnnot, nFlag); 188 ASSERT(*pAnnot);
189 GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag);
185 } 190 }
186 191
187 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, 192 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot,
188 uint32_t nChar, 193 uint32_t nChar,
189 uint32_t nFlags) { 194 uint32_t nFlags) {
190 return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags); 195 return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags);
191 } 196 }
192 197
193 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, 198 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
194 int nKeyCode, 199 int nKeyCode,
195 int nFlag) { 200 int nFlag) {
196 if (m_pEnv->IsCTRLKeyDown(nFlag) || m_pEnv->IsALTKeyDown(nFlag)) 201 if (m_pEnv->IsCTRLKeyDown(nFlag) || m_pEnv->IsALTKeyDown(nFlag))
197 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag); 202 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag);
198 203
199 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); 204 CPDFSDK_PageView* pPage = pAnnot->GetPageView();
200 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); 205 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot();
201 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { 206 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) {
202 CPDFSDK_Annot* pNext = 207 CPDFSDK_Annot::ObservedPtr pNext(
203 GetNextAnnot(pFocusAnnot, !m_pEnv->IsSHIFTKeyDown(nFlag)); 208 GetNextAnnot(pFocusAnnot, !m_pEnv->IsSHIFTKeyDown(nFlag)));
204 209 if (pNext && pNext.Get() != pFocusAnnot) {
205 if (pNext && pNext != pFocusAnnot) { 210 pPage->GetSDKDocument()->SetFocusAnnot(&pNext);
206 CPDFSDK_Document* pDocument = pPage->GetSDKDocument();
207 pDocument->SetFocusAnnot(pNext);
208 return TRUE; 211 return TRUE;
209 } 212 }
210 } 213 }
211 214
212 return FALSE; 215 return FALSE;
213 } 216 }
214 217
215 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, 218 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot,
216 int nKeyCode, 219 int nKeyCode,
217 int nFlag) { 220 int nFlag) {
218 return FALSE; 221 return FALSE;
219 } 222 }
220 223
221 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, 224 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(
222 uint32_t nFlag) { 225 CPDFSDK_Annot::ObservedPtr* pAnnot,
223 ASSERT(pAnnot); 226 uint32_t nFlag) {
224 227 ASSERT(*pAnnot);
225 if (!GetAnnotHandler(pAnnot)->OnSetFocus(pAnnot, nFlag)) 228 if (!GetAnnotHandler(pAnnot->Get())->OnSetFocus(pAnnot, nFlag))
226 return FALSE; 229 return FALSE;
227 230
228 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); 231 (*pAnnot)->GetPageView()->GetSDKDocument();
229 pPage->GetSDKDocument();
230 return TRUE; 232 return TRUE;
231 } 233 }
232 234
233 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, 235 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(
234 uint32_t nFlag) { 236 CPDFSDK_Annot::ObservedPtr* pAnnot,
235 ASSERT(pAnnot); 237 uint32_t nFlag) {
236 return GetAnnotHandler(pAnnot)->OnKillFocus(pAnnot, nFlag); 238 ASSERT(*pAnnot);
239 return GetAnnotHandler(pAnnot->Get())->OnKillFocus(pAnnot, nFlag);
237 } 240 }
238 241
239 #ifdef PDF_ENABLE_XFA 242 #ifdef PDF_ENABLE_XFA
240 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( 243 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(
241 CPDFSDK_Annot* pSetAnnot, 244 CPDFSDK_Annot::ObservedPtr* pSetAnnot,
242 CPDFSDK_Annot* pKillAnnot) { 245 CPDFSDK_Annot::ObservedPtr* pKillAnnot) {
243 FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || 246 FX_BOOL bXFA = (*pSetAnnot && (*pSetAnnot)->GetXFAWidget()) ||
244 (pKillAnnot && pKillAnnot->GetXFAWidget()); 247 (*pKillAnnot && (*pKillAnnot)->GetXFAWidget());
245 248
246 if (bXFA) { 249 if (bXFA) {
247 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = 250 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler =
248 GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET)) 251 GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET))
249 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); 252 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot);
250 } 253 }
251 254
252 return TRUE; 255 return TRUE;
253 } 256 }
254 #endif // PDF_ENABLE_XFA 257 #endif // PDF_ENABLE_XFA
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); 302 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious();
300 if (!hNextFocus && pSDKAnnot) 303 if (!hNextFocus && pSDKAnnot)
301 hNextFocus = pWidgetIterator->MoveToFirst(); 304 hNextFocus = pWidgetIterator->MoveToFirst();
302 305
303 return pPageView->GetAnnotByXFAWidget(hNextFocus); 306 return pPageView->GetAnnotByXFAWidget(hNextFocus);
304 #else // PDF_ENABLE_XFA 307 #else // PDF_ENABLE_XFA
305 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET); 308 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET);
306 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); 309 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
307 #endif // PDF_ENABLE_XFA 310 #endif // PDF_ENABLE_XFA
308 } 311 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/cpdfsdk_baannothandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698