Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_cssrulecollection.cpp
Go to the documentation of this file.
1// Copyright 2016 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 "core/fxcrt/css/cfx_cssrulecollection.h"
8
9#include <algorithm>
10#include <utility>
11
12#include "core/fxcrt/css/cfx_cssdeclaration.h"
13#include "core/fxcrt/css/cfx_cssselector.h"
14#include "core/fxcrt/css/cfx_cssstylerule.h"
15#include "core/fxcrt/css/cfx_cssstylesheet.h"
16#include "core/fxcrt/css/cfx_csssyntaxparser.h"
17
19
21
23CFX_CSSRuleCollection::GetTagRuleData(const WideString& tagname) const {
24 auto it = m_TagRules.find(FX_HashCode_GetLoweredW(tagname.AsStringView()));
25 return it != m_TagRules.end() ? &it->second : nullptr;
26}
27
29 m_TagRules.clear();
30 for (size_t i = 0; i < sheet->CountRules(); ++i)
31 AddRule(sheet->GetRule(i));
32}
33
34void CFX_CSSRuleCollection::AddRule(CFX_CSSStyleRule* pStyleRule) {
35 CFX_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
36 size_t nSelectors = pStyleRule->CountSelectorLists();
37 for (size_t i = 0; i < nSelectors; ++i) {
38 CFX_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
39 m_TagRules[pSelector->name_hash()].push_back(
40 std::make_unique<Data>(pSelector, pDeclaration));
41 }
42}
43
47
48CFX_CSSRuleCollection::Data::~Data() = default;
Data(CFX_CSSSelector *pSel, CFX_CSSDeclaration *pDecl)
const std::vector< std::unique_ptr< Data > > * GetTagRuleData(const WideString &tagname) const
void SetRulesFromSheet(const CFX_CSSStyleSheet *sheet)
CFX_CSSDeclaration * GetDeclaration()