summaryrefslogtreecommitdiff
path: root/xfa/fde/css
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde/css')
-rw-r--r--xfa/fde/css/fde_cssdatatable.cpp8
-rw-r--r--xfa/fde/css/fde_cssdatatable.h14
-rw-r--r--xfa/fde/css/fde_cssdeclaration.cpp23
-rw-r--r--xfa/fde/css/fde_cssdeclaration.h6
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp4
-rw-r--r--xfa/fde/css/fde_cssstylesheet.h4
6 files changed, 30 insertions, 29 deletions
diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp
index db4302b9fc..4399053518 100644
--- a/xfa/fde/css/fde_cssdatatable.cpp
+++ b/xfa/fde/css/fde_cssdatatable.cpp
@@ -565,7 +565,7 @@ FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo) {
return (ePersudo < FDE_CSSPERSUDO_NONE) ? (g_FDE_CSSPersudoType + ePersudo)
: NULL;
}
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(
+const FDE_CSSPROPERTYTABLE* FDE_GetCSSPropertyByName(
const CFX_WideStringC& wsName) {
ASSERT(!wsName.IsEmpty());
uint32_t dwHash = FX_HashCode_GetW(wsName, true);
@@ -585,10 +585,10 @@ FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(
} while (iStart <= iEnd);
return NULL;
}
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) {
+const FDE_CSSPROPERTYTABLE* FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) {
return (eName < FDE_CSSPROPERTY_MAX) ? (g_FDE_CSSProperties + eName) : NULL;
}
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
+const FDE_CSSPROPERTYVALUETABLE* FDE_GetCSSPropertyValueByName(
const CFX_WideStringC& wsName) {
ASSERT(!wsName.IsEmpty());
uint32_t dwHash = FX_HashCode_GetW(wsName, true);
@@ -608,7 +608,7 @@ FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
} while (iStart <= iEnd);
return NULL;
}
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum(
+const FDE_CSSPROPERTYVALUETABLE* FDE_GetCSSPropertyValueByEnum(
FDE_CSSPROPERTYVALUE eName) {
return (eName < FDE_CSSPROPERTYVALUE_MAX) ? (g_FDE_CSSPropertyValues + eName)
: NULL;
diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h
index 30e7eb0ee6..2cc6c48fde 100644
--- a/xfa/fde/css/fde_cssdatatable.h
+++ b/xfa/fde/css/fde_cssdatatable.h
@@ -129,27 +129,29 @@ class CFDE_CSSValueListParser : public CFX_Target {
#define FDE_CSSVALUETYPE_MaybeFunction 0x2000
#define FDE_IsOnlyValue(type, enum) \
(((type) & ~(enum)) == FDE_CSSVALUETYPE_Primitive)
+
struct FDE_CSSPROPERTYTABLE {
FDE_CSSPROPERTY eName;
const FX_WCHAR* pszName;
uint32_t dwHash;
uint32_t dwType;
};
-typedef FDE_CSSPROPERTYTABLE const* FDE_LPCCSSPROPERTYTABLE;
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const CFX_WideStringC& wsName);
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName);
+const FDE_CSSPROPERTYTABLE* FDE_GetCSSPropertyByName(
+ const CFX_WideStringC& wsName);
+const FDE_CSSPROPERTYTABLE* FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName);
+
struct FDE_CSSPROPERTYVALUETABLE {
FDE_CSSPROPERTYVALUE eName;
const FX_WCHAR* pszName;
uint32_t dwHash;
};
-typedef FDE_CSSPROPERTYVALUETABLE const* FDE_LPCCSSPROPERTYVALUETABLE;
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
+const FDE_CSSPROPERTYVALUETABLE* FDE_GetCSSPropertyValueByName(
const CFX_WideStringC& wsName);
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum(
+const FDE_CSSPROPERTYVALUETABLE* FDE_GetCSSPropertyValueByEnum(
FDE_CSSPROPERTYVALUE eName);
+
struct FDE_CSSMEDIATYPETABLE {
uint16_t wHash;
uint16_t wValue;
diff --git a/xfa/fde/css/fde_cssdeclaration.cpp b/xfa/fde/css/fde_cssdeclaration.cpp
index f4f55fc0db..570b60c670 100644
--- a/xfa/fde/css/fde_cssdeclaration.cpp
+++ b/xfa/fde/css/fde_cssdeclaration.cpp
@@ -53,26 +53,21 @@ const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal(
const FX_WCHAR* pszValue,
int32_t iValueLen) {
ASSERT(iValueLen > 0);
- CFX_MapPtrToPtr* pCache = pArgs->pStringCache;
- void* pKey = NULL;
+ std::unordered_map<uint32_t, FX_WCHAR*>* pCache = pArgs->pStringCache;
+ uint32_t key = 0;
if (pCache) {
- void* pszCached = NULL;
- pKey = (void*)(uintptr_t)FX_HashCode_GetW(
- CFX_WideStringC(pszValue, iValueLen), false);
- if (pCache->Lookup(pKey, pszCached)) {
- return (const FX_WCHAR*)pszCached;
- }
+ key = FX_HashCode_GetW(CFX_WideStringC(pszValue, iValueLen), false);
+ auto it = pCache->find(key);
+ if (it != pCache->end())
+ return it->second;
}
FX_WCHAR* psz =
(FX_WCHAR*)pArgs->pStaticStore->Alloc((iValueLen + 1) * sizeof(FX_WCHAR));
- if (psz == NULL) {
- return NULL;
- }
FXSYS_wcsncpy(psz, pszValue, iValueLen);
psz[iValueLen] = '\0';
- if (pCache) {
- pCache->SetAt(pKey, psz);
- }
+ if (pCache)
+ (*pCache)[key] = psz;
+
return psz;
}
IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewNumberValue(
diff --git a/xfa/fde/css/fde_cssdeclaration.h b/xfa/fde/css/fde_cssdeclaration.h
index 4fa6858f97..d33e7107c8 100644
--- a/xfa/fde/css/fde_cssdeclaration.h
+++ b/xfa/fde/css/fde_cssdeclaration.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_CSS_FDE_CSSDECLARATION_H_
#define XFA_FDE_CSS_FDE_CSSDECLARATION_H_
+#include <unordered_map>
+
#include "xfa/fde/css/fde_cssdatatable.h"
class FDE_CSSPropertyHolder : public CFX_Target {
@@ -26,8 +28,8 @@ class FDE_CSSCustomProperty : public CFX_Target {
struct FDE_CSSPROPERTYARGS {
IFX_MemoryAllocator* pStaticStore;
- CFX_MapPtrToPtr* pStringCache;
- FDE_LPCCSSPROPERTYTABLE pProperty;
+ std::unordered_map<uint32_t, FX_WCHAR*>* pStringCache;
+ const FDE_CSSPROPERTYTABLE* pProperty;
};
class CFDE_CSSDeclaration : public CFX_Target {
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index b07031c354..dcfd302a58 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -102,7 +102,7 @@ void CFDE_CSSStyleSheet::Reset() {
}
m_RuleArray.RemoveAll();
m_Selectors.RemoveAll();
- m_StringCache.RemoveAll();
+ m_StringCache.clear();
delete m_pAllocator;
m_pAllocator = nullptr;
}
@@ -175,7 +175,7 @@ FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) {
}
} while (eStatus >= FDE_CSSSYNTAXSTATUS_None);
m_Selectors.RemoveAll();
- m_StringCache.RemoveAll();
+ m_StringCache.clear();
return eStatus != FDE_CSSSYNTAXSTATUS_Error;
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h
index a78ae487bb..9362fb15b4 100644
--- a/xfa/fde/css/fde_cssstylesheet.h
+++ b/xfa/fde/css/fde_cssstylesheet.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_
#define XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_
+#include <unordered_map>
+
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
@@ -134,7 +136,7 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
CFDE_CSSRuleArray m_RuleArray;
CFX_WideString m_szUrl;
CFDE_CSSSelectorArray m_Selectors;
- CFX_MapPtrToPtr m_StringCache;
+ std::unordered_map<uint32_t, FX_WCHAR*> m_StringCache;
};
#endif // XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_