Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1074)

Unified Diff: xfa/fde/css/cfde_cssrulecollection.cpp

Issue 2616813002: Remove CFX_MapPtrToPtr from xfa/fde. (Closed)
Patch Set: no FDE_LPC* Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | xfa/fde/css/fde_css.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fde/css/cfde_cssrulecollection.cpp
diff --git a/xfa/fde/css/cfde_cssrulecollection.cpp b/xfa/fde/css/cfde_cssrulecollection.cpp
index 2f91c136286609dc6b3ca210fca53a124361edc4..5a439724a092b16c731f797732d9211b4d091b07 100644
--- a/xfa/fde/css/cfde_cssrulecollection.cpp
+++ b/xfa/fde/css/cfde_cssrulecollection.cpp
@@ -7,6 +7,7 @@
#include "xfa/fde/css/fde_cssstyleselector.h"
#include <algorithm>
+#include <map>
#include <memory>
#include "xfa/fde/css/fde_csscache.h"
@@ -18,9 +19,9 @@
#define FDE_CSSUNIVERSALHASH ('*')
void CFDE_CSSRuleCollection::Clear() {
- m_IDRules.RemoveAll();
- m_TagRules.RemoveAll();
- m_ClassRules.RemoveAll();
+ m_IDRules.clear();
+ m_TagRules.clear();
+ m_ClassRules.clear();
m_pUniversalRules = nullptr;
m_pStaticStore = nullptr;
m_iSelectors = 0;
@@ -29,7 +30,7 @@ void CFDE_CSSRuleCollection::Clear() {
CFDE_CSSRuleCollection::CFDE_CSSRuleCollection()
: m_pStaticStore(nullptr),
m_pUniversalRules(nullptr),
- m_pPersudoRules(nullptr),
+ m_pPseudoRules(nullptr),
m_iSelectors(0) {}
CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() {
@@ -62,33 +63,34 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_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_Persudo) {
+ if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Pseudo) {
FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
- AddRuleTo(m_pPersudoRules, pData);
+ AddRuleTo(&m_pPseudoRules, pData);
continue;
}
if (pSelector->GetNameHash() != FDE_CSSUNIVERSALHASH) {
- AddRuleTo(m_TagRules, pSelector->GetNameHash(), pSelector,
+ AddRuleTo(&m_TagRules, pSelector->GetNameHash(), pSelector,
pDeclaration);
continue;
}
CFDE_CSSSelector* pNext = pSelector->GetNextSelector();
if (!pNext) {
FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
- AddRuleTo(m_pUniversalRules, pData);
+ AddRuleTo(&m_pUniversalRules, pData);
continue;
}
switch (pNext->GetType()) {
case FDE_CSSSELECTORTYPE_ID:
- AddRuleTo(m_IDRules, pNext->GetNameHash(), pSelector, pDeclaration);
+ AddRuleTo(&m_IDRules, pNext->GetNameHash(), pSelector,
+ pDeclaration);
break;
case FDE_CSSSELECTORTYPE_Class:
- AddRuleTo(m_ClassRules, pNext->GetNameHash(), pSelector,
+ AddRuleTo(&m_ClassRules, pNext->GetNameHash(), pSelector,
pDeclaration);
break;
case FDE_CSSSELECTORTYPE_Descendant:
case FDE_CSSSELECTORTYPE_Element:
- AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration));
+ AddRuleTo(&m_pUniversalRules, NewRuleData(pSelector, pDeclaration));
break;
default:
ASSERT(false);
@@ -111,29 +113,28 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
}
}
-void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map,
- uint32_t dwKey,
- CFDE_CSSSelector* pSel,
- CFDE_CSSDeclaration* pDecl) {
- void* pKey = (void*)(uintptr_t)dwKey;
+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 = nullptr;
- if (!map.Lookup(pKey, (void*&)pList)) {
- map.SetAt(pKey, pData);
- } else if (AddRuleTo(pList, pData)) {
- map.SetAt(pKey, pList);
+ FDE_CSSRuleData* pList = (*pMap)[dwKey];
+ if (!pList) {
+ (*pMap)[dwKey] = pData;
+ } else if (AddRuleTo(&pList, pData)) {
+ (*pMap)[dwKey] = pList;
}
}
-bool CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList,
+bool CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData** pList,
FDE_CSSRuleData* pData) {
- if (pList) {
- pData->pNext = pList->pNext;
- pList->pNext = pData;
+ if (*pList) {
+ pData->pNext = (*pList)->pNext;
+ (*pList)->pNext = pData;
return false;
}
-
- pList = pData;
+ *pList = pData;
return true;
}
« no previous file with comments | « no previous file | xfa/fde/css/fde_css.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698