Remove strings/hashes from element-atttribute table. "Join" instead based on the attribute enum after looking it up in the attribute table. Change-Id: I28bb6e550703170c470e0d66159d4a3f09423623 Reviewed-on: https://pdfium-review.googlesource.com/c/47051 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxfa/parser/xfa_basic_data.cpp b/xfa/fxfa/parser/xfa_basic_data.cpp index 2042fb5..554490e 100644 --- a/xfa/fxfa/parser/xfa_basic_data.cpp +++ b/xfa/fxfa/parser/xfa_basic_data.cpp
@@ -542,14 +542,12 @@ static_assert(static_cast<int>(XFA_Element::Placeholder4) == 320, "320"); struct ElementAttributeRecord { - uint32_t uHash; // Hashed as wide string. XFA_Attribute attribute; - XFA_ScriptType eValueType; XFA_ATTRIBUTE_CALLBACK callback; }; #undef ATTR -#define ATTR(a, b, c, d, e) a, d, e, reinterpret_cast<XFA_ATTRIBUTE_CALLBACK>(c) +#define ATTR(a, b, c, d, e) d, reinterpret_cast<XFA_ATTRIBUTE_CALLBACK>(c) const ElementAttributeRecord g_ElementAttributeTable[] = { /* ps */ @@ -6630,10 +6628,10 @@ Optional<XFA_SCRIPTATTRIBUTEINFO> XFA_GetScriptAttributeByName( XFA_Element eElement, WideStringView wsAttributeName) { - if (wsAttributeName.IsEmpty()) + Optional<XFA_ATTRIBUTEINFO> attr = XFA_GetAttributeByName(wsAttributeName); + if (!attr.has_value()) return {}; - uint32_t uHash = FX_HashCode_GetW(wsAttributeName, false); while (eElement != XFA_Element::Unknown) { const ScriptIndexRecord* scriptIndex = &g_ScriptIndexTable[static_cast<size_t>(eElement)]; @@ -6641,10 +6639,10 @@ size_t iEnd = iStart + scriptIndex->wAttributeCount; for (size_t iter = iStart; iter < iEnd; ++iter) { const ElementAttributeRecord* pInfo = &g_ElementAttributeTable[iter]; - if (uHash == pInfo->uHash) { + if (attr.value().attribute == pInfo->attribute) { XFA_SCRIPTATTRIBUTEINFO result; - result.attribute = pInfo->attribute; - result.eValueType = pInfo->eValueType; + result.attribute = attr.value().attribute; + result.eValueType = attr.value().eValueType; result.callback = pInfo->callback; return result; }