OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 capturer_count_(0), | 388 capturer_count_(0), |
389 should_normally_be_visible_(true), | 389 should_normally_be_visible_(true), |
390 is_being_destroyed_(false), | 390 is_being_destroyed_(false), |
391 notify_disconnection_(false), | 391 notify_disconnection_(false), |
392 dialog_manager_(NULL), | 392 dialog_manager_(NULL), |
393 is_showing_before_unload_dialog_(false), | 393 is_showing_before_unload_dialog_(false), |
394 last_active_time_(base::TimeTicks::Now()), | 394 last_active_time_(base::TimeTicks::Now()), |
395 closed_by_user_gesture_(false), | 395 closed_by_user_gesture_(false), |
396 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 396 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
397 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 397 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
| 398 zoom_scroll_amount_(0), |
398 render_view_message_source_(NULL), | 399 render_view_message_source_(NULL), |
399 render_frame_message_source_(NULL), | 400 render_frame_message_source_(NULL), |
400 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), | 401 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), |
401 fullscreen_widget_had_focus_at_shutdown_(false), | 402 fullscreen_widget_had_focus_at_shutdown_(false), |
402 is_subframe_(false), | 403 is_subframe_(false), |
403 force_disable_overscroll_content_(false), | 404 force_disable_overscroll_content_(false), |
404 last_dialog_suppressed_(false), | 405 last_dialog_suppressed_(false), |
405 geolocation_service_context_(new GeolocationServiceContext()), | 406 geolocation_service_context_(new GeolocationServiceContext()), |
406 accessibility_mode_( | 407 accessibility_mode_( |
407 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), | 408 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 #if !defined(OS_MACOSX) | 1585 #if !defined(OS_MACOSX) |
1585 // On platforms other than Mac, control+mousewheel may change zoom. On Mac, | 1586 // On platforms other than Mac, control+mousewheel may change zoom. On Mac, |
1586 // this isn't done for two reasons: | 1587 // this isn't done for two reasons: |
1587 // -the OS already has a gesture to do this through pinch-zoom | 1588 // -the OS already has a gesture to do this through pinch-zoom |
1588 // -if a user starts an inertial scroll, let's go, and presses control | 1589 // -if a user starts an inertial scroll, let's go, and presses control |
1589 // (i.e. control+tab) then the OS's buffered scroll events will come in | 1590 // (i.e. control+tab) then the OS's buffered scroll events will come in |
1590 // with control key set which isn't what the user wants | 1591 // with control key set which isn't what the user wants |
1591 if (delegate_ && event.wheelTicksY && | 1592 if (delegate_ && event.wheelTicksY && |
1592 (event.modifiers & blink::WebInputEvent::ControlKey) && | 1593 (event.modifiers & blink::WebInputEvent::ControlKey) && |
1593 !event.canScroll) { | 1594 !event.canScroll) { |
1594 delegate_->ContentsZoomChange(event.wheelTicksY > 0); | 1595 // Count only integer cumulative scrolls as zoom events; this handles |
| 1596 // smooth scroll and regular scroll device behavior. |
| 1597 zoom_scroll_amount_ += event.wheelTicksY; |
| 1598 int whole_zoom_scroll_amount = round(zoom_scroll_amount_); |
| 1599 zoom_scroll_amount_ -= whole_zoom_scroll_amount; |
| 1600 if (whole_zoom_scroll_amount != 0) { |
| 1601 delegate_->ContentsZoomChange(whole_zoom_scroll_amount > 0); |
| 1602 } |
1595 return true; | 1603 return true; |
1596 } | 1604 } |
1597 #endif | 1605 #endif |
1598 return false; | 1606 return false; |
1599 } | 1607 } |
1600 | 1608 |
1601 bool WebContentsImpl::PreHandleGestureEvent( | 1609 bool WebContentsImpl::PreHandleGestureEvent( |
1602 const blink::WebGestureEvent& event) { | 1610 const blink::WebGestureEvent& event) { |
1603 return delegate_ && delegate_->PreHandleGestureEvent(this, event); | 1611 return delegate_ && delegate_->PreHandleGestureEvent(this, event); |
1604 } | 1612 } |
(...skipping 3198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4803 return NULL; | 4811 return NULL; |
4804 } | 4812 } |
4805 | 4813 |
4806 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4814 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4807 force_disable_overscroll_content_ = force_disable; | 4815 force_disable_overscroll_content_ = force_disable; |
4808 if (view_) | 4816 if (view_) |
4809 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4817 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4810 } | 4818 } |
4811 | 4819 |
4812 } // namespace content | 4820 } // namespace content |
OLD | NEW |