diff options
author | dsinclair <dsinclair@chromium.org> | 2016-04-21 13:37:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-21 13:37:10 -0700 |
commit | bc1cbabe8d8bfa74d25160c14afa30d5b40df335 (patch) | |
tree | bc8ba8fbf303f863ca62d71f0bad013bd622309a /xfa/fde/css/fde_cssstyleselector.cpp | |
parent | 5d9da0c1255a75dd9b7b2005f8b7d6ae4948feaf (diff) | |
download | pdfium-bc1cbabe8d8bfa74d25160c14afa30d5b40df335.tar.xz |
Remove IFDE_CSSTagProvider.
There is only one subsclass, use that instead. Remove the use of WideStringC
in the API.
BUG=pdfium:468
Review URL: https://codereview.chromium.org/1911843002
Diffstat (limited to 'xfa/fde/css/fde_cssstyleselector.cpp')
-rw-r--r-- | xfa/fde/css/fde_cssstyleselector.cpp | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp index 60283a6628..30502303f4 100644 --- a/xfa/fde/css/fde_cssstyleselector.cpp +++ b/xfa/fde/css/fde_cssstyleselector.cpp @@ -10,6 +10,7 @@ #include "xfa/fde/css/fde_csscache.h" #include "xfa/fde/css/fde_cssdeclaration.h" +#include "xfa/fxfa/app/xfa_textlayout.h" #define FDE_CSSUNIVERSALHASH ('*') @@ -312,20 +313,22 @@ void CFDE_CSSStyleSelector::Reset() { } } int32_t CFDE_CSSStyleSelector::MatchDeclarations( - IFDE_CSSTagProvider* pTag, + CXFA_CSSTagProvider* pTag, CFDE_CSSDeclarationArray& matchedDecls, FDE_CSSPERSUDO ePersudoType) { - FXSYS_assert(m_pAccelerator != NULL && pTag != NULL); + FXSYS_assert(m_pAccelerator && pTag); + FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement(); - FXSYS_assert(pCache != NULL && pCache->GetTag() == pTag); + FXSYS_assert(pCache && pCache->GetTag() == pTag); + matchedDecls.RemoveAt(0, matchedDecls.GetSize()); for (int32_t ePriority = FDE_CSSSTYLESHEETPRIORITY_MAX - 1; ePriority >= 0; --ePriority) { FDE_CSSSTYLESHEETGROUP eGroup = m_ePriorities[ePriority]; CFDE_CSSRuleCollection& rules = m_RuleCollection[eGroup]; - if (rules.CountSelectors() == 0) { + if (rules.CountSelectors() == 0) continue; - } + if (ePersudoType == FDE_CSSPERSUDO_NONE) { MatchRules(pCache, rules.GetUniversalRuleData(), ePersudoType); if (pCache->HashTag()) { @@ -414,45 +417,47 @@ FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache, } void CFDE_CSSStyleSelector::ComputeStyle( - IFDE_CSSTagProvider* pTag, + CXFA_CSSTagProvider* pTag, const IFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount, IFDE_CSSComputedStyle* pDestStyle) { FXSYS_assert(iDeclCount >= 0); FXSYS_assert(pDestStyle); - FX_POSITION pos = pTag->GetFirstAttribute(); - if (pos != NULL) { - if (m_pInlineStyleStore == NULL) { + + static const uint32_t s_dwStyleHash = + FX_HashCode_String_GetW(L"style", 5, TRUE); + static const uint32_t s_dwAlignHash = + FX_HashCode_String_GetW(L"align", 5, TRUE); + + if (!pTag->empty()) { + if (!m_pInlineStyleStore) m_pInlineStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 2048, 0); - } - CFDE_CSSDeclaration* pDecl = NULL; - CFX_WideStringC wsAttri, wsValue; - uint32_t dwAttriHash; - do { - pTag->GetNextAttribute(pos, wsAttri, wsValue); - dwAttriHash = + + CFDE_CSSDeclaration* pDecl = nullptr; + for (auto it : *pTag) { + CFX_WideString wsAttri = it.first; + CFX_WideString wsValue = it.second; + + uint32_t dwAttriHash = FX_HashCode_String_GetW(wsAttri.c_str(), wsAttri.GetLength(), TRUE); - static const uint32_t s_dwStyleHash = - FX_HashCode_String_GetW(L"style", 5, TRUE); - static const uint32_t s_dwAlignHash = - FX_HashCode_String_GetW(L"align", 5, TRUE); if (dwAttriHash == s_dwStyleHash) { - if (pDecl == NULL) { + if (!pDecl) pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; - } + AppendInlineStyle(pDecl, wsValue.c_str(), wsValue.GetLength()); } else if (dwAttriHash == s_dwAlignHash) { - if (pDecl == NULL) { + if (!pDecl) pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; - } + FDE_CSSPROPERTYARGS args; - args.pStringCache = NULL; + args.pStringCache = nullptr; args.pStaticStore = m_pInlineStyleStore; args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign); pDecl->AddProperty(&args, wsValue.c_str(), wsValue.GetLength()); } - } while (pos != NULL); - if (pDecl != NULL) { + } + + if (pDecl) { CFDE_CSSDeclarationArray decls; decls.SetSize(iDeclCount + 1); IFDE_CSSDeclaration** ppInline = decls.GetData(); @@ -466,12 +471,15 @@ void CFDE_CSSStyleSelector::ComputeStyle( return; } } + if (iDeclCount > 0) { - FXSYS_assert(ppDeclArray != NULL); + FXSYS_assert(ppDeclArray); + ApplyDeclarations(TRUE, ppDeclArray, iDeclCount, pDestStyle); ApplyDeclarations(FALSE, ppDeclArray, iDeclCount, pDestStyle); } } + void CFDE_CSSStyleSelector::ApplyDeclarations( FX_BOOL bPriority, const IFDE_CSSDeclaration** ppDeclArray, |