diff options
19 files changed, 138 insertions, 83 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index e0f7125..51b26cc 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -38,7 +38,7 @@ InstantController::InstantController(InstantControllerDelegate* delegate, : delegate_(delegate), is_displayable_(false), is_out_of_date_(true), - commit_on_mouse_up_(false), + commit_on_pointer_release_(false), last_transition_type_(content::PAGE_TRANSITION_LINK), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), mode_(mode) { @@ -103,7 +103,7 @@ bool InstantController::Update(const AutocompleteMatch& match, suggested_text->clear(); is_out_of_date_ = false; - commit_on_mouse_up_ = false; + commit_on_pointer_release_ = false; last_transition_type_ = match.transition; last_url_ = match.destination_url; last_user_text_ = user_text; @@ -171,7 +171,7 @@ void InstantController::DestroyPreviewContents() { void InstantController::Hide() { is_out_of_date_ = true; - commit_on_mouse_up_ = false; + commit_on_pointer_release_ = false; if (is_displayable_) { is_displayable_ = false; delegate_->HideInstant(); @@ -241,25 +241,25 @@ bool InstantController::CommitIfCurrent() { return false; } -void InstantController::SetCommitOnMouseUp() { - commit_on_mouse_up_ = true; +void InstantController::SetCommitOnPointerRelease() { + commit_on_pointer_release_ = true; } -bool InstantController::IsMouseDownFromActivate() { +bool InstantController::IsPointerDownFromActivate() { DCHECK(loader_.get()); - return loader_->IsMouseDownFromActivate(); + return loader_->IsPointerDownFromActivate(); } #if defined(OS_MACOSX) void InstantController::OnAutocompleteLostFocus( gfx::NativeView view_gaining_focus) { - // If |IsMouseDownFromActivate()| returns false, the RenderWidgetHostView did - // not receive a mouseDown event. Therefore, we should destroy the preview. - // Otherwise, the RWHV was clicked, so we commit the preview. - if (!IsCurrent() || !IsMouseDownFromActivate()) + // If |IsPointerDownFromActivate()| returns false, the RenderWidgetHostView + // did not receive a mouseDown event. Therefore, we should destroy the + // preview. Otherwise, the RWHV was clicked, so we commit the preview. + if (!IsCurrent() || !IsPointerDownFromActivate()) DestroyPreviewContents(); else - SetCommitOnMouseUp(); + SetCommitOnPointerRelease(); } #else void InstantController::OnAutocompleteLostFocus( @@ -298,7 +298,7 @@ void InstantController::OnAutocompleteLostFocus( // Focus is going to the renderer. if (rwhv->GetNativeView() == view_gaining_focus || tab_view == view_gaining_focus) { - if (!IsMouseDownFromActivate()) { + if (!IsPointerDownFromActivate()) { // If the mouse is not down, focus is not going to the renderer. Someone // else moved focus and we shouldn't commit. DestroyPreviewContents(); @@ -308,7 +308,7 @@ void InstantController::OnAutocompleteLostFocus( // We're showing instant results. As instant results may shift when // committing we commit on the mouse up. This way a slow click still works // fine. - SetCommitOnMouseUp(); + SetCommitOnPointerRelease(); return; } @@ -358,7 +358,7 @@ TabContents* InstantController::ReleasePreviewContents( ClearBlacklist(); is_out_of_date_ = true; is_displayable_ = false; - commit_on_mouse_up_ = false; + commit_on_pointer_release_ = false; omnibox_bounds_ = gfx::Rect(); loader_.reset(); return tab; @@ -392,8 +392,8 @@ gfx::Rect InstantController::GetInstantBounds() { return delegate_->GetInstantBounds(); } -bool InstantController::ShouldCommitInstantOnMouseUp() { - return commit_on_mouse_up_; +bool InstantController::ShouldCommitInstantOnPointerRelease() { + return commit_on_pointer_release_; } void InstantController::CommitInstantLoader(InstantLoader* loader) { diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index 8f2a844..b6ad248 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -128,15 +128,14 @@ class InstantController : public InstantLoaderDelegate { // Returns false if there is no instant preview showing. bool CommitIfCurrent(); - // Sets InstantController so that when the mouse is released the preview is - // committed. - void SetCommitOnMouseUp(); + // Sets InstantController so that when the mouse is released or the + // touch-gesture ends, the preview is committed. + void SetCommitOnPointerRelease(); - bool commit_on_mouse_up() const { return commit_on_mouse_up_; } + bool commit_on_pointer_release() const { return commit_on_pointer_release_; } - // Returns true if the mouse is down as the result of activating the preview - // content. - bool IsMouseDownFromActivate(); + // Calls through to method of same name on loader. + bool IsPointerDownFromActivate(); // The autocomplete edit that was initiating the current instant session has // lost focus. Commit or discard the preview accordingly. @@ -179,7 +178,7 @@ class InstantController : public InstantLoaderDelegate { const string16& text, InstantCompleteBehavior behavior) OVERRIDE; virtual gfx::Rect GetInstantBounds() OVERRIDE; - virtual bool ShouldCommitInstantOnMouseUp() OVERRIDE; + virtual bool ShouldCommitInstantOnPointerRelease() OVERRIDE; virtual void CommitInstantLoader(InstantLoader* loader) OVERRIDE; virtual void InstantLoaderDoesntSupportInstant( InstantLoader* loader) OVERRIDE; @@ -243,8 +242,8 @@ class InstantController : public InstantLoaderDelegate { // See description above setter. gfx::Rect omnibox_bounds_; - // See description above CommitOnMouseUp. - bool commit_on_mouse_up_; + // See descritopn above for SetCommitOnPointerRelease. + bool commit_on_pointer_release_; // See description above getter. content::PageTransition last_transition_type_; diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index 195495f..a6fae58 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -197,8 +197,8 @@ class InstantLoader::WebContentsDelegateImpl // Invoked when the preview paints. Invokes PreviewPainted on the loader. void PreviewPainted(); - bool is_mouse_down_from_activate() const { - return is_mouse_down_from_activate_; + bool is_pointer_down_from_activate() const { + return is_pointer_down_from_activate_; } void set_user_typed_before_load() { user_typed_before_load_ = true; } @@ -240,7 +240,9 @@ class InstantLoader::WebContentsDelegateImpl int request_id, const std::string& request_method) OVERRIDE; virtual void HandleMouseUp() OVERRIDE; - virtual void HandleMouseActivate() OVERRIDE; + virtual void HandlePointerActivate() OVERRIDE; + virtual void HandleGestureBegin() OVERRIDE; + virtual void HandleGestureEnd() OVERRIDE; virtual bool OnGoToEntryOffset(int offset) OVERRIDE; virtual bool ShouldAddNavigationToHistory( const history::HistoryAddPageArgs& add_page_args, @@ -278,7 +280,8 @@ class InstantLoader::WebContentsDelegateImpl // instant. void OnInstantSupportDetermined(int32 page_id, bool result); - void CommitFromMouseReleaseIfNecessary(); + // Commits, if applicable, on mouse is released, or a gesture ends. + void CommitOnPointerReleaseIfNecessary(); InstantLoader* loader_; @@ -298,8 +301,8 @@ class InstantLoader::WebContentsDelegateImpl // NEW_PAGE navigation we don't add history items to add_page_vector_. bool waiting_for_new_page_; - // True if the mouse is down from an activate. - bool is_mouse_down_from_activate_; + // True if mouse-pointer or a touch-pointer is down from an activate. + bool is_pointer_down_from_activate_; // True if the user typed in the search box before the page loaded. bool user_typed_before_load_; @@ -313,7 +316,7 @@ InstantLoader::WebContentsDelegateImpl::WebContentsDelegateImpl( loader_(loader), registered_render_widget_host_(NULL), waiting_for_new_page_(true), - is_mouse_down_from_activate_(false), + is_pointer_down_from_activate_(false), user_typed_before_load_(false) { DCHECK(loader->preview_contents()); registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, @@ -492,11 +495,11 @@ void InstantLoader::WebContentsDelegateImpl::WebContentsFocused( } void InstantLoader::WebContentsDelegateImpl::LostCapture() { - CommitFromMouseReleaseIfNecessary(); + CommitOnPointerReleaseIfNecessary(); } void InstantLoader::WebContentsDelegateImpl::DragEnded() { - CommitFromMouseReleaseIfNecessary(); + CommitOnPointerReleaseIfNecessary(); } bool InstantLoader::WebContentsDelegateImpl::CanDownload( @@ -508,11 +511,18 @@ bool InstantLoader::WebContentsDelegateImpl::CanDownload( } void InstantLoader::WebContentsDelegateImpl::HandleMouseUp() { - CommitFromMouseReleaseIfNecessary(); + CommitOnPointerReleaseIfNecessary(); } -void InstantLoader::WebContentsDelegateImpl::HandleMouseActivate() { - is_mouse_down_from_activate_ = true; +void InstantLoader::WebContentsDelegateImpl::HandlePointerActivate() { + is_pointer_down_from_activate_ = true; +} + +void InstantLoader::WebContentsDelegateImpl::HandleGestureBegin() { +} + +void InstantLoader::WebContentsDelegateImpl::HandleGestureEnd() { + CommitOnPointerReleaseIfNecessary(); } bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) { @@ -623,10 +633,10 @@ void InstantLoader::WebContentsDelegateImpl::OnInstantSupportDetermined( } void InstantLoader::WebContentsDelegateImpl - ::CommitFromMouseReleaseIfNecessary() { - bool was_down = is_mouse_down_from_activate_; - is_mouse_down_from_activate_ = false; - if (was_down && loader_->ShouldCommitInstantOnMouseUp()) + ::CommitOnPointerReleaseIfNecessary() { + bool was_down = is_pointer_down_from_activate_; + is_pointer_down_from_activate_ = false; + if (was_down && loader_->ShouldCommitInstantOnPointerRelease()) loader_->CommitInstantLoader(); } @@ -758,7 +768,7 @@ void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { return; // Don't update the page while the mouse is down. http://crbug.com/71952 - if (IsMouseDownFromActivate()) + if (IsPointerDownFromActivate()) return; omnibox_bounds_ = bounds; @@ -779,9 +789,9 @@ void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { } } -bool InstantLoader::IsMouseDownFromActivate() { +bool InstantLoader::IsPointerDownFromActivate() { return preview_tab_contents_delegate_.get() && - preview_tab_contents_delegate_->is_mouse_down_from_activate(); + preview_tab_contents_delegate_->is_pointer_down_from_activate(); } TabContents* InstantLoader::ReleasePreviewContents( @@ -854,8 +864,8 @@ TabContents* InstantLoader::ReleasePreviewContents( return preview_contents_.release(); } -bool InstantLoader::ShouldCommitInstantOnMouseUp() { - return delegate_->ShouldCommitInstantOnMouseUp(); +bool InstantLoader::ShouldCommitInstantOnPointerRelease() { + return delegate_->ShouldCommitInstantOnPointerRelease(); } void InstantLoader::CommitInstantLoader() { diff --git a/chrome/browser/instant/instant_loader.h b/chrome/browser/instant/instant_loader.h index 38e1f1d..43f74fb 100644 --- a/chrome/browser/instant/instant_loader.h +++ b/chrome/browser/instant/instant_loader.h @@ -69,9 +69,9 @@ class InstantLoader : public content::NotificationObserver { // when showing results for a search provider that supports instant. void SetOmniboxBounds(const gfx::Rect& bounds); - // Returns true if the mouse is down as the result of activating the preview - // content. - bool IsMouseDownFromActivate(); + // Returns true if the mouse or a touch-pointer is down as the result of + // activating the preview content. + bool IsPointerDownFromActivate(); // Releases the preview TabContents passing ownership to the caller. // This is intended to be called when the preview TabContents is @@ -83,7 +83,7 @@ class InstantLoader : public content::NotificationObserver { TabContents* tab_contents); // Calls through to method of same name on delegate. - bool ShouldCommitInstantOnMouseUp(); + bool ShouldCommitInstantOnPointerRelease(); void CommitInstantLoader(); // Preload |template_url|'s instant URL, if the loader doesn't already have diff --git a/chrome/browser/instant/instant_loader_delegate.h b/chrome/browser/instant/instant_loader_delegate.h index bf393a1..9de5171 100644 --- a/chrome/browser/instant/instant_loader_delegate.h +++ b/chrome/browser/instant/instant_loader_delegate.h @@ -31,8 +31,9 @@ class InstantLoaderDelegate { // Returns the bounds of instant. virtual gfx::Rect GetInstantBounds() = 0; - // Returns true if instant should be committed on mouse up. - virtual bool ShouldCommitInstantOnMouseUp() = 0; + // Returns true if instant should be committed on mouse up or at the end of a + // touch-gesture. + virtual bool ShouldCommitInstantOnPointerRelease() = 0; // Invoked when the the loader should be committed. virtual void CommitInstantLoader(InstantLoader* loader) = 0; diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index 51282ac..297b4e0 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -439,7 +439,7 @@ void OmniboxEditModel::StartAutocomplete( void OmniboxEditModel::StopAutocomplete() { if (popup_->IsOpen() && !in_revert_) { InstantController* instant = controller_->GetInstant(); - if (instant && !instant->commit_on_mouse_up()) + if (instant && !instant->commit_on_pointer_release()) instant->DestroyPreviewContents(); } @@ -1107,7 +1107,7 @@ bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match, // omnibox view if the user clicked the renderer while IME composition was // active. In that case we still want to commit on mouse up, so don't call // Hide(). - if (!instant->commit_on_mouse_up()) + if (!instant->commit_on_pointer_release()) instant->Hide(); return false; } diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h index 9e43248..24fb700 100644 --- a/content/browser/renderer_host/render_view_host_delegate.h +++ b/content/browser/renderer_host/render_view_host_delegate.h @@ -317,7 +317,9 @@ class CONTENT_EXPORT RenderViewHostDelegate : public IPC::Listener { virtual void HandleMouseDown() {} virtual void HandleMouseLeave() {} virtual void HandleMouseUp() {} - virtual void HandleMouseActivate() {} + virtual void HandlePointerActivate() {} + virtual void HandleGestureBegin() {} + virtual void HandleGestureEnd() {} // Called when a file selection is to be done. virtual void RunFileChooser( diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 19dddf8..7a2c966 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -1527,8 +1527,8 @@ void RenderViewHostImpl::ForwardMouseEvent( } } -void RenderViewHostImpl::OnMouseActivate() { - delegate_->HandleMouseActivate(); +void RenderViewHostImpl::OnPointerEventActivate() { + delegate_->HandlePointerActivate(); } void RenderViewHostImpl::ForwardKeyboardEvent( diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h index 4d45ead..5495984 100644 --- a/content/browser/renderer_host/render_view_host_impl.h +++ b/content/browser/renderer_host/render_view_host_impl.h @@ -366,7 +366,7 @@ class CONTENT_EXPORT RenderViewHostImpl virtual void LostMouseLock() OVERRIDE; virtual void ForwardMouseEvent( const WebKit::WebMouseEvent& mouse_event) OVERRIDE; - virtual void OnMouseActivate() OVERRIDE; + virtual void OnPointerEventActivate() OVERRIDE; virtual void ForwardKeyboardEvent( const content::NativeWebKeyboardEvent& key_event) OVERRIDE; virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index e8b5dcb..c9aa3ce 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -782,7 +782,7 @@ void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { ForwardInputEvent(mouse_event, sizeof(WebMouseEvent), false); } -void RenderWidgetHostImpl::OnMouseActivate() { +void RenderWidgetHostImpl::OnPointerEventActivate() { } void RenderWidgetHostImpl::ForwardWheelEvent( diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 00438bc..470182a 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -238,8 +238,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, void CancelUpdateTextDirection(); - // Called when a mouse click activates the renderer. - virtual void OnMouseActivate(); + // Called when a mouse click/gesture tap activates the renderer. + virtual void OnPointerEventActivate(); // Notifies the renderer whether or not the input method attached to this // process is activated. diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index fa120ca..40b2e96 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -14,12 +14,14 @@ #include "base/string_number_conversions.h" #include "content/browser/renderer_host/backing_store_aura.h" #include "content/browser/renderer_host/dip_util.h" +#include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/web_input_event_aura.h" #include "content/common/gpu/client/gl_helper.h" #include "content/common/gpu/gpu_messages.h" #include "content/port/browser/render_widget_host_view_port.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_view_host.h" #include "content/public/browser/user_metrics.h" #include "content/public/common/content_switches.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h" @@ -48,6 +50,8 @@ using content::BrowserThread; using content::NativeWebKeyboardEvent; +using content::RenderViewHost; +using content::RenderViewHostDelegate; using content::RenderWidgetHost; using content::RenderWidgetHostImpl; using content::RenderWidgetHostView; @@ -1147,6 +1151,12 @@ ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( return ui::GESTURE_STATUS_CONSUMED; } + RenderViewHostDelegate* delegate = RenderViewHost::From(host_)->GetDelegate(); + if (event->type() == ui::ET_GESTURE_BEGIN && + event->details().touch_points() == 1) { + delegate->HandleGestureBegin(); + } + WebKit::WebGestureEvent gesture = content::MakeWebGestureEvent(event); if (event->type() == ui::ET_GESTURE_TAP_DOWN) { // Webkit does not stop a fling-scroll on tap-down. So explicitly send an @@ -1155,6 +1165,7 @@ ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; host_->ForwardGestureEvent(fling_cancel); } + if (gesture.type != WebKit::WebInputEvent::Undefined) { host_->ForwardGestureEvent(gesture); @@ -1168,6 +1179,11 @@ ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( } } + if (event->type() == ui::ET_GESTURE_END && + event->details().touch_points() == 1) { + delegate->HandleGestureEnd(); + } + // If a gesture is not processed by the webpage, then WebKit processes it // (e.g. generates synthetic mouse events). So CONSUMED should be returned // from here to avoid any duplicate synthetic mouse-events being generated @@ -1233,8 +1249,17 @@ void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: bool RenderWidgetHostViewAura::ShouldActivate(const aura::Event* event) { - if (event && event->type() == ui::ET_MOUSE_PRESSED) - host_->OnMouseActivate(); + bool activate = false; + if (event) { + if (event->type() == ui::ET_MOUSE_PRESSED) { + activate = true; + } else if (event->type() == ui::ET_GESTURE_BEGIN) { + activate = static_cast<const aura::GestureEvent*>(event)-> + details().touch_points() == 1; + } + } + if (activate) + host_->OnPointerEventActivate(); return is_fullscreen_; } diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index 436ee88..d32bf0e 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -318,7 +318,7 @@ class RenderWidgetHostViewGtkWidget { // If we don't have focus already, this mouse click will focus us. if (!gtk_widget_is_focus(widget)) - host_view->host_->OnMouseActivate(); + host_view->host_->OnPointerEventActivate(); // Confirm existing composition text on mouse click events, to make sure // the input caret won't be moved with an ongoing composition session. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 32e24b6..4492222 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -1497,7 +1497,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { // TODO(rohitrao): Probably need to handle other mouse down events here. if ([theEvent type] == NSLeftMouseDown && takesFocusOnlyOnMouseDown_) { if (renderWidgetHostView_->render_widget_host_) - renderWidgetHostView_->render_widget_host_->OnMouseActivate(); + renderWidgetHostView_->render_widget_host_->OnPointerEventActivate(); // Manually take focus after the click but before forwarding it to the // renderer. diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 0bd3f89..f04f1a8 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -2362,7 +2362,7 @@ LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT message, } } handled = FALSE; - render_widget_host_->OnMouseActivate(); + render_widget_host_->OnPointerEventActivate(); return MA_ACTIVATE; } diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index dad1b5a..600c7b1 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -1095,9 +1095,19 @@ void WebContentsImpl::HandleMouseUp() { delegate_->HandleMouseUp(); } -void WebContentsImpl::HandleMouseActivate() { +void WebContentsImpl::HandlePointerActivate() { if (delegate_) - delegate_->HandleMouseActivate(); + delegate_->HandlePointerActivate(); +} + +void WebContentsImpl::HandleGestureBegin() { + if (delegate_) + delegate_->HandleGestureBegin(); +} + +void WebContentsImpl::HandleGestureEnd() { + if (delegate_) + delegate_->HandleGestureEnd(); } void WebContentsImpl::ToggleFullscreenMode(bool enter_fullscreen) { diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 6acc418..49959b3 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -362,7 +362,9 @@ class CONTENT_EXPORT WebContentsImpl virtual void LostCapture() OVERRIDE; virtual void HandleMouseDown() OVERRIDE; virtual void HandleMouseUp() OVERRIDE; - virtual void HandleMouseActivate() OVERRIDE; + virtual void HandlePointerActivate() OVERRIDE; + virtual void HandleGestureBegin() OVERRIDE; + virtual void HandleGestureEnd() OVERRIDE; virtual void RunFileChooser( content::RenderViewHost* render_view_host, const content::FileChooserParams& params) OVERRIDE; diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 062946a..e9bc561 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -255,7 +255,13 @@ class CONTENT_EXPORT WebContentsDelegate { virtual void HandleMouseDown() {} virtual void HandleMouseUp() {} - virtual void HandleMouseActivate() {} + + // Handles activation resulting from a pointer event (e.g. when mouse is + // pressed, or a touch-gesture begins). + virtual void HandlePointerActivate() {} + + virtual void HandleGestureBegin() {} + virtual void HandleGestureEnd() {} // Render view drag n drop ended. virtual void DragEnded() {} diff --git a/ui/aura/shared/compound_event_filter.cc b/ui/aura/shared/compound_event_filter.cc index d3d0993..f32d480 100644 --- a/ui/aura/shared/compound_event_filter.cc +++ b/ui/aura/shared/compound_event_filter.cc @@ -125,17 +125,7 @@ bool CompoundEventFilter::PreHandleMouseEvent(aura::Window* target, ui::TouchStatus CompoundEventFilter::PreHandleTouchEvent( aura::Window* target, aura::TouchEvent* event) { - ui::TouchStatus status = FilterTouchEvent(target, event); - if (status != ui::TOUCH_STATUS_UNKNOWN) - return status; - - if (event->type() == ui::ET_TOUCH_PRESSED) { - SetVisibilityOnEvent(event, false); - target->GetFocusManager()->SetFocusedWindow( - FindFocusableWindowFor(target), event); - } - - return ui::TOUCH_STATUS_UNKNOWN; + return FilterTouchEvent(target, event); } ui::GestureStatus CompoundEventFilter::PreHandleGestureEvent( @@ -150,6 +140,16 @@ ui::GestureStatus CompoundEventFilter::PreHandleGestureEvent( status = filter->PreHandleGestureEvent(target, event); } } + + if (event->type() == ui::ET_GESTURE_BEGIN && + event->details().touch_points() == 1 && + target->GetRootWindow() && + GetActiveWindow(target) != target) { + SetVisibilityOnEvent(event, false); + target->GetFocusManager()->SetFocusedWindow( + FindFocusableWindowFor(target), event); + } + return status; } |