Skip to content

Commit

Permalink
PDF Viewer: Disable panning code on Windows.
Browse files Browse the repository at this point in the history
Windows can already perform panning natively.

BUG=829791

Change-Id: I1607e85645cba201d12c415f203531459c838442
Reviewed-on: https://chromium-review.googlesource.com/1000833
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549082}
  • Loading branch information
leizleiz authored and Commit Bot committed Apr 8, 2018
1 parent 28e1f4b commit 50b9ff0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pdf/pdfium/pdfium_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ constexpr int kMaxPasswordTries = 3;
constexpr base::TimeDelta kTouchLongPressTimeout =
base::TimeDelta::FromMilliseconds(300);

// Windows has native panning capabilities. No need to use our own.
#if defined(OS_WIN)
constexpr bool kViewerImplementedPanning = false;
#else
constexpr bool kViewerImplementedPanning = true;
#endif

// See Table 3.20 in
// http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf
const uint32_t kPDFPermissionPrintLowQualityMask = 1 << 2;
Expand Down Expand Up @@ -1979,8 +1986,10 @@ bool PDFiumEngine::OnMiddleMouseDown(const pp::MouseInputEvent& event) {
if (IsLinkArea(area))
return true;

// Switch to hand cursor when panning.
client_->UpdateCursor(PP_CURSORTYPE_HAND);
if (kViewerImplementedPanning) {
// Switch to hand cursor when panning.
client_->UpdateCursor(PP_CURSORTYPE_HAND);
}

// Prevent middle mouse button from selecting texts.
return false;
Expand Down Expand Up @@ -2108,8 +2117,11 @@ bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) {
}

if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) {
// Update the cursor when panning stops.
client_->UpdateCursor(DetermineCursorType(area, form_type));
if (kViewerImplementedPanning) {
// Update the cursor when panning stops.
client_->UpdateCursor(DetermineCursorType(area, form_type));
}

// Prevent middle mouse button from selecting texts.
return false;
}
Expand Down Expand Up @@ -2165,7 +2177,7 @@ bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) {
SetFormSelectedText(form_, pages_[last_page_mouse_down_]->GetPage());
}

if (mouse_middle_button_down_) {
if (kViewerImplementedPanning && mouse_middle_button_down_) {
// Subtract (origin - destination) so delta is already the delta for
// moving the page, rather than the delta the mouse moved.
// GetMovement() does not work here, as small mouse movements are
Expand Down Expand Up @@ -2194,7 +2206,7 @@ bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) {

PP_CursorType_Dev PDFiumEngine::DetermineCursorType(PDFiumPage::Area area,
int form_type) const {
if (mouse_middle_button_down_) {
if (kViewerImplementedPanning && mouse_middle_button_down_) {
return PP_CURSORTYPE_HAND;
}

Expand Down

0 comments on commit 50b9ff0

Please sign in to comment.