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

Side by Side Diff: core/fpdfapi/parser/cpdf_document.h

Issue 2461063003: Revert of Traverse PDF page tree only once in CPDF_Document Try 2 (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | core/fpdfapi/parser/cpdf_document.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_
9 9
10 #include <functional> 10 #include <functional>
11 #include <memory> 11 #include <memory>
12 #include <stack>
13 12
14 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" 13 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
15 #include "core/fpdfapi/parser/cpdf_object.h" 14 #include "core/fpdfapi/parser/cpdf_object.h"
16 #include "core/fpdfdoc/cpdf_linklist.h" 15 #include "core/fpdfdoc/cpdf_linklist.h"
17 #include "core/fxcrt/cfx_string_pool_template.h" 16 #include "core/fxcrt/cfx_string_pool_template.h"
18 #include "core/fxcrt/cfx_weak_ptr.h" 17 #include "core/fxcrt/cfx_weak_ptr.h"
19 #include "core/fxcrt/fx_basic.h" 18 #include "core/fxcrt/fx_basic.h"
20 19
21 class CFX_Font; 20 class CFX_Font;
22 class CFX_Matrix; 21 class CFX_Matrix;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 FX_BOOL bVert, 98 FX_BOOL bVert,
100 FX_BOOL bTranslateName = FALSE); 99 FX_BOOL bTranslateName = FALSE);
101 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, 100 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont,
102 FX_BOOL bVert, 101 FX_BOOL bVert,
103 FX_BOOL bTranslateName = FALSE); 102 FX_BOOL bTranslateName = FALSE);
104 #endif 103 #endif
105 104
106 protected: 105 protected:
107 // Retrieve page count information by getting count value from the tree nodes 106 // Retrieve page count information by getting count value from the tree nodes
108 int RetrievePageCount() const; 107 int RetrievePageCount() const;
109 CPDF_Dictionary* TraversePDFPages(int iPage, int nPagesToGo); 108 CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages,
109 int iPage,
110 int nPagesToGo,
111 int level);
110 int FindPageIndex(CPDF_Dictionary* pNode, 112 int FindPageIndex(CPDF_Dictionary* pNode,
111 uint32_t& skip_count, 113 uint32_t& skip_count,
112 uint32_t objnum, 114 uint32_t objnum,
113 int& index, 115 int& index,
114 int level = 0); 116 int level = 0);
115 CPDF_Object* ParseIndirectObject(uint32_t objnum) override; 117 CPDF_Object* ParseIndirectObject(uint32_t objnum) override;
116 void LoadDocInternal(); 118 void LoadDocInternal();
117 size_t CalculateEncodingDict(int charset, CPDF_Dictionary* pBaseDict); 119 size_t CalculateEncodingDict(int charset, CPDF_Dictionary* pBaseDict);
118 CPDF_Dictionary* GetPagesDict() const; 120 CPDF_Dictionary* GetPagesDict() const;
119 CPDF_Dictionary* ProcessbCJK( 121 CPDF_Dictionary* ProcessbCJK(
120 CPDF_Dictionary* pBaseDict, 122 CPDF_Dictionary* pBaseDict,
121 int charset, 123 int charset,
122 FX_BOOL bVert, 124 FX_BOOL bVert,
123 CFX_ByteString basefont, 125 CFX_ByteString basefont,
124 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert); 126 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert);
125 int InsertDeletePDFPage(CPDF_Dictionary* pPages, 127
126 int nPagesToGo,
127 CPDF_Dictionary* pPage,
128 FX_BOOL bInsert,
129 std::set<CPDF_Dictionary*>* pVisited);
130 int InsertNewPage(int iPage,
131 CPDF_Dictionary* pPageDict,
132 CFX_ArrayTemplate<uint32_t>& pageList);
133 void PopAndPropagate();
134 std::unique_ptr<CPDF_Parser> m_pParser; 128 std::unique_ptr<CPDF_Parser> m_pParser;
135 CPDF_Dictionary* m_pRootDict; 129 CPDF_Dictionary* m_pRootDict;
136 CPDF_Dictionary* m_pInfoDict; 130 CPDF_Dictionary* m_pInfoDict;
137 // Stack of page nodes to know current position in page tree. Int is the index
138 // of last processed child.
139 std::stack<std::pair<CPDF_Dictionary*, int>> m_pTreeTraversal;
140 // Index of last page (leaf) processed from page tree.
141 int m_iLastPageTraversed;
142 bool m_bLinearized; 131 bool m_bLinearized;
143 int m_iFirstPageNo; 132 int m_iFirstPageNo;
144 uint32_t m_dwFirstPageObjNum; 133 uint32_t m_dwFirstPageObjNum;
145 // TODO(thestig): Figure out why this cannot be a std::unique_ptr. 134 // TODO(thestig): Figure out why this cannot be a std::unique_ptr.
146 CPDF_DocPageData* m_pDocPage; 135 CPDF_DocPageData* m_pDocPage;
147 std::unique_ptr<CPDF_DocRenderData> m_pDocRender; 136 std::unique_ptr<CPDF_DocRenderData> m_pDocRender;
148 std::unique_ptr<JBig2_DocumentContext> m_pCodecContext; 137 std::unique_ptr<JBig2_DocumentContext> m_pCodecContext;
149 std::unique_ptr<CPDF_LinkList> m_pLinksContext; 138 std::unique_ptr<CPDF_LinkList> m_pLinksContext;
150 CFX_ArrayTemplate<uint32_t> m_PageList; 139 CFX_ArrayTemplate<uint32_t> m_PageList;
151 CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool; 140 CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool;
152 }; 141 };
153 142
154 #endif // CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ 143 #endif // CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/parser/cpdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698