OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "components/mus/public/cpp/types.h" | 9 #include "components/mus/public/cpp/types.h" |
10 #include "components/mus/public/cpp/view.h" | 10 #include "components/mus/public/cpp/view.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 373 } |
374 | 374 |
375 void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override { | 375 void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override { |
376 DCHECK(embedder_for_roots_.find(view) != embedder_for_roots_.end()); | 376 DCHECK(embedder_for_roots_.find(view) != embedder_for_roots_.end()); |
377 if (event->key_data && | 377 if (event->key_data && |
378 (event->action != mojo::EVENT_TYPE_KEY_PRESSED || | 378 (event->action != mojo::EVENT_TYPE_KEY_PRESSED || |
379 event->key_data->is_char)) { | 379 event->key_data->is_char)) { |
380 return; | 380 return; |
381 } | 381 } |
382 | 382 |
| 383 // TODO(rjkroege): Make panning and scrolling more performant and |
| 384 // responsive to gesture events. |
383 if ((event->key_data && | 385 if ((event->key_data && |
384 event->key_data->windows_key_code == mojo::KEYBOARD_CODE_DOWN) || | 386 event->key_data->windows_key_code == mojo::KEYBOARD_CODE_DOWN) || |
385 (event->pointer_data && event->pointer_data->vertical_wheel < 0)) { | 387 (event->wheel_data && event->wheel_data && |
| 388 event->wheel_data->delta_y < 0)) { |
386 if (current_page_ < (page_count_ - 1)) { | 389 if (current_page_ < (page_count_ - 1)) { |
387 current_page_++; | 390 current_page_++; |
388 DrawBitmap(embedder_for_roots_[view]); | 391 DrawBitmap(embedder_for_roots_[view]); |
389 } | 392 } |
390 } else if ((event->key_data && | 393 } else if ((event->key_data && |
391 event->key_data->windows_key_code == mojo::KEYBOARD_CODE_UP) || | 394 event->key_data->windows_key_code == mojo::KEYBOARD_CODE_UP) || |
392 (event->pointer_data && | 395 (event->pointer_data && event->wheel_data && |
393 event->pointer_data->vertical_wheel > 0)) { | 396 event->wheel_data->delta_y > 0)) { |
394 if (current_page_ > 0) { | 397 if (current_page_ > 0) { |
395 current_page_--; | 398 current_page_--; |
396 DrawBitmap(embedder_for_roots_[view]); | 399 DrawBitmap(embedder_for_roots_[view]); |
397 } | 400 } |
398 } | 401 } |
399 } | 402 } |
400 | 403 |
401 void OnViewDestroyed(mus::View* view) override { | 404 void OnViewDestroyed(mus::View* view) override { |
402 DCHECK(embedder_for_roots_.find(view) != embedder_for_roots_.end()); | 405 DCHECK(embedder_for_roots_.find(view) != embedder_for_roots_.end()); |
403 const auto& it = embedder_for_roots_.find(view); | 406 const auto& it = embedder_for_roots_.find(view); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 DISALLOW_COPY_AND_ASSIGN(PDFViewer); | 516 DISALLOW_COPY_AND_ASSIGN(PDFViewer); |
514 }; | 517 }; |
515 | 518 |
516 } // namespace | 519 } // namespace |
517 } // namespace pdf_viewer | 520 } // namespace pdf_viewer |
518 | 521 |
519 MojoResult MojoMain(MojoHandle application_request) { | 522 MojoResult MojoMain(MojoHandle application_request) { |
520 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); | 523 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); |
521 return runner.Run(application_request); | 524 return runner.Run(application_request); |
522 } | 525 } |
OLD | NEW |