Get rid of bool arg to hashcode functions.
Change-Id: I3a4c9f429457785ace8d23c58bdf8f60ad80f71e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81114
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 0defe22..8046b2a 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -777,26 +777,30 @@
} // namespace fxcrt
-uint32_t FX_HashCode_GetA(ByteStringView str, bool bIgnoreCase) {
+uint32_t FX_HashCode_GetA(ByteStringView str) {
uint32_t dwHashCode = 0;
- if (bIgnoreCase) {
- for (ByteStringView::UnsignedType c : str)
- dwHashCode = 31 * dwHashCode + tolower(c);
- } else {
- for (ByteStringView::UnsignedType c : str)
- dwHashCode = 31 * dwHashCode + c;
- }
+ for (ByteStringView::UnsignedType c : str)
+ dwHashCode = 31 * dwHashCode + c;
return dwHashCode;
}
-uint32_t FX_HashCode_GetAsIfW(ByteStringView str, bool bIgnoreCase) {
+uint32_t FX_HashCode_GetLoweredA(ByteStringView str) {
uint32_t dwHashCode = 0;
- if (bIgnoreCase) {
- for (ByteStringView::UnsignedType c : str)
- dwHashCode = 1313 * dwHashCode + FXSYS_towlower(c);
- } else {
- for (ByteStringView::UnsignedType c : str)
- dwHashCode = 1313 * dwHashCode + c;
- }
+ for (ByteStringView::UnsignedType c : str)
+ dwHashCode = 31 * dwHashCode + tolower(c);
+ return dwHashCode;
+}
+
+uint32_t FX_HashCode_GetAsIfW(ByteStringView str) {
+ uint32_t dwHashCode = 0;
+ for (ByteStringView::UnsignedType c : str)
+ dwHashCode = 1313 * dwHashCode + c;
+ return dwHashCode;
+}
+
+uint32_t FX_HashCode_GetLoweredAsIfW(ByteStringView str) {
+ uint32_t dwHashCode = 0;
+ for (ByteStringView::UnsignedType c : str)
+ dwHashCode = 1313 * dwHashCode + FXSYS_towlower(c);
return dwHashCode;
}
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index cba9a0f..38ada07 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -276,15 +276,17 @@
using ByteString = fxcrt::ByteString;
-uint32_t FX_HashCode_GetA(ByteStringView str, bool bIgnoreCase);
-uint32_t FX_HashCode_GetAsIfW(ByteStringView str, bool bIgnoreCase);
+uint32_t FX_HashCode_GetA(ByteStringView str);
+uint32_t FX_HashCode_GetLoweredA(ByteStringView str);
+uint32_t FX_HashCode_GetAsIfW(ByteStringView str);
+uint32_t FX_HashCode_GetLoweredAsIfW(ByteStringView str);
namespace std {
template <>
struct hash<ByteString> {
std::size_t operator()(const ByteString& str) const {
- return FX_HashCode_GetA(str.AsStringView(), false);
+ return FX_HashCode_GetA(str.AsStringView());
}
};
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp
index a726b66..7fe9ebf 100644
--- a/core/fxcrt/bytestring_unittest.cpp
+++ b/core/fxcrt/bytestring_unittest.cpp
@@ -1910,21 +1910,21 @@
}
TEST(ByteString, FX_HashCode_Ascii) {
- EXPECT_EQ(0u, FX_HashCode_GetA("", false));
- EXPECT_EQ(65u, FX_HashCode_GetA("A", false));
- EXPECT_EQ(97u, FX_HashCode_GetA("A", true));
- EXPECT_EQ(31 * 65u + 66u, FX_HashCode_GetA("AB", false));
- EXPECT_EQ(31u * 65u + 255u, FX_HashCode_GetA("A\xff", false));
- EXPECT_EQ(31u * 97u + 255u, FX_HashCode_GetA("A\xff", true));
+ EXPECT_EQ(0u, FX_HashCode_GetA(""));
+ EXPECT_EQ(65u, FX_HashCode_GetA("A"));
+ EXPECT_EQ(97u, FX_HashCode_GetLoweredA("A"));
+ EXPECT_EQ(31 * 65u + 66u, FX_HashCode_GetA("AB"));
+ EXPECT_EQ(31u * 65u + 255u, FX_HashCode_GetA("A\xff"));
+ EXPECT_EQ(31u * 97u + 255u, FX_HashCode_GetLoweredA("A\xff"));
}
TEST(ByteString, FX_HashCode_Wide) {
- EXPECT_EQ(0u, FX_HashCode_GetAsIfW("", false));
- EXPECT_EQ(65u, FX_HashCode_GetAsIfW("A", false));
- EXPECT_EQ(97u, FX_HashCode_GetAsIfW("A", true));
- EXPECT_EQ(1313u * 65u + 66u, FX_HashCode_GetAsIfW("AB", false));
- EXPECT_EQ(1313u * 65u + 255u, FX_HashCode_GetAsIfW("A\xff", false));
- EXPECT_EQ(1313u * 97u + 255u, FX_HashCode_GetAsIfW("A\xff", true));
+ EXPECT_EQ(0u, FX_HashCode_GetAsIfW(""));
+ EXPECT_EQ(65u, FX_HashCode_GetAsIfW("A"));
+ EXPECT_EQ(97u, FX_HashCode_GetLoweredAsIfW("A"));
+ EXPECT_EQ(1313u * 65u + 66u, FX_HashCode_GetAsIfW("AB"));
+ EXPECT_EQ(1313u * 65u + 255u, FX_HashCode_GetAsIfW("A\xff"));
+ EXPECT_EQ(1313u * 97u + 255u, FX_HashCode_GetLoweredAsIfW("A\xff"));
}
} // namespace fxcrt
diff --git a/core/fxcrt/css/cfx_cssdata.cpp b/core/fxcrt/css/cfx_cssdata.cpp
index cd80427..dca0719 100644
--- a/core/fxcrt/css/cfx_cssdata.cpp
+++ b/core/fxcrt/css/cfx_cssdata.cpp
@@ -285,7 +285,7 @@
if (name.IsEmpty())
return nullptr;
- uint32_t hash = FX_HashCode_GetW(name, true);
+ uint32_t hash = FX_HashCode_GetLoweredW(name);
auto* result =
std::lower_bound(std::begin(propertyTable), std::end(propertyTable), hash,
[](const CFX_CSSData::Property& iter,
@@ -306,7 +306,7 @@
if (wsName.IsEmpty())
return nullptr;
- uint32_t hash = FX_HashCode_GetW(wsName, true);
+ uint32_t hash = FX_HashCode_GetLoweredW(wsName);
auto* result = std::lower_bound(
std::begin(propertyValueTable), std::end(propertyValueTable), hash,
[](const PropertyValue& iter, const uint32_t& hash) {
diff --git a/core/fxcrt/css/cfx_cssrulecollection.cpp b/core/fxcrt/css/cfx_cssrulecollection.cpp
index cbb799e..fe6d936 100644
--- a/core/fxcrt/css/cfx_cssrulecollection.cpp
+++ b/core/fxcrt/css/cfx_cssrulecollection.cpp
@@ -28,7 +28,7 @@
const std::vector<std::unique_ptr<CFX_CSSRuleCollection::Data>>*
CFX_CSSRuleCollection::GetTagRuleData(const WideString& tagname) const {
- auto it = m_TagRules.find(FX_HashCode_GetW(tagname.AsStringView(), true));
+ auto it = m_TagRules.find(FX_HashCode_GetLoweredW(tagname.AsStringView()));
return it != m_TagRules.end() ? &it->second : nullptr;
}
diff --git a/core/fxcrt/css/cfx_cssselector.cpp b/core/fxcrt/css/cfx_cssselector.cpp
index 0ef9981..ea61d2b 100644
--- a/core/fxcrt/css/cfx_cssselector.cpp
+++ b/core/fxcrt/css/cfx_cssselector.cpp
@@ -26,8 +26,7 @@
CFX_CSSSelector::CFX_CSSSelector(WideStringView str,
std::unique_ptr<CFX_CSSSelector> next)
- : name_hash_(FX_HashCode_GetW(str, /*bIgnoreCase=*/true)),
- next_(std::move(next)) {}
+ : name_hash_(FX_HashCode_GetLoweredW(str)), next_(std::move(next)) {}
CFX_CSSSelector::~CFX_CSSSelector() = default;
diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp
index 78ad2da..8c7dcb0 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.cpp
+++ b/core/fxcrt/css/cfx_cssstyleselector.cpp
@@ -74,7 +74,7 @@
// just say we don't support them to simplify the code for now.
if (!pSel || pSel->next_selector() || pSel->is_descendant())
return false;
- return pSel->name_hash() == FX_HashCode_GetW(tagname.AsStringView(), true);
+ return pSel->name_hash() == FX_HashCode_GetLoweredW(tagname.AsStringView());
}
void CFX_CSSStyleSelector::ComputeStyle(
diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
index 315c245..9e4b426 100644
--- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
@@ -46,7 +46,7 @@
EXPECT_EQ(selectors.size(), style->CountSelectorLists());
for (size_t i = 0; i < selectors.size(); i++) {
- uint32_t hash = FX_HashCode_GetW(selectors[i].AsStringView(), true);
+ uint32_t hash = FX_HashCode_GetLoweredW(selectors[i].AsStringView());
EXPECT_EQ(hash, style->GetSelectorList(i)->name_hash());
}
@@ -95,7 +95,7 @@
}
static bool HasSelector(CFX_CSSStyleRule* style, WideStringView selector) {
- uint32_t hash = FX_HashCode_GetW(selector, true);
+ uint32_t hash = FX_HashCode_GetLoweredW(selector);
for (size_t i = 0; i < style->CountSelectorLists(); ++i) {
if (style->GetSelectorList(i)->name_hash() == hash)
return true;
@@ -202,15 +202,15 @@
const auto* sel = style->GetSelectorList(0);
ASSERT_TRUE(sel);
- EXPECT_EQ(FX_HashCode_GetW(L"c", true), sel->name_hash());
+ EXPECT_EQ(FX_HashCode_GetLoweredW(L"c"), sel->name_hash());
sel = sel->next_selector();
ASSERT_TRUE(sel);
- EXPECT_EQ(FX_HashCode_GetW(L"b", true), sel->name_hash());
+ EXPECT_EQ(FX_HashCode_GetLoweredW(L"b"), sel->name_hash());
sel = sel->next_selector();
ASSERT_TRUE(sel);
- EXPECT_EQ(FX_HashCode_GetW(L"a", true), sel->name_hash());
+ EXPECT_EQ(FX_HashCode_GetLoweredW(L"a"), sel->name_hash());
sel = sel->next_selector();
EXPECT_FALSE(sel);
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index ef8184e..13939da 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -1122,14 +1122,16 @@
} // namespace fxcrt
-uint32_t FX_HashCode_GetW(WideStringView str, bool bIgnoreCase) {
+uint32_t FX_HashCode_GetW(WideStringView str) {
uint32_t dwHashCode = 0;
- if (bIgnoreCase) {
- for (wchar_t c : str) // match FXSYS_towlower() arg type.
- dwHashCode = 1313 * dwHashCode + FXSYS_towlower(c);
- } else {
- for (WideStringView::UnsignedType c : str)
- dwHashCode = 1313 * dwHashCode + c;
- }
+ for (WideStringView::UnsignedType c : str)
+ dwHashCode = 1313 * dwHashCode + c;
+ return dwHashCode;
+}
+
+uint32_t FX_HashCode_GetLoweredW(WideStringView str) {
+ uint32_t dwHashCode = 0;
+ for (wchar_t c : str) // match FXSYS_towlower() arg type.
+ dwHashCode = 1313 * dwHashCode + FXSYS_towlower(c);
return dwHashCode;
}
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index ad24799..402d95f 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -298,14 +298,15 @@
using WideString = fxcrt::WideString;
-uint32_t FX_HashCode_GetW(WideStringView str, bool bIgnoreCase);
+uint32_t FX_HashCode_GetW(WideStringView str);
+uint32_t FX_HashCode_GetLoweredW(WideStringView str);
namespace std {
template <>
struct hash<WideString> {
std::size_t operator()(const WideString& str) const {
- return FX_HashCode_GetW(str.AsStringView(), false);
+ return FX_HashCode_GetW(str.AsStringView());
}
};
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 4575d90..640d11c 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -2033,14 +2033,13 @@
}
TEST(WideString, FX_HashCode_Wide) {
- EXPECT_EQ(0u, FX_HashCode_GetW(L"", false));
- EXPECT_EQ(65u, FX_HashCode_GetW(L"A", false));
- EXPECT_EQ(97u, FX_HashCode_GetW(L"A", true));
- EXPECT_EQ(1313 * 65u + 66u, FX_HashCode_GetW(L"AB", false));
- EXPECT_EQ(FX_HashCode_GetAsIfW("AB\xff", false),
- FX_HashCode_GetW(L"AB\xff", false));
- EXPECT_EQ(FX_HashCode_GetAsIfW("AB\xff", true),
- FX_HashCode_GetW(L"AB\xff", true));
+ EXPECT_EQ(0u, FX_HashCode_GetW(L""));
+ EXPECT_EQ(65u, FX_HashCode_GetW(L"A"));
+ EXPECT_EQ(97u, FX_HashCode_GetLoweredW(L"A"));
+ EXPECT_EQ(1313 * 65u + 66u, FX_HashCode_GetW(L"AB"));
+ EXPECT_EQ(FX_HashCode_GetAsIfW("AB\xff"), FX_HashCode_GetW(L"AB\xff"));
+ EXPECT_EQ(FX_HashCode_GetLoweredAsIfW("AB\xff"),
+ FX_HashCode_GetLoweredW(L"AB\xff"));
}
} // namespace fxcrt
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index 058ed487..ce2ff2a 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -282,8 +282,8 @@
if (szPropName == kFormCalcRuntime)
return lpScriptContext->m_FM2JSContext->GlobalPropertyGetter();
- XFA_HashCode uHashCode = static_cast<XFA_HashCode>(
- FX_HashCode_GetW(wsPropName.AsStringView(), false));
+ XFA_HashCode uHashCode =
+ static_cast<XFA_HashCode>(FX_HashCode_GetW(wsPropName.AsStringView()));
if (uHashCode != XFA_HASHCODE_Layout) {
CXFA_Object* pObj =
lpScriptContext->GetDocument()->GetXFAObject(uHashCode);
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp
index f69019a..9c9fc30 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.cpp
+++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -165,7 +165,7 @@
return false;
XFA_HashCode dwNameHash = static_cast<XFA_HashCode>(
- FX_HashCode_GetW(wsName.AsStringView().Last(iNameLen - 1), false));
+ FX_HashCode_GetW(wsName.AsStringView().Last(iNameLen - 1)));
if (dwNameHash == XFA_HASHCODE_Xfa) {
rnd.m_Result.objects.emplace_back(rnd.m_pSC->GetDocument()->GetRoot());
} else {
@@ -192,7 +192,7 @@
rndFind.m_CurObject = datasets;
rndFind.m_wsName = rnd.m_wsName.Last(rnd.m_wsName.GetLength() - 1);
rndFind.m_uHashName = static_cast<XFA_HashCode>(
- FX_HashCode_GetW(rndFind.m_wsName.AsStringView(), false));
+ FX_HashCode_GetW(rndFind.m_wsName.AsStringView()));
rndFind.m_nLevel = rnd.m_nLevel + 1;
rndFind.m_dwStyles = XFA_RESOLVENODE_Children;
rndFind.m_wsCondition = rnd.m_wsCondition;
@@ -219,7 +219,7 @@
rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes;
rndFind.m_wsName = std::move(wsName);
rndFind.m_uHashName = static_cast<XFA_HashCode>(
- FX_HashCode_GetW(rndFind.m_wsName.AsStringView(), false));
+ FX_HashCode_GetW(rndFind.m_wsName.AsStringView()));
rndFind.m_wsCondition = wsCondition;
rndFind.m_CurObject = curNode;
ResolveNormal(pIsolate, rndFind);
@@ -603,7 +603,7 @@
wsName.Trim();
wsCondition.Trim();
rnd.m_uHashName =
- static_cast<XFA_HashCode>(FX_HashCode_GetW(wsName.AsStringView(), false));
+ static_cast<XFA_HashCode>(FX_HashCode_GetW(wsName.AsStringView()));
return nStart;
}
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp
index c724bf4..c73438a 100644
--- a/fxjs/xfa/cjx_instancemanager.cpp
+++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -62,7 +62,7 @@
? wsInstManagerName
: wsInstManagerName.Last(wsInstManagerName.GetLength() - 1));
uint32_t dInstanceNameHash =
- FX_HashCode_GetW(wsInstanceName.AsStringView(), false);
+ FX_HashCode_GetW(wsInstanceName.AsStringView());
CXFA_Node* pPrevSibling = iDesired == 0
? GetXFANode()
: GetXFANode()->GetItemIfExists(iDesired - 1);
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index 4d3c66a..e53ae3e 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -76,7 +76,7 @@
if (wsEventName.IsEmpty())
return nullptr;
- uint32_t uHash = FX_HashCode_GetW(wsEventName, false);
+ uint32_t uHash = FX_HashCode_GetW(wsEventName);
auto* result = std::lower_bound(
std::begin(kExecEventParaInfoTable), std::end(kExecEventParaInfoTable),
uHash, [](const ExecEventParaInfo& iter, const uint16_t& hash) {
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index a82382b..3c5aa1b 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -54,7 +54,7 @@
};
uint32_t GetMapKey_Custom(WideStringView wsKey) {
- uint32_t dwKey = FX_HashCode_GetW(wsKey, false);
+ uint32_t dwKey = FX_HashCode_GetW(wsKey);
return ((dwKey << 1) | XFA_KEYTYPE_Custom);
}
diff --git a/xfa/fgas/crt/cfgas_stringformatter.cpp b/xfa/fgas/crt/cfgas_stringformatter.cpp
index bfeaf01..94b8223 100644
--- a/xfa/fgas/crt/cfgas_stringformatter.cpp
+++ b/xfa/fgas/crt/cfgas_stringformatter.cpp
@@ -904,7 +904,7 @@
wsCategory += m_spPattern[ccf];
ccf++;
}
- uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringView(), false);
+ uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringView());
if (dwHash == FX_LOCALECATEGORY_DateTimeHash)
return Category::kDateTime;
if (dwHash == FX_LOCALECATEGORY_TextHash)
@@ -1027,8 +1027,7 @@
m_spPattern[ccf] != '{') {
wsSubCategory += m_spPattern[ccf++];
}
- uint32_t dwSubHash =
- FX_HashCode_GetW(wsSubCategory.AsStringView(), false);
+ uint32_t dwSubHash = FX_HashCode_GetW(wsSubCategory.AsStringView());
LocaleIface::NumSubcategory eSubCategory =
LocaleIface::NumSubcategory::kDecimal;
for (const auto& data : kLocaleNumSubcategoryData) {
@@ -1637,8 +1636,7 @@
m_spPattern[ccf] != '{')
wsSubCategory += m_spPattern[ccf++];
- uint32_t dwSubHash =
- FX_HashCode_GetW(wsSubCategory.AsStringView(), false);
+ uint32_t dwSubHash = FX_HashCode_GetW(wsSubCategory.AsStringView());
LocaleIface::DateTimeSubcategory eSubCategory =
LocaleIface::DateTimeSubcategory::kMedium;
for (const auto& data : kLocaleDateTimeSubcategoryData) {
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index af46421..19cb57a 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -751,7 +751,7 @@
const wchar_t* pszFontFamily) {
ByteString bsHash = ByteString::Format("%d, %d", wCodePage, dwFontStyles);
bsHash += FX_UTF8Encode(WideStringView(pszFontFamily));
- uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView(), false);
+ uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView());
auto* pFontVector = &m_Hash2Fonts[dwHash];
if (!pFontVector->empty()) {
for (auto iter = pFontVector->begin(); iter != pFontVector->end(); ++iter) {
@@ -814,7 +814,7 @@
bsHash = ByteString::Format("%d, %d", wCodePage, dwFontStyles);
}
bsHash += FX_UTF8Encode(WideStringView(pszFontFamily));
- uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView(), false);
+ uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView());
std::vector<RetainPtr<CFGAS_GEFont>>& fonts = m_Hash2Fonts[dwHash];
for (auto& pFont : fonts) {
if (VerifyUnicode(pFont, wUnicode))
@@ -831,7 +831,7 @@
#if defined(OS_WIN)
ByteString bsHash = ByteString::Format("%d, %d", wCodePage, dwFontStyles);
bsHash += FX_UTF8Encode(WideStringView(pszFontFamily));
- uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView(), false);
+ uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView());
std::vector<RetainPtr<CFGAS_GEFont>>* pFontArray = &m_Hash2Fonts[dwHash];
if (!pFontArray->empty())
return (*pFontArray)[0];
diff --git a/xfa/fgas/font/cfgas_pdffontmgr.cpp b/xfa/fgas/font/cfgas_pdffontmgr.cpp
index 130e634..3f97d65 100644
--- a/xfa/fgas/font/cfgas_pdffontmgr.cpp
+++ b/xfa/fgas/font/cfgas_pdffontmgr.cpp
@@ -76,7 +76,7 @@
RetainPtr<CFGAS_GEFont> CFGAS_PDFFontMgr::GetFont(WideStringView wsFontFamily,
uint32_t dwFontStyles,
bool bStrictMatch) {
- uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily);
ByteString strKey = ByteString::Format("%u%u", dwHashCode, dwFontStyles);
auto it = m_FontMap.find(strKey);
if (it != m_FontMap.end())
diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp
index 9965b14..2c50e3b 100644
--- a/xfa/fgas/font/fgas_fontutils.cpp
+++ b/xfa/fgas/font/fgas_fontutils.cpp
@@ -1873,7 +1873,7 @@
}
WideString FGAS_FontNameToEnglishName(WideStringView wsLocalName) {
- uint32_t dwLocalNameHash = FX_HashCode_GetW(wsLocalName, true);
+ uint32_t dwLocalNameHash = FX_HashCode_GetLoweredW(wsLocalName);
const FGAS_FontInfo* pEnd = g_XFAFontsMap + pdfium::size(g_XFAFontsMap);
const FGAS_FontInfo* pFontInfo =
std::lower_bound(g_XFAFontsMap, pEnd, dwLocalNameHash,
@@ -1889,7 +1889,7 @@
WideString wsFontNameTemp(wsFontName);
wsFontNameTemp.Remove(L' ');
uint32_t dwCurFontNameHash =
- FX_HashCode_GetW(wsFontNameTemp.AsStringView(), true);
+ FX_HashCode_GetLoweredW(wsFontNameTemp.AsStringView());
const FGAS_FontInfo* pEnd = g_XFAFontsMap + pdfium::size(g_XFAFontsMap);
const FGAS_FontInfo* pFontInfo =
std::lower_bound(g_XFAFontsMap, pEnd, dwCurFontNameHash,
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp
index 5a6b3c5..9a73b2d 100644
--- a/xfa/fxfa/cxfa_ffbarcode.cpp
+++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -124,7 +124,7 @@
auto* it = std::lower_bound(
std::begin(g_BarCodeData), std::end(g_BarCodeData),
- FX_HashCode_GetW(wsName.AsStringView(), true),
+ FX_HashCode_GetLoweredW(wsName.AsStringView()),
[](const BarCodeInfo& arg, uint32_t hash) { return arg.uHash < hash; });
if (it != std::end(g_BarCodeData) && wsName.EqualsASCII(it->pName))
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index d78393b..35bd682 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -268,7 +268,7 @@
RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(WideStringView wsName,
int32_t& iImageXDpi,
int32_t& iImageYDpi) {
- uint32_t dwHash = FX_HashCode_GetW(wsName, false);
+ uint32_t dwHash = FX_HashCode_GetW(wsName);
auto it = m_HashToDibDpiMap.find(dwHash);
if (it != m_HashToDibDpiMap.end()) {
iImageXDpi = it->second.iImageXDpi;
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 56401f3..7df3561 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -657,7 +657,7 @@
wsValueRef.IsEmpty() || wsValueRef.EqualsASCII("$");
WideString wsValue;
WideString wsLabel;
- uint32_t uValueHash = FX_HashCode_GetW(wsValueRef.AsStringView(), false);
+ uint32_t uValueHash = FX_HashCode_GetW(wsValueRef.AsStringView());
for (auto& refObject : maybeRS.value().objects) {
CXFA_Node* refNode = refObject->AsNode();
if (!refNode)
diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp
index d9afbee..882b4f7 100644
--- a/xfa/fxfa/cxfa_fontmgr.cpp
+++ b/xfa/fxfa/cxfa_fontmgr.cpp
@@ -25,7 +25,7 @@
RetainPtr<CFGAS_GEFont> CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
WideStringView wsFontFamily,
uint32_t dwFontStyles) {
- uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false);
+ uint32_t dwHash = FX_HashCode_GetW(wsFontFamily);
ByteString bsKey = ByteString::Format("%u%u%u", dwHash, dwFontStyles, 0xFFFF);
auto iter = m_FontMap.find(bsKey);
if (iter != m_FontMap.end())
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 787711b..2872d9a 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -985,12 +985,12 @@
float fLeft = 0;
if (m_pTabstopContext->m_bHasTabstops) {
uint32_t dwAlign = m_pTabstopContext->m_tabstops[iTabstopsIndex].dwAlign;
- if (dwAlign == FX_HashCode_GetW(L"center", false)) {
+ if (dwAlign == FX_HashCode_GetW(L"center")) {
fLeft = pPiece->rtPiece.width / 2.0f;
- } else if (dwAlign == FX_HashCode_GetW(L"right", false) ||
- dwAlign == FX_HashCode_GetW(L"before", false)) {
+ } else if (dwAlign == FX_HashCode_GetW(L"right") ||
+ dwAlign == FX_HashCode_GetW(L"before")) {
fLeft = pPiece->rtPiece.width;
- } else if (dwAlign == FX_HashCode_GetW(L"decimal", false)) {
+ } else if (dwAlign == FX_HashCode_GetW(L"decimal")) {
int32_t iChars = pPiece->iChars;
for (int32_t i = 0; i < iChars; i++) {
if (pPiece->szText[i] == L'.')
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 3ac9e3e..0ac6018 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -283,7 +283,7 @@
0xdb8ac455, // html
};
return std::binary_search(std::begin(s_XFATagName), std::end(s_XFATagName),
- FX_HashCode_GetW(wsName.AsStringView(), true));
+ FX_HashCode_GetLoweredW(wsName.AsStringView()));
}
// static
@@ -599,7 +599,7 @@
break;
case TabStopStatus::Location:
if (ch == ' ') {
- uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringView(), true);
+ uint32_t dwHashCode = FX_HashCode_GetLoweredW(wsAlign.AsStringView());
CXFA_Measurement ms(
WideStringView(spTabStops.subspan(iLast, iCur - iLast)));
float fPos = ms.ToUnit(XFA_Unit::Pt);
@@ -615,7 +615,7 @@
}
if (!wsAlign.IsEmpty()) {
- uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringView(), true);
+ uint32_t dwHashCode = FX_HashCode_GetLoweredW(wsAlign.AsStringView());
CXFA_Measurement ms(
WideStringView(spTabStops.subspan(iLast, iCur - iLast)));
float fPos = ms.ToUnit(XFA_Unit::Pt);
diff --git a/xfa/fxfa/fxfa_basic_unittest.cpp b/xfa/fxfa/fxfa_basic_unittest.cpp
index 5f77708..ad604f7 100644
--- a/xfa/fxfa/fxfa_basic_unittest.cpp
+++ b/xfa/fxfa/fxfa_basic_unittest.cpp
@@ -11,10 +11,10 @@
void HashTestCase(uint32_t hash, const char* str, uint32_t* so_far) {
if (hash != 0xffffffffu) {
- EXPECT_EQ(hash, FX_HashCode_GetAsIfW(str, false)) << str;
+ EXPECT_EQ(hash, FX_HashCode_GetAsIfW(str)) << str;
EXPECT_LT(*so_far, hash) << hash;
} else {
- EXPECT_NE(hash, FX_HashCode_GetAsIfW(str, false)) << str;
+ EXPECT_NE(hash, FX_HashCode_GetAsIfW(str)) << str;
}
*so_far = hash;
}
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 4ec94e9..1ac2e2c 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -189,8 +189,7 @@
WideString wsSubformName =
pTemplateNode->JSObject()->GetCData(XFA_Attribute::Name);
WideString wsInstMgrNodeName = L"_" + wsSubformName;
- uint32_t dwInstNameHash =
- FX_HashCode_GetW(wsInstMgrNodeName.AsStringView(), false);
+ uint32_t dwInstNameHash = FX_HashCode_GetW(wsInstMgrNodeName.AsStringView());
CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance(
pDocument, XFA_Element::InstanceManager, dwInstNameHash, pFormParent);
if (pExistingNode) {
@@ -302,7 +301,7 @@
if (wsName.IsEmpty())
return nullptr;
- uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringView(), false);
+ uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringView());
CXFA_Node* pBounded = pDocument->GetGlobalBinding(dwNameHash);
if (!pBounded) {
pBounded =
@@ -319,7 +318,7 @@
if (wsName.IsEmpty())
return nullptr;
- uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringView(), false);
+ uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringView());
CXFA_Node* pLastDataScope = nullptr;
for (CXFA_Node* pCurDataScope = pDataScope;
pCurDataScope &&
@@ -1526,7 +1525,7 @@
pNode = sIterator.MoveToNext()) {
WideString wsIDVal = pNode->JSObject()->GetCData(XFA_Attribute::Id);
if (!wsIDVal.IsEmpty())
- mIDMap[FX_HashCode_GetW(wsIDVal.AsStringView(), false)] = pNode;
+ mIDMap[FX_HashCode_GetW(wsIDVal.AsStringView())] = pNode;
WideString wsUseVal = pNode->JSObject()->GetCData(XFA_Attribute::Use);
if (!wsUseVal.IsEmpty()) {
@@ -1590,7 +1589,7 @@
pProtoNode = pFirstObject->AsNode();
}
} else if (!wsID.IsEmpty()) {
- auto it = mIDMap.find(FX_HashCode_GetW(wsID, false));
+ auto it = mIDMap.find(FX_HashCode_GetW(wsID));
if (it == mIDMap.end())
continue;
pProtoNode = it->second;
diff --git a/xfa/fxfa/parser/cxfa_document_builder.cpp b/xfa/fxfa/parser/cxfa_document_builder.cpp
index 931e8d9..21bcbc0 100644
--- a/xfa/fxfa/parser/cxfa_document_builder.cpp
+++ b/xfa/fxfa/parser/cxfa_document_builder.cpp
@@ -187,7 +187,7 @@
case CFX_XMLNode::Type::kElement: {
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
WideString wsTag = pXMLElement->GetLocalTagName();
- uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringView(), true);
+ uint32_t uTag = FX_HashCode_GetLoweredW(wsTag.AsStringView());
if (uTag == 0x0001f714) {
wsPlainText += L"\n";
} else if (uTag == 0x00000070) {
@@ -358,7 +358,7 @@
continue;
}
// TODO(tsepez): make GetFirstChildByName() take a name.
- uint32_t hash = FX_HashCode_GetW(config_packet.name, false);
+ uint32_t hash = FX_HashCode_GetW(config_packet.name);
if (pXFARootNode->GetFirstChildByName(hash))
return nullptr;
@@ -416,7 +416,7 @@
if (packet_info.has_value() &&
(packet_info.value().flags & XFA_XDPPACKET_FLAGS_SUPPORTONE) &&
pXFARootNode->GetFirstChildByName(
- FX_HashCode_GetW(packet_info.value().name, false))) {
+ FX_HashCode_GetW(packet_info.value().name))) {
return nullptr;
}
pXFARootNode->InsertChildAndNotify(pPacketNode, nullptr);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index ff66fdc..32ef519 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1640,7 +1640,7 @@
}
CXFA_Node* CXFA_Node::GetFirstChildByName(WideStringView wsName) const {
- return GetFirstChildByName(FX_HashCode_GetW(wsName, false));
+ return GetFirstChildByName(FX_HashCode_GetW(wsName));
}
CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const {
@@ -1672,7 +1672,7 @@
CXFA_Node* CXFA_Node::GetNextSameNameSiblingInternal(
WideStringView wsNodeName) const {
- return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false));
+ return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName));
}
CXFA_Node* CXFA_Node::GetNextSameClassSiblingInternal(XFA_Element eType) const {
@@ -1685,7 +1685,7 @@
}
CXFA_Node* CXFA_Node::GetOneChildNamed(WideStringView wsName) {
- return FindFirstSiblingNamed(this, FX_HashCode_GetW(wsName, false));
+ return FindFirstSiblingNamed(this, FX_HashCode_GetW(wsName));
}
CXFA_Node* CXFA_Node::GetOneChildOfClass(WideStringView wsClass) {
@@ -1817,7 +1817,7 @@
void CXFA_Node::UpdateNameHash() {
WideString wsName = JSObject()->GetCData(XFA_Attribute::Name);
- m_dwNameHash = FX_HashCode_GetW(wsName.AsStringView(), false);
+ m_dwNameHash = FX_HashCode_GetW(wsName.AsStringView());
}
CFX_XMLNode* CXFA_Node::CreateXMLMappingNode() {
@@ -4075,7 +4075,7 @@
}
CXFA_Node* CXFA_Node::SetSelectedMember(WideStringView wsName) {
- uint32_t nameHash = FX_HashCode_GetW(wsName, false);
+ uint32_t nameHash = FX_HashCode_GetW(wsName);
for (CXFA_Node* pNode = ToNode(GetFirstChild()); pNode;
pNode = pNode->GetNextSibling()) {
if (pNode->GetNameHash() == nameHash) {
diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp
index a80a543..caaa8c3 100644
--- a/xfa/fxfa/parser/cxfa_object.cpp
+++ b/xfa/fxfa/parser/cxfa_object.cpp
@@ -24,7 +24,7 @@
: m_objectType(objectType),
m_elementType(elementType),
m_elementName(XFA_ElementToName(elementType)),
- m_elementNameHash(FX_HashCode_GetAsIfW(m_elementName, false)),
+ m_elementNameHash(FX_HashCode_GetAsIfW(m_elementName)),
m_pDocument(pDocument),
m_pJSObject(jsObject) {}
diff --git a/xfa/fxfa/parser/cxfa_treelist.cpp b/xfa/fxfa/parser/cxfa_treelist.cpp
index dcc7f76..a77dd32 100644
--- a/xfa/fxfa/parser/cxfa_treelist.cpp
+++ b/xfa/fxfa/parser/cxfa_treelist.cpp
@@ -22,7 +22,7 @@
CXFA_TreeList::~CXFA_TreeList() = default;
CXFA_Node* CXFA_TreeList::NamedItem(WideStringView wsName) {
- uint32_t dwHashCode = FX_HashCode_GetW(wsName, false);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsName);
size_t count = GetLength();
for (size_t i = 0; i < count; i++) {
CXFA_Node* ret = Item(i);
diff --git a/xfa/fxfa/parser/xfa_basic_data.cpp b/xfa/fxfa/parser/xfa_basic_data.cpp
index d17baee..a69932d 100644
--- a/xfa/fxfa/parser/xfa_basic_data.cpp
+++ b/xfa/fxfa/parser/xfa_basic_data.cpp
@@ -171,7 +171,7 @@
}
Optional<XFA_PACKETINFO> XFA_GetPacketByName(WideStringView wsName) {
- uint32_t hash = FX_HashCode_GetW(wsName, false);
+ uint32_t hash = FX_HashCode_GetW(wsName);
auto* elem = std::lower_bound(
std::begin(g_PacketTable), std::end(g_PacketTable), hash,
[](const PacketRecord& a, uint32_t hash) { return a.hash < hash; });
@@ -185,7 +185,7 @@
}
XFA_Element XFA_GetElementByName(WideStringView name) {
- uint32_t hash = FX_HashCode_GetW(name, false);
+ uint32_t hash = FX_HashCode_GetW(name);
auto* elem = std::lower_bound(
std::begin(kElementRecords), std::end(kElementRecords), hash,
[](const ElementRecord& a, uint32_t hash) { return a.hash < hash; });
@@ -202,7 +202,7 @@
}
Optional<XFA_ATTRIBUTEINFO> XFA_GetAttributeByName(WideStringView name) {
- uint32_t hash = FX_HashCode_GetW(name, false);
+ uint32_t hash = FX_HashCode_GetW(name);
auto* elem = std::lower_bound(
std::begin(kAttributeRecords), std::end(kAttributeRecords), hash,
[](const AttributeRecord& a, uint32_t hash) { return a.hash < hash; });
@@ -224,11 +224,12 @@
}
Optional<XFA_AttributeValue> XFA_GetAttributeValueByName(WideStringView name) {
- auto* it = std::lower_bound(std::begin(kAttributeValueRecords),
- std::end(kAttributeValueRecords),
- FX_HashCode_GetW(name, false),
- [](const AttributeValueRecord& arg,
- uint32_t hash) { return arg.uHash < hash; });
+ auto* it =
+ std::lower_bound(std::begin(kAttributeValueRecords),
+ std::end(kAttributeValueRecords), FX_HashCode_GetW(name),
+ [](const AttributeValueRecord& arg, uint32_t hash) {
+ return arg.uHash < hash;
+ });
if (it == std::end(kAttributeValueRecords))
return pdfium::nullopt;