diff options
Diffstat (limited to 'xfa/fxfa/app/cxfa_textparser.cpp')
-rw-r--r-- | xfa/fxfa/app/cxfa_textparser.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index 6386edfad8..9bf033f9b0 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -101,11 +101,11 @@ std::unique_ptr<CFDE_CSSStyleSheet> CXFA_TextParser::LoadDefaultSheetStyle() { : nullptr; } -CFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( +CFX_RetainPtr<CFDE_CSSComputedStyle> CXFA_TextParser::CreateRootStyle( CXFA_TextProvider* pTextProvider) { CXFA_Font font = pTextProvider->GetFontNode(); CXFA_Para para = pTextProvider->GetParaNode(); - CFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(nullptr); + auto pStyle = m_pSelector->CreateComputedStyle(nullptr); FX_FLOAT fLineHeight = 0; FX_FLOAT fFontSize = 10; @@ -163,10 +163,9 @@ CFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( return pStyle; } -CFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( +CFX_RetainPtr<CFDE_CSSComputedStyle> CXFA_TextParser::CreateStyle( CFDE_CSSComputedStyle* pParentStyle) { - CFDE_CSSComputedStyle* pNewStyle = - m_pSelector->CreateComputedStyle(pParentStyle); + auto pNewStyle = m_pSelector->CreateComputedStyle(pParentStyle); ASSERT(pNewStyle); if (!pParentStyle) return pNewStyle; @@ -185,7 +184,7 @@ CFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( return pNewStyle; } -CFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( +CFX_RetainPtr<CFDE_CSSComputedStyle> CXFA_TextParser::ComputeStyle( CFDE_XMLNode* pXMLNode, CFDE_CSSComputedStyle* pParentStyle) { auto it = m_mapXMLNodeToParseContext.find(pXMLNode); @@ -196,19 +195,18 @@ CFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( if (!pContext) return nullptr; - pContext->m_pParentStyle = pParentStyle; - pParentStyle->Retain(); + pContext->m_pParentStyle.Reset(pParentStyle); CXFA_CSSTagProvider tagProvider; ParseTagInfo(pXMLNode, tagProvider); if (tagProvider.m_bContent) return nullptr; - CFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); + auto pStyle = CreateStyle(pParentStyle); CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); pCSSAccel->OnEnterTag(&tagProvider); m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), - pContext->CountDecls(), pStyle); + pContext->CountDecls(), pStyle.Get()); pCSSAccel->OnLeaveTag(&tagProvider); return pStyle; } @@ -220,9 +218,8 @@ void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, m_bParsed = true; InitCSSData(pTextProvider); - CFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); - ParseRichText(pXMLContainer, pRootStyle); - pRootStyle->Release(); + auto pRootStyle = CreateRootStyle(pTextProvider); + ParseRichText(pXMLContainer, pRootStyle.Get()); } void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, @@ -235,7 +232,7 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, if (!tagProvider.m_bTagAvailable) return; - CFDE_CSSComputedStyle* pNewStyle = nullptr; + CFX_RetainPtr<CFDE_CSSComputedStyle> pNewStyle; if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { CXFA_TextParseContext* pTextContext = new CXFA_TextParseContext; @@ -250,7 +247,7 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, const CFDE_CSSDeclaration** ppMatchDecls = const_cast<const CFDE_CSSDeclaration**>(DeclArray.GetData()); m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls, - pNewStyle); + pNewStyle.Get()); pCSSAccel->OnLeaveTag(&tagProvider); if (iMatchedDecls > 0) pTextContext->SetDecls(ppMatchDecls, iMatchedDecls); @@ -265,10 +262,8 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { - ParseRichText(pXMLChild, pNewStyle); + ParseRichText(pXMLChild, pNewStyle.Get()); } - if (pNewStyle) - pNewStyle->Release(); } bool CXFA_TextParser::TagValidate(const CFX_WideString& wsName) const { |