[unseasoned-pdf] Migrate 'setScrollPosition' messages
Migrate from a Pepper OutOfProcessInstance implementation to a common PdfViewPluginBase one. Bug: 1109796 Change-Id: I810926054749d4e6bad00425e6c516cab14a7fa3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2720075 Commit-Queue: Daniel Hosseinian <dhoss@chromium.org> Reviewed-by: Hui Yingst <nigi@chromium.org> Cr-Commit-Position: refs/heads/master@{#858044}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5d8f6e647d
commit
de41a53bc6
@ -155,12 +155,10 @@ constexpr char kJSPrintPreviewPageCount[] = "pageCount";
|
||||
constexpr char kJSLoadPreviewPageType[] = "loadPreviewPage";
|
||||
constexpr char kJSPreviewPageUrl[] = "url";
|
||||
constexpr char kJSPreviewPageIndex[] = "index";
|
||||
// Set scroll position (Plugin -> Page)
|
||||
constexpr char kJSSetScrollPositionType[] = "setScrollPosition";
|
||||
constexpr char kJSPositionX[] = "x";
|
||||
constexpr char kJSPositionY[] = "y";
|
||||
// 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";
|
||||
@ -1070,21 +1068,6 @@ void OutOfProcessInstance::DidScroll(const gfx::Vector2d& offset) {
|
||||
paint_manager().ScrollRect(available_area(), offset);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::ScrollToX(int x_in_screen_coords) {
|
||||
pp::VarDictionary position;
|
||||
position.Set(kType, kJSSetScrollPositionType);
|
||||
position.Set(kJSPositionX, pp::Var(x_in_screen_coords / device_scale()));
|
||||
PostMessage(position);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::ScrollToY(int y_in_screen_coords) {
|
||||
pp::VarDictionary position;
|
||||
position.Set(kType, kJSSetScrollPositionType);
|
||||
float new_y_viewport_coords = y_in_screen_coords / device_scale();
|
||||
position.Set(kJSPositionY, pp::Var(new_y_viewport_coords));
|
||||
PostMessage(position);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::ScrollBy(const gfx::Vector2d& scroll_delta) {
|
||||
pp::VarDictionary position;
|
||||
position.Set(kType, kJSScrollByType);
|
||||
|
@ -99,8 +99,6 @@ class OutOfProcessInstance : public PdfViewPluginBase,
|
||||
|
||||
// PdfViewPluginBase:
|
||||
void DidScroll(const gfx::Vector2d& offset) override;
|
||||
void ScrollToX(int x_in_screen_coords) override;
|
||||
void ScrollToY(int y_in_screen_coords) override;
|
||||
void ScrollBy(const gfx::Vector2d& scroll_delta) override;
|
||||
void ScrollToPage(int page) override;
|
||||
void NavigateTo(const std::string& url,
|
||||
|
@ -136,8 +136,8 @@ class PDFEngine {
|
||||
// Scroll the horizontal/vertical scrollbars to a given position.
|
||||
// Values are in screen coordinates, where 0 is the top/left of the document
|
||||
// and a positive value is the distance in pixels from that line.
|
||||
virtual void ScrollToX(int x_in_screen_coords) {}
|
||||
virtual void ScrollToY(int y_in_screen_coords) {}
|
||||
virtual void ScrollToX(int x_screen_coords) {}
|
||||
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) {}
|
||||
|
@ -122,6 +122,24 @@ void PdfViewPluginBase::Invalidate(const gfx::Rect& rect) {
|
||||
paint_manager_.InvalidateRect(offset_rect);
|
||||
}
|
||||
|
||||
void PdfViewPluginBase::ScrollToX(int x_screen_coords) {
|
||||
const float x_scroll_pos = x_screen_coords / device_scale_;
|
||||
|
||||
base::Value message(base::Value::Type::DICTIONARY);
|
||||
message.SetStringKey("type", "setScrollPosition");
|
||||
message.SetDoubleKey("x", x_scroll_pos);
|
||||
SendMessage(std::move(message));
|
||||
}
|
||||
|
||||
void PdfViewPluginBase::ScrollToY(int y_screen_coords) {
|
||||
const float y_scroll_pos = y_screen_coords / device_scale_;
|
||||
|
||||
base::Value message(base::Value::Type::DICTIONARY);
|
||||
message.SetStringKey("type", "setScrollPosition");
|
||||
message.SetDoubleKey("y", y_scroll_pos);
|
||||
SendMessage(std::move(message));
|
||||
}
|
||||
|
||||
SkColor PdfViewPluginBase::GetBackgroundColor() {
|
||||
return background_color_;
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ class PdfViewPluginBase : public PDFEngine::Client,
|
||||
// PDFEngine::Client:
|
||||
void ProposeDocumentLayout(const DocumentLayout& layout) override;
|
||||
void Invalidate(const gfx::Rect& rect) override;
|
||||
void ScrollToX(int x_screen_coords) override;
|
||||
void ScrollToY(int y_screen_coords) override;
|
||||
SkColor GetBackgroundColor() override;
|
||||
void SetIsSelecting(bool is_selecting) override;
|
||||
|
||||
|
@ -199,10 +199,6 @@ void PdfViewWebPlugin::DidFailLoading(const blink::WebURLError& error) {}
|
||||
|
||||
void PdfViewWebPlugin::DidScroll(const gfx::Vector2d& offset) {}
|
||||
|
||||
void PdfViewWebPlugin::ScrollToX(int x_in_screen_coords) {}
|
||||
|
||||
void PdfViewWebPlugin::ScrollToY(int y_in_screen_coords) {}
|
||||
|
||||
void PdfViewWebPlugin::ScrollBy(const gfx::Vector2d& scroll_delta) {}
|
||||
|
||||
void PdfViewWebPlugin::ScrollToPage(int page) {}
|
||||
|
@ -58,8 +58,6 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
|
||||
|
||||
// PdfViewPluginBase:
|
||||
void DidScroll(const gfx::Vector2d& offset) override;
|
||||
void ScrollToX(int x_in_screen_coords) override;
|
||||
void ScrollToY(int y_in_screen_coords) override;
|
||||
void ScrollBy(const gfx::Vector2d& scroll_delta) override;
|
||||
void ScrollToPage(int page) override;
|
||||
void NavigateTo(const std::string& url,
|
||||
|
Reference in New Issue
Block a user