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

Unified Diff: xfa/fxfa/app/xfa_textlayout.cpp

Issue 1996623002: Remove CFX_DSPATemplate usage in CXFA_TextParser (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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 | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/app/xfa_textlayout_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxfa/app/xfa_textlayout.cpp
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index b7dfa3f168cc841257237898fe01f9af7ca59d59..91dd814e8d8126bca52a1a94e4bda64fa1325e30 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -220,14 +220,14 @@ void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer,
}
void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
IFDE_CSSComputedStyle* pParentStyle) {
- if (pXMLNode == NULL) {
+ if (!pXMLNode)
return;
- }
+
CXFA_CSSTagProvider tagProvider;
ParseTagInfo(pXMLNode, tagProvider);
- if (!tagProvider.m_bTagAviliable) {
+ if (!tagProvider.m_bTagAvailable)
return;
- }
+
IFDE_CSSComputedStyle* pNewStyle = NULL;
if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) ||
(tagProvider.GetTagName() != FX_WSTRC(L"html"))) {
@@ -263,30 +263,45 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
if (pNewStyle)
pNewStyle->Release();
}
-void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode,
- CXFA_CSSTagProvider& tagProvider) {
+
+bool CXFA_TextParser::TagValidate(const CFX_WideString& wsName) const {
static const uint32_t s_XFATagName[] = {
- 0x61, 0x62, 0x69, 0x70, 0x0001f714,
- 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8,
- 0xa73e3af2, 0xb182eaae, 0xdb8ac455,
+ 0x61, // a
+ 0x62, // b
+ 0x69, // i
+ 0x70, // p
+ 0x0001f714, // br
+ 0x00022a55, // li
+ 0x000239bb, // ol
+ 0x00025881, // ul
+ 0x0bd37faa, // sub
+ 0x0bd37fb8, // sup
+ 0xa73e3af2, // span
+ 0xb182eaae, // body
+ 0xdb8ac455, // html
};
+ static const int32_t s_iCount = FX_ArraySize(s_XFATagName);
+
+ return std::binary_search(s_XFATagName, s_XFATagName + s_iCount,
+ FX_HashCode_GetW(wsName.AsStringC(), true));
+}
+
+void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode,
+ CXFA_CSSTagProvider& tagProvider) {
CFX_WideString wsName;
if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
pXMLElement->GetLocalTagName(wsName);
tagProvider.SetTagNameObj(wsName);
- uint32_t dwHashCode = FX_HashCode_GetW(wsName.AsStringC(), true);
- static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t);
- CFX_DSPATemplate<uint32_t> lookup;
- tagProvider.m_bTagAviliable =
- lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1;
+ tagProvider.m_bTagAvailable = TagValidate(wsName);
+
CFX_WideString wsValue;
pXMLElement->GetString(L"style", wsValue);
if (!wsValue.IsEmpty()) {
tagProvider.SetAttribute(L"style", wsValue);
}
} else if (pXMLNode->GetType() == FDE_XMLNODE_Text) {
- tagProvider.m_bTagAviliable = TRUE;
+ tagProvider.m_bTagAvailable = TRUE;
tagProvider.m_bContent = TRUE;
}
}
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/app/xfa_textlayout_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698