• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 PDFium Authors. All rights reserved.
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_FDE_CSS_CFDE_CSSRULECOLLECTION_H_
8 #define XFA_FDE_CSS_CFDE_CSSRULECOLLECTION_H_
9 
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 #include "core/fxcrt/fx_basic.h"
15 
16 class CFDE_CSSDeclaration;
17 class CFDE_CSSSelector;
18 class CFDE_CSSStyleRule;
19 class CFDE_CSSStyleSheet;
20 class CFGAS_FontMgr;
21 
22 class CFDE_CSSRuleCollection {
23  public:
24   class Data {
25    public:
26     Data(CFDE_CSSSelector* pSel, CFDE_CSSDeclaration* pDecl);
27 
28     CFDE_CSSSelector* const pSelector;
29     CFDE_CSSDeclaration* const pDeclaration;
30   };
31 
32   CFDE_CSSRuleCollection();
33   ~CFDE_CSSRuleCollection();
34 
35   void AddRulesFrom(const CFDE_CSSStyleSheet* sheet, CFGAS_FontMgr* pFontMgr);
36   void Clear();
CountSelectors()37   int32_t CountSelectors() const { return m_iSelectors; }
38 
39   const std::vector<std::unique_ptr<Data>>* GetTagRuleData(
40       const CFX_WideString& tagname) const;
41 
42  private:
43   void AddRulesFrom(const CFDE_CSSStyleSheet* pStyleSheet,
44                     CFDE_CSSStyleRule* pRule,
45                     CFGAS_FontMgr* pFontMgr);
46 
47   std::map<uint32_t, std::vector<std::unique_ptr<Data>>> m_TagRules;
48   int32_t m_iSelectors;
49 };
50 
51 #endif  // XFA_FDE_CSS_CFDE_CSSRULECOLLECTION_H_
52