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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 1711753004: Cleanup misc nits in the PDF plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | pdf/pdfium/pdfium_page.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 53f9746063fad9729697cac90038f1846f90dfde..13c16c9159dd363d31a37b3c80141bc4765703cb 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -156,14 +156,14 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic,
// printing).
// TODO(noamsml): Real font substitution (http://crbug.com/391978)
if (!pp::Module::Get())
- return NULL;
+ return nullptr;
pp::BrowserFontDescription description;
// Pretend the system does not have the Symbol font to force a fallback to
// the built in Symbol font in CFX_FontMapper::FindSubstFont().
if (strcmp(face, "Symbol") == 0)
- return NULL;
+ return nullptr;
if (pitch_family & FXFONT_FF_FIXEDPITCH) {
description.set_family(PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE);
@@ -254,7 +254,7 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic,
if (!pp::PDF::IsAvailable()) {
NOTREACHED();
- return NULL;
+ return nullptr;
}
PP_Resource font_resource = pp::PDF::GetFontFileWithFallback(
@@ -406,7 +406,7 @@ void FormatStringForOS(base::string16* text) {
// Returns a VarDictionary (representing a bookmark), which in turn contains
// child VarDictionaries (representing the child bookmarks).
-// If NULL is passed in as the bookmark then we traverse from the "root".
+// If nullptr is passed in as the bookmark then we traverse from the "root".
// Note that the "root" bookmark contains no useful information.
pp::VarDictionary TraverseBookmarks(FPDF_DOCUMENT doc,
FPDF_BOOKMARK bookmark,
@@ -532,8 +532,8 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
current_rotation_(0),
doc_loader_(this),
password_tries_remaining_(0),
- doc_(NULL),
- form_(NULL),
+ doc_(nullptr),
+ form_(nullptr),
defer_page_unload_(false),
selecting_(false),
mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA,
@@ -543,7 +543,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
last_character_index_to_search_(-1),
permissions_(0),
permissions_handler_revision_(-1),
- fpdf_availability_(NULL),
+ fpdf_availability_(nullptr),
next_timer_id_(0),
last_page_mouse_down_(-1),
most_visible_page_(-1),
@@ -572,7 +572,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
// PDFiumEngine.
FPDF_FORMFILLINFO::version = 1;
FPDF_FORMFILLINFO::m_pJsPlatform = this;
- FPDF_FORMFILLINFO::Release = NULL;
+ FPDF_FORMFILLINFO::Release = nullptr;
FPDF_FORMFILLINFO::FFI_Invalidate = Form_Invalidate;
FPDF_FORMFILLINFO::FFI_OutputSelectedRect = Form_OutputSelectedRect;
FPDF_FORMFILLINFO::FFI_SetCursor = Form_SetCursor;
@@ -616,7 +616,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
IPDF_JSPLATFORM::Field_browse = Form_Browse;
IFSDK_PAUSE::version = 1;
- IFSDK_PAUSE::user = NULL;
+ IFSDK_PAUSE::user = nullptr;
IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow;
#if defined(OS_LINUX)
@@ -1351,7 +1351,7 @@ pp::Buffer_Dev PDFiumEngine::PrintPagesAsRasterPDF(
FPDF_CloseDocument(temp_doc);
PDFiumMemBufferFileRead file_read(buffer.data(), buffer.size());
- temp_doc = FPDF_LoadCustomDocument(&file_read, NULL);
+ temp_doc = FPDF_LoadCustomDocument(&file_read, nullptr);
FPDF_BOOL imported = FPDF_ImportPages(output_doc, temp_doc, "1", i);
FPDF_CloseDocument(temp_doc);
@@ -2236,7 +2236,7 @@ int PDFiumEngine::GetNumberOfPages() {
}
pp::VarArray PDFiumEngine::GetBookmarks() {
- pp::VarDictionary dict = TraverseBookmarks(doc_, NULL, 0);
+ pp::VarDictionary dict = TraverseBookmarks(doc_, nullptr, 0);
// The root bookmark contains no useful information.
return pp::VarArray(dict.Get(pp::Var("children")));
}
@@ -2626,7 +2626,8 @@ bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) {
if (!doc_ || !form_)
return false;
- if (static_cast<int>(pages_.size()) > index && pages_[index]->available())
+ const int num_pages = static_cast<int>(pages_.size());
+ if (index < num_pages && pages_[index]->available())
return true;
if (!FPDFAvail_IsPageAvail(fpdf_availability_, index, &download_hints_)) {
@@ -2641,7 +2642,7 @@ bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) {
return false;
}
- if (static_cast<int>(pages_.size()) > index)
+ if (index < num_pages)
pages_[index]->set_available(true);
if (!default_page_size_.GetArea())
default_page_size_ = GetPageSize(index);
@@ -2674,7 +2675,7 @@ int PDFiumEngine::StartPaint(int page_index, const pp::Rect& dirty) {
ProgressivePaint progressive;
progressive.rect = dirty;
progressive.page_index = page_index;
- progressive.bitmap = NULL;
+ progressive.bitmap = nullptr;
progressive.painted_ = false;
progressive_paints_.push_back(progressive);
return progressive_paints_.size() - 1;
@@ -2840,7 +2841,7 @@ void PDFiumEngine::DrawSelections(int progressive_index,
int page_index = progressive_paints_[progressive_index].page_index;
pp::Rect dirty_in_screen = progressive_paints_[progressive_index].rect;
- void* region = NULL;
+ void* region = nullptr;
int stride;
GetRegion(dirty_in_screen.point(), image_data, &region, &stride);
@@ -2905,7 +2906,7 @@ FPDF_BITMAP PDFiumEngine::CreateBitmap(const pp::Rect& rect,
int stride;
GetRegion(rect.point(), image_data, &region, &stride);
if (!region)
- return NULL;
+ return nullptr;
return FPDFBitmap_CreateEx(
rect.width(), rect.height(), FPDFBitmap_BGRx, region, stride);
}
@@ -3284,7 +3285,7 @@ void PDFiumEngine::GetRegion(const pp::Point& location,
if (image_data->is_null()) {
DCHECK(plugin_size_.IsEmpty());
*stride = 0;
- *region = NULL;
+ *region = nullptr;
return;
}
char* buffer = static_cast<char*>(image_data->data());
@@ -3294,7 +3295,7 @@ void PDFiumEngine::GetRegion(const pp::Point& location,
// TODO: update this when we support BIDI and scrollbars can be on the left.
if (!buffer ||
!pp::Rect(page_offset_, plugin_size_).Contains(offset_location)) {
- *region = NULL;
+ *region = nullptr;
return;
}
@@ -3416,7 +3417,7 @@ FPDF_PAGE PDFiumEngine::Form_GetPage(FPDF_FORMFILLINFO* param,
int page_index) {
PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
if (page_index < 0 || page_index >= static_cast<int>(engine->pages_.size()))
- return NULL;
+ return nullptr;
return engine->pages_[page_index]->GetPage();
}
@@ -3429,7 +3430,7 @@ FPDF_PAGE PDFiumEngine::Form_GetCurrentPage(FPDF_FORMFILLINFO* param,
index = engine->GetMostVisiblePage();
if (index == -1) {
NOTREACHED();
- return NULL;
+ return nullptr;
}
}
@@ -3733,7 +3734,7 @@ bool PDFiumEngineExports::RenderPDFPageToDC(const void* pdf_buffer,
int page_number,
const RenderingSettings& settings,
HDC dc) {
- FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, NULL);
+ FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, nullptr);
if (!doc)
return false;
FPDF_PAGE page = FPDF_LoadPage(doc, page_number);
@@ -3805,7 +3806,8 @@ bool PDFiumEngineExports::RenderPDFPageToBitmap(
int page_number,
const RenderingSettings& settings,
void* bitmap_buffer) {
- FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
+ FPDF_DOCUMENT doc =
+ FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
if (!doc)
return false;
FPDF_PAGE page = FPDF_LoadPage(doc, page_number);
@@ -3839,7 +3841,7 @@ bool PDFiumEngineExports::GetPDFDocInfo(const void* pdf_buffer,
int buffer_size,
int* page_count,
double* max_page_width) {
- FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, NULL);
+ FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, nullptr);
if (!doc)
return false;
int page_count_local = FPDF_GetPageCount(doc);
@@ -3867,7 +3869,8 @@ bool PDFiumEngineExports::GetPDFPageSizeByIndex(
int page_number,
double* width,
double* height) {
- FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
+ FPDF_DOCUMENT doc =
+ FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
if (!doc)
return false;
bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
« no previous file with comments | « no previous file | pdf/pdfium/pdfium_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698