Commit a2e41ca9 authored by Hui Yingst's avatar Hui Yingst Committed by Chromium LUCI CQ

Make PdfViewWebPlugin a derived class from PaintManager::Client.

Similar to OutOfProcessInstance, this CL makes PdfViewWebPlugin a
derived class from PaintManager::Client, and adds an attribute
|paint_manager_| to it, so that PdfViewWebPlugin can use the current
PaintManager in the future.

Bug: 1099020
Change-Id: If0ec99e02a4e82a6ada049e499387e5d3df41a20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580523
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837296}
parent 00dd30ff
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "pdf/pdf_engine.h" #include "pdf/pdf_engine.h"
#include "pdf/pdf_init.h" #include "pdf/pdf_init.h"
#include "pdf/pdfium/pdfium_engine.h" #include "pdf/pdfium/pdfium_engine.h"
#include "pdf/ppapi_migration/graphics.h"
#include "pdf/ppapi_migration/url_loader.h" #include "pdf/ppapi_migration/url_loader.h"
#include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_errors.h"
#include "third_party/blink/public/common/input/web_coalesced_input_event.h" #include "third_party/blink/public/common/input/web_coalesced_input_event.h"
...@@ -339,6 +340,26 @@ PdfViewWebPlugin::CreateAssociatedURLLoader( ...@@ -339,6 +340,26 @@ PdfViewWebPlugin::CreateAssociatedURLLoader(
options); options);
} }
std::unique_ptr<Graphics> PdfViewWebPlugin::CreatePaintGraphics(
const gfx::Size& size) {
auto graphics = SkiaGraphics::Create(size);
DCHECK(graphics);
return graphics;
}
bool PdfViewWebPlugin::BindPaintGraphics(Graphics& graphics) {
NOTIMPLEMENTED_LOG_ONCE();
return false;
}
// TODO(https://crbug.com/1099020): To be implemented as a Pepper-free version
// of `OutOfProcessInstance::OnPaint()`
void PdfViewWebPlugin::OnPaint(const std::vector<gfx::Rect>& paint_rects,
std::vector<PaintReadyRect>* ready,
std::vector<gfx::Rect>* pending) {
NOTIMPLEMENTED_LOG_ONCE();
}
base::WeakPtr<PdfViewPluginBase> PdfViewWebPlugin::GetWeakPtr() { base::WeakPtr<PdfViewPluginBase> PdfViewWebPlugin::GetWeakPtr() {
return weak_factory_.GetWeakPtr(); return weak_factory_.GetWeakPtr();
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define PDF_PDF_VIEW_WEB_PLUGIN_H_ #define PDF_PDF_VIEW_WEB_PLUGIN_H_
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "pdf/paint_manager.h"
#include "pdf/pdf_view_plugin_base.h" #include "pdf/pdf_view_plugin_base.h"
#include "pdf/ppapi_migration/url_loader.h" #include "pdf/ppapi_migration/url_loader.h"
#include "third_party/blink/public/web/web_plugin.h" #include "third_party/blink/public/web/web_plugin.h"
...@@ -20,7 +21,8 @@ namespace chrome_pdf { ...@@ -20,7 +21,8 @@ namespace chrome_pdf {
// Skeleton for a `blink::WebPlugin` to replace `OutOfProcessInstance`. // Skeleton for a `blink::WebPlugin` to replace `OutOfProcessInstance`.
class PdfViewWebPlugin final : public PdfViewPluginBase, class PdfViewWebPlugin final : public PdfViewPluginBase,
public blink::WebPlugin, public blink::WebPlugin,
public BlinkUrlLoader::Client { public BlinkUrlLoader::Client,
public PaintManager::Client {
public: public:
explicit PdfViewWebPlugin(const blink::WebPluginParams& params); explicit PdfViewWebPlugin(const blink::WebPluginParams& params);
PdfViewWebPlugin(const PdfViewWebPlugin& other) = delete; PdfViewWebPlugin(const PdfViewWebPlugin& other) = delete;
...@@ -113,6 +115,13 @@ class PdfViewWebPlugin final : public PdfViewPluginBase, ...@@ -113,6 +115,13 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
std::unique_ptr<blink::WebAssociatedURLLoader> CreateAssociatedURLLoader( std::unique_ptr<blink::WebAssociatedURLLoader> CreateAssociatedURLLoader(
const blink::WebAssociatedURLLoaderOptions& options) override; const blink::WebAssociatedURLLoaderOptions& options) override;
// PaintManager::Client:
std::unique_ptr<Graphics> CreatePaintGraphics(const gfx::Size& size) override;
bool BindPaintGraphics(Graphics& graphics) override;
void OnPaint(const std::vector<gfx::Rect>& paint_rects,
std::vector<PaintReadyRect>* ready,
std::vector<gfx::Rect>* pending) override;
protected: protected:
// PdfViewPluginBase: // PdfViewPluginBase:
base::WeakPtr<PdfViewPluginBase> GetWeakPtr() override; base::WeakPtr<PdfViewPluginBase> GetWeakPtr() override;
...@@ -128,6 +137,8 @@ class PdfViewWebPlugin final : public PdfViewPluginBase, ...@@ -128,6 +137,8 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
blink::WebPluginParams initial_params_; blink::WebPluginParams initial_params_;
blink::WebPluginContainer* container_ = nullptr; blink::WebPluginContainer* container_ = nullptr;
PaintManager paint_manager_{this};
// The background color of the PDF viewer. // The background color of the PDF viewer.
uint32_t background_color_ = 0; uint32_t background_color_ = 0;
// The blank space above the first page of the document reserved for the // The blank space above the first page of the document reserved for the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment