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

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

Issue 2207093005: Use smart pointers for class owned pointers (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: one more change Created 4 years, 4 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 | « xfa/fwl/core/fwl_noteimp.h ('k') | xfa/fwl/core/fwl_widgetimp.h » ('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 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/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "third_party/base/stl_util.h" 10 #include "third_party/base/stl_util.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (!pDriver) 63 if (!pDriver)
64 return; 64 return;
65 65
66 pDriver->SendEvent(&ev); 66 pDriver->SendEvent(&ev);
67 } 67 }
68 CFWL_NoteDriver::CFWL_NoteDriver() 68 CFWL_NoteDriver::CFWL_NoteDriver()
69 : m_pHover(nullptr), 69 : m_pHover(nullptr),
70 m_pFocus(nullptr), 70 m_pFocus(nullptr),
71 m_pGrab(nullptr), 71 m_pGrab(nullptr),
72 m_pNoteLoop(new CFWL_NoteLoop) { 72 m_pNoteLoop(new CFWL_NoteLoop) {
73 PushNoteLoop(m_pNoteLoop); 73 PushNoteLoop(m_pNoteLoop.get());
74 } 74 }
75 CFWL_NoteDriver::~CFWL_NoteDriver() { 75 CFWL_NoteDriver::~CFWL_NoteDriver() {
76 delete m_pNoteLoop;
77 ClearInvalidEventTargets(TRUE); 76 ClearInvalidEventTargets(TRUE);
78 } 77 }
79 78
80 void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { 79 void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) {
81 if (m_eventTargets.empty()) 80 if (m_eventTargets.empty())
82 return; 81 return;
83 82
84 for (const auto& pair : m_eventTargets) { 83 for (const auto& pair : m_eventTargets) {
85 CFWL_EventTarget* pEventTarget = pair.second; 84 CFWL_EventTarget* pEventTarget = pair.second;
86 if (pEventTarget && !pEventTarget->IsInvalid()) 85 if (pEventTarget && !pEventTarget->IsInvalid())
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 auto old = it++; 647 auto old = it++;
649 if (old->second && (bRemoveAll || old->second->IsInvalid())) { 648 if (old->second && (bRemoveAll || old->second->IsInvalid())) {
650 delete old->second; 649 delete old->second;
651 m_eventTargets.erase(old); 650 m_eventTargets.erase(old);
652 } 651 }
653 } 652 }
654 } 653 }
655 654
656 class CFWL_CoreToolTipDP : public IFWL_ToolTipDP { 655 class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
657 public: 656 public:
657 CFWL_CoreToolTipDP(int32_t iInitDelayTime, int32_t iAutoDelayTime);
658
658 // IFWL_ToolTipDP 659 // IFWL_ToolTipDP
659 FWL_Error GetCaption(IFWL_Widget* pWidget, 660 FWL_Error GetCaption(IFWL_Widget* pWidget,
660 CFX_WideString& wsCaption) override; 661 CFX_WideString& wsCaption) override;
661 int32_t GetInitialDelay(IFWL_Widget* pWidget) override; 662 int32_t GetInitialDelay(IFWL_Widget* pWidget) override;
662 int32_t GetAutoPopDelay(IFWL_Widget* pWidget) override; 663 int32_t GetAutoPopDelay(IFWL_Widget* pWidget) override;
663 CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget) override; 664 CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget) override;
664 CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget) override; 665 CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget) override;
665 666
666 CFX_RectF GetAnchor(); 667 CFX_RectF GetAnchor();
667 CFWL_CoreToolTipDP();
668 668
669 CFX_WideString m_wsCaption; 669 CFX_WideString m_wsCaption;
670 int32_t m_nInitDelayTime; 670 int32_t m_nInitDelayTime;
671 int32_t m_nAutoPopDelayTime; 671 int32_t m_nAutoPopDelayTime;
672 CFX_RectF m_fAnchor; 672 CFX_RectF m_fAnchor;
673 }; 673 };
674 674
675 CFWL_CoreToolTipDP::CFWL_CoreToolTipDP() { 675 CFWL_CoreToolTipDP::CFWL_CoreToolTipDP(int32_t iInitDelayTime,
676 m_nInitDelayTime = 500; 676 int32_t iAutoDelayTime)
677 m_nAutoPopDelayTime = 50000; 677 : m_nInitDelayTime(iInitDelayTime), m_nAutoPopDelayTime(iAutoDelayTime) {
678 m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); 678 m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
679 } 679 }
680 680
681 FWL_Error CFWL_CoreToolTipDP::GetCaption(IFWL_Widget* pWidget, 681 FWL_Error CFWL_CoreToolTipDP::GetCaption(IFWL_Widget* pWidget,
682 CFX_WideString& wsCaption) { 682 CFX_WideString& wsCaption) {
683 wsCaption = m_wsCaption; 683 wsCaption = m_wsCaption;
684 return FWL_Error::Succeeded; 684 return FWL_Error::Succeeded;
685 } 685 }
686 686
687 int32_t CFWL_CoreToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { 687 int32_t CFWL_CoreToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK); 766 return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK);
767 case CFWL_EventType::Idle: 767 case CFWL_EventType::Idle:
768 return !!(dwFilter & FWL_EVENT_IDLE_MASK); 768 return !!(dwFilter & FWL_EVENT_IDLE_MASK);
769 default: 769 default:
770 return !!(dwFilter & FWL_EVENT_CONTROL_MASK); 770 return !!(dwFilter & FWL_EVENT_CONTROL_MASK);
771 } 771 }
772 } 772 }
773 773
774 CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = nullptr; 774 CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = nullptr;
775 775
776 CFWL_ToolTipContainer::CFWL_ToolTipContainer() : m_pToolTipImp(nullptr) { 776 CFWL_ToolTipContainer::CFWL_ToolTipContainer()
777 m_ToolTipDp = new CFWL_CoreToolTipDP; 777 : m_pToolTipImp(nullptr), m_pToolTipDp(new CFWL_CoreToolTipDP(0, 2000)) {}
778 m_ToolTipDp->m_nInitDelayTime = 0; 778
779 m_ToolTipDp->m_nAutoPopDelayTime = 2000;
780 }
781 CFWL_ToolTipContainer::~CFWL_ToolTipContainer() { 779 CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
782 if (m_pToolTipImp) { 780 if (m_pToolTipImp) {
783 IFWL_ToolTip* pToolTip = 781 IFWL_ToolTip* pToolTip =
784 static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface()); 782 static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface());
785 pToolTip->Finalize(); 783 pToolTip->Finalize();
786 delete pToolTip; 784 delete pToolTip;
787 } 785 }
788 delete m_ToolTipDp;
789 } 786 }
790 787
791 // static 788 // static
792 CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() { 789 CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() {
793 if (!s_pInstance) 790 if (!s_pInstance)
794 s_pInstance = new CFWL_ToolTipContainer; 791 s_pInstance = new CFWL_ToolTipContainer;
795 return s_pInstance; 792 return s_pInstance;
796 } 793 }
797 794
798 // static 795 // static
799 void CFWL_ToolTipContainer::DeleteInstance() { 796 void CFWL_ToolTipContainer::DeleteInstance() {
800 delete s_pInstance; 797 delete s_pInstance;
801 s_pInstance = nullptr; 798 s_pInstance = nullptr;
802 } 799 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/fwl_noteimp.h ('k') | xfa/fwl/core/fwl_widgetimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698