xref: /aosp_15_r20/external/pdfium/xfa/fxfa/cxfa_ffapp.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2014 The PDFium Authors
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 
7 #include "xfa/fxfa/cxfa_ffapp.h"
8 
9 #include "xfa/fwl/cfwl_notedriver.h"
10 #include "xfa/fwl/cfwl_widgetmgr.h"
11 #include "xfa/fxfa/cxfa_ffdoc.h"
12 #include "xfa/fxfa/cxfa_ffwidgethandler.h"
13 #include "xfa/fxfa/cxfa_fontmgr.h"
14 #include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
15 #include "xfa/fxfa/cxfa_fwltheme.h"
16 
CXFA_FFApp(CallbackIface * pProvider)17 CXFA_FFApp::CXFA_FFApp(CallbackIface* pProvider) : m_pProvider(pProvider) {
18   // Ensure fully initialized before making objects based on |this|.
19   m_pXFAFontMgr = cppgc::MakeGarbageCollected<CXFA_FontMgr>(
20       GetHeap()->GetAllocationHandle());
21   m_pFWLApp = cppgc::MakeGarbageCollected<CFWL_App>(
22       GetHeap()->GetAllocationHandle(), this);
23 }
24 
25 CXFA_FFApp::~CXFA_FFApp() = default;
26 
Trace(cppgc::Visitor * visitor) const27 void CXFA_FFApp::Trace(cppgc::Visitor* visitor) const {
28   visitor->Trace(m_pXFAFontMgr);
29   visitor->Trace(m_pAdapterWidgetMgr);
30   visitor->Trace(m_pFWLTheme);
31   visitor->Trace(m_pFWLApp);
32 }
33 
LoadFWLTheme(CXFA_FFDoc * doc)34 bool CXFA_FFApp::LoadFWLTheme(CXFA_FFDoc* doc) {
35   auto* fwl_theme = cppgc::MakeGarbageCollected<CXFA_FWLTheme>(
36       GetHeap()->GetAllocationHandle(), GetHeap(), this);
37   if (!fwl_theme->LoadCalendarFont(doc))
38     return false;
39 
40   m_pFWLTheme = fwl_theme;
41   return true;
42 }
43 
GetWidgetMgrAdapter()44 CFWL_WidgetMgr::AdapterIface* CXFA_FFApp::GetWidgetMgrAdapter() {
45   if (!m_pAdapterWidgetMgr) {
46     m_pAdapterWidgetMgr = cppgc::MakeGarbageCollected<CXFA_FWLAdapterWidgetMgr>(
47         GetHeap()->GetAllocationHandle());
48   }
49   return m_pAdapterWidgetMgr;
50 }
51 
GetTimerHandler()52 CFX_Timer::HandlerIface* CXFA_FFApp::GetTimerHandler() {
53   return m_pProvider->GetTimerHandler();
54 }
55 
GetThemeProvider()56 IFWL_ThemeProvider* CXFA_FFApp::GetThemeProvider() {
57   return m_pFWLTheme;
58 }
59 
GetHeap()60 cppgc::Heap* CXFA_FFApp::GetHeap() {
61   return m_pProvider->GetGCHeap();
62 }
63