xref: /aosp_15_r20/external/pdfium/xfa/fxfa/cxfa_textprovider.h (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 #ifndef XFA_FXFA_CXFA_TEXTPROVIDER_H_
8 #define XFA_FXFA_CXFA_TEXTPROVIDER_H_
9 
10 #include "core/fxcrt/widestring.h"
11 #include "fxjs/gc/heap.h"
12 #include "third_party/abseil-cpp/absl/types/optional.h"
13 #include "v8/include/cppgc/garbage-collected.h"
14 #include "v8/include/cppgc/member.h"
15 #include "v8/include/cppgc/visitor.h"
16 #include "xfa/fxfa/cxfa_textlayout.h"
17 
18 class CXFA_Font;
19 class CXFA_Node;
20 class CXFA_Para;
21 
22 class CXFA_TextProvider : public cppgc::GarbageCollected<CXFA_TextProvider> {
23  public:
24   enum class Type : uint8_t {
25     kText,
26     kCaption,
27     kRollover,
28     kDown,
29   };
30 
31   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
32   ~CXFA_TextProvider();
33 
34   void Trace(cppgc::Visitor* visitor) const;
35 
36   CXFA_Node* GetTextNode(bool* bRichText);
37   CXFA_Para* GetParaIfExists();
38   CXFA_Font* GetFontIfExists();
39   bool IsCheckButtonAndAutoWidth() const;
40   absl::optional<WideString> GetEmbeddedObj(const WideString& wsAttr) const;
41 
42  private:
43   CXFA_TextProvider(CXFA_Node* pNode, Type eType);
44 
45   cppgc::Member<CXFA_Node> m_pNode;
46   const Type m_eType;
47 };
48 
49 #endif  // XFA_FXFA_CXFA_TEXTPROVIDER_H_
50