Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Side by Side Diff: xfa/fxfa/app/xfa_textlayout.cpp

Issue 2208423002: Use smart pointers for class owned pointers under xfa/fde (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: one more change Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fgas/crt/fgas_memory.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/app/xfa_textlayout.h" 7 #include "xfa/fxfa/app/xfa_textlayout.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 m_pAllocator.reset(); 89 m_pAllocator.reset();
90 } 90 }
91 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { 91 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
92 if (!pTextProvider) 92 if (!pTextProvider)
93 return; 93 return;
94 94
95 if (!m_pSelector) { 95 if (!m_pSelector) {
96 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); 96 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
97 IFGAS_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); 97 IFGAS_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
98 ASSERT(pFontMgr); 98 ASSERT(pFontMgr);
99 m_pSelector.reset(new CFDE_CSSStyleSelector); 99 m_pSelector.reset(new CFDE_CSSStyleSelector(pFontMgr));
100 m_pSelector->SetFontMgr(pFontMgr);
101 FX_FLOAT fFontSize = 10; 100 FX_FLOAT fFontSize = 10;
102 CXFA_Font font = pTextProvider->GetFontNode(); 101 CXFA_Font font = pTextProvider->GetFontNode();
103 if (font) { 102 if (font) {
104 fFontSize = font.GetFontSize(); 103 fFontSize = font.GetFontSize();
105 } 104 }
106 m_pSelector->SetDefFontSize(fFontSize); 105 m_pSelector->SetDefFontSize(fFontSize);
107 } 106 }
108 if (!m_pUASheet) { 107 if (!m_pUASheet) {
109 m_pUASheet = LoadDefaultSheetStyle(); 108 m_pUASheet = LoadDefaultSheetStyle();
110 m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); 109 m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), 244 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(),
246 pContext->CountDecls(), pStyle); 245 pContext->CountDecls(), pStyle);
247 pCSSAccel->OnLeaveTag(&tagProvider); 246 pCSSAccel->OnLeaveTag(&tagProvider);
248 return pStyle; 247 return pStyle;
249 } 248 }
250 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, 249 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer,
251 CXFA_TextProvider* pTextProvider) { 250 CXFA_TextProvider* pTextProvider) {
252 if (!pXMLContainer || !pTextProvider || m_pAllocator) { 251 if (!pXMLContainer || !pTextProvider || m_pAllocator) {
253 return; 252 return;
254 } 253 }
255 m_pAllocator.reset(IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, 254 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32,
256 sizeof(CXFA_CSSTagProvider))); 255 sizeof(CXFA_CSSTagProvider));
257 InitCSSData(pTextProvider); 256 InitCSSData(pTextProvider);
258 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); 257 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider);
259 ParseRichText(pXMLContainer, pRootStyle); 258 ParseRichText(pXMLContainer, pRootStyle);
260 pRootStyle->Release(); 259 pRootStyle->Release();
261 } 260 }
262 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, 261 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
263 IFDE_CSSComputedStyle* pParentStyle) { 262 IFDE_CSSComputedStyle* pParentStyle) {
264 if (!pXMLNode) 263 if (!pXMLNode)
265 return; 264 return;
266 265
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); 1286 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j);
1288 CFX_RectF& rect = pPiece->rtPiece; 1287 CFX_RectF& rect = pPiece->rtPiece;
1289 rect.top += fHeight; 1288 rect.top += fHeight;
1290 } 1289 }
1291 } 1290 }
1292 } 1291 }
1293 FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText, 1292 FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText,
1294 FX_FLOAT& fLinePos, 1293 FX_FLOAT& fLinePos,
1295 FX_BOOL bSavePieces) { 1294 FX_BOOL bSavePieces) {
1296 if (!m_pAllocator) { 1295 if (!m_pAllocator) {
1297 m_pAllocator.reset( 1296 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0);
1298 IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0));
1299 } 1297 }
1300 GetTextDataNode(); 1298 GetTextDataNode();
1301 if (!m_pTextDataNode) 1299 if (!m_pTextDataNode)
1302 return TRUE; 1300 return TRUE;
1303 1301
1304 if (m_bRichText) { 1302 if (m_bRichText) {
1305 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); 1303 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode();
1306 if (pXMLContainer) { 1304 if (pXMLContainer) {
1307 if (!m_textParser.IsParsed()) { 1305 if (!m_textParser.IsParsed()) {
1308 m_textParser.DoParse(pXMLContainer, m_pTextProvider); 1306 m_textParser.DoParse(pXMLContainer, m_pTextProvider);
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 m_tabstops.RemoveAll(); 2081 m_tabstops.RemoveAll();
2084 m_iTabCount = 0; 2082 m_iTabCount = 0;
2085 } 2083 }
2086 2084
2087 void CXFA_TextTabstopsContext::Reset() { 2085 void CXFA_TextTabstopsContext::Reset() {
2088 m_iTabIndex = -1; 2086 m_iTabIndex = -1;
2089 m_bTabstops = FALSE; 2087 m_bTabstops = FALSE;
2090 m_fTabWidth = 0; 2088 m_fTabWidth = 0;
2091 m_fLeft = 0; 2089 m_fLeft = 0;
2092 } 2090 }
OLDNEW
« no previous file with comments | « xfa/fgas/crt/fgas_memory.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698