Turn on enforce-in-pdf Clang plugin flag.
Fix remaining errors in pdf/ and fix some nits. Review-Url: https://codereview.chromium.org/2270463003 Cr-Commit-Position: refs/heads/master@{#413689}
This commit is contained in:
@ -43,6 +43,10 @@ config("find_bad_constructs") {
|
||||
"-plugin-arg-find-bad-constructs",
|
||||
"-Xclang",
|
||||
"follow-macro-expansion",
|
||||
"-Xclang",
|
||||
"-plugin-arg-find-bad-constructs",
|
||||
"-Xclang",
|
||||
"enforce-in-pdf",
|
||||
]
|
||||
|
||||
if ((is_linux || is_android) && !is_chromecast) {
|
||||
|
@ -297,8 +297,7 @@ class DisablePluginHelper : public content::DownloadManager::Observer,
|
||||
public content::NotificationObserver {
|
||||
public:
|
||||
DisablePluginHelper() {}
|
||||
|
||||
virtual ~DisablePluginHelper() {}
|
||||
~DisablePluginHelper() override {}
|
||||
|
||||
void DisablePlugin(Profile* profile) {
|
||||
registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
|
||||
|
@ -34,11 +34,11 @@ bool IsNegative(int32_t num) {
|
||||
// therefore be treated as an invalidation.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
PaintAggregator::PaintUpdate::PaintUpdate() {
|
||||
}
|
||||
PaintAggregator::PaintUpdate::PaintUpdate() = default;
|
||||
|
||||
PaintAggregator::PaintUpdate::~PaintUpdate() {
|
||||
}
|
||||
PaintAggregator::PaintUpdate::PaintUpdate(const PaintUpdate& that) = default;
|
||||
|
||||
PaintAggregator::PaintUpdate::~PaintUpdate() = default;
|
||||
|
||||
PaintAggregator::InternalPaintUpdate::InternalPaintUpdate() :
|
||||
synthesized_scroll_damage_rect_(false) {
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "ppapi/cpp/image_data.h"
|
||||
#include "ppapi/cpp/rect.h"
|
||||
#include "ppapi/cpp/rect.h"
|
||||
|
||||
// This class is responsible for aggregating multiple invalidation and scroll
|
||||
// commands to produce a scroll and repaint sequence. You can use this manually
|
||||
@ -31,6 +30,7 @@ class PaintAggregator {
|
||||
|
||||
struct PaintUpdate {
|
||||
PaintUpdate();
|
||||
PaintUpdate(const PaintUpdate& that);
|
||||
~PaintUpdate();
|
||||
|
||||
// True if there is a scroll applied. This indicates that the scroll delta
|
||||
|
@ -14,13 +14,22 @@
|
||||
#include "ppapi/cpp/instance.h"
|
||||
#include "ppapi/cpp/module.h"
|
||||
|
||||
PaintManager::ReadyRect::ReadyRect() = default;
|
||||
|
||||
PaintManager::ReadyRect::ReadyRect(const pp::Rect& r,
|
||||
const pp::ImageData& i,
|
||||
bool f)
|
||||
: rect(r), image_data(i), flush_now(f) {}
|
||||
|
||||
PaintManager::ReadyRect::ReadyRect(const ReadyRect& that) = default;
|
||||
|
||||
PaintManager::PaintManager(pp::Instance* instance,
|
||||
Client* client,
|
||||
bool is_always_opaque)
|
||||
: instance_(instance),
|
||||
client_(client),
|
||||
is_always_opaque_(is_always_opaque),
|
||||
callback_factory_(NULL),
|
||||
callback_factory_(nullptr),
|
||||
manual_callback_pending_(false),
|
||||
flush_pending_(false),
|
||||
has_pending_resize_(false),
|
||||
@ -164,8 +173,8 @@ void PaintManager::EnsureCallbackPending() {
|
||||
void PaintManager::DoPaint() {
|
||||
in_paint_ = true;
|
||||
|
||||
std::vector<ReadyRect> ready;
|
||||
std::vector<pp::Rect> pending;
|
||||
std::vector<ReadyRect> ready_rects;
|
||||
std::vector<pp::Rect> pending_rects;
|
||||
|
||||
DCHECK(aggregator_.HasPendingUpdate());
|
||||
|
||||
@ -201,18 +210,18 @@ void PaintManager::DoPaint() {
|
||||
}
|
||||
|
||||
PaintAggregator::PaintUpdate update = aggregator_.GetPendingUpdate();
|
||||
client_->OnPaint(update.paint_rects, &ready, &pending);
|
||||
client_->OnPaint(update.paint_rects, &ready_rects, &pending_rects);
|
||||
|
||||
if (ready.empty() && pending.empty()) {
|
||||
if (ready_rects.empty() && pending_rects.empty()) {
|
||||
in_paint_ = false;
|
||||
return; // Nothing was painted, don't schedule a flush.
|
||||
}
|
||||
|
||||
std::vector<PaintAggregator::ReadyRect> ready_now;
|
||||
if (pending.empty()) {
|
||||
if (pending_rects.empty()) {
|
||||
std::vector<PaintAggregator::ReadyRect> temp_ready;
|
||||
temp_ready.insert(temp_ready.end(), ready.begin(), ready.end());
|
||||
aggregator_.SetIntermediateResults(temp_ready, pending);
|
||||
temp_ready.insert(temp_ready.end(), ready_rects.begin(), ready_rects.end());
|
||||
aggregator_.SetIntermediateResults(temp_ready, pending_rects);
|
||||
ready_now = aggregator_.GetReadyRects();
|
||||
aggregator_.ClearPendingUpdate();
|
||||
|
||||
@ -223,7 +232,7 @@ void PaintManager::DoPaint() {
|
||||
view_size_changed_waiting_for_paint_ = false;
|
||||
} else {
|
||||
std::vector<PaintAggregator::ReadyRect> ready_later;
|
||||
for (const auto& ready_rect : ready) {
|
||||
for (const auto& ready_rect : ready_rects) {
|
||||
// Don't flush any part (i.e. scrollbars) if we're resizing the browser,
|
||||
// as that'll lead to flashes. Until we flush, the browser will use the
|
||||
// previous image, but if we flush, it'll revert to using the blank image.
|
||||
@ -238,7 +247,7 @@ void PaintManager::DoPaint() {
|
||||
}
|
||||
// Take the rectangles, except the ones that need to be flushed right away,
|
||||
// and save them so that everything is flushed at once.
|
||||
aggregator_.SetIntermediateResults(ready_later, pending);
|
||||
aggregator_.SetIntermediateResults(ready_later, pending_rects);
|
||||
|
||||
if (ready_now.empty()) {
|
||||
in_paint_ = false;
|
||||
|
@ -33,13 +33,9 @@ class PaintManager {
|
||||
// it should be flushed to the screen immediately or when the rest of the
|
||||
// plugin viewport is ready.
|
||||
struct ReadyRect {
|
||||
pp::Point offset;
|
||||
pp::Rect rect;
|
||||
pp::ImageData image_data;
|
||||
bool flush_now;
|
||||
|
||||
ReadyRect(const pp::Rect& r, const pp::ImageData& i, bool f)
|
||||
: rect(r), image_data(i), flush_now(f) {}
|
||||
ReadyRect();
|
||||
ReadyRect(const pp::Rect& r, const pp::ImageData& i, bool f);
|
||||
ReadyRect(const ReadyRect& that);
|
||||
|
||||
operator PaintAggregator::ReadyRect() const {
|
||||
PaintAggregator::ReadyRect rv;
|
||||
@ -48,6 +44,11 @@ class PaintManager {
|
||||
rv.image_data = image_data;
|
||||
return rv;
|
||||
}
|
||||
|
||||
pp::Point offset;
|
||||
pp::Rect rect;
|
||||
pp::ImageData image_data;
|
||||
bool flush_now;
|
||||
};
|
||||
class Client {
|
||||
public:
|
||||
@ -72,6 +73,7 @@ class PaintManager {
|
||||
virtual void OnPaint(const std::vector<pp::Rect>& paint_rects,
|
||||
std::vector<ReadyRect>* ready,
|
||||
std::vector<pp::Rect>* pending) = 0;
|
||||
|
||||
protected:
|
||||
// You shouldn't be doing deleting through this interface.
|
||||
virtual ~Client() {}
|
||||
|
@ -305,12 +305,9 @@ class PDFEngineExports {
|
||||
bool stretch_to_bounds,
|
||||
bool keep_aspect_ratio,
|
||||
bool center_in_bounds,
|
||||
bool autorotate)
|
||||
: dpi_x(dpi_x), dpi_y(dpi_y), bounds(bounds),
|
||||
fit_to_bounds(fit_to_bounds), stretch_to_bounds(stretch_to_bounds),
|
||||
keep_aspect_ratio(keep_aspect_ratio),
|
||||
center_in_bounds(center_in_bounds), autorotate(autorotate) {
|
||||
}
|
||||
bool autorotate);
|
||||
RenderingSettings(const RenderingSettings& that);
|
||||
|
||||
int dpi_x;
|
||||
int dpi_y;
|
||||
pp::Rect bounds;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
@ -2300,6 +2301,10 @@ pp::Rect PDFiumEngine::GetPageContentsRect(int index) {
|
||||
return GetScreenRect(pages_[index]->rect());
|
||||
}
|
||||
|
||||
int PDFiumEngine::GetVerticalScrollbarYPosition() {
|
||||
return position_.y();
|
||||
}
|
||||
|
||||
void PDFiumEngine::SetGrayscale(bool grayscale) {
|
||||
render_grayscale_ = grayscale;
|
||||
}
|
||||
@ -3777,6 +3782,26 @@ int CalculatePosition(FPDF_PAGE page,
|
||||
|
||||
} // namespace
|
||||
|
||||
PDFEngineExports::RenderingSettings::RenderingSettings(int dpi_x,
|
||||
int dpi_y,
|
||||
const pp::Rect& bounds,
|
||||
bool fit_to_bounds,
|
||||
bool stretch_to_bounds,
|
||||
bool keep_aspect_ratio,
|
||||
bool center_in_bounds,
|
||||
bool autorotate)
|
||||
: dpi_x(dpi_x),
|
||||
dpi_y(dpi_y),
|
||||
bounds(bounds),
|
||||
fit_to_bounds(fit_to_bounds),
|
||||
stretch_to_bounds(stretch_to_bounds),
|
||||
keep_aspect_ratio(keep_aspect_ratio),
|
||||
center_in_bounds(center_in_bounds),
|
||||
autorotate(autorotate) {}
|
||||
|
||||
PDFEngineExports::RenderingSettings::RenderingSettings(
|
||||
const RenderingSettings& that) = default;
|
||||
|
||||
PDFEngineExports* PDFEngineExports::Get() {
|
||||
return g_pdf_engine_exports.Pointer();
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
pp::Rect GetPageBoundsRect(int index) override;
|
||||
pp::Rect GetPageContentsRect(int index) override;
|
||||
pp::Rect GetPageScreenRect(int page_index) const override;
|
||||
int GetVerticalScrollbarYPosition() override { return position_.y(); }
|
||||
int GetVerticalScrollbarYPosition() override;
|
||||
void SetGrayscale(bool grayscale) override;
|
||||
void OnCallback(int id) override;
|
||||
int GetCharCount(int page_index) override;
|
||||
|
@ -82,14 +82,15 @@ PDFiumPage::PDFiumPage(PDFiumEngine* engine,
|
||||
const pp::Rect& r,
|
||||
bool available)
|
||||
: engine_(engine),
|
||||
page_(NULL),
|
||||
text_page_(NULL),
|
||||
page_(nullptr),
|
||||
text_page_(nullptr),
|
||||
index_(i),
|
||||
loading_count_(0),
|
||||
rect_(r),
|
||||
calculated_links_(false),
|
||||
available_(available) {
|
||||
}
|
||||
available_(available) {}
|
||||
|
||||
PDFiumPage::PDFiumPage(const PDFiumPage& that) = default;
|
||||
|
||||
PDFiumPage::~PDFiumPage() {
|
||||
DCHECK_EQ(0, loading_count_);
|
||||
@ -102,7 +103,7 @@ void PDFiumPage::Unload() {
|
||||
|
||||
if (text_page_) {
|
||||
FPDFText_ClosePage(text_page_);
|
||||
text_page_ = NULL;
|
||||
text_page_ = nullptr;
|
||||
}
|
||||
|
||||
if (page_) {
|
||||
@ -110,14 +111,14 @@ void PDFiumPage::Unload() {
|
||||
FORM_OnBeforeClosePage(page_, engine_->form());
|
||||
}
|
||||
FPDF_ClosePage(page_);
|
||||
page_ = NULL;
|
||||
page_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
FPDF_PAGE PDFiumPage::GetPage() {
|
||||
ScopedUnsupportedFeature scoped_unsupported_feature(engine_);
|
||||
if (!available_)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!page_) {
|
||||
ScopedLoadCounter scoped_load(this);
|
||||
page_ = FPDF_LoadPage(engine_->doc(), index_);
|
||||
@ -131,7 +132,7 @@ FPDF_PAGE PDFiumPage::GetPage() {
|
||||
FPDF_PAGE PDFiumPage::GetPrintPage() {
|
||||
ScopedUnsupportedFeature scoped_unsupported_feature(engine_);
|
||||
if (!available_)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!page_) {
|
||||
ScopedLoadCounter scoped_load(this);
|
||||
page_ = FPDF_LoadPage(engine_->doc(), index_);
|
||||
@ -146,13 +147,13 @@ void PDFiumPage::ClosePrintPage() {
|
||||
|
||||
if (page_) {
|
||||
FPDF_ClosePage(page_);
|
||||
page_ = NULL;
|
||||
page_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
FPDF_TEXTPAGE PDFiumPage::GetTextPage() {
|
||||
if (!available_)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!text_page_) {
|
||||
ScopedLoadCounter scoped_load(this);
|
||||
text_page_ = FPDFText_LoadPage(GetPage());
|
||||
@ -319,7 +320,7 @@ PDFiumPage::Area PDFiumPage::GetLinkTarget(
|
||||
case PDFACTION_URI: {
|
||||
if (target) {
|
||||
size_t buffer_size =
|
||||
FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0);
|
||||
FPDFAction_GetURIPath(engine_->doc(), action, nullptr, 0);
|
||||
if (buffer_size > 0) {
|
||||
PDFiumAPIStringBufferAdapter<std::string> api_string_adapter(
|
||||
&target->url, buffer_size, true);
|
||||
@ -403,7 +404,7 @@ void PDFiumPage::CalculateLinks() {
|
||||
int count = FPDFLink_CountWebLinks(links);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
base::string16 url;
|
||||
int url_length = FPDFLink_GetURL(links, i, NULL, 0);
|
||||
int url_length = FPDFLink_GetURL(links, i, nullptr, 0);
|
||||
if (url_length > 0) {
|
||||
PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(
|
||||
&url, url_length, true);
|
||||
@ -497,10 +498,10 @@ PDFiumPage::ScopedLoadCounter::~ScopedLoadCounter() {
|
||||
page_->loading_count_--;
|
||||
}
|
||||
|
||||
PDFiumPage::Link::Link() {
|
||||
}
|
||||
PDFiumPage::Link::Link() = default;
|
||||
|
||||
PDFiumPage::Link::~Link() {
|
||||
}
|
||||
PDFiumPage::Link::Link(const Link& that) = default;
|
||||
|
||||
PDFiumPage::Link::~Link() = default;
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -25,6 +25,7 @@ class PDFiumPage {
|
||||
int i,
|
||||
const pp::Rect& r,
|
||||
bool available);
|
||||
PDFiumPage(const PDFiumPage& that);
|
||||
~PDFiumPage();
|
||||
|
||||
// Unloads the PDFium data for this page from memory.
|
||||
@ -123,6 +124,7 @@ class PDFiumPage {
|
||||
|
||||
struct Link {
|
||||
Link();
|
||||
Link(const Link& that);
|
||||
~Link();
|
||||
|
||||
std::string url;
|
||||
|
@ -17,8 +17,9 @@ PDFiumRange::PDFiumRange(PDFiumPage* page, int char_index, int char_count)
|
||||
cached_screen_rects_zoom_(0) {
|
||||
}
|
||||
|
||||
PDFiumRange::~PDFiumRange() {
|
||||
}
|
||||
PDFiumRange::PDFiumRange(const PDFiumRange& that) = default;
|
||||
|
||||
PDFiumRange::~PDFiumRange() = default;
|
||||
|
||||
void PDFiumRange::SetCharCount(int char_count) {
|
||||
char_count_ = char_count;
|
||||
|
@ -18,6 +18,7 @@ namespace chrome_pdf {
|
||||
class PDFiumRange {
|
||||
public:
|
||||
PDFiumRange(PDFiumPage* page, int char_index, int char_count);
|
||||
PDFiumRange(const PDFiumRange& that);
|
||||
~PDFiumRange();
|
||||
|
||||
// Update how many characters are in the selection. Could be negative if
|
||||
|
Reference in New Issue
Block a user