Skip to content

Commit

Permalink
[unseasoned-pdf] Migrate ScrollToPage()
Browse files Browse the repository at this point in the history
Migrate from a Pepper OutOfProcessInstance implementation to a common
PdfViewPluginBase one.

Bug: 1109796
Change-Id: I19bce405c372752fe0da257ef64d45e646761228
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2731072
Reviewed-by: Hui Yingst <nigi@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#859461}
  • Loading branch information
ankk0294 authored and Chromium LUCI CQ committed Mar 3, 2021
1 parent 953a2de commit 476f0b1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
13 changes: 0 additions & 13 deletions pdf/out_of_process_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ constexpr char kJSDataToSave[] = "dataToSave";
constexpr char kJSConsumeSaveTokenType[] = "consumeSaveToken";
// Notify when touch selection occurs (Plugin -> Page)
constexpr char kJSTouchSelectionOccurredType[] = "touchSelectionOccurred";
// Go to page (Plugin -> Page)
constexpr char kJSGoToPageType[] = "goToPage";
constexpr char kJSPageNumber[] = "page";
// Reset print preview mode (Page -> Plugin)
constexpr char kJSResetPrintPreviewModeType[] = "resetPrintPreviewMode";
constexpr char kJSPrintPreviewUrl[] = "url";
Expand Down Expand Up @@ -1042,16 +1039,6 @@ void OutOfProcessInstance::DidScroll(const gfx::Vector2d& offset) {
paint_manager().ScrollRect(available_area(), offset);
}

void OutOfProcessInstance::ScrollToPage(int page) {
if (!engine() || engine()->GetNumberOfPages() == 0)
return;

pp::VarDictionary message;
message.Set(kType, kJSGoToPageType);
message.Set(kJSPageNumber, pp::Var(page));
PostMessage(message);
}

void OutOfProcessInstance::NavigateTo(const std::string& url,
WindowOpenDisposition disposition) {
pp::VarDictionary message;
Expand Down
1 change: 0 additions & 1 deletion pdf/out_of_process_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class OutOfProcessInstance : public PdfViewPluginBase,

// PdfViewPluginBase:
void DidScroll(const gfx::Vector2d& offset) override;
void ScrollToPage(int page) override;
void NavigateTo(const std::string& url,
WindowOpenDisposition disposition) override;
void NavigateToDestination(int page,
Expand Down
10 changes: 10 additions & 0 deletions pdf/pdf_view_plugin_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ void PdfViewPluginBase::ScrollBy(const gfx::Vector2d& delta) {
SendMessage(std::move(message));
}

void PdfViewPluginBase::ScrollToPage(int page) {
if (!engine_ || engine_->GetNumberOfPages() == 0)
return;

base::Value message(base::Value::Type::DICTIONARY);
message.SetStringKey("type", "goToPage");
message.SetIntKey("page", page);
SendMessage(std::move(message));
}

void PdfViewPluginBase::GetDocumentPassword(
base::OnceCallback<void(const std::string&)> callback) {
DCHECK(password_callback_.is_null());
Expand Down
1 change: 1 addition & 0 deletions pdf/pdf_view_plugin_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PdfViewPluginBase : public PDFEngine::Client,
void ScrollToX(int x_screen_coords) override;
void ScrollToY(int y_screen_coords) override;
void ScrollBy(const gfx::Vector2d& delta) override;
void ScrollToPage(int page) override;
void GetDocumentPassword(
base::OnceCallback<void(const std::string&)> callback) override;
SkColor GetBackgroundColor() override;
Expand Down
2 changes: 0 additions & 2 deletions pdf/pdf_view_web_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ void PdfViewWebPlugin::DidFailLoading(const blink::WebURLError& error) {}

void PdfViewWebPlugin::DidScroll(const gfx::Vector2d& offset) {}

void PdfViewWebPlugin::ScrollToPage(int page) {}

void PdfViewWebPlugin::NavigateTo(const std::string& url,
WindowOpenDisposition disposition) {}

Expand Down
1 change: 0 additions & 1 deletion pdf/pdf_view_web_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,

// PdfViewPluginBase:
void DidScroll(const gfx::Vector2d& offset) override;
void ScrollToPage(int page) override;
void NavigateTo(const std::string& url,
WindowOpenDisposition disposition) override;
void NavigateToDestination(int page,
Expand Down

0 comments on commit 476f0b1

Please sign in to comment.