summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/views/app_launcher.cc45
-rw-r--r--chrome/browser/views/app_launcher.h35
-rw-r--r--chrome/browser/views/info_bubble.cc28
-rw-r--r--chrome/browser/views/info_bubble.h2
-rw-r--r--chrome/common/notification_type.h3
5 files changed, 72 insertions, 41 deletions
diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc
index 8521300..e993cdc 100644
--- a/chrome/browser/views/app_launcher.cc
+++ b/chrome/browser/views/app_launcher.cc
@@ -11,12 +11,9 @@
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/string_util.h"
-#include "base/task.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_window.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/dom_view.h"
#include "chrome/browser/views/info_bubble.h"
@@ -37,6 +34,11 @@ const int kNavigationBarBottomPadding = 3;
// NavigationBar constants.
const int kNavigationBarBorderThickness = 1;
+// The speed in pixels per milli-second at which the animation should progress.
+// It is easier to use a speed than a duration as the contents may report
+// several changes in size over-time.
+const double kAnimationSpeedPxPerMS = 1.5;
+
const SkColor kBorderColor = SkColorSetRGB(205, 201, 201);
// Command line switch for specifying url of the page.
@@ -228,8 +230,7 @@ void InfoBubbleContentsView::Layout() {
location_bar_height);
int render_y = location_bar_->bounds().bottom() + kNavigationBarBottomPadding;
dom_view_->SetBounds(0, render_y,
- width(),
- std::max(0, bounds.height() - render_y + bounds.y()));
+ width(), app_launcher_->contents_pref_size_.height());
}
void InfoBubbleContentsView::ExecuteCommand(int id) {
@@ -248,6 +249,8 @@ AppLauncher::AppLauncher(Browser* browser)
info_bubble_(NULL) {
DCHECK(browser);
info_bubble_content_ = new InfoBubbleContentsView(this);
+ animation_.reset(new SlideAnimation(this));
+ animation_->SetTweenType(Tween::LINEAR);
}
AppLauncher::~AppLauncher() {
@@ -326,8 +329,31 @@ void AppLauncher::UpdatePreferredSize(const gfx::Size& pref_size) {
if (pref_size.width() == 0 || pref_size.height() == 0)
return;
- gfx::Size size(pref_size);
- info_bubble_content_->ComputePreferredSize(size);
+ previous_contents_pref_size_ = contents_pref_size_;
+ contents_pref_size_ = pref_size;
+
+ int original_height = previous_contents_pref_size_.height();
+ int new_height = contents_pref_size_.height();
+ int new_duration;
+ if (animation_->is_animating()) {
+ // Modify the animation duration so that the current running animation does
+ // not appear janky.
+ new_duration = static_cast<int>(new_height / kAnimationSpeedPxPerMS);
+ } else {
+ // The animation is not running.
+ animation_->Reset(); // It may have already been run.
+ new_duration = static_cast<int>(abs(new_height - original_height) /
+ kAnimationSpeedPxPerMS);
+ }
+ animation_->SetSlideDuration(new_duration);
+ animation_->Show(); // No-op if already showing.
+}
+
+void AppLauncher::AnimationProgressed(const Animation* animation) {
+ gfx::Size contents_size(contents_pref_size_.width(),
+ animation->CurrentValueBetween(previous_contents_pref_size_.height(),
+ contents_pref_size_.height()));
+ info_bubble_content_->ComputePreferredSize(contents_size);
info_bubble_->SizeToContents();
}
@@ -372,3 +398,8 @@ void AppLauncher::AddTabWithURL(const GURL& url,
NULL, std::string());
#endif
}
+
+void AppLauncher::Resize(const gfx::Size& contents_size) {
+ info_bubble_content_->ComputePreferredSize(contents_size);
+ info_bubble_->SizeToContents();
+}
diff --git a/chrome/browser/views/app_launcher.h b/chrome/browser/views/app_launcher.h
index 670ead4..8891ec6 100644
--- a/chrome/browser/views/app_launcher.h
+++ b/chrome/browser/views/app_launcher.h
@@ -5,26 +5,14 @@
#ifndef CHROME_BROWSER_VIEWS_APP_LAUNCHER_H_
#define CHROME_BROWSER_VIEWS_APP_LAUNCHER_H_
+#include "app/slide_animation.h"
#include "base/scoped_ptr.h"
+#include "base/task.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/views/pinned_contents_info_bubble.h"
-#include "views/view.h"
class Browser;
-class SiteInstance;
-
-namespace gfx {
-class Size;
-}
-namespace views {
-class NativeViewHost;
-class View;
-class WidgetGtk;
-}
-
class InfoBubbleContentsView;
-class NavigationBar;
-class TabContentsDelegateImpl;
// AppLauncher manages showing the application launcher and optionally the
// navigation bar in compact navigation bar mode. The app launcher is
@@ -38,7 +26,8 @@ class TabContentsDelegateImpl;
//
// When a new url is opened, or the user clicks outsides the bounds of the
// widget the app launcher is closed.
-class AppLauncher : public InfoBubbleDelegate,
+class AppLauncher : public AnimationDelegate,
+ public InfoBubbleDelegate,
public TabContentsDelegate {
public:
// Shows an application launcher bubble pointing to the |bounds| (which should
@@ -72,6 +61,9 @@ class AppLauncher : public InfoBubbleDelegate,
// Hides the app launcher.
void Hide();
+ // AnimationDelegate overrides:
+ virtual void AnimationProgressed(const Animation* animation);
+
// InfoBubbleDelegate overrides.
virtual void InfoBubbleClosing(InfoBubble* info_bubble,
bool closed_by_escape);
@@ -109,7 +101,6 @@ class AppLauncher : public InfoBubbleDelegate,
private:
friend class DeleteTask<AppLauncher>;
- friend class NavigationBar;
friend class InfoBubbleContentsView;
explicit AppLauncher(Browser* browser);
@@ -117,6 +108,9 @@ class AppLauncher : public InfoBubbleDelegate,
void AddTabWithURL(const GURL& url, PageTransition::Type transition);
+ // Resizes the bubble so it matches its contents's size |contents_size|.
+ void Resize(const gfx::Size& contents_size);
+
// The currently active browser. We use this to open urls.
Browser* browser_;
@@ -130,6 +124,15 @@ class AppLauncher : public InfoBubbleDelegate,
// sent into the launcher's HTML page via its hash.
std::string hash_params_;
+ // The preferred size of the DOM contents.
+ gfx::Size contents_pref_size_;
+
+ // The previous preferred size of the DOM contents.
+ gfx::Size previous_contents_pref_size_;
+
+ // The animation that grows the info-bubble.
+ scoped_ptr<SlideAnimation> animation_;
+
DISALLOW_COPY_AND_ASSIGN(AppLauncher);
};
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index e672004..4894f1a 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -195,7 +195,6 @@ int BorderContents::GetInsetsLength(const gfx::Insets& insets, bool vertical) {
// BorderWidget ---------------------------------------------------------------
BorderWidget::BorderWidget() : border_contents_(NULL) {
- set_delete_on_destroy(false); // Our owner will free us manually.
set_window_style(WS_POPUP);
set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED);
}
@@ -204,7 +203,7 @@ void BorderWidget::Init(BorderContents* border_contents, HWND owner) {
DCHECK(!border_contents_);
border_contents_ = border_contents;
border_contents_->Init();
- WidgetWin::Init(GetAncestor(owner, GA_ROOT), gfx::Rect());
+ WidgetWin::Init(owner, gfx::Rect());
SetContentsView(border_contents_);
SetWindowPos(owner, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOREDRAW);
@@ -222,16 +221,6 @@ gfx::Rect BorderWidget::SizeAndGetBounds(
&window_bounds);
SetBounds(window_bounds);
- // Chop a hole out of our region to show the contents through.
- // CreateRectRgn() expects (left, top, right, bottom) in window coordinates.
- HRGN contents_region = CreateRectRgn(contents_bounds.x(), contents_bounds.y(),
- contents_bounds.right(), contents_bounds.bottom());
- HRGN window_region = CreateRectRgn(0, 0, window_bounds.width(),
- window_bounds.height());
- CombineRgn(window_region, window_region, contents_region, RGN_XOR);
- DeleteObject(contents_region);
- SetWindowRgn(window_region, true);
-
// Return |contents_bounds| in screen coordinates.
contents_bounds.Offset(window_bounds.origin());
return contents_bounds;
@@ -290,6 +279,8 @@ InfoBubble::InfoBubble()
#if defined(OS_LINUX)
WidgetGtk(TYPE_WINDOW),
border_contents_(NULL),
+#elif defined(OS_WIN)
+ border_(NULL),
#endif
delegate_(NULL),
closed_(false) {
@@ -312,7 +303,14 @@ void InfoBubble::Init(views::Widget* parent,
parent_window->DisableInactiveRendering();
set_window_style(WS_POPUP | WS_CLIPCHILDREN);
set_window_ex_style(WS_EX_TOOLWINDOW);
- WidgetWin::Init(parent->GetNativeView(), gfx::Rect());
+
+ DCHECK(!border_);
+ border_ = new BorderWidget();
+ border_->Init(CreateBorderContents(), parent->GetNativeView());
+
+ // We make the BorderWidget the owner of the InfoBubble HWND, so that the
+ // latter is displayed on top of the former.
+ WidgetWin::Init(border_->GetNativeView(), gfx::Rect());
#elif defined(OS_LINUX)
MakeTransparent();
make_transient_to_parent();
@@ -343,10 +341,6 @@ void InfoBubble::Init(views::Widget* parent,
gfx::Rect window_bounds;
#if defined(OS_WIN)
- DCHECK(!border_.get());
- border_.reset(new BorderWidget());
- border_->Init(CreateBorderContents(), GetNativeView());
-
// Initialize and position the border window.
window_bounds = border_->SizeAndGetBounds(position_relative_to,
arrow_location,
diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h
index 21289e6..40994af 100644
--- a/chrome/browser/views/info_bubble.h
+++ b/chrome/browser/views/info_bubble.h
@@ -226,7 +226,7 @@ class InfoBubble
#if defined(OS_WIN)
// The window used to render the padding, border and arrow.
- scoped_ptr<BorderWidget> border_;
+ BorderWidget* border_;
#elif defined(OS_LINUX)
// The view displaying the border.
BorderContents* border_contents_;
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index ec2a858..7e17a68 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -253,6 +253,9 @@ class NotificationType {
PAGE_TRANSLATED,
// Sent after the renderer returns a snapshot of tab contents.
+ // The source (Source<RenderViewHost>) is the RenderViewHost for which the
+ // snapshot was generated and the details (Details<const SkBitmap>) is the
+ // actual snapshot.
TAB_SNAPSHOT_TAKEN,
// Send after the code is run in specified tab.