summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/cxfa_textparser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-26 09:45:57 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-26 15:05:05 +0000
commit35ee5bb4a2e51fd42f07c23a4008bfb97e390b25 (patch)
treec15fd938e4ab87136dc97ef7bdd4e576d1378703 /xfa/fxfa/app/cxfa_textparser.cpp
parentcff5618d4e847b9f13e1f051d56e09ee00cfb089 (diff)
downloadpdfium-35ee5bb4a2e51fd42f07c23a4008bfb97e390b25.tar.xz
Cleanup memory in CFDE_CSSStyleSelector
This CL fixes up the bare new calls in CFDE_CSSStyleSelector and replaces them with unique_ptrs. Code massaged to work correclty with new types. Change-Id: I90fce1ed7486da97fe7b5e597e9d423748c069c0 Reviewed-on: https://pdfium-review.googlesource.com/2353 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/app/cxfa_textparser.cpp')
-rw-r--r--xfa/fxfa/app/cxfa_textparser.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp
index 9bf033f9b0..2a724cc243 100644
--- a/xfa/fxfa/app/cxfa_textparser.cpp
+++ b/xfa/fxfa/app/cxfa_textparser.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
#include <utility>
+#include <vector>
#include "third_party/base/ptr_util.h"
#include "xfa/fde/css/cfde_cssaccelerator.h"
@@ -205,8 +206,8 @@ CFX_RetainPtr<CFDE_CSSComputedStyle> CXFA_TextParser::ComputeStyle(
auto pStyle = CreateStyle(pParentStyle);
CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
pCSSAccel->OnEnterTag(&tagProvider);
- m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(),
- pContext->CountDecls(), pStyle.Get());
+
+ m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), pStyle.Get());
pCSSAccel->OnLeaveTag(&tagProvider);
return pStyle;
}
@@ -241,16 +242,13 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
pNewStyle = CreateStyle(pParentStyle);
CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
pCSSAccel->OnEnterTag(&tagProvider);
- CFX_ArrayTemplate<CFDE_CSSDeclaration*> DeclArray;
- int32_t iMatchedDecls =
- m_pSelector->MatchDeclarations(&tagProvider, DeclArray);
- const CFDE_CSSDeclaration** ppMatchDecls =
- const_cast<const CFDE_CSSDeclaration**>(DeclArray.GetData());
- m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls,
- pNewStyle.Get());
+
+ auto declArray = m_pSelector->MatchDeclarations(&tagProvider);
+ m_pSelector->ComputeStyle(&tagProvider, declArray, pNewStyle.Get());
+
pCSSAccel->OnLeaveTag(&tagProvider);
- if (iMatchedDecls > 0)
- pTextContext->SetDecls(ppMatchDecls, iMatchedDecls);
+ if (!declArray.empty())
+ pTextContext->SetDecls(std::move(declArray));
eDisplay = pNewStyle->GetDisplay();
}