Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: pdf/instance.cc

Issue 573523002: PDF Viewer - PageUp/Down don't move pdf by page size in FitToPage mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/instance.h" 5 #include "pdf/instance.h"
6 6
7 #include <algorithm> // for min() 7 #include <algorithm> // for min()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 return true; 502 return true;
503 503
504 // Left/Right arrows should scroll to the beginning of the Prev/Next page if 504 // Left/Right arrows should scroll to the beginning of the Prev/Next page if
505 // there is no horizontal scroll bar. 505 // there is no horizontal scroll bar.
506 // If fit-to-height, PgDown/PgUp should scroll to the beginning of the 506 // If fit-to-height, PgDown/PgUp should scroll to the beginning of the
507 // Prev/Next page. Spacebar / shift+spacebar should do the same. 507 // Prev/Next page. Spacebar / shift+spacebar should do the same.
508 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) { 508 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) {
509 pp::KeyboardInputEvent keyboard_event(event); 509 pp::KeyboardInputEvent keyboard_event(event);
510 bool no_h_scrollbar = !h_scrollbar_.get(); 510 bool no_h_scrollbar = !h_scrollbar_.get();
511 uint32_t key_code = keyboard_event.GetKeyCode(); 511 uint32_t key_code = keyboard_event.GetKeyCode();
512 bool page_down = no_h_scrollbar && key_code == ui::VKEY_RIGHT; 512 // Page down is ui::VKEY_NEXT.
513 bool page_up = no_h_scrollbar && key_code == ui::VKEY_LEFT; 513 bool page_down = no_h_scrollbar &&
514 (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_NEXT);
515 // Page up is ui::VKEY_PRIOR.
516 bool page_up = no_h_scrollbar &&
517 (key_code == ui::VKEY_LEFT || key_code == ui::VKEY_PRIOR);
514 if (zoom_mode_ == ZOOM_FIT_TO_PAGE) { 518 if (zoom_mode_ == ZOOM_FIT_TO_PAGE) {
515 bool has_shift = 519 bool has_shift =
516 keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY; 520 keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY;
517 bool key_is_space = key_code == ui::VKEY_SPACE; 521 bool key_is_space = key_code == ui::VKEY_SPACE;
518 page_down |= key_is_space || key_code == ui::VKEY_NEXT; 522 page_down |= key_is_space || key_code == ui::VKEY_NEXT;
raymes 2014/09/15 00:12:14 But it should get set here when in ZOOM_FIT_TO_PAG
Nikhil 2014/09/16 10:23:29 Acknowledged.
519 page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR); 523 page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR);
520 } 524 }
521 if (page_down) { 525 if (page_down) {
522 int page = engine_->GetFirstVisiblePage(); 526 int page = engine_->GetFirstVisiblePage();
523 // Engine calculates visible page including delimiter to the page size. 527 // Engine calculates visible page including delimiter to the page size.
524 // We need to check here if the page itself is completely out of view and 528 // We need to check here if the page itself is completely out of view and
525 // scroll to the next one in that case. 529 // scroll to the next one in that case.
526 if (engine_->GetPageRect(page).bottom() * zoom_ <= 530 if (engine_->GetPageRect(page).bottom() * zoom_ <=
527 v_scrollbar_->GetValue()) 531 v_scrollbar_->GetValue())
528 page++; 532 page++;
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 return instance_->HasScriptableMethod(name, exception); 2743 return instance_->HasScriptableMethod(name, exception);
2740 } 2744 }
2741 2745
2742 pp::Var PDFScriptableObject::Call(const pp::Var& method, 2746 pp::Var PDFScriptableObject::Call(const pp::Var& method,
2743 const std::vector<pp::Var>& args, 2747 const std::vector<pp::Var>& args,
2744 pp::Var* exception) { 2748 pp::Var* exception) {
2745 return instance_->CallScriptableMethod(method, args, exception); 2749 return instance_->CallScriptableMethod(method, args, exception);
2746 } 2750 }
2747 2751
2748 } // namespace chrome_pdf 2752 } // namespace chrome_pdf
OLDNEW
« chrome/browser/resources/pdf/pdf.js ('K') | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698