summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwnwen@chromium.org <wnwen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 21:25:10 +0000
committerwnwen@chromium.org <wnwen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 21:25:10 +0000
commitd03fd56e9f30e2cf2f7161135f2231b43455e7b3 (patch)
treea69ef88ef2081a42b52f0e5b97a95a8457a9af81
parentee554d89d1c822537345ce4d03d2bff8783d7f1b (diff)
downloadchromium_src-d03fd56e9f30e2cf2f7161135f2231b43455e7b3.zip
chromium_src-d03fd56e9f30e2cf2f7161135f2231b43455e7b3.tar.gz
chromium_src-d03fd56e9f30e2cf2f7161135f2231b43455e7b3.tar.bz2
In immersive mode when top container is closed, decrease the hit target of the render view.
This steals a few pixels from the content so that slide gestures can be appropriately generated even if the content page consumes touch events (in which case without stealing these pixels result in no gestures being generated and so no sliding out of the top container in immersive mode). Increased number of pixels to steal slightly (from 5 to 8) to improve accuracy, may be tweaked later. BUG=chromium:252225 TEST=Works reliably even when page consumes touch/mouse events. Works on rotation. TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/18539015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212428 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h1
-rw-r--r--chrome/browser/ui/views/frame/immersive_mode_controller.h8
-rw-r--r--chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc22
-rw-r--r--chrome/browser/ui/views/frame/immersive_mode_controller_ash.h7
-rw-r--r--chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc34
-rw-r--r--chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc3
-rw-r--r--ui/aura/window.h4
8 files changed, 81 insertions, 2 deletions
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 31f310c..9390677 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1867,6 +1867,10 @@ void BrowserView::SetImmersiveStyle(bool immersive) {
tabstrip_->SetImmersiveStyle(immersive);
}
+WebContents* BrowserView::GetWebContents() {
+ return GetActiveWebContents();
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, InfoBarContainer::Delegate overrides:
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index dd56ccf..6d0c871 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -435,6 +435,7 @@ class BrowserView : public BrowserWindow,
virtual FullscreenController* GetFullscreenController() OVERRIDE;
virtual void FullscreenStateChanged() OVERRIDE;
virtual void SetImmersiveStyle(bool immersive) OVERRIDE;
+ virtual content::WebContents* GetWebContents() OVERRIDE;
// InfoBarContainer::Delegate overrides
virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE;
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller.h b/chrome/browser/ui/views/frame/immersive_mode_controller.h
index f8f23de..f4a504b 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller.h
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller.h
@@ -11,6 +11,10 @@
class BookmarkBarView;
class FullscreenController;
+namespace content {
+class WebContents;
+}
+
namespace gfx {
class Rect;
class Size;
@@ -61,6 +65,10 @@ class ImmersiveModeController {
// Returns the browser's FullscreenController.
virtual FullscreenController* GetFullscreenController() = 0;
+ // Returns the browser's active web contents for the active tab, or NULL if
+ // such does not exist.
+ virtual content::WebContents* GetWebContents() = 0;
+
// Notifies the delegate that fullscreen has been entered or exited.
virtual void FullscreenStateChanged() = 0;
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
index 8b1b5f7..9fd4fac 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
#include <set>
+#include <vector>
#include "ash/ash_switches.h"
#include "ash/shell.h"
@@ -16,6 +17,8 @@
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
@@ -48,7 +51,7 @@ const int kRevealFastAnimationDurationMs = 200;
// How many pixels a gesture can start away from |top_container_| when in
// closed state and still be considered near it. This is needed to overcome
// issues with poor location values near the edge of the display.
-const int kNearTopContainerDistance = 5;
+const int kNearTopContainerDistance = 8;
// Used to multiply x value of an update in check to determine if gesture is
// vertical. This is used to make sure that gesture is close to vertical instead
@@ -347,6 +350,7 @@ void ImmersiveModeControllerAsh::SetEnabled(bool enabled) {
reveal_state_ = CLOSED;
EnablePaintToLayer(false);
delegate_->SetImmersiveStyle(false);
+ SetRenderWindowTopInsetsForTouch(0);
// Relayout the root view because disabling immersive fullscreen may have
// changed the result of NonClientFrameView::GetBoundsForClientView().
@@ -940,6 +944,7 @@ void ImmersiveModeControllerAsh::MaybeStartReveal(Animate animate) {
// top-of-window views to their initial offscreen position for the
// animation.
delegate_->SetImmersiveStyle(false);
+ SetRenderWindowTopInsetsForTouch(0);
LayoutBrowserRootView();
// Do not do any more processing if LayoutBrowserView() changed
@@ -959,7 +964,7 @@ void ImmersiveModeControllerAsh::MaybeStartReveal(Animate animate) {
animation_->Show();
}
- if (previous_reveal_state == CLOSED)
+ if (previous_reveal_state == CLOSED)
FOR_EACH_OBSERVER(Observer, observers_, OnImmersiveRevealStarted());
}
@@ -1037,6 +1042,7 @@ void ImmersiveModeControllerAsh::OnSlideClosedAnimationCompleted() {
EnablePaintToLayer(false);
// Update tabstrip for closed state.
delegate_->SetImmersiveStyle(true);
+ SetRenderWindowTopInsetsForTouch(kNearTopContainerDistance);
LayoutBrowserRootView();
}
@@ -1083,6 +1089,18 @@ bool ImmersiveModeControllerAsh::ShouldHandleGestureEvent(
(location.x() < near_bounds.right()));
}
+void ImmersiveModeControllerAsh::SetRenderWindowTopInsetsForTouch(
+ int top_inset) {
+ content::WebContents* contents = delegate_->GetWebContents();
+ if (contents) {
+ aura::Window* window = contents->GetView()->GetContentNativeView();
+ gfx::Insets inset(top_inset, 0, 0, 0);
+ window->SetHitTestBoundsOverrideOuter(
+ window->hit_test_bounds_override_outer_mouse(),
+ inset);
+ }
+}
+
void ImmersiveModeControllerAsh::RecreateBubbleManager() {
bubble_manager_.reset(new BubbleManager(this));
const std::vector<aura::Window*> transient_children =
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h
index a1e909e..8ba1f2a 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h
@@ -223,6 +223,13 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
// child of |top_container_|.
void RecreateBubbleManager();
+ // Shrinks or expands the touch hit test by updating insets for the render
+ // window depending on if top_inset is positive or negative respectively.
+ // Used to ensure that touch events at the top of the screen go to the top
+ // container so a slide gesture can be generated when the content window is
+ // consuming all touch events sent to it.
+ void SetRenderWindowTopInsetsForTouch(int top_inset);
+
// Injected dependencies. Not owned.
Delegate* delegate_;
views::Widget* widget_;
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc
index 644798b..450115c 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc
@@ -23,6 +23,8 @@
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
#include "content/public/test/test_utils.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
@@ -422,4 +424,36 @@ IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerAshTest,
EXPECT_TRUE(controller()->ShouldHideTabIndicators());
}
+// Validate top container touch insets are being updated at the correct time in
+// immersive mode.
+IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerAshTest,
+ ImmersiveTopContainerInsets) {
+ content::WebContents* contents = browser_view()->GetActiveWebContents();
+ aura::Window* window = contents->GetView()->GetContentNativeView();
+
+ // Turning immersive mode on sets positive top touch insets on the render view
+ // window.
+ chrome::ToggleFullscreenMode(browser());
+ ASSERT_TRUE(browser_view()->IsFullscreen());
+ ASSERT_TRUE(controller()->IsEnabled());
+ EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() > 0);
+
+ // Trigger a reveal resets insets as now the touch target for the top
+ // container is large enough.
+ controller()->StartRevealForTest(true);
+ EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() == 0);
+
+ // End reveal by moving the mouse off the top-of-window views. We
+ // should see the top insets being positive again to allow a bigger touch
+ // target.
+ controller()->SetMouseHoveredForTest(false);
+ EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() > 0);
+
+ // Disabling immersive mode resets the top touch insets to 0.
+ chrome::ToggleFullscreenMode(browser());
+ ASSERT_FALSE(browser_view()->IsFullscreen());
+ ASSERT_FALSE(controller()->IsEnabled());
+ EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() == 0);
+}
+
#endif // defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
index b02982b..3a206ab 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
@@ -34,6 +34,9 @@ class MockImmersiveModeControllerDelegate
virtual void SetImmersiveStyle(bool immersive) OVERRIDE {
immersive_style_ = immersive;
}
+ virtual content::WebContents* GetWebContents() OVERRIDE {
+ return NULL;
+ }
private:
bool immersive_style_;
diff --git a/ui/aura/window.h b/ui/aura/window.h
index de4ca12..92dfa90 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -245,6 +245,10 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
hit_test_bounds_override_outer_touch_ = touch_insets;
}
+ gfx::Insets hit_test_bounds_override_outer_touch() const {
+ return hit_test_bounds_override_outer_touch_;
+ }
+
gfx::Insets hit_test_bounds_override_outer_mouse() const {
return hit_test_bounds_override_outer_mouse_;
}