xref: /aosp_15_r20/external/pdfium/core/fxcrt/css/cfx_cssrulecollection.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2017 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 CORE_FXCRT_CSS_CFX_CSSRULECOLLECTION_H_
8 #define CORE_FXCRT_CSS_CFX_CSSRULECOLLECTION_H_
9 
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 #include "core/fxcrt/unowned_ptr.h"
15 #include "core/fxcrt/widestring.h"
16 
17 class CFX_CSSDeclaration;
18 class CFX_CSSSelector;
19 class CFX_CSSStyleRule;
20 class CFX_CSSStyleSheet;
21 
22 class CFX_CSSRuleCollection {
23  public:
24   class Data {
25    public:
26     Data(CFX_CSSSelector* pSel, CFX_CSSDeclaration* pDecl);
27     ~Data();
28 
29     UnownedPtr<CFX_CSSSelector> const pSelector;
30     UnownedPtr<CFX_CSSDeclaration> const pDeclaration;
31   };
32 
33   CFX_CSSRuleCollection();
34   ~CFX_CSSRuleCollection();
35 
36   void SetRulesFromSheet(const CFX_CSSStyleSheet* sheet);
37 
38   const std::vector<std::unique_ptr<Data>>* GetTagRuleData(
39       const WideString& tagname) const;
40 
41  private:
42   void AddRule(CFX_CSSStyleRule* pRule);
43 
44   std::map<uint32_t, std::vector<std::unique_ptr<Data>>> m_TagRules;
45 };
46 
47 #endif  // CORE_FXCRT_CSS_CFX_CSSRULECOLLECTION_H_
48