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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1554253004: Made page zoom handling work with smooth scroll devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 capturer_count_(0), 389 capturer_count_(0),
390 should_normally_be_visible_(true), 390 should_normally_be_visible_(true),
391 is_being_destroyed_(false), 391 is_being_destroyed_(false),
392 notify_disconnection_(false), 392 notify_disconnection_(false),
393 dialog_manager_(NULL), 393 dialog_manager_(NULL),
394 is_showing_before_unload_dialog_(false), 394 is_showing_before_unload_dialog_(false),
395 last_active_time_(base::TimeTicks::Now()), 395 last_active_time_(base::TimeTicks::Now()),
396 closed_by_user_gesture_(false), 396 closed_by_user_gesture_(false),
397 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 397 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
398 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 398 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
399 zoom_scroll_amount_(0),
399 render_view_message_source_(NULL), 400 render_view_message_source_(NULL),
400 render_frame_message_source_(NULL), 401 render_frame_message_source_(NULL),
401 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 402 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
402 fullscreen_widget_had_focus_at_shutdown_(false), 403 fullscreen_widget_had_focus_at_shutdown_(false),
403 is_subframe_(false), 404 is_subframe_(false),
404 force_disable_overscroll_content_(false), 405 force_disable_overscroll_content_(false),
405 last_dialog_suppressed_(false), 406 last_dialog_suppressed_(false),
406 geolocation_service_context_(new GeolocationServiceContext()), 407 geolocation_service_context_(new GeolocationServiceContext()),
407 accessibility_mode_( 408 accessibility_mode_(
408 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), 409 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 #if !defined(OS_MACOSX) 1581 #if !defined(OS_MACOSX)
1581 // On platforms other than Mac, control+mousewheel may change zoom. On Mac, 1582 // On platforms other than Mac, control+mousewheel may change zoom. On Mac,
1582 // this isn't done for two reasons: 1583 // this isn't done for two reasons:
1583 // -the OS already has a gesture to do this through pinch-zoom 1584 // -the OS already has a gesture to do this through pinch-zoom
1584 // -if a user starts an inertial scroll, let's go, and presses control 1585 // -if a user starts an inertial scroll, let's go, and presses control
1585 // (i.e. control+tab) then the OS's buffered scroll events will come in 1586 // (i.e. control+tab) then the OS's buffered scroll events will come in
1586 // with control key set which isn't what the user wants 1587 // with control key set which isn't what the user wants
1587 if (delegate_ && event.wheelTicksY && 1588 if (delegate_ && event.wheelTicksY &&
1588 (event.modifiers & blink::WebInputEvent::ControlKey) && 1589 (event.modifiers & blink::WebInputEvent::ControlKey) &&
1589 !event.canScroll) { 1590 !event.canScroll) {
1590 delegate_->ContentsZoomChange(event.wheelTicksY > 0); 1591 // Count only integer cumulative scrolls as zoom events; this handles
1592 // smooth scroll and regular scroll device behavior.
1593 zoom_scroll_amount_ += event.wheelTicksY;
1594 int whole_zoom_scroll_amount = round(zoom_scroll_amount_);
Avi (use Gerrit) 2016/01/05 01:46:24 Let's make it C++, so do std::lround, since we're
Will Shackleton 2016/01/05 21:50:05 Done.
1595 zoom_scroll_amount_ -= whole_zoom_scroll_amount;
1596 if (whole_zoom_scroll_amount != 0) {
1597 delegate_->ContentsZoomChange(whole_zoom_scroll_amount > 0);
1598 }
1591 return true; 1599 return true;
1592 } 1600 }
1593 #endif 1601 #endif
1594 return false; 1602 return false;
1595 } 1603 }
1596 1604
1597 bool WebContentsImpl::PreHandleGestureEvent( 1605 bool WebContentsImpl::PreHandleGestureEvent(
1598 const blink::WebGestureEvent& event) { 1606 const blink::WebGestureEvent& event) {
1599 return delegate_ && delegate_->PreHandleGestureEvent(this, event); 1607 return delegate_ && delegate_->PreHandleGestureEvent(this, event);
1600 } 1608 }
(...skipping 3120 matching lines...) Expand 10 before | Expand all | Expand 10 after
4721 const WebContentsObserver::MediaPlayerId& id) { 4729 const WebContentsObserver::MediaPlayerId& id) {
4722 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); 4730 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id));
4723 } 4731 }
4724 4732
4725 void WebContentsImpl::MediaStoppedPlaying( 4733 void WebContentsImpl::MediaStoppedPlaying(
4726 const WebContentsObserver::MediaPlayerId& id) { 4734 const WebContentsObserver::MediaPlayerId& id) {
4727 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); 4735 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id));
4728 } 4736 }
4729 4737
4730 } // namespace content 4738 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698