Commit c858acfa authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Animate the fullscreen exit bubble's opacity instead of its bounds when in immersive fullscreen.

BUG=188567
Test=Manual, see instructions below.

1) Run Chrome with --ash-immersive-fullscreen
2) Go to http://html5-demos.appspot.com/static/fullscreen.html
3) Use F11 to toggle immersive fullscreen
4) With the top-of-window views closed, click on the "Toggle Fullscreen" button on the web page.
5) Hover at the top of the screen till the top-of-window views reveal. (Do this before the exit bubble fades out) Check that the exit fullscreen bubble animates with the top-of-window views.
6) Once the exit bubble disappears, check that it cannot be brought back by hovering at the top of the screen.
7) Exit tab fullscreen and browser fullscreen.
8) Enter tab fullscreen again by pressing the "Toggle fullscreen" button on the web page
9) Check that the exit fullscreen bubble slides in and out.
   (Note that when the exit bubble is initially shown it does not animate at all)
10) Go to chrome://settings > Show advanced settings... > Content settings... > Mouse cursor > Manage exceptions...
11) Remove an exception for www.html5rocks.com if there is one
12) Go to www.html5rocks.com/en/tutorials/pointerlock/intro
13) Use F11 to toggle immersive fullscreen
14) With the top-of-window views closed, click on the "Click me!" yellow box on the web page. (in the Interactive Example) section.
15) Hover at the top of the screen till the top-of-window views reveal. Check that the mouse lock bubble animates with the top-of-window views.
16) Click on the "Allow" button in the bubble.
17) Check that the mouse lock bubble fades out (as opposed to sliding out).
18) Press Escape and F11 to exit mouse lock and fullscreen
19) Click on the "Click me!" yellow box again. Check that the bubble slides out.

Review URL: https://chromiumcodereview.appspot.com/13866033

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195281 0039d316-1c4b-4281-b951-d872f2087c98
parent 2862df46
...@@ -60,6 +60,10 @@ void FullscreenExitBubble::StopWatchingMouse() { ...@@ -60,6 +60,10 @@ void FullscreenExitBubble::StopWatchingMouse() {
mouse_position_checker_.Stop(); mouse_position_checker_.Stop();
} }
bool FullscreenExitBubble::IsWatchingMouse() const {
return mouse_position_checker_.IsRunning();
}
void FullscreenExitBubble::CheckMousePosition() { void FullscreenExitBubble::CheckMousePosition() {
// Desired behavior: // Desired behavior:
// //
...@@ -101,10 +105,12 @@ void FullscreenExitBubble::CheckMousePosition() { ...@@ -101,10 +105,12 @@ void FullscreenExitBubble::CheckMousePosition() {
if (!initial_delay_.IsRunning()) { if (!initial_delay_.IsRunning()) {
Hide(); Hide();
} }
} else if ((cursor_pos.y() < kSlideInRegionHeightPx) || } else if (cursor_pos.y() < kSlideInRegionHeightPx &&
IsAnimating()) { CanMouseTriggerSlideIn()) {
// The cursor is not idle, and either it's in the slide-in region or it's in Show();
// the neutral region and we're sliding out. } else if (IsAnimating()) {
// The cursor is not idle and either it's in the slide-in region or it's in
// the neutral region and we're sliding in or out.
Show(); Show();
} }
} }
......
...@@ -56,12 +56,17 @@ class FullscreenExitBubble : public ui::AnimationDelegate { ...@@ -56,12 +56,17 @@ class FullscreenExitBubble : public ui::AnimationDelegate {
virtual bool IsAnimating() = 0; virtual bool IsAnimating() = 0;
// Called repeatedly to get the current mouse position and animate the bubble // True if the mouse position can trigger sliding in the exit fullscreen
// on or off the screen as appropriate. // bubble when the bubble is hidden.
void CheckMousePosition(); virtual bool CanMouseTriggerSlideIn() const = 0;
void StartWatchingMouse(); void StartWatchingMouse();
void StopWatchingMouse(); void StopWatchingMouse();
bool IsWatchingMouse() const;
// Called repeatedly to get the current mouse position and animate the bubble
// on or off the screen as appropriate.
void CheckMousePosition();
void ToggleFullscreen(); void ToggleFullscreen();
// Accepts the request. Can cause FullscreenExitBubble to be deleted. // Accepts the request. Can cause FullscreenExitBubble to be deleted.
......
...@@ -225,6 +225,10 @@ bool FullscreenExitBubbleGtk::IsAnimating() { ...@@ -225,6 +225,10 @@ bool FullscreenExitBubbleGtk::IsAnimating() {
return slide_widget_->IsAnimating(); return slide_widget_->IsAnimating();
} }
bool FullscreenExitBubbleGtk::CanMouseTriggerSlideIn() const {
return true;
}
void FullscreenExitBubbleGtk::StartWatchingMouseIfNecessary() { void FullscreenExitBubbleGtk::StartWatchingMouseIfNecessary() {
if (!fullscreen_bubble::ShowButtonsForType(bubble_type_)) if (!fullscreen_bubble::ShowButtonsForType(bubble_type_))
StartWatchingMouse(); StartWatchingMouse();
......
...@@ -42,6 +42,7 @@ class FullscreenExitBubbleGtk : public FullscreenExitBubble, ...@@ -42,6 +42,7 @@ class FullscreenExitBubbleGtk : public FullscreenExitBubble,
virtual void Hide() OVERRIDE; virtual void Hide() OVERRIDE;
virtual void Show() OVERRIDE; virtual void Show() OVERRIDE;
virtual bool IsAnimating() OVERRIDE; virtual bool IsAnimating() OVERRIDE;
virtual bool CanMouseTriggerSlideIn() const OVERRIDE;
private: private:
void InitWidgets(); void InitWidgets();
......
...@@ -809,7 +809,7 @@ void BrowserView::UpdateFullscreenExitBubbleContent( ...@@ -809,7 +809,7 @@ void BrowserView::UpdateFullscreenExitBubbleContent(
fullscreen_bubble_->UpdateContent(url, bubble_type); fullscreen_bubble_->UpdateContent(url, bubble_type);
} else { } else {
fullscreen_bubble_.reset(new FullscreenExitBubbleViews( fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
GetWidget(), browser_.get(), url, bubble_type)); this, url, bubble_type));
} }
} }
...@@ -2319,7 +2319,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen, ...@@ -2319,7 +2319,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen,
type != FOR_METRO && type != FOR_METRO &&
!UseImmersiveFullscreenForUrl(url)) { !UseImmersiveFullscreenForUrl(url)) {
fullscreen_bubble_.reset(new FullscreenExitBubbleViews( fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
GetWidget(), browser_.get(), url, bubble_type)); this, url, bubble_type));
} }
} else { } else {
#if defined(OS_WIN) && !defined(USE_AURA) #if defined(OS_WIN) && !defined(USE_AURA)
......
...@@ -218,7 +218,7 @@ class BrowserView : public BrowserWindow, ...@@ -218,7 +218,7 @@ class BrowserView : public BrowserWindow,
void FullScreenStateChanged(); void FullScreenStateChanged();
// See ImmersiveModeController for description. // See ImmersiveModeController for description.
ImmersiveModeController* immersive_mode_controller() { ImmersiveModeController* immersive_mode_controller() const {
return immersive_mode_controller_.get(); return immersive_mode_controller_.get();
} }
......
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble.h" #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/views/widget/widget_observer.h"
class BrowserView;
class GURL; class GURL;
namespace ui { namespace ui {
class SlideAnimation; class SlideAnimation;
...@@ -22,10 +26,11 @@ class Widget; ...@@ -22,10 +26,11 @@ class Widget;
// screen in fullscreen mode, telling users how to exit and providing a click // screen in fullscreen mode, telling users how to exit and providing a click
// target. The bubble auto-hides, and re-shows when the user moves to the // target. The bubble auto-hides, and re-shows when the user moves to the
// screen top. // screen top.
class FullscreenExitBubbleViews : public FullscreenExitBubble { class FullscreenExitBubbleViews : public FullscreenExitBubble,
public content::NotificationObserver,
public views::WidgetObserver {
public: public:
FullscreenExitBubbleViews(views::Widget* frame, FullscreenExitBubbleViews(BrowserView* browser,
Browser* browser,
const GURL& url, const GURL& url,
FullscreenExitBubbleType bubble_type); FullscreenExitBubbleType bubble_type);
virtual ~FullscreenExitBubbleViews(); virtual ~FullscreenExitBubbleViews();
...@@ -35,7 +40,26 @@ class FullscreenExitBubbleViews : public FullscreenExitBubble { ...@@ -35,7 +40,26 @@ class FullscreenExitBubbleViews : public FullscreenExitBubble {
private: private:
class FullscreenExitView; class FullscreenExitView;
// FullScreenExitBubble enum AnimatedAttribute {
ANIMATED_ATTRIBUTE_BOUNDS,
ANIMATED_ATTRIBUTE_OPACITY
};
// Starts or stops polling the mouse location based on |popup_| and
// |bubble_type_|.
void UpdateMouseWatcher();
// Updates any state which depends on whether the user is in immersive
// fullscreen.
void UpdateForImmersiveState();
// Updates |popup|'s bounds given |animation_| and |animated_attribute_|.
void UpdateBounds();
// Returns the root view containing |browser_view_|.
views::View* GetBrowserRootView() const;
// FullScreenExitBubble overrides:
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const OVERRIDE; virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const OVERRIDE;
...@@ -45,20 +69,32 @@ class FullscreenExitBubbleViews : public FullscreenExitBubble { ...@@ -45,20 +69,32 @@ class FullscreenExitBubbleViews : public FullscreenExitBubble {
virtual void Hide() OVERRIDE; virtual void Hide() OVERRIDE;
virtual void Show() OVERRIDE; virtual void Show() OVERRIDE;
virtual bool IsAnimating() OVERRIDE; virtual bool IsAnimating() OVERRIDE;
virtual bool CanMouseTriggerSlideIn() const OVERRIDE;
// content::NotificationObserver override:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
void StartWatchingMouseIfNecessary(); // views::WidgetObserver override:
virtual void OnWidgetVisibilityChanged(views::Widget* widget,
bool visible) OVERRIDE;
// The root view containing us. BrowserView* browser_view_;
views::View* root_view_;
views::Widget* popup_; views::Widget* popup_;
// Animation controlling sliding into/out of the top of the screen. // Animation controlling showing/hiding of the exit bubble.
scoped_ptr<ui::SlideAnimation> size_animation_; scoped_ptr<ui::SlideAnimation> animation_;
// Attribute animated by |animation_|.
AnimatedAttribute animated_attribute_;
// The contents of the popup. // The contents of the popup.
FullscreenExitView* view_; FullscreenExitView* view_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(FullscreenExitBubbleViews); DISALLOW_COPY_AND_ASSIGN(FullscreenExitBubbleViews);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment