summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/cxfa_textparser.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-15 13:33:09 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-15 21:35:19 +0000
commitc8493852c7a07241c18e14cb0a8d6292b1314726 (patch)
tree9800395fee45ecc018c7218895b2c6cd61d1d0f6 /xfa/fxfa/app/cxfa_textparser.cpp
parent9bbc354eba593527e26ed290e3b25a71959c8f62 (diff)
downloadpdfium-c8493852c7a07241c18e14cb0a8d6292b1314726.tar.xz
Use map of unique_ptr in cxfa_textparser.
Change-Id: I005f9da5ab64558689204f23d3444cdc68f3c59b Reviewed-on: https://pdfium-review.googlesource.com/3064 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/app/cxfa_textparser.cpp')
-rw-r--r--xfa/fxfa/app/cxfa_textparser.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp
index 6a9aeb04d8..546348083e 100644
--- a/xfa/fxfa/app/cxfa_textparser.cpp
+++ b/xfa/fxfa/app/cxfa_textparser.cpp
@@ -43,21 +43,13 @@ enum class TabStopStatus {
CXFA_TextParser::CXFA_TextParser()
: m_bParsed(false), m_cssInitialized(false) {}
-CXFA_TextParser::~CXFA_TextParser() {
- for (auto& pair : m_mapXMLNodeToParseContext) {
- if (pair.second)
- delete pair.second;
- }
-}
+CXFA_TextParser::~CXFA_TextParser() {}
void CXFA_TextParser::Reset() {
- for (auto& pair : m_mapXMLNodeToParseContext) {
- if (pair.second)
- delete pair.second;
- }
m_mapXMLNodeToParseContext.clear();
m_bParsed = false;
}
+
void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
if (!pTextProvider)
return;
@@ -67,12 +59,8 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
CFGAS_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
ASSERT(pFontMgr);
m_pSelector = pdfium::MakeUnique<CFDE_CSSStyleSelector>(pFontMgr);
- float fFontSize = 10;
CXFA_Font font = pTextProvider->GetFontNode();
- if (font) {
- fFontSize = font.GetFontSize();
- }
- m_pSelector->SetDefFontSize(fFontSize);
+ m_pSelector->SetDefFontSize(font ? font.GetFontSize() : 10.0f);
}
if (m_cssInitialized)
@@ -191,7 +179,7 @@ CFX_RetainPtr<CFDE_CSSComputedStyle> CXFA_TextParser::ComputeStyle(
if (it == m_mapXMLNodeToParseContext.end())
return nullptr;
- CXFA_TextParseContext* pContext = it->second;
+ CXFA_TextParseContext* pContext = it->second.get();
if (!pContext)
return nullptr;
@@ -231,7 +219,7 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
CFX_RetainPtr<CFDE_CSSComputedStyle> pNewStyle;
if ((tagProvider->GetTagName() != L"body") ||
(tagProvider->GetTagName() != L"html")) {
- CXFA_TextParseContext* pTextContext = new CXFA_TextParseContext;
+ auto pTextContext = pdfium::MakeUnique<CXFA_TextParseContext>();
FDE_CSSDisplay eDisplay = FDE_CSSDisplay::Inline;
if (!tagProvider->m_bContent) {
auto declArray =
@@ -247,7 +235,7 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
eDisplay = pNewStyle->GetDisplay();
}
pTextContext->SetDisplay(eDisplay);
- m_mapXMLNodeToParseContext[pXMLNode] = pTextContext;
+ m_mapXMLNodeToParseContext[pXMLNode] = std::move(pTextContext);
}
for (CFDE_XMLNode* pXMLChild =
@@ -383,7 +371,7 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
while (pXMLNode) {
auto it = m_mapXMLNodeToParseContext.find(pXMLNode);
if (it != m_mapXMLNodeToParseContext.end()) {
- CXFA_TextParseContext* pContext = it->second;
+ CXFA_TextParseContext* pContext = it->second.get();
if (pContext && pContext->m_pParentStyle &&
pContext->m_pParentStyle->GetCustomStyle(
L"xfa-font-horizontal-scale", wsValue)) {
@@ -547,7 +535,7 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap(
CFDE_XMLNode* pXMLNode) {
auto it = m_mapXMLNodeToParseContext.find(pXMLNode);
- return it != m_mapXMLNodeToParseContext.end() ? it->second : nullptr;
+ return it != m_mapXMLNodeToParseContext.end() ? it->second.get() : nullptr;
}
bool CXFA_TextParser::GetTabstops(CFDE_CSSComputedStyle* pStyle,