summaryrefslogtreecommitdiff
path: root/xfa/fde/css/cfde_cssrulecollection.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-23 13:54:53 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-23 19:48:54 +0000
commit6414b273506f97012f82c8a32c020b483d5df31a (patch)
treef790a25f03e78fe084ee22cb16418d95deaf3dd3 /xfa/fde/css/cfde_cssrulecollection.cpp
parenta0b2d23d1121202d3821291483943a47a3c9e32e (diff)
downloadpdfium-6414b273506f97012f82c8a32c020b483d5df31a.tar.xz
Cleanup CSS parsing
This Cl removes unused CSS parsing code. The only caller of CFDE_CSSStyleSheet::LoadeBuffer is from CXFA_TextParser which provides a static string. So, we know there are no Media rules, Import rules, FontFace rules or Page rules in the input style. These rules are also not allowed in inline styles. This CL removes the supporting code. Change-Id: I3a559352b2dd0769c465cbd3da40d1db5f9577b0 Reviewed-on: https://pdfium-review.googlesource.com/2330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/css/cfde_cssrulecollection.cpp')
-rw-r--r--xfa/fde/css/cfde_cssrulecollection.cpp102
1 files changed, 38 insertions, 64 deletions
diff --git a/xfa/fde/css/cfde_cssrulecollection.cpp b/xfa/fde/css/cfde_cssrulecollection.cpp
index 286f619b68..6f12105d85 100644
--- a/xfa/fde/css/cfde_cssrulecollection.cpp
+++ b/xfa/fde/css/cfde_cssrulecollection.cpp
@@ -11,8 +11,6 @@
#include <memory>
#include "xfa/fde/css/cfde_cssdeclaration.h"
-#include "xfa/fde/css/cfde_cssmediarule.h"
-#include "xfa/fde/css/cfde_cssrule.h"
#include "xfa/fde/css/cfde_cssselector.h"
#include "xfa/fde/css/cfde_cssstylerule.h"
#include "xfa/fde/css/cfde_cssstylesheet.h"
@@ -38,78 +36,54 @@ CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() {
void CFDE_CSSRuleCollection::AddRulesFrom(
const CFX_ArrayTemplate<CFDE_CSSStyleSheet*>& sheets,
- uint32_t dwMediaList,
CFGAS_FontMgr* pFontMgr) {
int32_t iSheets = sheets.GetSize();
for (int32_t i = 0; i < iSheets; ++i) {
CFDE_CSSStyleSheet* pSheet = sheets.GetAt(i);
- if (uint32_t dwMatchMedia = pSheet->GetMediaList() & dwMediaList) {
- int32_t iRules = pSheet->CountRules();
- for (int32_t j = 0; j < iRules; j++) {
- AddRulesFrom(pSheet, pSheet->GetRule(j), dwMatchMedia, pFontMgr);
- }
+ int32_t iRules = pSheet->CountRules();
+ for (int32_t j = 0; j < iRules; j++) {
+ AddRulesFrom(pSheet, pSheet->GetRule(j), pFontMgr);
}
}
}
void CFDE_CSSRuleCollection::AddRulesFrom(CFDE_CSSStyleSheet* pStyleSheet,
- CFDE_CSSRule* pRule,
- uint32_t dwMediaList,
+ CFDE_CSSStyleRule* pStyleRule,
CFGAS_FontMgr* pFontMgr) {
- switch (pRule->GetType()) {
- case FDE_CSSRuleType::Style: {
- CFDE_CSSStyleRule* pStyleRule = static_cast<CFDE_CSSStyleRule*>(pRule);
- CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
- int32_t iSelectors = pStyleRule->CountSelectorLists();
- for (int32_t i = 0; i < iSelectors; ++i) {
- CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
- if (pSelector->GetType() == FDE_CSSSelectorType::Pseudo) {
- Data* pData = NewRuleData(pSelector, pDeclaration);
- AddRuleTo(&m_pPseudoRules, pData);
- continue;
- }
- if (pSelector->GetNameHash() != FDE_CSSUNIVERSALHASH) {
- AddRuleTo(&m_TagRules, pSelector->GetNameHash(), pSelector,
- pDeclaration);
- continue;
- }
- CFDE_CSSSelector* pNext = pSelector->GetNextSelector();
- if (!pNext) {
- Data* pData = NewRuleData(pSelector, pDeclaration);
- AddRuleTo(&m_pUniversalRules, pData);
- continue;
- }
- switch (pNext->GetType()) {
- case FDE_CSSSelectorType::ID:
- AddRuleTo(&m_IDRules, pNext->GetNameHash(), pSelector,
- pDeclaration);
- break;
- case FDE_CSSSelectorType::Class:
- AddRuleTo(&m_ClassRules, pNext->GetNameHash(), pSelector,
- pDeclaration);
- break;
- case FDE_CSSSelectorType::Descendant:
- case FDE_CSSSelectorType::Element:
- AddRuleTo(&m_pUniversalRules, NewRuleData(pSelector, pDeclaration));
- break;
- default:
- ASSERT(false);
- break;
- }
- }
- } break;
- case FDE_CSSRuleType::Media: {
- CFDE_CSSMediaRule* pMediaRule = static_cast<CFDE_CSSMediaRule*>(pRule);
- if (pMediaRule->GetMediaList() & dwMediaList) {
- int32_t iRules = pMediaRule->CountRules();
- for (int32_t i = 0; i < iRules; ++i) {
- AddRulesFrom(pStyleSheet, pMediaRule->GetRule(i), dwMediaList,
- pFontMgr);
- }
- }
- } break;
- default:
- break;
+ CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
+ int32_t iSelectors = pStyleRule->CountSelectorLists();
+ for (int32_t i = 0; i < iSelectors; ++i) {
+ CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
+ if (pSelector->GetType() == FDE_CSSSelectorType::Pseudo) {
+ Data* pData = NewRuleData(pSelector, pDeclaration);
+ AddRuleTo(&m_pPseudoRules, pData);
+ continue;
+ }
+ if (pSelector->GetNameHash() != FDE_CSSUNIVERSALHASH) {
+ AddRuleTo(&m_TagRules, pSelector->GetNameHash(), pSelector, pDeclaration);
+ continue;
+ }
+ CFDE_CSSSelector* pNext = pSelector->GetNextSelector();
+ if (!pNext) {
+ Data* pData = NewRuleData(pSelector, pDeclaration);
+ AddRuleTo(&m_pUniversalRules, pData);
+ continue;
+ }
+ switch (pNext->GetType()) {
+ case FDE_CSSSelectorType::ID:
+ AddRuleTo(&m_IDRules, pNext->GetNameHash(), pSelector, pDeclaration);
+ break;
+ case FDE_CSSSelectorType::Class:
+ AddRuleTo(&m_ClassRules, pNext->GetNameHash(), pSelector, pDeclaration);
+ break;
+ case FDE_CSSSelectorType::Descendant:
+ case FDE_CSSSelectorType::Element:
+ AddRuleTo(&m_pUniversalRules, NewRuleData(pSelector, pDeclaration));
+ break;
+ default:
+ ASSERT(false);
+ break;
+ }
}
}