diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-01-23 16:24:26 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-24 15:05:29 +0000 |
commit | 7e5fdd0b1a2ce17e89723fee3e58ae472e32461f (patch) | |
tree | e8e14a43410d3d159cef27a0140c4fa8a633f8db /xfa/fxfa/app/cxfa_textparser.cpp | |
parent | aee2d80f628ba02d0561c921b7bb1939b3480fca (diff) | |
download | pdfium-7e5fdd0b1a2ce17e89723fee3e58ae472e32461f.tar.xz |
Track CFDE_CSSComputedStyle with retained ptrs
Remove the bare new and use CFX_RetainPtr to keep track of the computed styles.
Change-Id: Icf235623529797176707482c78676814b7a81b9e
Reviewed-on: https://pdfium-review.googlesource.com/2292
Reviewed-by: Tom Sepez <tsepez@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.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 { |