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

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

Issue 2003843002: Remove Release() from CFX_RTFBreak (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Consistent use of override. Created 4 years, 7 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/layout/fgas_rtfbreak.h ('k') | xfa/fxfa/app/xfa_textlayout.cpp » ('j') | 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 #ifndef XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ 7 #ifndef XFA_FXFA_APP_XFA_TEXTLAYOUT_H_
8 #define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ 8 #define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 class CXFA_TextParser { 81 class CXFA_TextParser {
82 public: 82 public:
83 CXFA_TextParser(); 83 CXFA_TextParser();
84 virtual ~CXFA_TextParser(); 84 virtual ~CXFA_TextParser();
85 void Reset(); 85 void Reset();
86 void DoParse(CFDE_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider); 86 void DoParse(CFDE_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider);
87 IFDE_CSSComputedStyle* CreateRootStyle(CXFA_TextProvider* pTextProvider); 87 IFDE_CSSComputedStyle* CreateRootStyle(CXFA_TextProvider* pTextProvider);
88 IFDE_CSSComputedStyle* ComputeStyle(CFDE_XMLNode* pXMLNode, 88 IFDE_CSSComputedStyle* ComputeStyle(CFDE_XMLNode* pXMLNode,
89 IFDE_CSSComputedStyle* pParentStyle); 89 IFDE_CSSComputedStyle* pParentStyle);
90 FX_BOOL IsParsed() const { return m_pAllocator != NULL; } 90 FX_BOOL IsParsed() const { return !!m_pAllocator; }
91 91
92 int32_t GetVAlign(CXFA_TextProvider* pTextProvider) const; 92 int32_t GetVAlign(CXFA_TextProvider* pTextProvider) const;
93 FX_FLOAT GetTabInterval(IFDE_CSSComputedStyle* pStyle) const; 93 FX_FLOAT GetTabInterval(IFDE_CSSComputedStyle* pStyle) const;
94 int32_t CountTabs(IFDE_CSSComputedStyle* pStyle) const; 94 int32_t CountTabs(IFDE_CSSComputedStyle* pStyle) const;
95 FX_BOOL IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const; 95 FX_BOOL IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const;
96 FX_BOOL GetTabstops(IFDE_CSSComputedStyle* pStyle, 96 FX_BOOL GetTabstops(IFDE_CSSComputedStyle* pStyle,
97 CXFA_TextTabstopsContext* pTabstopContext); 97 CXFA_TextTabstopsContext* pTabstopContext);
98 IFX_Font* GetFont(CXFA_TextProvider* pTextProvider, 98 IFX_Font* GetFont(CXFA_TextProvider* pTextProvider,
99 IFDE_CSSComputedStyle* pStyle) const; 99 IFDE_CSSComputedStyle* pStyle) const;
100 FX_FLOAT GetFontSize(CXFA_TextProvider* pTextProvider, 100 FX_FLOAT GetFontSize(CXFA_TextProvider* pTextProvider,
(...skipping 26 matching lines...) Expand all
127 protected: 127 protected:
128 bool TagValidate(const CFX_WideString& str) const; 128 bool TagValidate(const CFX_WideString& str) const;
129 129
130 private: 130 private:
131 void InitCSSData(CXFA_TextProvider* pTextProvider); 131 void InitCSSData(CXFA_TextProvider* pTextProvider);
132 void ParseRichText(CFDE_XMLNode* pXMLNode, 132 void ParseRichText(CFDE_XMLNode* pXMLNode,
133 IFDE_CSSComputedStyle* pParentStyle); 133 IFDE_CSSComputedStyle* pParentStyle);
134 void ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider); 134 void ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider);
135 IFDE_CSSStyleSheet* LoadDefaultSheetStyle(); 135 IFDE_CSSStyleSheet* LoadDefaultSheetStyle();
136 IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle); 136 IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle);
137 IFX_MemoryAllocator* m_pAllocator; 137 std::unique_ptr<IFX_MemoryAllocator> m_pAllocator;
138 std::unique_ptr<CFDE_CSSStyleSelector> m_pSelector; 138 std::unique_ptr<CFDE_CSSStyleSelector> m_pSelector;
139 IFDE_CSSStyleSheet* m_pUASheet; 139 IFDE_CSSStyleSheet* m_pUASheet;
140 CFX_MapPtrTemplate<CFDE_XMLNode*, CXFA_TextParseContext*> 140 CFX_MapPtrTemplate<CFDE_XMLNode*, CXFA_TextParseContext*>
141 m_mapXMLNodeToParseContext; 141 m_mapXMLNodeToParseContext;
142 }; 142 };
143 143
144 class CXFA_LoaderContext { 144 class CXFA_LoaderContext {
145 public: 145 public:
146 CXFA_LoaderContext() 146 CXFA_LoaderContext()
147 : m_bSaveLineHeight(FALSE), 147 : m_bSaveLineHeight(FALSE),
(...skipping 19 matching lines...) Expand all
167 CXFA_Node* m_pNode; 167 CXFA_Node* m_pNode;
168 IFDE_CSSComputedStyle* m_pParentStyle; 168 IFDE_CSSComputedStyle* m_pParentStyle;
169 CFX_ArrayTemplate<FX_FLOAT> m_lineHeights; 169 CFX_ArrayTemplate<FX_FLOAT> m_lineHeights;
170 uint32_t m_dwFlags; 170 uint32_t m_dwFlags;
171 CFX_FloatArray m_BlocksHeight; 171 CFX_FloatArray m_BlocksHeight;
172 }; 172 };
173 173
174 class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target { 174 class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target {
175 public: 175 public:
176 CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, FX_WCHAR* pszText) 176 CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, FX_WCHAR* pszText)
177 : m_pAllocator(pAllocator), m_dwRefCount(1) { 177 : m_pAllocator(pAllocator), m_dwRefCount(1), m_wsURLContent(pszText) {}
178 m_pszURLContent = pszText; 178
179 } 179 ~CXFA_LinkUserData() override {}
180 ~CXFA_LinkUserData() {} 180
181 virtual uint32_t Release() { 181 uint32_t AddRef() override { return ++m_dwRefCount; }
182 uint32_t Release() override {
182 uint32_t dwRefCount = --m_dwRefCount; 183 uint32_t dwRefCount = --m_dwRefCount;
183 if (dwRefCount <= 0) { 184 if (dwRefCount <= 0)
184 FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); 185 FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this);
185 }
186 return dwRefCount; 186 return dwRefCount;
187 } 187 }
188 virtual uint32_t AddRef() { return ++m_dwRefCount; }
189 188
190 const FX_WCHAR* GetLinkURL() { return m_pszURLContent.c_str(); } 189 const FX_WCHAR* GetLinkURL() { return m_wsURLContent.c_str(); }
191 190
192 protected: 191 protected:
193 IFX_MemoryAllocator* m_pAllocator; 192 IFX_MemoryAllocator* m_pAllocator;
194 uint32_t m_dwRefCount; 193 uint32_t m_dwRefCount;
195 CFX_WideString m_pszURLContent; 194 CFX_WideString m_wsURLContent;
196 }; 195 };
197 196
198 class CXFA_TextUserData : public IFX_Unknown, public CFX_Target { 197 class CXFA_TextUserData : public IFX_Unknown, public CFX_Target {
199 public: 198 public:
200 CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, 199 CXFA_TextUserData(IFX_MemoryAllocator* pAllocator,
201 IFDE_CSSComputedStyle* pStyle) 200 IFDE_CSSComputedStyle* pStyle)
202 : m_pStyle(pStyle), 201 : m_pStyle(pStyle),
203 m_pLinkData(nullptr), 202 m_pLinkData(nullptr),
204 m_pAllocator(pAllocator), 203 m_pAllocator(pAllocator),
205 m_dwRefCount(0) { 204 m_dwRefCount(0) {
206 ASSERT(m_pAllocator); 205 ASSERT(m_pAllocator);
207 if (m_pStyle) 206 if (m_pStyle)
208 m_pStyle->AddRef(); 207 m_pStyle->AddRef();
209 } 208 }
210 CXFA_TextUserData(IFX_MemoryAllocator* pAllocator, 209 CXFA_TextUserData(IFX_MemoryAllocator* pAllocator,
211 IFDE_CSSComputedStyle* pStyle, 210 IFDE_CSSComputedStyle* pStyle,
212 CXFA_LinkUserData* pLinkData) 211 CXFA_LinkUserData* pLinkData)
213 : m_pStyle(pStyle), 212 : m_pStyle(pStyle),
214 m_pLinkData(pLinkData), 213 m_pLinkData(pLinkData),
215 m_pAllocator(pAllocator), 214 m_pAllocator(pAllocator),
216 m_dwRefCount(0) { 215 m_dwRefCount(0) {
217 ASSERT(m_pAllocator); 216 ASSERT(m_pAllocator);
218 if (m_pStyle) 217 if (m_pStyle)
219 m_pStyle->AddRef(); 218 m_pStyle->AddRef();
220 } 219 }
221 ~CXFA_TextUserData() { 220 ~CXFA_TextUserData() override {
222 if (m_pStyle) 221 if (m_pStyle)
223 m_pStyle->Release(); 222 m_pStyle->Release();
224 if (m_pLinkData) 223 if (m_pLinkData)
225 m_pLinkData->Release(); 224 m_pLinkData->Release();
226 } 225 }
227 virtual uint32_t Release() { 226
227 uint32_t AddRef() override { return ++m_dwRefCount; }
228 uint32_t Release() override {
228 uint32_t dwRefCount = --m_dwRefCount; 229 uint32_t dwRefCount = --m_dwRefCount;
229 if (dwRefCount == 0) { 230 if (dwRefCount == 0)
230 FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); 231 FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this);
231 }
232 return dwRefCount; 232 return dwRefCount;
233 } 233 }
234 virtual uint32_t AddRef() { return ++m_dwRefCount; }
235 234
236 IFDE_CSSComputedStyle* m_pStyle; 235 IFDE_CSSComputedStyle* m_pStyle;
237 CXFA_LinkUserData* m_pLinkData; 236 CXFA_LinkUserData* m_pLinkData;
238 237
239 protected: 238 protected:
240 IFX_MemoryAllocator* m_pAllocator; 239 IFX_MemoryAllocator* m_pAllocator;
241 uint32_t m_dwRefCount; 240 uint32_t m_dwRefCount;
242 }; 241 };
243 242
244 class XFA_TextPiece : public CFX_Target { 243 class XFA_TextPiece : public CFX_Target {
245 public: 244 public:
246 XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} 245 XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {}
247 ~XFA_TextPiece() { 246 ~XFA_TextPiece() override {
248 if (pLinkData) 247 if (pLinkData)
249 pLinkData->Release(); 248 pLinkData->Release();
250 } 249 }
251 250
252 FX_WCHAR* pszText; 251 FX_WCHAR* pszText;
253 int32_t iChars; 252 int32_t iChars;
254 int32_t* pWidths; 253 int32_t* pWidths;
255 int32_t iHorScale; 254 int32_t iHorScale;
256 int32_t iVerScale; 255 int32_t iVerScale;
257 int32_t iBidiLevel; 256 int32_t iBidiLevel;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 CFX_ArrayTemplate<XFA_TABSTOPS> m_tabstops; 314 CFX_ArrayTemplate<XFA_TABSTOPS> m_tabstops;
316 int32_t m_iTabCount; 315 int32_t m_iTabCount;
317 int32_t m_iTabIndex; 316 int32_t m_iTabIndex;
318 FX_BOOL m_bTabstops; 317 FX_BOOL m_bTabstops;
319 FX_FLOAT m_fTabWidth; 318 FX_FLOAT m_fTabWidth;
320 FX_FLOAT m_fLeft; 319 FX_FLOAT m_fLeft;
321 }; 320 };
322 321
323 class CXFA_TextLayout { 322 class CXFA_TextLayout {
324 public: 323 public:
325 CXFA_TextLayout(CXFA_TextProvider* pTextProvider); 324 explicit CXFA_TextLayout(CXFA_TextProvider* pTextProvider);
326 virtual ~CXFA_TextLayout(); 325 ~CXFA_TextLayout();
326
327 int32_t GetText(CFX_WideString& wsText); 327 int32_t GetText(CFX_WideString& wsText);
328 FX_FLOAT GetLayoutHeight(); 328 FX_FLOAT GetLayoutHeight();
329 FX_FLOAT StartLayout(FX_FLOAT fWidth = -1); 329 FX_FLOAT StartLayout(FX_FLOAT fWidth = -1);
330 FX_BOOL DoLayout(int32_t iBlockIndex, 330 FX_BOOL DoLayout(int32_t iBlockIndex,
331 FX_FLOAT& fCalcHeight, 331 FX_FLOAT& fCalcHeight,
332 FX_FLOAT fContentAreaHeight = -1, 332 FX_FLOAT fContentAreaHeight = -1,
333 FX_FLOAT fTextHeight = -1); 333 FX_FLOAT fTextHeight = -1);
334 334
335 FX_BOOL CalcSize(const CFX_SizeF& minSize, 335 FX_BOOL CalcSize(const CFX_SizeF& minSize,
336 const CFX_SizeF& maxSize, 336 const CFX_SizeF& maxSize,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 FXTEXT_CHARPOS* pCharPos, 402 FXTEXT_CHARPOS* pCharPos,
403 FX_BOOL bCharCode = FALSE); 403 FX_BOOL bCharCode = FALSE);
404 FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); 404 FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr);
405 void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); 405 void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine);
406 FX_BOOL Layout(int32_t iBlock); 406 FX_BOOL Layout(int32_t iBlock);
407 int32_t CountBlocks() const; 407 int32_t CountBlocks() const;
408 408
409 CXFA_TextProvider* m_pTextProvider; 409 CXFA_TextProvider* m_pTextProvider;
410 CXFA_Node* m_pTextDataNode; 410 CXFA_Node* m_pTextDataNode;
411 FX_BOOL m_bRichText; 411 FX_BOOL m_bRichText;
412 IFX_MemoryAllocator* m_pAllocator; 412 std::unique_ptr<IFX_MemoryAllocator> m_pAllocator;
413 CFX_RTFBreak* m_pBreak; 413 std::unique_ptr<CFX_RTFBreak> m_pBreak;
414 CXFA_LoaderContext* m_pLoader; 414 std::unique_ptr<CXFA_LoaderContext> m_pLoader;
415 int32_t m_iLines; 415 int32_t m_iLines;
416 FX_FLOAT m_fMaxWidth; 416 FX_FLOAT m_fMaxWidth;
417 CXFA_TextParser m_textParser; 417 CXFA_TextParser m_textParser;
418 CXFA_PieceLineArray m_pieceLines; 418 CXFA_PieceLineArray m_pieceLines;
419 CXFA_TextTabstopsContext* m_pTabstopContext; 419 std::unique_ptr<CXFA_TextTabstopsContext> m_pTabstopContext;
420 FX_BOOL m_bBlockContinue; 420 FX_BOOL m_bBlockContinue;
421 }; 421 };
422 422
423 #endif // XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ 423 #endif // XFA_FXFA_APP_XFA_TEXTLAYOUT_H_
OLDNEW
« no previous file with comments | « xfa/fgas/layout/fgas_rtfbreak.h ('k') | xfa/fxfa/app/xfa_textlayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698