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

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

Issue 1887703003: Fold the FWL NoteThread classes up to the Thread classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
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_widgetimp.h" 7 #include "xfa/fwl/core/fwl_widgetimp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return static_cast<CFWL_WidgetImp*>(GetImpl()) 127 return static_cast<CFWL_WidgetImp*>(GetImpl())
128 ->SetThemeProvider(pThemeProvider); 128 ->SetThemeProvider(pThemeProvider);
129 } 129 }
130 FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) { 130 FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) {
131 return static_cast<CFWL_WidgetImp*>(GetImpl()) 131 return static_cast<CFWL_WidgetImp*>(GetImpl())
132 ->SetDataProvider(pDataProvider); 132 ->SetDataProvider(pDataProvider);
133 } 133 }
134 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { 134 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
135 return static_cast<CFWL_WidgetImp*>(GetImpl())->SetDelegate(pDelegate); 135 return static_cast<CFWL_WidgetImp*>(GetImpl())->SetDelegate(pDelegate);
136 } 136 }
137 IFWL_NoteThread* IFWL_Widget::GetOwnerThread() const { 137 IFWL_Thread* IFWL_Widget::GetOwnerThread() const {
138 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerThread(); 138 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerThread();
139 } 139 }
140 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { 140 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) {
141 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); 141 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent);
142 } 142 }
143 FWL_ERR CFWL_WidgetImp::Initialize() { 143 FWL_ERR CFWL_WidgetImp::Initialize() {
144 IFWL_App* pApp = FWL_GetApp(); 144 IFWL_App* pApp = FWL_GetApp();
145 if (!pApp) 145 if (!pApp)
146 return FWL_ERR_Indefinite; 146 return FWL_ERR_Indefinite;
147 IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative(); 147 IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative();
148 if (!pAdapter) 148 if (!pAdapter)
149 return FWL_ERR_Indefinite; 149 return FWL_ERR_Indefinite;
150 IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr(); 150 IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr();
151 if (!pAdapterThread) 151 if (!pAdapterThread)
152 return FWL_ERR_Indefinite; 152 return FWL_ERR_Indefinite;
153 SetOwnerThread(static_cast<CFWL_NoteThreadImp*>( 153 SetOwnerThread(static_cast<CFWL_ThreadImp*>(
154 pAdapterThread->GetCurrentThread()->GetImpl())); 154 pAdapterThread->GetCurrentThread()->GetImpl()));
155 IFWL_Widget* pParent = m_pProperties->m_pParent; 155 IFWL_Widget* pParent = m_pProperties->m_pParent;
156 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); 156 m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
157 if (!IsChild()) { 157 if (!IsChild()) {
158 { 158 {
159 IFWL_Widget* pOwner = m_pProperties->m_pOwner; 159 IFWL_Widget* pOwner = m_pProperties->m_pOwner;
160 if (pOwner) { 160 if (pOwner) {
161 m_pWidgetMgr->SetOwner(pOwner, m_pInterface); 161 m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
162 } 162 }
163 } 163 }
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 if (!m_pCurDelegate) { 490 if (!m_pCurDelegate) {
491 m_pCurDelegate = m_pDelegate; 491 m_pCurDelegate = m_pDelegate;
492 } 492 }
493 if (!pDelegate) { 493 if (!pDelegate) {
494 return m_pCurDelegate; 494 return m_pCurDelegate;
495 } 495 }
496 IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; 496 IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate;
497 m_pCurDelegate = pDelegate; 497 m_pCurDelegate = pDelegate;
498 return pOldDelegate; 498 return pOldDelegate;
499 } 499 }
500 IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const { 500 IFWL_Thread* CFWL_WidgetImp::GetOwnerThread() const {
501 return static_cast<IFWL_NoteThread*>(m_pOwnerThread->GetInterface()); 501 return static_cast<IFWL_Thread*>(m_pOwnerThread->GetInterface());
502 } 502 }
503 FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread) { 503 FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_ThreadImp* pOwnerThread) {
504 m_pOwnerThread = pOwnerThread; 504 m_pOwnerThread = pOwnerThread;
505 return FWL_ERR_Succeeded; 505 return FWL_ERR_Succeeded;
506 } 506 }
507 IFWL_Widget* CFWL_WidgetImp::GetInterface() const { 507 IFWL_Widget* CFWL_WidgetImp::GetInterface() const {
508 return m_pInterface; 508 return m_pInterface;
509 } 509 }
510 void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) { 510 void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) {
511 m_pInterface = pInterface; 511 m_pInterface = pInterface;
512 } 512 }
513 CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, 513 CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 CFWL_ThemeText calPart; 675 CFWL_ThemeText calPart;
676 calPart.m_pWidget = m_pInterface; 676 calPart.m_pWidget = m_pInterface;
677 calPart.m_wsText = wsText; 677 calPart.m_wsText = wsText;
678 calPart.m_dwTTOStyles = dwTTOStyles; 678 calPart.m_dwTTOStyles = dwTTOStyles;
679 calPart.m_iTTOAlign = iTTOAlign; 679 calPart.m_iTTOAlign = iTTOAlign;
680 pTheme->CalcTextRect(&calPart, rect); 680 pTheme->CalcTextRect(&calPart, rect);
681 } 681 }
682 void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) { 682 void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) {
683 if (m_pWidgetMgr->IsFormDisabled()) 683 if (m_pWidgetMgr->IsFormDisabled())
684 return; 684 return;
685 IFWL_NoteThread* pThread = GetOwnerThread(); 685 IFWL_Thread* pThread = GetOwnerThread();
686 if (!pThread) 686 if (!pThread)
687 return; 687 return;
688 CFWL_NoteDriver* pDriver = 688 CFWL_NoteDriver* pDriver =
689 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); 689 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
690 if (!pDriver) 690 if (!pDriver)
691 return; 691 return;
692 IFWL_Widget* curFocus = pDriver->GetFocus(); 692 IFWL_Widget* curFocus = pDriver->GetFocus();
693 if (bFocus && curFocus != m_pInterface) { 693 if (bFocus && curFocus != m_pInterface) {
694 pDriver->SetFocus(m_pInterface); 694 pDriver->SetFocus(m_pInterface);
695 } else if (!bFocus && curFocus == m_pInterface) { 695 } else if (!bFocus && curFocus == m_pInterface) {
696 pDriver->SetFocus(NULL); 696 pDriver->SetFocus(NULL);
697 } 697 }
698 } 698 }
699 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { 699 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) {
700 IFWL_NoteThread* pThread = GetOwnerThread(); 700 IFWL_Thread* pThread = GetOwnerThread();
701 if (!pThread) 701 if (!pThread)
702 return; 702 return;
703 CFWL_NoteDriver* pDriver = 703 CFWL_NoteDriver* pDriver =
704 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); 704 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
705 pDriver->SetGrab(m_pInterface, bSet); 705 pDriver->SetGrab(m_pInterface, bSet);
706 } 706 }
707 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight, 707 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight,
708 FX_FLOAT fMaxHeight, 708 FX_FLOAT fMaxHeight,
709 const CFX_RectF& rtAnchor, 709 const CFX_RectF& rtAnchor,
710 CFX_RectF& rtPopup) { 710 CFX_RectF& rtPopup) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 rtPopup.height); 806 rtPopup.height);
807 } 807 }
808 rtPopup.Offset(fx, fy); 808 rtPopup.Offset(fx, fy);
809 return TRUE; 809 return TRUE;
810 } 810 }
811 FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) { 811 FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) {
812 return FALSE; 812 return FALSE;
813 } 813 }
814 void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource, 814 void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource,
815 uint32_t dwFilter) { 815 uint32_t dwFilter) {
816 IFWL_NoteThread* pThread = GetOwnerThread(); 816 IFWL_Thread* pThread = GetOwnerThread();
817 if (!pThread) 817 if (!pThread)
818 return; 818 return;
819 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); 819 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
820 if (!pNoteDriver) 820 if (!pNoteDriver)
821 return; 821 return;
822 pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter); 822 pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter);
823 } 823 }
824 void CFWL_WidgetImp::UnregisterEventTarget() { 824 void CFWL_WidgetImp::UnregisterEventTarget() {
825 IFWL_NoteThread* pThread = GetOwnerThread(); 825 IFWL_Thread* pThread = GetOwnerThread();
826 if (!pThread) 826 if (!pThread)
827 return; 827 return;
828 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); 828 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
829 if (!pNoteDriver) 829 if (!pNoteDriver)
830 return; 830 return;
831 pNoteDriver->UnregisterEventTarget(m_pInterface); 831 pNoteDriver->UnregisterEventTarget(m_pInterface);
832 } 832 }
833 void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) { 833 void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) {
834 if (!pNote) 834 if (!pNote)
835 return; 835 return;
836 CFWL_EvtKey* pEvent = new CFWL_EvtKey; 836 CFWL_EvtKey* pEvent = new CFWL_EvtKey;
837 pEvent->m_pSrcTarget = m_pInterface; 837 pEvent->m_pSrcTarget = m_pInterface;
838 pEvent->m_dwCmd = pNote->m_dwCmd; 838 pEvent->m_dwCmd = pNote->m_dwCmd;
839 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; 839 pEvent->m_dwKeyCode = pNote->m_dwKeyCode;
840 pEvent->m_dwFlags = pNote->m_dwFlags; 840 pEvent->m_dwFlags = pNote->m_dwFlags;
841 DispatchEvent(pEvent); 841 DispatchEvent(pEvent);
842 pEvent->Release(); 842 pEvent->Release();
843 } 843 }
844 void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { 844 void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) {
845 if (m_pOuter) { 845 if (m_pOuter) {
846 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL); 846 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL);
847 pDelegate->OnProcessEvent(pEvent); 847 pDelegate->OnProcessEvent(pEvent);
848 return; 848 return;
849 } 849 }
850 IFWL_NoteThread* pThread = GetOwnerThread(); 850 IFWL_Thread* pThread = GetOwnerThread();
851 if (!pThread) 851 if (!pThread)
852 return; 852 return;
853 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); 853 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
854 if (!pNoteDriver) 854 if (!pNoteDriver)
855 return; 855 return;
856 pNoteDriver->SendNote(pEvent); 856 pNoteDriver->SendNote(pEvent);
857 } 857 }
858 void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { 858 void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) {
859 if (pRect) { 859 if (pRect) {
860 m_pWidgetMgr->RepaintWidget(m_pInterface, pRect); 860 m_pWidgetMgr->RepaintWidget(m_pInterface, pRect);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 param.m_pWidget = m_pInterface; 907 param.m_pWidget = m_pInterface;
908 param.m_iPart = iPartEdge; 908 param.m_iPart = iPartEdge;
909 param.m_pGraphics = pGraphics; 909 param.m_pGraphics = pGraphics;
910 if (pMatrix) { 910 if (pMatrix) {
911 param.m_matrix.Concat(*pMatrix, TRUE); 911 param.m_matrix.Concat(*pMatrix, TRUE);
912 } 912 }
913 param.m_rtPart = rtEdge; 913 param.m_rtPart = rtEdge;
914 pTheme->DrawBackground(&param); 914 pTheme->DrawBackground(&param);
915 } 915 }
916 void CFWL_WidgetImp::NotifyDriver() { 916 void CFWL_WidgetImp::NotifyDriver() {
917 IFWL_NoteThread* pThread = GetOwnerThread(); 917 IFWL_Thread* pThread = GetOwnerThread();
918 if (!pThread) 918 if (!pThread)
919 return; 919 return;
920 CFWL_NoteDriver* pDriver = 920 CFWL_NoteDriver* pDriver =
921 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); 921 static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
922 if (!pDriver) 922 if (!pDriver)
923 return; 923 return;
924 pDriver->NotifyTargetDestroy(m_pInterface); 924 pDriver->NotifyTargetDestroy(m_pInterface);
925 } 925 }
926 CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) { 926 CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) {
927 if (pParent == GetInterface()) 927 if (pParent == GetInterface())
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 } 1022 }
1023 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { 1023 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
1024 return FWL_ERR_Succeeded; 1024 return FWL_ERR_Succeeded;
1025 } 1025 }
1026 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 1026 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
1027 const CFX_Matrix* pMatrix) { 1027 const CFX_Matrix* pMatrix) {
1028 CFWL_EvtDraw evt; 1028 CFWL_EvtDraw evt;
1029 evt.m_pGraphics = pGraphics; 1029 evt.m_pGraphics = pGraphics;
1030 return FWL_ERR_Succeeded; 1030 return FWL_ERR_Succeeded;
1031 } 1031 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698