summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/app')
-rw-r--r--xfa/fxfa/app/cxfa_textparsecontext.cpp17
-rw-r--r--xfa/fxfa/app/cxfa_textparsecontext.h16
-rw-r--r--xfa/fxfa/app/cxfa_textparser.cpp20
3 files changed, 19 insertions, 34 deletions
diff --git a/xfa/fxfa/app/cxfa_textparsecontext.cpp b/xfa/fxfa/app/cxfa_textparsecontext.cpp
index e4beb1fcb0..851d84456b 100644
--- a/xfa/fxfa/app/cxfa_textparsecontext.cpp
+++ b/xfa/fxfa/app/cxfa_textparsecontext.cpp
@@ -12,21 +12,6 @@
CXFA_TextParseContext::CXFA_TextParseContext()
: m_pParentStyle(nullptr),
- m_ppMatchedDecls(nullptr),
- m_dwMatchedDecls(0),
m_eDisplay(FDE_CSSDisplay::None) {}
-CXFA_TextParseContext::~CXFA_TextParseContext() {
- FX_Free(m_ppMatchedDecls);
-}
-
-void CXFA_TextParseContext::SetDecls(const CFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount) {
- if (iDeclCount <= 0 || !ppDeclArray)
- return;
-
- m_dwMatchedDecls = iDeclCount;
- m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount);
- FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray,
- iDeclCount * sizeof(CFDE_CSSDeclaration*));
-}
+CXFA_TextParseContext::~CXFA_TextParseContext() {}
diff --git a/xfa/fxfa/app/cxfa_textparsecontext.h b/xfa/fxfa/app/cxfa_textparsecontext.h
index d13f35b6df..5ea68e9473 100644
--- a/xfa/fxfa/app/cxfa_textparsecontext.h
+++ b/xfa/fxfa/app/cxfa_textparsecontext.h
@@ -7,9 +7,13 @@
#ifndef XFA_FXFA_APP_CXFA_TEXTPARSECONTEXT_H_
#define XFA_FXFA_APP_CXFA_TEXTPARSECONTEXT_H_
+#include <utility>
+#include <vector>
+
+#include "third_party/base/stl_util.h"
+#include "xfa/fde/css/cfde_cssdeclaration.h"
#include "xfa/fde/css/fde_css.h"
-class CFDE_CSSDeclaration;
class CFDE_CSSComputedStyle;
class CXFA_TextParseContext {
@@ -20,17 +24,15 @@ class CXFA_TextParseContext {
void SetDisplay(FDE_CSSDisplay eDisplay) { m_eDisplay = eDisplay; }
FDE_CSSDisplay GetDisplay() const { return m_eDisplay; }
- void SetDecls(const CFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount);
- const CFDE_CSSDeclaration** GetDecls() {
- return const_cast<const CFDE_CSSDeclaration**>(m_ppMatchedDecls);
+ void SetDecls(std::vector<const CFDE_CSSDeclaration*>&& decl) {
+ decls_ = std::move(decl);
}
- uint32_t CountDecls() const { return m_dwMatchedDecls; }
+ const std::vector<const CFDE_CSSDeclaration*>& GetDecls() { return decls_; }
CFX_RetainPtr<CFDE_CSSComputedStyle> m_pParentStyle;
protected:
- CFDE_CSSDeclaration** m_ppMatchedDecls;
- uint32_t m_dwMatchedDecls;
+ std::vector<const CFDE_CSSDeclaration*> decls_;
FDE_CSSDisplay m_eDisplay;
};
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();
}