diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 00:12:10 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 00:12:10 +0000 |
commit | b0c0692fd55e929474207de270de6a6b23809475 (patch) | |
tree | aa0637cd47a8320ee2d6f8c3e673e6e40d094cb9 /content | |
parent | afb07be1f1f2a9c5fef361ebabd2f0ee8818804a (diff) | |
download | chromium_src-b0c0692fd55e929474207de270de6a6b23809475.zip chromium_src-b0c0692fd55e929474207de270de6a6b23809475.tar.gz chromium_src-b0c0692fd55e929474207de270de6a6b23809475.tar.bz2 |
mac: Only let two-finger-scrolling trigger history if web doesn't swallow gesture
Use the intended APIs for swipe tracking. Remove the old, wrong, and now unneeded two-finger swipe detection code. Make target 'browser' depend on the block support target, since this is the first CL that uses ObjC blocks (only on 10.7).
No UI yet.
Approach:
* Scroll events are always first sent to the renderer
* RWH informs its view if a wheel event came back unhandled
* If a scroll event came back, and the viewport is pinned to
the left or there is no horizontal scrollbar, a back navigation
is triggered
* If a scroll event came back, and the viewport is pinned to
the right or there is no horizontal scrollbar, a forward navigation
is triggered
Depends on https://bugs.webkit.org/show_bug.cgi?id=66206
BUG=91513,90652,92786,90228,91144
TEST=
1.) Open http://en.wikipedia.org/wiki/Main_Page , then click a link and go back (so that back and forward buttons are active). Swiping left should go back, swiping right should go forward. Make browser window narrow so that horizontal scroller appears. Now sliding should scroll first if not at the edge, and trigger history if the viewport is on an edge at gesture start.
2.) Open http://pastie.org/2371939 . Scrolling over the div shouldn't trigger history, scrolling everywhere else should (or if there's no history, bounce instead)
3.) Open http://maps.google.com/ . Scrolling over the map area shouldn't trigger history, scrolling over the search box should.
4.) Open http://itunes.apple.com/us/app/cut-the-rope/id380293530?mt=8 Scrollling over the screenshot area should move screenshots (slowly), should tigger history (or bounce) everywhere else.
5.) With the back button active but the forward button inactive, going left/right/left/right in a single gesture should toggle between history on the left and bouncing on the right seamlessly.
Test this with an MBP, a magic trackpad, a magic mouse, and with scroll directions set to "natural" on and off in sysprefs. Also set "Swipe between pages" to three fingers and check if that works, and disable it and check that it's disabled.
Also check that the behavior on 10.5/10.6 and the behavior of mouses with conventional scroll wheels didn't change.
Review URL: http://codereview.chromium.org/7618036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
5 files changed, 36 insertions, 7 deletions
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 8af8ed8..463ad36 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -1009,16 +1009,17 @@ void RenderViewHost::OnMsgDidContentsPreferredSizeChange( void RenderViewHost::OnMsgDidChangeScrollbarsForMainFrame( bool has_horizontal_scrollbar, bool has_vertical_scrollbar) { - // TODO(thakis): Implement, http://crbug.com/90228 + if (view()) + view()->SetHasHorizontalScrollbar(has_horizontal_scrollbar); } void RenderViewHost::OnMsgDidChangeScrollOffsetPinningForMainFrame( bool is_pinned_to_left, bool is_pinned_to_right) { - // TODO(thakis): Implement, http://crbug.com/90228 + if (view()) + view()->SetScrollOffsetPinning(is_pinned_to_left, is_pinned_to_right); } void RenderViewHost::OnMsgDidChangeNumWheelEvents(int count) { - // TODO(thakis): Implement, http://crbug.com/90228 } void RenderViewHost::OnMsgSelectionChanged(const std::string& text, diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 820ab67..811392a 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -554,6 +554,7 @@ void RenderWidgetHost::ForwardWheelEvent( return; } mouse_wheel_pending_ = true; + current_wheel_event_ = wheel_event; HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize", coalesced_mouse_wheel_events_.size()); @@ -1013,8 +1014,6 @@ void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); ForwardMouseEvent(*next_mouse_move_); } - } else if (type == WebInputEvent::MouseWheel) { - ProcessWheelAck(); } else if (WebInputEvent::isKeyboardEventType(type)) { bool processed = false; if (!message.ReadBool(&iter, &processed)) { @@ -1023,6 +1022,14 @@ void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { } ProcessKeyboardEventAck(type, processed); + } else if (type == WebInputEvent::MouseWheel) { + bool processed = false; + if (!message.ReadBool(&iter, &processed)) { + UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); + process()->ReceivedBadMessage(); + } + + ProcessWheelAck(processed); } else if (type == WebInputEvent::TouchMove) { touch_move_pending_ = false; if (touch_event_is_queued_) { @@ -1037,7 +1044,7 @@ void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { Details<int>(&type)); } -void RenderWidgetHost::ProcessWheelAck() { +void RenderWidgetHost::ProcessWheelAck(bool processed) { mouse_wheel_pending_ = false; // Now send the next (coalesced) mouse wheel event. @@ -1047,6 +1054,9 @@ void RenderWidgetHost::ProcessWheelAck() { coalesced_mouse_wheel_events_.pop_front(); ForwardWheelEvent(next_wheel_event); } + + if (!processed && !is_hidden_ && view_) + view_->UnhandledWheelEvent(current_wheel_event_); } void RenderWidgetHost::OnMsgFocus() { diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 841ba51..fe03a3e 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -404,6 +404,10 @@ class RenderWidgetHost : public IPC::Channel::Listener, // overridden by RenderView to send upwards to its delegate. virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} + // Called when a mousewheel event was not processed by the renderer. This is + // overridden by RenderView to send upwards to its delegate. + virtual void UnhandledWheelEvent(const WebKit::WebMouseWheelEvent& event) {} + // Notification that the user has made some kind of input that could // perform an action. The render view host overrides this to forward the // information to its delegate (see corresponding function in @@ -510,7 +514,7 @@ class RenderWidgetHost : public IPC::Channel::Listener, // Called by OnMsgInputEventAck() to process a wheel event ack message. // This could result in a task being posted to allow additional wheel // input messages to be coalesced. - void ProcessWheelAck(); + void ProcessWheelAck(bool processed); // True if renderer accessibility is enabled. This should only be set when a // screenreader is detected as it can potentially slow down Chrome. @@ -586,6 +590,7 @@ class RenderWidgetHost : public IPC::Channel::Listener, // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent // and we are waiting for a corresponding ack. bool mouse_wheel_pending_; + WebKit::WebMouseWheelEvent current_wheel_event_; typedef std::deque<WebKit::WebMouseWheelEvent> WheelEventQueue; diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index cd1bc2f..bffd520 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -16,6 +16,7 @@ #include "base/process_util.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" #include "ui/base/ime/text_input_type.h" #include "ui/base/range/range.h" @@ -296,6 +297,12 @@ class RenderWidgetHostView { // ignored. virtual void SetVisuallyDeemphasized(const SkColor* color, bool animate) = 0; + virtual void UnhandledWheelEvent(const WebKit::WebMouseWheelEvent& event) = 0; + + virtual void SetHasHorizontalScrollbar(bool has_horizontal_scrollbar) = 0; + virtual void SetScrollOffsetPinning( + bool is_pinned_to_left, bool is_pinned_to_right) = 0; + void set_popup_type(WebKit::WebPopupType popup_type) { popup_type_ = popup_type; } diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 1c58db9..6a3841e 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -124,6 +124,12 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void ShowCompositorHostWindow(bool show) OVERRIDE; #endif virtual void SetVisuallyDeemphasized(const SkColor* color, bool animate) { } + virtual void UnhandledWheelEvent( + const WebKit::WebMouseWheelEvent& event) { } + virtual void SetHasHorizontalScrollbar( + bool has_horizontal_scrollbar) { } + virtual void SetScrollOffsetPinning( + bool is_pinned_to_left, bool is_pinned_to_right) { } #if defined(TOUCH_UI) virtual void AcceleratedSurfaceSetIOSurface( |