Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc

Issue 7058046: Adjust virtual keyboard size base on input method candidates. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
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 9ba91608a547f0687f502b24600adb2c89ca6fac..19c4bb96afe1b3bcbc8e69d600e4a908d8b20a7f 100644
--- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
+++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
@@ -28,7 +28,7 @@
namespace {
-const int kKeyboardHeight = 360;
+const int kDefaultKeyboardHeight = 300;
const int kKeyboardSlideDuration = 500; // In milliseconds
PropertyAccessor<bool>* GetFocusedStateAccessor() {
@@ -54,6 +54,7 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
BrowserView* browser_view)
: OpaqueBrowserFrameView(frame, browser_view),
keyboard_showing_(false),
+ keyboard_height_(kDefaultKeyboardHeight),
focus_listener_added_(false),
keyboard_(NULL) {
registrar_.Add(this,
@@ -68,6 +69,9 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
registrar_.Add(this,
NotificationType::HIDE_KEYBOARD_INVOKED,
NotificationService::AllSources());
+ registrar_.Add(this,
+ NotificationType::SET_KEYBOARD_HEIGHT_INVOKED,
+ NotificationService::AllSources());
browser_view->browser()->tabstrip_model()->AddObserver(this);
@@ -97,8 +101,8 @@ void TouchBrowserFrameView::Layout() {
// 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);
+ bounds.set_y(bounds.y() - keyboard_height_);
+ bounds.set_height(keyboard_height_);
}
keyboard_->SetBoundsRect(bounds);
}
@@ -116,7 +120,7 @@ void TouchBrowserFrameView::FocusWillChange(views::View* focused_before,
///////////////////////////////////////////////////////////////////////////////
// TouchBrowserFrameView, protected:
int TouchBrowserFrameView::GetReservedHeight() const {
- return keyboard_showing_ ? kKeyboardHeight : 0;
+ return keyboard_showing_ ? keyboard_height_ : 0;
}
void TouchBrowserFrameView::ViewHierarchyChanged(bool is_add,
@@ -174,7 +178,7 @@ void TouchBrowserFrameView::UpdateKeyboardAndLayout(bool should_show_keyboard) {
animation_->Hide();
browser_view()->set_clip_y(ui::Tween::ValueBetween(
- animation_->GetCurrentValue(), 0, kKeyboardHeight));
+ animation_->GetCurrentValue(), 0, keyboard_height_));
parent()->Layout();
}
}
@@ -286,6 +290,15 @@ void TouchBrowserFrameView::Observe(NotificationType type,
false);
}
UpdateKeyboardAndLayout(false);
+ } else if (type == NotificationType::SET_KEYBOARD_HEIGHT_INVOKED) {
+ int height = *reinterpret_cast<int*>(details.map_key());
+ if (height != keyboard_height_) {
+ DCHECK_GE(height, 0) << "Height of the keyboar is less than 0.";
+ DCHECK_LE(height, View::height()) << "Height of the keyboard is great "
+ "than the height of frame view.";
+ keyboard_height_ = height;
bryeung 2011/06/07 22:45:03 Please do not set the height or call Layout if the
Peng 2011/06/08 14:59:57 I added code in extension_input_api.cc to check th
+ parent()->Layout();
+ }
}
}
@@ -294,10 +307,10 @@ void TouchBrowserFrameView::Observe(NotificationType type,
void TouchBrowserFrameView::AnimationProgressed(const ui::Animation* anim) {
ui::Transform transform;
transform.SetTranslateY(
- ui::Tween::ValueBetween(anim->GetCurrentValue(), kKeyboardHeight, 0));
+ ui::Tween::ValueBetween(anim->GetCurrentValue(), keyboard_height_, 0));
keyboard_->SetTransform(transform);
browser_view()->set_clip_y(
- ui::Tween::ValueBetween(anim->GetCurrentValue(), 0, kKeyboardHeight));
+ ui::Tween::ValueBetween(anim->GetCurrentValue(), 0, keyboard_height_));
SchedulePaint();
}

Powered by Google App Engine
This is Rietveld 408576698