diff options
-rw-r--r-- | chrome/browser/ui/views/bookmark_bar_view.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/browser_actions_container.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/views/reload_button.cc | 3 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_views.cc | 3 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_win.cc | 1 | ||||
-rw-r--r-- | views/metrics.cc | 11 | ||||
-rw-r--r-- | views/metrics.h | 26 | ||||
-rw-r--r-- | views/metrics_gtk.cc | 20 | ||||
-rw-r--r-- | views/metrics_win.cc | 22 | ||||
-rw-r--r-- | views/view.cc | 3 | ||||
-rw-r--r-- | views/view.h | 14 | ||||
-rw-r--r-- | views/view_gtk.cc | 12 | ||||
-rw-r--r-- | views/view_win.cc | 15 | ||||
-rw-r--r-- | views/views.gyp | 4 |
14 files changed, 94 insertions, 50 deletions
diff --git a/chrome/browser/ui/views/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmark_bar_view.cc index bab8e07..5b64fc3 100644 --- a/chrome/browser/ui/views/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmark_bar_view.cc @@ -50,6 +50,7 @@ #include "views/controls/label.h" #include "views/controls/menu/menu_item_view.h" #include "views/drag_utils.h" +#include "views/metrics.h" #include "views/view_constants.h" #include "views/widget/tooltip_manager.h" #include "views/widget/widget.h" @@ -98,10 +99,6 @@ static SkBitmap* kFolderIcon = NULL; // BookmarkBarView. static const int kMenuOffset = 3; -// Delay during drag and drop before the menu pops up. This is only used if -// we can't get the value from the OS. -static const int kShowFolderDropMenuDelay = 400; - // Color of the drop indicator. static const SkColor kDropIndicatorColor = SK_ColorBLACK; @@ -1371,7 +1368,7 @@ void BookmarkBarView::StartShowFolderDropMenuTimer(const BookmarkNode* node) { } DCHECK(!show_folder_drop_menu_task_); show_folder_drop_menu_task_ = new ShowFolderDropMenuTask(this, node); - int delay = View::GetMenuShowDelay(); + int delay = views::GetMenuShowDelay(); MessageLoop::current()->PostDelayedTask(FROM_HERE, show_folder_drop_menu_task_, delay); } diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index c405253..8a94fd4 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -42,6 +42,7 @@ #include "views/controls/button/text_button.h" #include "views/controls/menu/menu_2.h" #include "views/drag_utils.h" +#include "views/metrics.h" #include "views/window/window.h" #include "grit/theme_resources.h" @@ -1011,7 +1012,7 @@ void BrowserActionsContainer::StopShowFolderDropMenuTimer() { } void BrowserActionsContainer::StartShowFolderDropMenuTimer() { - int delay = View::GetMenuShowDelay(); + int delay = views::GetMenuShowDelay(); MessageLoop::current()->PostDelayedTask(FROM_HERE, show_menu_task_factory_.NewRunnableMethod( &BrowserActionsContainer::ShowDropFolder), diff --git a/chrome/browser/ui/views/reload_button.cc b/chrome/browser/ui/views/reload_button.cc index 4189dd1..87a88b7 100644 --- a/chrome/browser/ui/views/reload_button.cc +++ b/chrome/browser/ui/views/reload_button.cc @@ -11,6 +11,7 @@ #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "views/metrics.h" //////////////////////////////////////////////////////////////////////////////// // ReloadButton, public: @@ -22,7 +23,7 @@ ReloadButton::ReloadButton(LocationBarView* location_bar, Browser* browser) intended_mode_(MODE_RELOAD), visible_mode_(MODE_RELOAD), double_click_timer_delay_( - base::TimeDelta::FromMilliseconds(GetDoubleClickTimeMS())), + base::TimeDelta::FromMilliseconds(views::GetDoubleClickInterval())), stop_to_reload_timer_delay_(base::TimeDelta::FromMilliseconds(1350)), testing_mouse_hovered_(false), testing_reload_count_(0) { diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index b49fcb6..21313a0 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -21,6 +21,7 @@ #include "views/controls/textfield/textfield.h" #include "views/controls/textfield/textfield_views_model.h" #include "views/events/event.h" +#include "views/metrics.h" #include "views/views_delegate.h" #if defined(OS_LINUX) @@ -788,7 +789,7 @@ bool NativeTextfieldViews::HandleMousePressed(const views::MouseEvent& e) { last_mouse_press_location_ = e.location(); if (e.IsLeftMouseButton()) { if (!ExceededDragThreshold(location_delta.x(), location_delta.y()) - && time_delta.InMilliseconds() <= GetDoubleClickTimeMS()) { + && time_delta.InMilliseconds() <= GetDoubleClickInterval()) { // Multiple mouse press detected. Check for double or triple. switch (click_state_) { case TRACKING_DOUBLE_CLICK: diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index e08be41..2047d40 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -27,6 +27,7 @@ #include "views/controls/textfield/textfield.h" #include "views/focus/focus_manager.h" #include "views/focus/focus_util_win.h" +#include "views/metrics.h" #include "views/views_delegate.h" #include "views/widget/widget.h" diff --git a/views/metrics.cc b/views/metrics.cc new file mode 100644 index 0000000..525bab0 --- /dev/null +++ b/views/metrics.cc @@ -0,0 +1,11 @@ +// 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 "views/metrics.h" + +namespace views { + +const int kDefaultMenuShowDelay = 400; + +} // namespace views diff --git a/views/metrics.h b/views/metrics.h new file mode 100644 index 0000000..88b8fd4 --- /dev/null +++ b/views/metrics.h @@ -0,0 +1,26 @@ +// 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. + +#ifndef VIEWS_METRICS_H_ +#define VIEWS_METRICS_H_ +#pragma once + +namespace views { + +// NOTE: All times in this file are/should be expressed in milliseconds. + +// The default value for how long to wait before showing a menu button on hover. +// This value is used if the OS doesn't supply one. +extern const int kDefaultMenuShowDelay; + +// Returns the amount of time between double clicks. +int GetDoubleClickInterval(); + +// Returns the amount of time to wait from hovering over a menu button until +// showing the menu. +int GetMenuShowDelay(); + +} // namespace views + +#endif // VIEWS_METRICS_H_ diff --git a/views/metrics_gtk.cc b/views/metrics_gtk.cc new file mode 100644 index 0000000..01be70e --- /dev/null +++ b/views/metrics_gtk.cc @@ -0,0 +1,20 @@ +// 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 "views/metrics.h" + +#include <gtk/gtk.h> + +namespace views { + +int GetDoubleClickInterval() { + GdkDisplay* display = gdk_display_get_default(); + return display ? display->double_click_time : 500; +} + +int GetMenuShowDelay() { + return kDefaultMenuShowDelay; +} + +} // namespace views diff --git a/views/metrics_win.cc b/views/metrics_win.cc new file mode 100644 index 0000000..8150f5a --- /dev/null +++ b/views/metrics_win.cc @@ -0,0 +1,22 @@ +// 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 "views/metrics.h" + +#include <windows.h> + +namespace views { + +int GetDoubleClickInterval() { + return ::GetDoubleClickTime(); +} + +int GetMenuShowDelay() { + static DWORD delay = 0; + if (!delay && !SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &delay, 0)) + delay = kDefaultMenuShowDelay; + return delay; +} + +} // namespace views diff --git a/views/view.cc b/views/view.cc index d616fc7..8ffb77e 100644 --- a/views/view.cc +++ b/views/view.cc @@ -40,9 +40,6 @@ ViewsDelegate* ViewsDelegate::views_delegate = NULL; // static char View::kViewClassName[] = "views/View"; -// static -const int View::kShowFolderDropMenuDelay = 400; - //////////////////////////////////////////////////////////////////////////////// // View, public: diff --git a/views/view.h b/views/view.h index 1c5761c..4e6ace3 100644 --- a/views/view.h +++ b/views/view.h @@ -147,15 +147,6 @@ class View : public AcceleratorTarget { // TO BE MOVED --------------------------------------------------------------- // TODO(beng): These methods are to be moved to other files/classes. - // TODO(beng): move to metrics.h - // Returns the amount of time between double clicks, in milliseconds. - static int GetDoubleClickTimeMS(); - - // TODO(beng): move to metrics.h - // Returns the amount of time to wait from hovering over a menu button until - // showing the menu. - static int GetMenuShowDelay(); - // TODO(beng): delete // Set whether this view is hottracked. A disabled view cannot be hottracked. // If flag differs from the current value, SchedulePaint is invoked. @@ -1307,11 +1298,6 @@ class View : public AcceleratorTarget { ////////////////////////////////////////////////////////////////////////////// - // TODO(beng): move to metrics.h - // The default value for how long to wait (in ms) before showing a menu - // button on hover. This value is used if the OS doesn't supply one. - static const int kShowFolderDropMenuDelay; - // Creation and lifetime ----------------------------------------------------- // Whether this view is owned by its parent. diff --git a/views/view_gtk.cc b/views/view_gtk.cc index 464534a..b666338 100644 --- a/views/view_gtk.cc +++ b/views/view_gtk.cc @@ -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. @@ -11,16 +11,6 @@ namespace views { -// static -int View::GetDoubleClickTimeMS() { - GdkDisplay* display = gdk_display_get_default(); - return display ? display->double_click_time : 500; -} - -int View::GetMenuShowDelay() { - return kShowFolderDropMenuDelay; -} - void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type, bool send_native_event) { // Send the notification to the delegate. diff --git a/views/view_win.cc b/views/view_win.cc index f95e9e0..2c213c2 100644 --- a/views/view_win.cc +++ b/views/view_win.cc @@ -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. @@ -22,19 +22,6 @@ namespace views { -// static -int View::GetDoubleClickTimeMS() { - return ::GetDoubleClickTime(); -} - -// static -int View::GetMenuShowDelay() { - static DWORD delay = 0; - if (!delay && !SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &delay, 0)) - delay = View::kShowFolderDropMenuDelay; - return delay; -} - void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type, bool send_native_event) { // Send the notification to the delegate. diff --git a/views/views.gyp b/views/views.gyp index 8586d1e..7952a93 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -292,6 +292,10 @@ 'layout/layout_constants.h', 'layout/layout_manager.cc', 'layout/layout_manager.h', + 'metrics.cc', + 'metrics.h', + 'metrics_gtk.cc', + 'metrics_win.cc', 'mouse_watcher.cc', 'mouse_watcher.h', 'painter.cc', |