summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/css/cfde_cssrulecollection.cpp7
-rw-r--r--xfa/fde/css/cfde_cssrulecollection.h2
-rw-r--r--xfa/fde/css/cfde_cssselector.cpp35
-rw-r--r--xfa/fde/css/cfde_cssstyleselector.cpp33
-rw-r--r--xfa/fde/css/cfde_cssstyleselector.h10
-rw-r--r--xfa/fde/css/cfde_cssstylesheet_unittest.cpp12
-rw-r--r--xfa/fde/css/fde_css.h3
-rw-r--r--xfa/fde/css/fde_cssdatatable.cpp9
-rw-r--r--xfa/fde/css/fde_cssdatatable.h8
9 files changed, 14 insertions, 105 deletions
diff --git a/xfa/fde/css/cfde_cssrulecollection.cpp b/xfa/fde/css/cfde_cssrulecollection.cpp
index 7ef36f2093..db3342cfc6 100644
--- a/xfa/fde/css/cfde_cssrulecollection.cpp
+++ b/xfa/fde/css/cfde_cssrulecollection.cpp
@@ -28,7 +28,7 @@ void CFDE_CSSRuleCollection::Clear() {
}
CFDE_CSSRuleCollection::CFDE_CSSRuleCollection()
- : m_pUniversalRules(nullptr), m_pPseudoRules(nullptr), m_iSelectors(0) {}
+ : m_pUniversalRules(nullptr), m_iSelectors(0) {}
CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() {
Clear();
@@ -48,11 +48,6 @@ void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheet* pStyleSheet,
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;
diff --git a/xfa/fde/css/cfde_cssrulecollection.h b/xfa/fde/css/cfde_cssrulecollection.h
index 87677457e4..03698748e6 100644
--- a/xfa/fde/css/cfde_cssrulecollection.h
+++ b/xfa/fde/css/cfde_cssrulecollection.h
@@ -52,7 +52,6 @@ class CFDE_CSSRuleCollection {
}
Data* GetUniversalRuleData() { return m_pUniversalRules; }
- Data* GetPseudoRuleData() { return m_pPseudoRules; }
private:
void AddRulesFrom(const CFDE_CSSStyleSheet* pStyleSheet,
@@ -69,7 +68,6 @@ class CFDE_CSSRuleCollection {
std::map<uint32_t, Data*> m_TagRules;
std::map<uint32_t, Data*> m_ClassRules;
Data* m_pUniversalRules;
- Data* m_pPseudoRules;
int32_t m_iSelectors;
};
diff --git a/xfa/fde/css/cfde_cssselector.cpp b/xfa/fde/css/cfde_cssselector.cpp
index 4d32bd1cfa..bd800c0fa5 100644
--- a/xfa/fde/css/cfde_cssselector.cpp
+++ b/xfa/fde/css/cfde_cssselector.cpp
@@ -16,19 +16,6 @@ bool IsCSSChar(FX_WCHAR wch) {
return (wch >= 'a' && wch <= 'z') || (wch >= 'A' && wch <= 'Z');
}
-int32_t GetCSSPseudoLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
- ASSERT(*psz == ':');
- const FX_WCHAR* pStart = psz;
- while (psz < pEnd) {
- FX_WCHAR wch = *psz;
- if (IsCSSChar(wch) || wch == ':')
- ++psz;
- else
- break;
- }
- return psz - pStart;
-}
-
int32_t GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
const FX_WCHAR* pStart = psz;
while (psz < pEnd) {
@@ -88,8 +75,6 @@ std::unique_ptr<CFDE_CSSSelector> CFDE_CSSSelector::FromString(
std::unique_ptr<CFDE_CSSSelector> pFirst = nullptr;
CFDE_CSSSelector* pLast = nullptr;
- std::unique_ptr<CFDE_CSSSelector> pPseudoFirst = nullptr;
- CFDE_CSSSelector* pPseudoLast = nullptr;
for (psz = pStart; psz < pEnd;) {
FX_WCHAR wch = *psz;
@@ -134,29 +119,11 @@ std::unique_ptr<CFDE_CSSSelector> CFDE_CSSSelector::FromString(
pFirst = std::move(p);
pLast = pFirst.get();
psz += iNameLen;
- } else if (wch == ':') {
- int32_t iNameLen = GetCSSPseudoLen(psz, pEnd);
- if (iNameLen == 0)
- return nullptr;
-
- auto p = pdfium::MakeUnique<CFDE_CSSSelector>(FDE_CSSSelectorType::Pseudo,
- psz, iNameLen, true);
- CFDE_CSSSelector* ptr = p.get();
- if (pPseudoFirst)
- pPseudoLast->SetNext(std::move(p));
- else
- pPseudoFirst = std::move(p);
- pPseudoLast = ptr;
- psz += iNameLen;
} else if (wch == ' ') {
psz++;
} else {
return nullptr;
}
}
- if (!pPseudoFirst)
- return pFirst;
-
- pPseudoLast->SetNext(std::move(pFirst));
- return pPseudoFirst;
+ return pFirst;
}
diff --git a/xfa/fde/css/cfde_cssstyleselector.cpp b/xfa/fde/css/cfde_cssstyleselector.cpp
index fb2a1e2fbb..c4156c4d49 100644
--- a/xfa/fde/css/cfde_cssstyleselector.cpp
+++ b/xfa/fde/css/cfde_cssstyleselector.cpp
@@ -77,8 +77,7 @@ void CFDE_CSSStyleSelector::UpdateStyleIndex() {
int32_t CFDE_CSSStyleSelector::MatchDeclarations(
CXFA_CSSTagProvider* pTag,
- CFX_ArrayTemplate<CFDE_CSSDeclaration*>& matchedDecls,
- FDE_CSSPseudo ePseudoType) {
+ CFX_ArrayTemplate<CFDE_CSSDeclaration*>& matchedDecls) {
ASSERT(pTag);
CFDE_CSSTagCache* pCache = m_pAccelerator->top();
ASSERT(pCache && pCache->GetTag() == pTag);
@@ -88,21 +87,15 @@ int32_t CFDE_CSSStyleSelector::MatchDeclarations(
if (m_UARules.CountSelectors() == 0)
return 0;
- if (ePseudoType == FDE_CSSPseudo::NONE) {
- MatchRules(pCache, m_UARules.GetUniversalRuleData(), ePseudoType);
- if (pCache->HashTag()) {
- MatchRules(pCache, m_UARules.GetTagRuleData(pCache->HashTag()),
- ePseudoType);
+ MatchRules(pCache, m_UARules.GetUniversalRuleData());
+ if (pCache->HashTag()) {
+ MatchRules(pCache, m_UARules.GetTagRuleData(pCache->HashTag()));
}
int32_t iCount = pCache->CountHashClass();
for (int32_t i = 0; i < iCount; i++) {
pCache->SetClassIndex(i);
- MatchRules(pCache, m_UARules.GetClassRuleData(pCache->HashClass()),
- ePseudoType);
+ MatchRules(pCache, m_UARules.GetClassRuleData(pCache->HashClass()));
}
- } else {
- MatchRules(pCache, m_UARules.GetPseudoRuleData(), ePseudoType);
- }
std::sort(m_MatchedRules.begin(), m_MatchedRules.end(),
[](const CFDE_CSSRuleCollection::Data* p1,
@@ -117,18 +110,16 @@ int32_t CFDE_CSSStyleSelector::MatchDeclarations(
}
void CFDE_CSSStyleSelector::MatchRules(CFDE_CSSTagCache* pCache,
- CFDE_CSSRuleCollection::Data* pList,
- FDE_CSSPseudo ePseudoType) {
+ CFDE_CSSRuleCollection::Data* pList) {
while (pList) {
- if (MatchSelector(pCache, pList->pSelector, ePseudoType))
+ if (MatchSelector(pCache, pList->pSelector))
m_MatchedRules.push_back(pList);
pList = pList->pNext;
}
}
bool CFDE_CSSStyleSelector::MatchSelector(CFDE_CSSTagCache* pCache,
- CFDE_CSSSelector* pSel,
- FDE_CSSPseudo ePseudoType) {
+ CFDE_CSSSelector* pSel) {
uint32_t dwHash;
while (pSel && pCache) {
switch (pSel->GetType()) {
@@ -138,7 +129,7 @@ bool CFDE_CSSStyleSelector::MatchSelector(CFDE_CSSTagCache* pCache,
if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) {
continue;
}
- if (MatchSelector(pCache, pSel->GetNextSelector(), ePseudoType)) {
+ if (MatchSelector(pCache, pSel->GetNextSelector())) {
return true;
}
}
@@ -161,12 +152,6 @@ bool CFDE_CSSStyleSelector::MatchSelector(CFDE_CSSTagCache* pCache,
return false;
}
break;
- case FDE_CSSSelectorType::Pseudo:
- dwHash = FDE_GetCSSPseudoByEnum(ePseudoType)->dwHash;
- if (dwHash != pSel->GetNameHash()) {
- return false;
- }
- break;
default:
ASSERT(false);
break;
diff --git a/xfa/fde/css/cfde_cssstyleselector.h b/xfa/fde/css/cfde_cssstyleselector.h
index 4d6a7c8ed2..6eb32aef62 100644
--- a/xfa/fde/css/cfde_cssstyleselector.h
+++ b/xfa/fde/css/cfde_cssstyleselector.h
@@ -41,8 +41,7 @@ class CFDE_CSSStyleSelector {
CFDE_CSSComputedStyle* pParentStyle);
int32_t MatchDeclarations(
CXFA_CSSTagProvider* pTag,
- CFX_ArrayTemplate<CFDE_CSSDeclaration*>& matchedDecls,
- FDE_CSSPseudo ePseudoType = FDE_CSSPseudo::NONE);
+ CFX_ArrayTemplate<CFDE_CSSDeclaration*>& matchedDecls);
void ComputeStyle(CXFA_CSSTagProvider* pTag,
const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount,
@@ -50,11 +49,8 @@ class CFDE_CSSStyleSelector {
private:
void MatchRules(CFDE_CSSTagCache* pCache,
- CFDE_CSSRuleCollection::Data* pList,
- FDE_CSSPseudo ePseudoType);
- bool MatchSelector(CFDE_CSSTagCache* pCache,
- CFDE_CSSSelector* pSel,
- FDE_CSSPseudo ePseudoType);
+ CFDE_CSSRuleCollection::Data* pList);
+ bool MatchSelector(CFDE_CSSTagCache* pCache, CFDE_CSSSelector* pSel);
void AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz,
int32_t iLen);
diff --git a/xfa/fde/css/cfde_cssstylesheet_unittest.cpp b/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
index 1c50f65607..048eeb7c84 100644
--- a/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
+++ b/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
@@ -139,18 +139,6 @@ TEST_F(CFDE_CSSStyleSheetTest, ParseMultipleSelectorsCombined) {
LoadAndVerifyDecl(L"a, b, c { border: 5px; }", {L"a", L"b", L"c"}, 4);
}
-TEST_F(CFDE_CSSStyleSheetTest, ParseWithPseudo) {
- // TODO(dsinclair): I think this is wrong, as the selector just becomes
- // :before and we lose the a?
- LoadAndVerifyDecl(L"a:before { border: 10px; }", {L":before"}, 4);
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseWithSelectorsAndPseudo) {
- // TODO(dsinclair): I think this is wrong as we lose the b on the b:before
- LoadAndVerifyDecl(L"a, b:before, c { border: 1px; }",
- {L"a", L":before", L"c"}, 4);
-}
-
TEST_F(CFDE_CSSStyleSheetTest, ParseBorder) {
LoadAndVerifyDecl(L"a { border: 5px; }", {L"a"}, 4);
VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 5.0, FDE_CSSNumberType::Pixels);
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index 17ef7e46f0..f131f0b34b 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -125,13 +125,10 @@ enum class FDE_CSSProperty : uint8_t {
LAST_MARKER
};
-enum class FDE_CSSPseudo : uint8_t { After, Before, NONE };
-
enum class FDE_CSSSelectorType : uint8_t {
Element = 0,
Descendant,
Class,
- Pseudo,
ID,
};
diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp
index a8a0920afa..d61c610fe9 100644
--- a/xfa/fde/css/fde_cssdatatable.cpp
+++ b/xfa/fde/css/fde_cssdatatable.cpp
@@ -196,15 +196,6 @@ static const FDE_CSSCOLORTABLE g_FDE_CSSColors[] = {
{0xF6EFFF31, 0xff008000},
};
-static const FDE_CSSPseudoTable g_FDE_CSSPseudoType[] = {
- {FDE_CSSPseudo::After, L":after", 0x16EE1FEC},
- {FDE_CSSPseudo::Before, L":before", 0x7DCDDE2D},
-};
-
-const FDE_CSSPseudoTable* FDE_GetCSSPseudoByEnum(FDE_CSSPseudo ePseudo) {
- return g_FDE_CSSPseudoType + static_cast<int>(ePseudo);
-}
-
const FDE_CSSPropertyTable* FDE_GetCSSPropertyByName(
const CFX_WideStringC& wsName) {
ASSERT(!wsName.IsEmpty());
diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h
index a9de83a088..afb0b8502d 100644
--- a/xfa/fde/css/fde_cssdatatable.h
+++ b/xfa/fde/css/fde_cssdatatable.h
@@ -41,12 +41,6 @@ struct FDE_CSSCOLORTABLE {
FX_ARGB dwValue;
};
-struct FDE_CSSPseudoTable {
- FDE_CSSPseudo eName;
- const FX_WCHAR* pszName;
- uint32_t dwHash;
-};
-
const FDE_CSSPropertyTable* FDE_GetCSSPropertyByName(
const CFX_WideStringC& wsName);
const FDE_CSSPropertyTable* FDE_GetCSSPropertyByEnum(FDE_CSSProperty eName);
@@ -59,6 +53,4 @@ const FDE_CSSLengthUnitTable* FDE_GetCSSLengthUnitByName(
const FDE_CSSCOLORTABLE* FDE_GetCSSColorByName(const CFX_WideStringC& wsName);
-const FDE_CSSPseudoTable* FDE_GetCSSPseudoByEnum(FDE_CSSPseudo ePseudo);
-
#endif // XFA_FDE_CSS_FDE_CSSDATATABLE_H_