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 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 #if !defined(OS_MACOSX) | 1584 #if !defined(OS_MACOSX) |
1585 // On platforms other than Mac, control+mousewheel may change zoom. On Mac, | 1585 // On platforms other than Mac, control+mousewheel may change zoom. On Mac, |
1586 // this isn't done for two reasons: | 1586 // this isn't done for two reasons: |
1587 // -the OS already has a gesture to do this through pinch-zoom | 1587 // -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 | 1588 // -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 | 1589 // (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 | 1590 // with control key set which isn't what the user wants |
1591 if (delegate_ && event.wheelTicksY && | 1591 if (delegate_ && event.wheelTicksY && |
1592 (event.modifiers & blink::WebInputEvent::ControlKey) && | 1592 (event.modifiers & blink::WebInputEvent::ControlKey) && |
1593 !event.canScroll) { | 1593 !event.canScroll) { |
1594 delegate_->ContentsZoomChange(event.wheelTicksY > 0); | 1594 // Count only integer cumulative scrolls as zoom events; this handles |
| 1595 // smooth scroll and regular scroll device behavior. |
| 1596 zoom_scroll_amount_ += event.wheelTicksY; |
| 1597 int whole_zoom_scroll_amount = round(zoom_scroll_amount_); |
| 1598 zoom_scroll_amount_ -= whole_zoom_scroll_amount; |
| 1599 if (whole_zoom_scroll_amount != 0) { |
| 1600 delegate_->ContentsZoomChange(whole_zoom_scroll_amount > 0); |
| 1601 } |
1595 return true; | 1602 return true; |
1596 } | 1603 } |
1597 #endif | 1604 #endif |
1598 return false; | 1605 return false; |
1599 } | 1606 } |
1600 | 1607 |
1601 bool WebContentsImpl::PreHandleGestureEvent( | 1608 bool WebContentsImpl::PreHandleGestureEvent( |
1602 const blink::WebGestureEvent& event) { | 1609 const blink::WebGestureEvent& event) { |
1603 return delegate_ && delegate_->PreHandleGestureEvent(this, event); | 1610 return delegate_ && delegate_->PreHandleGestureEvent(this, event); |
1604 } | 1611 } |
(...skipping 3198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4803 return NULL; | 4810 return NULL; |
4804 } | 4811 } |
4805 | 4812 |
4806 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4813 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4807 force_disable_overscroll_content_ = force_disable; | 4814 force_disable_overscroll_content_ = force_disable; |
4808 if (view_) | 4815 if (view_) |
4809 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4816 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4810 } | 4817 } |
4811 | 4818 |
4812 } // namespace content | 4819 } // namespace content |
OLD | NEW |