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

Unified Diff: core/fpdfapi/fpdf_font/fpdf_font.cpp

Issue 2364643003: Make CPDF_Font::Create() return a std::unique_ptr. (Closed)
Patch Set: Stray file Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | core/fpdfapi/fpdf_font/include/cpdf_font.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_font/fpdf_font.cpp
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp
index 1cb67be51f5086b64b6d9dd814879c2660e63c18..a463c15da598f602fa2b6350e894e67a0cb024ce 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -60,10 +60,12 @@ CPDF_Font* CFX_StockFontArray::GetFont(uint32_t index) const {
return m_StockFonts[index].get();
}
-void CFX_StockFontArray::SetFont(uint32_t index, CPDF_Font* font) {
- if (index >= FX_ArraySize(m_StockFonts))
- return;
- m_StockFonts[index].reset(font);
+CPDF_Font* CFX_StockFontArray::SetFont(uint32_t index,
+ std::unique_ptr<CPDF_Font> pFont) {
+ CPDF_Font* result = pFont.get();
+ if (index < FX_ArraySize(m_StockFonts))
+ m_StockFonts[index] = std::move(pFont);
+ return result;
}
CPDF_FontGlobals::CPDF_FontGlobals() {
@@ -80,12 +82,12 @@ CPDF_Font* CPDF_FontGlobals::Find(CPDF_Document* pDoc, uint32_t index) {
return it->second ? it->second->GetFont(index) : nullptr;
}
-void CPDF_FontGlobals::Set(CPDF_Document* pDoc,
- uint32_t index,
- CPDF_Font* pFont) {
+CPDF_Font* CPDF_FontGlobals::Set(CPDF_Document* pDoc,
+ uint32_t index,
+ std::unique_ptr<CPDF_Font> pFont) {
if (!pdfium::ContainsKey(m_StockMap, pDoc))
m_StockMap[pDoc].reset(new CFX_StockFontArray);
- m_StockMap[pDoc]->SetFont(index, pFont);
+ return m_StockMap[pDoc]->SetFont(index, std::move(pFont));
}
void CPDF_FontGlobals::Clear(CPDF_Document* pDoc) {
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | core/fpdfapi/fpdf_font/include/cpdf_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698