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

Side by Side Diff: core/fpdfapi/page/cpdf_page.cpp

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase Created 4 years 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_form.cpp ('k') | core/fpdfapi/page/cpdf_tilingpattern.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 #include "core/fpdfapi/page/cpdf_page.h" 7 #include "core/fpdfapi/page/cpdf_page.h"
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 11
12 #include "core/fpdfapi/cpdf_pagerendercontext.h" 12 #include "core/fpdfapi/cpdf_pagerendercontext.h"
13 #include "core/fpdfapi/page/cpdf_contentparser.h" 13 #include "core/fpdfapi/page/cpdf_contentparser.h"
14 #include "core/fpdfapi/page/cpdf_pageobject.h" 14 #include "core/fpdfapi/page/cpdf_pageobject.h"
15 #include "core/fpdfapi/page/pageint.h" 15 #include "core/fpdfapi/page/pageint.h"
16 #include "core/fpdfapi/parser/cpdf_array.h" 16 #include "core/fpdfapi/parser/cpdf_array.h"
17 #include "core/fpdfapi/parser/cpdf_dictionary.h" 17 #include "core/fpdfapi/parser/cpdf_dictionary.h"
18 #include "core/fpdfapi/parser/cpdf_object.h" 18 #include "core/fpdfapi/parser/cpdf_object.h"
19 #include "core/fpdfapi/render/cpdf_pagerendercache.h" 19 #include "core/fpdfapi/render/cpdf_pagerendercache.h"
20 #include "third_party/base/ptr_util.h"
20 #include "third_party/base/stl_util.h" 21 #include "third_party/base/stl_util.h"
21 22
22 CPDF_Page::CPDF_Page(CPDF_Document* pDocument, 23 CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
23 CPDF_Dictionary* pPageDict, 24 CPDF_Dictionary* pPageDict,
24 bool bPageCache) 25 bool bPageCache)
25 : m_PageWidth(100), 26 : m_PageWidth(100),
26 m_PageHeight(100), 27 m_PageHeight(100),
27 m_pView(nullptr), 28 m_pView(nullptr),
28 m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) { 29 m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) {
29 m_pFormDict = pPageDict; 30 m_pFormDict = pPageDict;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 m_Transparency = PDFTRANS_ISOLATED; 82 m_Transparency = PDFTRANS_ISOLATED;
82 LoadTransInfo(); 83 LoadTransInfo();
83 } 84 }
84 85
85 CPDF_Page::~CPDF_Page() {} 86 CPDF_Page::~CPDF_Page() {}
86 87
87 void CPDF_Page::StartParse() { 88 void CPDF_Page::StartParse() {
88 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) 89 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
89 return; 90 return;
90 91
91 m_pParser.reset(new CPDF_ContentParser); 92 m_pParser = pdfium::MakeUnique<CPDF_ContentParser>();
92 m_pParser->Start(this); 93 m_pParser->Start(this);
93 m_ParseState = CONTENT_PARSING; 94 m_ParseState = CONTENT_PARSING;
94 } 95 }
95 96
96 void CPDF_Page::ParseContent() { 97 void CPDF_Page::ParseContent() {
97 StartParse(); 98 StartParse();
98 ContinueParse(nullptr); 99 ContinueParse(nullptr);
99 } 100 }
100 101
101 void CPDF_Page::SetRenderContext( 102 void CPDF_Page::SetRenderContext(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 x2 = xPos + xSize; 169 x2 = xPos + xSize;
169 y2 = yPos; 170 y2 = yPos;
170 break; 171 break;
171 } 172 }
172 display_matrix.Set((x2 - x0) / m_PageWidth, (y2 - y0) / m_PageWidth, 173 display_matrix.Set((x2 - x0) / m_PageWidth, (y2 - y0) / m_PageWidth,
173 (x1 - x0) / m_PageHeight, (y1 - y0) / m_PageHeight, x0, 174 (x1 - x0) / m_PageHeight, (y1 - y0) / m_PageHeight, x0,
174 y0); 175 y0);
175 matrix = m_PageMatrix; 176 matrix = m_PageMatrix;
176 matrix.Concat(display_matrix); 177 matrix.Concat(display_matrix);
177 } 178 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_form.cpp ('k') | core/fpdfapi/page/cpdf_tilingpattern.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698