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

Side by Side Diff: xfa/fwl/core/fwl_noteimp.cpp

Issue 2505703003: Cleaning up nits in fwl/core files. (Closed)
Patch Set: Created 4 years, 1 month 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
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 "xfa/fwl/core/fwl_noteimp.h" 7 #include "xfa/fwl/core/fwl_noteimp.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 #include "third_party/base/ptr_util.h" 10 #include "third_party/base/ptr_util.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 MouseSecondary(static_cast<CFWL_MsgMouse*>(pMessage)); 225 MouseSecondary(static_cast<CFWL_MsgMouse*>(pMessage));
226 return true; 226 return true;
227 } 227 }
228 return false; 228 return false;
229 } 229 }
230 230
231 bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, 231 bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
232 IFWL_Widget* pMessageForm) { 232 IFWL_Widget* pMessageForm) {
233 bool bRet = false; 233 bool bRet = false;
234 switch (pMessage->GetClassID()) { 234 switch (pMessage->GetClassID()) {
235 case CFWL_MessageType::Activate: {
236 bRet = DoActivate(static_cast<CFWL_MsgActivate*>(pMessage), pMessageForm);
237 break;
238 }
239 case CFWL_MessageType::Deactivate: {
240 bRet = DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage),
241 pMessageForm);
242 break;
243 }
244 case CFWL_MessageType::SetFocus: { 235 case CFWL_MessageType::SetFocus: {
245 bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm); 236 bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm);
246 break; 237 break;
247 } 238 }
248 case CFWL_MessageType::KillFocus: { 239 case CFWL_MessageType::KillFocus: {
249 bRet = 240 bRet =
250 DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm); 241 DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm);
251 break; 242 break;
252 } 243 }
253 case CFWL_MessageType::Key: { 244 case CFWL_MessageType::Key: {
254 bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm); 245 bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm);
255 break; 246 break;
256 } 247 }
257 case CFWL_MessageType::Mouse: { 248 case CFWL_MessageType::Mouse: {
258 bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm); 249 bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm);
259 break; 250 break;
260 } 251 }
261 case CFWL_MessageType::MouseWheel: { 252 case CFWL_MessageType::MouseWheel: {
262 bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm); 253 bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm);
263 break; 254 break;
264 } 255 }
265 case CFWL_MessageType::Size: {
266 bRet = DoSize(static_cast<CFWL_MsgSize*>(pMessage));
267 break;
268 }
269 case CFWL_MessageType::Cursor: {
270 bRet = true;
271 break;
272 }
273 case CFWL_MessageType::WindowMove: {
274 bRet = DoWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage),
275 pMessageForm);
276 break;
277 }
278 case CFWL_MessageType::DropFiles: {
279 bRet =
280 DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm);
281 break;
282 }
283 default: { 256 default: {
284 bRet = true; 257 bRet = true;
285 break; 258 break;
286 } 259 }
287 } 260 }
288 if (bRet) { 261 if (bRet) {
289 if (IFWL_WidgetDelegate* pDelegate = 262 if (IFWL_WidgetDelegate* pDelegate =
290 pMessage->m_pDstTarget->GetDelegate()) { 263 pMessage->m_pDstTarget->GetDelegate()) {
291 pDelegate->OnProcessMessage(pMessage); 264 pDelegate->OnProcessMessage(pMessage);
292 } 265 }
293 } 266 }
294 return bRet; 267 return bRet;
295 } 268 }
296 269
297 bool CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg,
298 IFWL_Widget* pMessageForm) {
299 pMsg->m_pDstTarget = pMessageForm;
300 return !!(pMsg->m_pDstTarget->GetStates() & FWL_WGTSTATE_Deactivated);
301 }
302
303 bool CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg,
304 IFWL_Widget* pMessageForm) {
305 int32_t iTrackLoop = m_noteLoopQueue.GetSize();
306 if (iTrackLoop <= 0)
307 return false;
308 if (iTrackLoop == 1) {
309 if (pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
310 return false;
311 }
312 if (pMsg->m_pSrcTarget &&
313 pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
314 return false;
315 }
316 if (pMsg->m_pSrcTarget &&
317 pMsg->m_pSrcTarget->GetClassID() == FWL_Type::ToolTip) {
318 return false;
319 }
320 return true;
321 }
322 IFWL_Widget* pDst = pMsg->m_pDstTarget;
323 if (!pDst)
324 return false;
325 #if (_FX_OS_ == _FX_MACOSX_)
326 if (pDst == pMessageForm && pDst->IsInstance(L"FWL_FORMPROXY")) {
327 return true;
328 }
329 #endif
330 return pDst != pMessageForm &&
331 !pDst->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")) &&
332 !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"));
333 }
334 bool CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg, 270 bool CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg,
335 IFWL_Widget* pMessageForm) { 271 IFWL_Widget* pMessageForm) {
336 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 272 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
337 if (pWidgetMgr->IsFormDisabled()) { 273 if (pWidgetMgr->IsFormDisabled()) {
338 m_pFocus = pMsg->m_pDstTarget; 274 m_pFocus = pMsg->m_pDstTarget;
339 return true; 275 return true;
340 } 276 }
341 IFWL_Widget* pWidget = pMsg->m_pDstTarget; 277 IFWL_Widget* pWidget = pMsg->m_pDstTarget;
342 if (pWidget) { 278 if (pWidget) {
343 IFWL_Form* pForm = static_cast<IFWL_Form*>(pWidget); 279 IFWL_Form* pForm = static_cast<IFWL_Form*>(pWidget);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 373
438 IFWL_Widget* pDst = 374 IFWL_Widget* pDst =
439 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); 375 pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
440 if (!pDst) 376 if (!pDst)
441 return false; 377 return false;
442 378
443 pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy); 379 pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
444 pMsg->m_pDstTarget = pDst; 380 pMsg->m_pDstTarget = pDst;
445 return true; 381 return true;
446 } 382 }
447 bool CFWL_NoteDriver::DoSize(CFWL_MsgSize* pMsg) { 383
448 CFWL_WidgetMgr* pWidgetMgr =
449 pMsg->m_pDstTarget->GetOwnerApp()->GetWidgetMgr();
450 if (!pWidgetMgr)
451 return false;
452 pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth,
453 (FX_FLOAT)pMsg->m_iHeight);
454 return true;
455 }
456 bool CFWL_NoteDriver::DoWindowMove(CFWL_MsgWindowMove* pMsg,
457 IFWL_Widget* pMessageForm) {
458 return pMsg->m_pDstTarget == pMessageForm;
459 }
460 bool CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg,
461 IFWL_Widget* pMessageForm) {
462 return pMsg->m_pDstTarget == pMessageForm;
463 }
464 bool CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg, 384 bool CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg,
465 IFWL_Widget* pMessageForm) { 385 IFWL_Widget* pMessageForm) {
466 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); 386 CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
467 if (!pWidgetMgr) 387 if (!pWidgetMgr)
468 return false; 388 return false;
469 IFWL_Widget* pTarget = nullptr; 389 IFWL_Widget* pTarget = nullptr;
470 if (m_pGrab) 390 if (m_pGrab)
471 pTarget = m_pGrab; 391 pTarget = m_pGrab;
472 if (!pTarget) { 392 if (!pTarget) {
473 pTarget = 393 pTarget =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 m_pHover = pTarget; 425 m_pHover = pTarget;
506 CFWL_MsgMouse msHover; 426 CFWL_MsgMouse msHover;
507 msHover.m_pDstTarget = pTarget; 427 msHover.m_pDstTarget = pTarget;
508 msHover.m_fx = pMsg->m_fx; 428 msHover.m_fx = pMsg->m_fx;
509 msHover.m_fy = pMsg->m_fy; 429 msHover.m_fy = pMsg->m_fy;
510 msHover.m_dwFlags = 0; 430 msHover.m_dwFlags = 0;
511 msHover.m_dwCmd = FWL_MouseCommand::Hover; 431 msHover.m_dwCmd = FWL_MouseCommand::Hover;
512 DispatchMessage(&msHover, nullptr); 432 DispatchMessage(&msHover, nullptr);
513 } 433 }
514 bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { 434 bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
515 if (pMessage->GetClassID() == CFWL_MessageType::Post)
516 return true;
517
518 int32_t iCount = m_noteLoopQueue.GetSize(); 435 int32_t iCount = m_noteLoopQueue.GetSize();
519 for (int32_t i = 0; i < iCount; i++) { 436 for (int32_t i = 0; i < iCount; i++) {
520 CFWL_NoteLoop* pNoteLoop = static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[i]); 437 CFWL_NoteLoop* pNoteLoop = static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[i]);
521 IFWL_Widget* pForm = pNoteLoop->GetForm(); 438 IFWL_Widget* pForm = pNoteLoop->GetForm();
522 if (pForm && (pForm == pMessage->m_pDstTarget)) 439 if (pForm && (pForm == pMessage->m_pDstTarget))
523 return true; 440 return true;
524 } 441 }
525 iCount = m_forms.GetSize(); 442 iCount = m_forms.GetSize();
526 for (int32_t j = 0; j < iCount; j++) { 443 for (int32_t j = 0; j < iCount; j++) {
527 IFWL_Form* pForm = static_cast<IFWL_Form*>(m_forms[j]); 444 IFWL_Form* pForm = static_cast<IFWL_Form*>(m_forms[j]);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 return false; 501 return false;
585 if (m_eventSources.GetCount() == 0) { 502 if (m_eventSources.GetCount() == 0) {
586 pDelegate->OnProcessEvent(pEvent); 503 pDelegate->OnProcessEvent(pEvent);
587 return true; 504 return true;
588 } 505 }
589 FX_POSITION pos = m_eventSources.GetStartPosition(); 506 FX_POSITION pos = m_eventSources.GetStartPosition();
590 while (pos) { 507 while (pos) {
591 IFWL_Widget* pSource = nullptr; 508 IFWL_Widget* pSource = nullptr;
592 uint32_t dwFilter = 0; 509 uint32_t dwFilter = 0;
593 m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); 510 m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter);
594 if (pSource == pEvent->m_pSrcTarget || 511 if (pSource == pEvent->m_pSrcTarget) {
595 pEvent->GetClassID() == CFWL_EventType::Idle) {
596 if (IsFilterEvent(pEvent, dwFilter)) { 512 if (IsFilterEvent(pEvent, dwFilter)) {
597 pDelegate->OnProcessEvent(pEvent); 513 pDelegate->OnProcessEvent(pEvent);
598 return true; 514 return true;
599 } 515 }
600 } 516 }
601 } 517 }
602 return false; 518 return false;
603 } 519 }
604 520
605 bool CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, 521 bool CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent,
606 uint32_t dwFilter) const { 522 uint32_t dwFilter) const {
607 if (dwFilter == FWL_EVENT_ALL_MASK) 523 if (dwFilter == FWL_EVENT_ALL_MASK)
608 return true; 524 return true;
609 525
610 switch (pEvent->GetClassID()) { 526 switch (pEvent->GetClassID()) {
611 case CFWL_EventType::Mouse: 527 case CFWL_EventType::Mouse:
612 return !!(dwFilter & FWL_EVENT_MOUSE_MASK); 528 return !!(dwFilter & FWL_EVENT_MOUSE_MASK);
613 case CFWL_EventType::MouseWheel: 529 case CFWL_EventType::MouseWheel:
614 return !!(dwFilter & FWL_EVENT_MOUSEWHEEL_MASK); 530 return !!(dwFilter & FWL_EVENT_MOUSEWHEEL_MASK);
615 case CFWL_EventType::Key: 531 case CFWL_EventType::Key:
616 return !!(dwFilter & FWL_EVENT_KEY_MASK); 532 return !!(dwFilter & FWL_EVENT_KEY_MASK);
617 case CFWL_EventType::SetFocus: 533 case CFWL_EventType::SetFocus:
618 case CFWL_EventType::KillFocus: 534 case CFWL_EventType::KillFocus:
619 return !!(dwFilter & FWL_EVENT_FOCUSCHANGED_MASK); 535 return !!(dwFilter & FWL_EVENT_FOCUSCHANGED_MASK);
620 case CFWL_EventType::Draw:
621 return !!(dwFilter & FWL_EVENT_DRAW_MASK);
622 case CFWL_EventType::Close: 536 case CFWL_EventType::Close:
623 return !!(dwFilter & FWL_EVENT_CLOSE_MASK); 537 return !!(dwFilter & FWL_EVENT_CLOSE_MASK);
624 case CFWL_EventType::SizeChanged: 538 case CFWL_EventType::SizeChanged:
625 return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK); 539 return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK);
626 case CFWL_EventType::Idle:
627 return !!(dwFilter & FWL_EVENT_IDLE_MASK);
628 default: 540 default:
629 return !!(dwFilter & FWL_EVENT_CONTROL_MASK); 541 return !!(dwFilter & FWL_EVENT_CONTROL_MASK);
630 } 542 }
631 } 543 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698