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 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/fx_string.h" 15 16 class CFX_CSSDeclaration; 17 class CFX_CSSSelector; 18 class CFX_CSSStyleRule; 19 class CFX_CSSStyleSheet; 20 21 class CFX_CSSRuleCollection { 22 public: 23 class Data { 24 public: 25 Data(CFX_CSSSelector* pSel, CFX_CSSDeclaration* pDecl); 26 27 CFX_CSSSelector* const pSelector; 28 CFX_CSSDeclaration* const pDeclaration; 29 }; 30 31 CFX_CSSRuleCollection(); 32 ~CFX_CSSRuleCollection(); 33 34 void AddRulesFrom(const CFX_CSSStyleSheet* sheet); 35 void Clear(); CountSelectors()36 int32_t CountSelectors() const { return m_iSelectors; } 37 38 const std::vector<std::unique_ptr<Data>>* GetTagRuleData( 39 const WideString& tagname) const; 40 41 private: 42 void AddRulesFrom(const CFX_CSSStyleSheet* pStyleSheet, 43 CFX_CSSStyleRule* pRule); 44 45 std::map<uint32_t, std::vector<std::unique_ptr<Data>>> m_TagRules; 46 int32_t m_iSelectors; 47 }; 48 49 #endif // CORE_FXCRT_CSS_CFX_CSSRULECOLLECTION_H_ 50