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

Side by Side Diff: core/fpdfapi/page/cpdf_streamcontentparser.h

Issue 2520133002: Remove some WrapUnique() calls by returing unique_ptrs (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 | « core/fpdfapi/page/cpdf_image.cpp ('k') | core/fpdfapi/page/cpdf_streamcontentparser.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_PAGE_CPDF_STREAMCONTENTPARSER_H_ 7 #ifndef CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ 8 #define CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_
9 9
10 #include <memory> 10 #include <memory>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; } 46 CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; }
47 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } 47 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); }
48 bool IsColored() const { return m_bColored; } 48 bool IsColored() const { return m_bColored; }
49 const FX_FLOAT* GetType3Data() const { return m_Type3Data; } 49 const FX_FLOAT* GetType3Data() const { return m_Type3Data; }
50 CPDF_Font* FindFont(const CFX_ByteString& name); 50 CPDF_Font* FindFont(const CFX_ByteString& name);
51 51
52 private: 52 private:
53 struct ContentParam { 53 struct ContentParam {
54 enum Type { OBJECT = 0, NUMBER, NAME }; 54 enum Type { OBJECT = 0, NUMBER, NAME };
55 Type m_Type; 55 Type m_Type;
56 union { 56 std::unique_ptr<CPDF_Object> m_pObject;
Tom Sepez 2016/11/21 22:11:14 note: made this into a struct rather than a union,
57 struct { 57 struct {
58 bool m_bInteger; 58 bool m_bInteger;
59 union { 59 union {
60 int m_Integer; 60 int m_Integer;
61 FX_FLOAT m_Float; 61 FX_FLOAT m_Float;
62 }; 62 };
63 } m_Number; 63 } m_Number;
64 CPDF_Object* m_pObject; 64 struct {
65 struct { 65 int m_Len;
66 int m_Len; 66 char m_Buffer[32];
67 char m_Buffer[32]; 67 } m_Name;
68 } m_Name;
69 };
70 }; 68 };
71 69
72 static const int kParamBufSize = 16; 70 static const int kParamBufSize = 16;
73 71
74 using OpCodes = 72 using OpCodes =
75 std::unordered_map<uint32_t, void (CPDF_StreamContentParser::*)()>; 73 std::unordered_map<uint32_t, void (CPDF_StreamContentParser::*)()>;
76 static OpCodes InitializeOpCodes(); 74 static OpCodes InitializeOpCodes();
77 75
78 void AddNumberParam(const FX_CHAR* str, int len); 76 void AddNumberParam(const FX_CHAR* str, int len);
79 void AddObjectParam(CPDF_Object* pObj); 77 void AddObjectParam(std::unique_ptr<CPDF_Object> pObj);
80 void AddNameParam(const FX_CHAR* name, int size); 78 void AddNameParam(const FX_CHAR* name, int size);
81 int GetNextParamPos(); 79 int GetNextParamPos();
82 void ClearAllParams(); 80 void ClearAllParams();
83 CPDF_Object* GetObject(uint32_t index); 81 CPDF_Object* GetObject(uint32_t index);
84 CFX_ByteString GetString(uint32_t index); 82 CFX_ByteString GetString(uint32_t index);
85 FX_FLOAT GetNumber(uint32_t index); 83 FX_FLOAT GetNumber(uint32_t index);
86 int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); } 84 int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); }
87 void OnOperator(const FX_CHAR* op); 85 void OnOperator(const FX_CHAR* op);
88 void AddTextObject(CFX_ByteString* pText, 86 void AddTextObject(CFX_ByteString* pText,
89 FX_FLOAT fInitKerning, 87 FX_FLOAT fInitKerning,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 CPDF_Image* m_pLastImage; 214 CPDF_Image* m_pLastImage;
217 CPDF_Dictionary* m_pLastImageDict; 215 CPDF_Dictionary* m_pLastImageDict;
218 CPDF_Dictionary* m_pLastCloneImageDict; 216 CPDF_Dictionary* m_pLastCloneImageDict;
219 bool m_bColored; 217 bool m_bColored;
220 FX_FLOAT m_Type3Data[6]; 218 FX_FLOAT m_Type3Data[6];
221 bool m_bResourceMissing; 219 bool m_bResourceMissing;
222 std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack; 220 std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack;
223 }; 221 };
224 222
225 #endif // CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ 223 #endif // CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_image.cpp ('k') | core/fpdfapi/page/cpdf_streamcontentparser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698