K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2014 The PDFium Authors |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 7 | #include "xfa/fxfa/cxfa_ffapp.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 8 | |
dsinclair | 447b1f3 | 2016-12-08 10:06:32 -0800 | [diff] [blame] | 9 | #include "xfa/fwl/cfwl_notedriver.h" |
| 10 | #include "xfa/fwl/cfwl_widgetmgr.h" |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 11 | #include "xfa/fxfa/cxfa_ffdoc.h" |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 12 | #include "xfa/fxfa/cxfa_ffwidgethandler.h" |
| 13 | #include "xfa/fxfa/cxfa_fontmgr.h" |
Dan Sinclair | 24ef633 | 2017-07-24 10:52:57 -0400 | [diff] [blame] | 14 | #include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h" |
| 15 | #include "xfa/fxfa/cxfa_fwltheme.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 16 | |
Tom Sepez | dc3718f | 2021-06-09 01:01:29 +0000 | [diff] [blame] | 17 | CXFA_FFApp::CXFA_FFApp(CallbackIface* pProvider) : m_pProvider(pProvider) { |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 18 | // Ensure fully initialized before making objects based on |this|. |
Tom Sepez | a7edf06 | 2020-09-09 22:48:17 +0000 | [diff] [blame] | 19 | m_pXFAFontMgr = cppgc::MakeGarbageCollected<CXFA_FontMgr>( |
| 20 | GetHeap()->GetAllocationHandle()); |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 21 | m_pFWLApp = cppgc::MakeGarbageCollected<CFWL_App>( |
| 22 | GetHeap()->GetAllocationHandle(), this); |
Tom Sepez | cc20513 | 2017-05-16 14:01:47 -0700 | [diff] [blame] | 23 | } |
tsepez | 0aae2a7 | 2016-05-18 14:01:15 -0700 | [diff] [blame] | 24 | |
Lei Zhang | 0e744a2 | 2020-06-02 00:44:28 +0000 | [diff] [blame] | 25 | CXFA_FFApp::~CXFA_FFApp() = default; |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 26 | |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 27 | void CXFA_FFApp::Trace(cppgc::Visitor* visitor) const { |
Tom Sepez | a7edf06 | 2020-09-09 22:48:17 +0000 | [diff] [blame] | 28 | visitor->Trace(m_pXFAFontMgr); |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 29 | visitor->Trace(m_pAdapterWidgetMgr); |
| 30 | visitor->Trace(m_pFWLTheme); |
| 31 | visitor->Trace(m_pFWLApp); |
| 32 | } |
| 33 | |
Tom Sepez | a911672 | 2020-08-13 22:18:18 +0000 | [diff] [blame] | 34 | bool CXFA_FFApp::LoadFWLTheme(CXFA_FFDoc* doc) { |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 35 | auto* fwl_theme = cppgc::MakeGarbageCollected<CXFA_FWLTheme>( |
Tom Sepez | 53f083a7 | 2020-10-12 23:33:27 +0000 | [diff] [blame] | 36 | GetHeap()->GetAllocationHandle(), GetHeap(), this); |
Tom Sepez | a911672 | 2020-08-13 22:18:18 +0000 | [diff] [blame] | 37 | if (!fwl_theme->LoadCalendarFont(doc)) |
| 38 | return false; |
| 39 | |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 40 | m_pFWLTheme = fwl_theme; |
Tom Sepez | a911672 | 2020-08-13 22:18:18 +0000 | [diff] [blame] | 41 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 42 | } |
weili | b4d1b57 | 2016-08-10 14:50:48 -0700 | [diff] [blame] | 43 | |
Tom Sepez | 1289953 | 2019-05-30 00:06:33 +0000 | [diff] [blame] | 44 | CFWL_WidgetMgr::AdapterIface* CXFA_FFApp::GetWidgetMgrAdapter() { |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 45 | if (!m_pAdapterWidgetMgr) { |
| 46 | m_pAdapterWidgetMgr = cppgc::MakeGarbageCollected<CXFA_FWLAdapterWidgetMgr>( |
| 47 | GetHeap()->GetAllocationHandle()); |
| 48 | } |
| 49 | return m_pAdapterWidgetMgr; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 50 | } |
weili | b4d1b57 | 2016-08-10 14:50:48 -0700 | [diff] [blame] | 51 | |
Tom Sepez | 8a5699d | 2020-10-13 21:23:53 +0000 | [diff] [blame] | 52 | CFX_Timer::HandlerIface* CXFA_FFApp::GetTimerHandler() { |
Tom Sepez | 3e5e563e | 2019-08-12 17:54:25 +0000 | [diff] [blame] | 53 | return m_pProvider->GetTimerHandler(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 54 | } |
Tom Sepez | a911672 | 2020-08-13 22:18:18 +0000 | [diff] [blame] | 55 | |
| 56 | IFWL_ThemeProvider* CXFA_FFApp::GetThemeProvider() { |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 57 | return m_pFWLTheme; |
Tom Sepez | a911672 | 2020-08-13 22:18:18 +0000 | [diff] [blame] | 58 | } |
Tom Sepez | 6602876 | 2020-08-18 20:35:37 +0000 | [diff] [blame] | 59 | |
| 60 | cppgc::Heap* CXFA_FFApp::GetHeap() { |
| 61 | return m_pProvider->GetGCHeap(); |
| 62 | } |