diff options
author | Kristian Monsen <kristianm@google.com> | 2011-06-09 11:47:42 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-29 14:33:03 +0100 |
commit | dc0f95d653279beabeb9817299e2902918ba123e (patch) | |
tree | 32eb121cd532053a5b9cb0c390331349af8d6baa /chrome/browser/ui/touch | |
parent | ba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff) | |
download | external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2 |
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'chrome/browser/ui/touch')
-rw-r--r-- | chrome/browser/ui/touch/frame/keyboard_container_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/touch/frame/touch_browser_frame_view.cc | 83 | ||||
-rw-r--r-- | chrome/browser/ui/touch/frame/touch_browser_frame_view.h | 14 | ||||
-rw-r--r-- | chrome/browser/ui/touch/tabs/touch_tab.cc | 12 | ||||
-rw-r--r-- | chrome/browser/ui/touch/tabs/touch_tab.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/touch/tabs/touch_tab_strip.cc | 10 |
6 files changed, 96 insertions, 31 deletions
diff --git a/chrome/browser/ui/touch/frame/keyboard_container_view.cc b/chrome/browser/ui/touch/frame/keyboard_container_view.cc index d11bdfb..d765a0a 100644 --- a/chrome/browser/ui/touch/frame/keyboard_container_view.cc +++ b/chrome/browser/ui/touch/frame/keyboard_container_view.cc @@ -5,9 +5,9 @@ #include "chrome/browser/ui/touch/frame/keyboard_container_view.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/ui/views/dom_view.h" #include "chrome/common/url_constants.h" +#include "content/browser/site_instance.h" namespace { @@ -49,4 +49,3 @@ void KeyboardContainerView::ViewHierarchyChanged(bool is_add, if (is_add) MakeViewHierarchyUnfocusable(child); } - diff --git a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc index c2d915d..58a7ca0 100644 --- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc +++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc @@ -1,14 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_widget_host_view_views.h" -#include "chrome/browser/tab_contents/navigation_controller.h" -#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -16,12 +13,17 @@ #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" +#include "content/browser/renderer_host/render_view_host.h" +#include "content/browser/tab_contents/navigation_controller.h" +#include "content/browser/tab_contents/tab_contents.h" +#include "ui/base/animation/slide_animation.h" #include "ui/gfx/rect.h" #include "views/controls/textfield/textfield.h" namespace { const int kKeyboardHeight = 300; +const int kKeyboardSlideDuration = 500; // In milliseconds PropertyAccessor<bool>* GetFocusedStateAccessor() { static PropertyAccessor<bool> state; @@ -50,6 +52,10 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame, NotificationService::AllSources()); browser_view->browser()->tabstrip_model()->AddObserver(this); + + animation_.reset(new ui::SlideAnimation(this)); + animation_->SetTweenType(ui::Tween::LINEAR); + animation_->SetSlideDuration(kKeyboardSlideDuration); } TouchBrowserFrameView::~TouchBrowserFrameView() { @@ -62,8 +68,17 @@ void TouchBrowserFrameView::Layout() { if (!keyboard_) return; - keyboard_->SetVisible(keyboard_showing_); - keyboard_->SetBoundsRect(GetBoundsForReservedArea()); + keyboard_->SetVisible(keyboard_showing_ || animation_->is_animating()); + gfx::Rect bounds = GetBoundsForReservedArea(); + if (animation_->is_animating() && !keyboard_showing_) { + // The keyboard is in the process of hiding. So pretend it still has the + // same bounds as when the keyboard is visible. But + // |GetBoundsForReservedArea| should not take this into account so that the + // render view gets the entire area to relayout itself. + bounds.set_y(bounds.y() - kKeyboardHeight); + bounds.set_height(kKeyboardHeight); + } + keyboard_->SetBoundsRect(bounds); } void TouchBrowserFrameView::FocusWillChange(views::View* focused_before, @@ -79,10 +94,7 @@ void TouchBrowserFrameView::FocusWillChange(views::View* focused_before, /////////////////////////////////////////////////////////////////////////////// // TouchBrowserFrameView, protected: int TouchBrowserFrameView::GetReservedHeight() const { - if (keyboard_showing_) - return kKeyboardHeight; - - return 0; + return keyboard_showing_ ? kKeyboardHeight : 0; } void TouchBrowserFrameView::ViewHierarchyChanged(bool is_add, @@ -128,17 +140,19 @@ void TouchBrowserFrameView::UpdateKeyboardAndLayout(bool should_show_keyboard) { DCHECK(keyboard_); keyboard_showing_ = should_show_keyboard; - - // Because the NonClientFrameView is a sibling of the ClientView, we rely on - // the parent to resize the ClientView instead of resizing it directly. - parent()->Layout(); - - // The keyboard that pops up may end up hiding the text entry. So make sure - // the renderer scrolls when necessary to keep the textfield visible. if (keyboard_showing_) { - RenderViewHost* host = - browser_view()->browser()->GetSelectedTabContents()->render_view_host(); - host->ScrollFocusedEditableNodeIntoView(); + animation_->Show(); + + // We don't re-layout the client view until the animation ends (see + // AnimationEnded below) because we want the client view to occupy the + // entire height during the animation. + Layout(); + } else { + animation_->Hide(); + + browser_view()->set_clip_y(ui::Tween::ValueBetween( + animation_->GetCurrentValue(), 0, kKeyboardHeight)); + parent()->Layout(); } } @@ -164,6 +178,9 @@ void TouchBrowserFrameView::TabSelectedAt(TabContentsWrapper* old_contents, TabContentsWrapper* new_contents, int index, bool user_gesture) { + if (new_contents == old_contents) + return; + TabContents* contents = new_contents->tab_contents(); bool* editable = GetFocusedStateAccessor()->GetProperty( contents->property_bag()); @@ -201,3 +218,29 @@ void TouchBrowserFrameView::Observe(NotificationType type, Source<TabContents>(source).ptr()->property_bag()); } } + +/////////////////////////////////////////////////////////////////////////////// +// ui::AnimationDelegate implementation +void TouchBrowserFrameView::AnimationProgressed(const ui::Animation* anim) { + keyboard_->SetTranslateY( + ui::Tween::ValueBetween(anim->GetCurrentValue(), kKeyboardHeight, 0)); + browser_view()->set_clip_y( + ui::Tween::ValueBetween(anim->GetCurrentValue(), 0, kKeyboardHeight)); + SchedulePaint(); +} + +void TouchBrowserFrameView::AnimationEnded(const ui::Animation* animation) { + browser_view()->set_clip_y(0); + if (keyboard_showing_) { + // Because the NonClientFrameView is a sibling of the ClientView, we rely on + // the parent to resize the ClientView instead of resizing it directly. + parent()->Layout(); + + // The keyboard that pops up may end up hiding the text entry. So make sure + // the renderer scrolls when necessary to keep the textfield visible. + RenderViewHost* host = + browser_view()->browser()->GetSelectedTabContents()->render_view_host(); + host->ScrollFocusedEditableNodeIntoView(); + } + SchedulePaint(); +} diff --git a/chrome/browser/ui/touch/frame/touch_browser_frame_view.h b/chrome/browser/ui/touch/frame/touch_browser_frame_view.h index e5700f4..7eb49b0 100644 --- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.h +++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" +#include "ui/base/animation/animation_delegate.h" #include "views/focus/focus_manager.h" class BrowserFrame; @@ -18,9 +19,14 @@ class KeyboardContainerView; class NotificationDetails; class NotificationSource; +namespace ui { +class SlideAnimation; +} + class TouchBrowserFrameView : public OpaqueBrowserFrameView, public views::FocusChangeListener, public TabStripModelObserver, + public ui::AnimationDelegate, public NotificationObserver { public: enum VirtualKeyboardType { @@ -61,11 +67,17 @@ class TouchBrowserFrameView : public OpaqueBrowserFrameView, const NotificationSource& source, const NotificationDetails& details); + // Overridden from ui::AnimationDelegate: + virtual void AnimationProgressed(const ui::Animation* animation); + virtual void AnimationEnded(const ui::Animation* animation); + bool keyboard_showing_; bool focus_listener_added_; KeyboardContainerView* keyboard_; NotificationRegistrar registrar_; + scoped_ptr<ui::SlideAnimation> animation_; + DISALLOW_COPY_AND_ASSIGN(TouchBrowserFrameView); }; diff --git a/chrome/browser/ui/touch/tabs/touch_tab.cc b/chrome/browser/ui/touch/tabs/touch_tab.cc index b4df099..69be10d 100644 --- a/chrome/browser/ui/touch/tabs/touch_tab.cc +++ b/chrome/browser/ui/touch/tabs/touch_tab.cc @@ -44,9 +44,19 @@ gfx::Size TouchTab::GetMinimumUnselectedSize() { } //////////////////////////////////////////////////////////////////////////////// +// TouchTab, protected: +const gfx::Rect& TouchTab::GetTitleBounds() const { + return title_bounds_; +} + +const gfx::Rect& TouchTab::GetIconBounds() const { + return favicon_bounds_; +} + +//////////////////////////////////////////////////////////////////////////////// // TouchTab, views::View overrides: -void TouchTab::Paint(gfx::Canvas* canvas) { +void TouchTab::OnPaint(gfx::Canvas* canvas) { // Don't paint if we're narrower than we can render correctly. (This should // only happen during animations). if (width() < GetMinimumUnselectedSize().width() && !data().mini) diff --git a/chrome/browser/ui/touch/tabs/touch_tab.h b/chrome/browser/ui/touch/tabs/touch_tab.h index bc7eb2f..614f18e 100644 --- a/chrome/browser/ui/touch/tabs/touch_tab.h +++ b/chrome/browser/ui/touch/tabs/touch_tab.h @@ -38,11 +38,12 @@ class TouchTab : public BaseTab { static gfx::Size GetMinimumUnselectedSize(); protected: - virtual const gfx::Rect& title_bounds() const { return title_bounds_; } + virtual const gfx::Rect& GetTitleBounds() const; + virtual const gfx::Rect& GetIconBounds() const; private: // Overridden from views::View: - virtual void Paint(gfx::Canvas* canvas); + virtual void OnPaint(gfx::Canvas* canvas); virtual void Layout(); virtual bool HasHitTestMask() const; virtual void GetHitTestMask(gfx::Path* path) const; diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc b/chrome/browser/ui/touch/tabs/touch_tab_strip.cc index b950fb0..0cec7be 100644 --- a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc +++ b/chrome/browser/ui/touch/tabs/touch_tab_strip.cc @@ -41,7 +41,7 @@ void TouchTabStrip::SetBackgroundOffset(const gfx::Point& offset) { } bool TouchTabStrip::IsPositionInWindowCaption(const gfx::Point& point) { - views::View* v = GetViewForPoint(point); + views::View* v = GetEventHandlerForPoint(point); // If there is no control at this location, claim the hit was in the title // bar to get a move action. @@ -157,13 +157,13 @@ void TouchTabStrip::PaintChildren(gfx::Canvas* canvas) { if (tab->dragging()) { dragging_tab = tab; } else if (!tab->IsSelected()) { - tab->ProcessPaint(canvas); + tab->Paint(canvas); } else { selected_tab = tab; } } - if (GetWindow()->GetNonClientView()->UseNativeFrame()) { + if (GetWindow()->non_client_view()->UseNativeFrame()) { // Make sure unselected tabs are somewhat transparent. SkPaint paint; paint.setColor(SkColorSetARGB(200, 255, 255, 255)); @@ -176,11 +176,11 @@ void TouchTabStrip::PaintChildren(gfx::Canvas* canvas) { // Paint the selected tab last, so it overlaps all the others. if (selected_tab) - selected_tab->ProcessPaint(canvas); + selected_tab->Paint(canvas); // And the dragged tab. if (dragging_tab) - dragging_tab->ProcessPaint(canvas); + dragging_tab->Paint(canvas); } TouchTab* TouchTabStrip::GetTabAtTabDataIndex(int tab_data_index) const { |