0

[unseasoned-pdf] Migrate 'scrollBy' message

Migrate from a Pepper OutOfProcessInstance implementation to a common
PdfViewPluginBase one.

Bug: 1109796
Change-Id: Ibf4b9a4a4518b205f36910a3495f2e0be1be5d22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2721000
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#858055}
This commit is contained in:
Daniel Hosseinian
2021-02-26 08:41:44 +00:00
committed by Chromium LUCI CQ
parent 109ae2d3ed
commit 1b645c3b4d
7 changed files with 14 additions and 17 deletions

@ -155,10 +155,6 @@ constexpr char kJSPrintPreviewPageCount[] = "pageCount";
constexpr char kJSLoadPreviewPageType[] = "loadPreviewPage";
constexpr char kJSPreviewPageUrl[] = "url";
constexpr char kJSPreviewPageIndex[] = "index";
// Scroll by (Plugin -> Page)
constexpr char kJSScrollByType[] = "scrollBy";
constexpr char kJSPositionX[] = "x";
constexpr char kJSPositionY[] = "y";
// Navigate to the given URL (Plugin -> Page)
constexpr char kJSNavigateType[] = "navigate";
constexpr char kJSNavigateUrl[] = "url";
@ -1059,14 +1055,6 @@ void OutOfProcessInstance::DidScroll(const gfx::Vector2d& offset) {
paint_manager().ScrollRect(available_area(), offset);
}
void OutOfProcessInstance::ScrollBy(const gfx::Vector2d& scroll_delta) {
pp::VarDictionary position;
position.Set(kType, kJSScrollByType);
position.Set(kJSPositionX, pp::Var(scroll_delta.x() / device_scale()));
position.Set(kJSPositionY, pp::Var(scroll_delta.y() / device_scale()));
PostMessage(position);
}
void OutOfProcessInstance::ScrollToPage(int page) {
if (!engine() || engine()->GetNumberOfPages() == 0)
return;

@ -99,7 +99,6 @@ class OutOfProcessInstance : public PdfViewPluginBase,
// PdfViewPluginBase:
void DidScroll(const gfx::Vector2d& offset) override;
void ScrollBy(const gfx::Vector2d& scroll_delta) override;
void ScrollToPage(int page) override;
void NavigateTo(const std::string& url,
WindowOpenDisposition disposition) override;

@ -140,7 +140,7 @@ class PDFEngine {
virtual void ScrollToY(int y_screen_coords) {}
// Scroll by a given delta relative to the current position.
virtual void ScrollBy(const gfx::Vector2d& scroll_delta) {}
virtual void ScrollBy(const gfx::Vector2d& delta) {}
// Scroll to zero-based |page|.
virtual void ScrollToPage(int page) {}

@ -40,6 +40,7 @@
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/skia_util.h"
namespace chrome_pdf {
@ -140,6 +141,17 @@ void PdfViewPluginBase::ScrollToY(int y_screen_coords) {
SendMessage(std::move(message));
}
void PdfViewPluginBase::ScrollBy(const gfx::Vector2d& delta) {
const float x_delta = delta.x() / device_scale_;
const float y_delta = delta.y() / device_scale_;
base::Value message(base::Value::Type::DICTIONARY);
message.SetStringKey("type", "scrollBy");
message.SetDoubleKey("x", x_delta);
message.SetDoubleKey("y", y_delta);
SendMessage(std::move(message));
}
SkColor PdfViewPluginBase::GetBackgroundColor() {
return background_color_;
}

@ -53,6 +53,7 @@ class PdfViewPluginBase : public PDFEngine::Client,
void Invalidate(const gfx::Rect& rect) override;
void ScrollToX(int x_screen_coords) override;
void ScrollToY(int y_screen_coords) override;
void ScrollBy(const gfx::Vector2d& delta) override;
SkColor GetBackgroundColor() override;
void SetIsSelecting(bool is_selecting) override;

@ -199,8 +199,6 @@ void PdfViewWebPlugin::DidFailLoading(const blink::WebURLError& error) {}
void PdfViewWebPlugin::DidScroll(const gfx::Vector2d& offset) {}
void PdfViewWebPlugin::ScrollBy(const gfx::Vector2d& scroll_delta) {}
void PdfViewWebPlugin::ScrollToPage(int page) {}
void PdfViewWebPlugin::NavigateTo(const std::string& url,

@ -58,7 +58,6 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
// PdfViewPluginBase:
void DidScroll(const gfx::Vector2d& offset) override;
void ScrollBy(const gfx::Vector2d& scroll_delta) override;
void ScrollToPage(int page) override;
void NavigateTo(const std::string& url,
WindowOpenDisposition disposition) override;