diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-01-19 10:27:58 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-19 15:49:07 +0000 |
commit | 95bec8046a28928df627ce4d48eee8b209b3e36e (patch) | |
tree | 46913cf24aacfc88a89bb55edcce8e3a2e724c4b /xfa/fde/css/cfde_cssrulecollection.cpp | |
parent | dd533baad22f5143c093b98e98463a0dc62899ea (diff) | |
download | pdfium-95bec8046a28928df627ce4d48eee8b209b3e36e.tar.xz |
Split fde/css files into individual class files.
This CL splits the files in xfa/fde/css into class per file and renames any
needed files to match the class names.
Update some of the classes to use std::stack.
Change-Id: I4eca0fb3556d949a15a873bb0f0fd732f47e4fb1
Reviewed-on: https://pdfium-review.googlesource.com/2253
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fde/css/cfde_cssrulecollection.cpp')
-rw-r--r-- | xfa/fde/css/cfde_cssrulecollection.cpp | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/xfa/fde/css/cfde_cssrulecollection.cpp b/xfa/fde/css/cfde_cssrulecollection.cpp index 5c386effeb..286f619b68 100644 --- a/xfa/fde/css/cfde_cssrulecollection.cpp +++ b/xfa/fde/css/cfde_cssrulecollection.cpp @@ -4,16 +4,20 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fde/css/fde_cssstyleselector.h" +#include "xfa/fde/css/cfde_cssrulecollection.h" #include <algorithm> #include <map> #include <memory> -#include "xfa/fde/css/fde_csscache.h" -#include "xfa/fde/css/fde_cssdeclaration.h" -#include "xfa/fde/css/fde_cssstylesheet.h" -#include "xfa/fde/css/fde_csssyntax.h" +#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" +#include "xfa/fde/css/cfde_csssyntaxparser.h" +#include "xfa/fde/css/cfde_csstagcache.h" #define FDE_CSSUNIVERSALHASH ('*') @@ -60,7 +64,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(CFDE_CSSStyleSheet* pStyleSheet, for (int32_t i = 0; i < iSelectors; ++i) { CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i); if (pSelector->GetType() == FDE_CSSSelectorType::Pseudo) { - FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); + Data* pData = NewRuleData(pSelector, pDeclaration); AddRuleTo(&m_pPseudoRules, pData); continue; } @@ -71,7 +75,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(CFDE_CSSStyleSheet* pStyleSheet, } CFDE_CSSSelector* pNext = pSelector->GetNextSelector(); if (!pNext) { - FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); + Data* pData = NewRuleData(pSelector, pDeclaration); AddRuleTo(&m_pUniversalRules, pData); continue; } @@ -109,13 +113,12 @@ void CFDE_CSSRuleCollection::AddRulesFrom(CFDE_CSSStyleSheet* pStyleSheet, } } -void CFDE_CSSRuleCollection::AddRuleTo( - std::map<uint32_t, FDE_CSSRuleData*>* pMap, - uint32_t dwKey, - CFDE_CSSSelector* pSel, - CFDE_CSSDeclaration* pDecl) { - FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); - FDE_CSSRuleData* pList = (*pMap)[dwKey]; +void CFDE_CSSRuleCollection::AddRuleTo(std::map<uint32_t, Data*>* pMap, + uint32_t dwKey, + CFDE_CSSSelector* pSel, + CFDE_CSSDeclaration* pDecl) { + Data* pData = NewRuleData(pSel, pDecl); + Data* pList = (*pMap)[dwKey]; if (!pList) { (*pMap)[dwKey] = pData; } else if (AddRuleTo(&pList, pData)) { @@ -123,8 +126,7 @@ void CFDE_CSSRuleCollection::AddRuleTo( } } -bool CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData** pList, - FDE_CSSRuleData* pData) { +bool CFDE_CSSRuleCollection::AddRuleTo(Data** pList, Data* pData) { if (*pList) { pData->pNext = (*pList)->pNext; (*pList)->pNext = pData; @@ -134,8 +136,23 @@ bool CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData** pList, return true; } -FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( +CFDE_CSSRuleCollection::Data* CFDE_CSSRuleCollection::NewRuleData( CFDE_CSSSelector* pSel, CFDE_CSSDeclaration* pDecl) { - return new FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors); + return new Data(pSel, pDecl, ++m_iSelectors); +} + +CFDE_CSSRuleCollection::Data::Data(CFDE_CSSSelector* pSel, + CFDE_CSSDeclaration* pDecl, + uint32_t dwPos) + : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(nullptr) { + static const uint32_t s_Specific[5] = {0x00010000, 0x00010000, 0x00100000, + 0x00100000, 0x01000000}; + for (; pSel; pSel = pSel->GetNextSelector()) { + FDE_CSSSelectorType eType = pSel->GetType(); + if (eType > FDE_CSSSelectorType::Descendant || + pSel->GetNameHash() != FDE_CSSUNIVERSALHASH) { + dwPriority += s_Specific[static_cast<int>(eType)]; + } + } } |