Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 22 matching lines...) Expand all Loading... | |
| 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) { |
| 178 m_pszURLContent = pszText; | 178 m_pszURLContent = pszText; |
| 179 } | 179 } |
| 180 ~CXFA_LinkUserData() {} | 180 ~CXFA_LinkUserData() {} |
|
Lei Zhang
2016/05/20 23:00:52
needs override
Tom Sepez
2016/05/20 23:07:29
Done.
| |
| 181 virtual uint32_t Release() { | 181 virtual uint32_t Release() { |
| 182 uint32_t dwRefCount = --m_dwRefCount; | 182 uint32_t dwRefCount = --m_dwRefCount; |
| 183 if (dwRefCount <= 0) { | 183 if (dwRefCount <= 0) { |
| 184 FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); | 184 FXTARGET_DeleteWith(CXFA_LinkUserData, m_pAllocator, this); |
| 185 } | 185 } |
| 186 return dwRefCount; | 186 return dwRefCount; |
| 187 } | 187 } |
| 188 virtual uint32_t AddRef() { return ++m_dwRefCount; } | 188 virtual uint32_t AddRef() { return ++m_dwRefCount; } |
| 189 | 189 |
| 190 const FX_WCHAR* GetLinkURL() { return m_pszURLContent.c_str(); } | 190 const FX_WCHAR* GetLinkURL() { return m_pszURLContent.c_str(); } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 211 IFDE_CSSComputedStyle* pStyle, | 211 IFDE_CSSComputedStyle* pStyle, |
| 212 CXFA_LinkUserData* pLinkData) | 212 CXFA_LinkUserData* pLinkData) |
| 213 : m_pStyle(pStyle), | 213 : m_pStyle(pStyle), |
| 214 m_pLinkData(pLinkData), | 214 m_pLinkData(pLinkData), |
| 215 m_pAllocator(pAllocator), | 215 m_pAllocator(pAllocator), |
| 216 m_dwRefCount(0) { | 216 m_dwRefCount(0) { |
| 217 ASSERT(m_pAllocator); | 217 ASSERT(m_pAllocator); |
| 218 if (m_pStyle) | 218 if (m_pStyle) |
| 219 m_pStyle->AddRef(); | 219 m_pStyle->AddRef(); |
| 220 } | 220 } |
| 221 ~CXFA_TextUserData() { | 221 ~CXFA_TextUserData() { |
|
Lei Zhang
2016/05/20 23:00:52
needs override
Tom Sepez
2016/05/20 23:07:29
Done.
| |
| 222 if (m_pStyle) | 222 if (m_pStyle) |
| 223 m_pStyle->Release(); | 223 m_pStyle->Release(); |
| 224 if (m_pLinkData) | 224 if (m_pLinkData) |
| 225 m_pLinkData->Release(); | 225 m_pLinkData->Release(); |
| 226 } | 226 } |
| 227 virtual uint32_t Release() { | 227 virtual uint32_t Release() { |
| 228 uint32_t dwRefCount = --m_dwRefCount; | 228 uint32_t dwRefCount = --m_dwRefCount; |
| 229 if (dwRefCount == 0) { | 229 if (dwRefCount == 0) { |
| 230 FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); | 230 FXTARGET_DeleteWith(CXFA_TextUserData, m_pAllocator, this); |
| 231 } | 231 } |
| 232 return dwRefCount; | 232 return dwRefCount; |
| 233 } | 233 } |
| 234 virtual uint32_t AddRef() { return ++m_dwRefCount; } | 234 virtual uint32_t AddRef() { return ++m_dwRefCount; } |
| 235 | 235 |
| 236 IFDE_CSSComputedStyle* m_pStyle; | 236 IFDE_CSSComputedStyle* m_pStyle; |
| 237 CXFA_LinkUserData* m_pLinkData; | 237 CXFA_LinkUserData* m_pLinkData; |
| 238 | 238 |
| 239 protected: | 239 protected: |
| 240 IFX_MemoryAllocator* m_pAllocator; | 240 IFX_MemoryAllocator* m_pAllocator; |
| 241 uint32_t m_dwRefCount; | 241 uint32_t m_dwRefCount; |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 class XFA_TextPiece : public CFX_Target { | 244 class XFA_TextPiece : public CFX_Target { |
| 245 public: | 245 public: |
| 246 XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} | 246 XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} |
| 247 ~XFA_TextPiece() { | 247 ~XFA_TextPiece() { |
|
Lei Zhang
2016/05/20 23:00:52
needs override
Tom Sepez
2016/05/20 23:07:29
Done.
| |
| 248 if (pLinkData) | 248 if (pLinkData) |
| 249 pLinkData->Release(); | 249 pLinkData->Release(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 FX_WCHAR* pszText; | 252 FX_WCHAR* pszText; |
| 253 int32_t iChars; | 253 int32_t iChars; |
| 254 int32_t* pWidths; | 254 int32_t* pWidths; |
| 255 int32_t iHorScale; | 255 int32_t iHorScale; |
| 256 int32_t iVerScale; | 256 int32_t iVerScale; |
| 257 int32_t iBidiLevel; | 257 int32_t iBidiLevel; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 CFX_ArrayTemplate<XFA_TABSTOPS> m_tabstops; | 315 CFX_ArrayTemplate<XFA_TABSTOPS> m_tabstops; |
| 316 int32_t m_iTabCount; | 316 int32_t m_iTabCount; |
| 317 int32_t m_iTabIndex; | 317 int32_t m_iTabIndex; |
| 318 FX_BOOL m_bTabstops; | 318 FX_BOOL m_bTabstops; |
| 319 FX_FLOAT m_fTabWidth; | 319 FX_FLOAT m_fTabWidth; |
| 320 FX_FLOAT m_fLeft; | 320 FX_FLOAT m_fLeft; |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 class CXFA_TextLayout { | 323 class CXFA_TextLayout { |
| 324 public: | 324 public: |
| 325 CXFA_TextLayout(CXFA_TextProvider* pTextProvider); | 325 CXFA_TextLayout(CXFA_TextProvider* pTextProvider); |
|
Lei Zhang
2016/05/20 23:00:52
explicit
| |
| 326 virtual ~CXFA_TextLayout(); | 326 virtual ~CXFA_TextLayout(); |
|
Lei Zhang
2016/05/20 23:00:52
No need to be virtual.
Tom Sepez
2016/05/20 23:07:29
Done.
| |
| 327 | |
| 327 int32_t GetText(CFX_WideString& wsText); | 328 int32_t GetText(CFX_WideString& wsText); |
| 328 FX_FLOAT GetLayoutHeight(); | 329 FX_FLOAT GetLayoutHeight(); |
| 329 FX_FLOAT StartLayout(FX_FLOAT fWidth = -1); | 330 FX_FLOAT StartLayout(FX_FLOAT fWidth = -1); |
| 330 FX_BOOL DoLayout(int32_t iBlockIndex, | 331 FX_BOOL DoLayout(int32_t iBlockIndex, |
| 331 FX_FLOAT& fCalcHeight, | 332 FX_FLOAT& fCalcHeight, |
| 332 FX_FLOAT fContentAreaHeight = -1, | 333 FX_FLOAT fContentAreaHeight = -1, |
| 333 FX_FLOAT fTextHeight = -1); | 334 FX_FLOAT fTextHeight = -1); |
| 334 | 335 |
| 335 FX_BOOL CalcSize(const CFX_SizeF& minSize, | 336 FX_BOOL CalcSize(const CFX_SizeF& minSize, |
| 336 const CFX_SizeF& maxSize, | 337 const CFX_SizeF& maxSize, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 FXTEXT_CHARPOS* pCharPos, | 403 FXTEXT_CHARPOS* pCharPos, |
| 403 FX_BOOL bCharCode = FALSE); | 404 FX_BOOL bCharCode = FALSE); |
| 404 FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); | 405 FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); |
| 405 void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); | 406 void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); |
| 406 FX_BOOL Layout(int32_t iBlock); | 407 FX_BOOL Layout(int32_t iBlock); |
| 407 int32_t CountBlocks() const; | 408 int32_t CountBlocks() const; |
| 408 | 409 |
| 409 CXFA_TextProvider* m_pTextProvider; | 410 CXFA_TextProvider* m_pTextProvider; |
| 410 CXFA_Node* m_pTextDataNode; | 411 CXFA_Node* m_pTextDataNode; |
| 411 FX_BOOL m_bRichText; | 412 FX_BOOL m_bRichText; |
| 412 IFX_MemoryAllocator* m_pAllocator; | 413 std::unique_ptr<IFX_MemoryAllocator> m_pAllocator; |
| 413 CFX_RTFBreak* m_pBreak; | 414 std::unique_ptr<CFX_RTFBreak> m_pBreak; |
| 414 CXFA_LoaderContext* m_pLoader; | 415 std::unique_ptr<CXFA_LoaderContext> m_pLoader; |
| 415 int32_t m_iLines; | 416 int32_t m_iLines; |
| 416 FX_FLOAT m_fMaxWidth; | 417 FX_FLOAT m_fMaxWidth; |
| 417 CXFA_TextParser m_textParser; | 418 CXFA_TextParser m_textParser; |
| 418 CXFA_PieceLineArray m_pieceLines; | 419 CXFA_PieceLineArray m_pieceLines; |
| 419 CXFA_TextTabstopsContext* m_pTabstopContext; | 420 std::unique_ptr<CXFA_TextTabstopsContext> m_pTabstopContext; |
| 420 FX_BOOL m_bBlockContinue; | 421 FX_BOOL m_bBlockContinue; |
| 421 }; | 422 }; |
| 422 | 423 |
| 423 #endif // XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ | 424 #endif // XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ |
| OLD | NEW |