summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_provider_win.cc2
-rw-r--r--chrome/browser/chromeos/frame/panel_controller.cc33
-rw-r--r--chrome/browser/chromeos/frame/panel_controller.h19
-rw-r--r--chrome/browser/chromeos/input_method/candidate_window.cc27
-rw-r--r--chrome/browser/chromeos/panels/panel_scroller.cc4
-rw-r--r--chrome/browser/chromeos/panels/panel_scroller.h15
-rw-r--r--chrome/browser/chromeos/panels/panel_scroller_header.cc7
-rw-r--r--chrome/browser/chromeos/panels/panel_scroller_header.h9
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.cc4
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.h3
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc11
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h4
-rw-r--r--chrome/browser/ui/views/browser_actions_container.cc7
-rw-r--r--chrome/browser/ui/views/browser_actions_container.h3
-rw-r--r--chrome/browser/ui/views/content_setting_bubble_contents.cc15
-rw-r--r--chrome/browser/ui/views/download_item_view.cc23
-rw-r--r--chrome/browser/ui/views/download_item_view.h4
-rw-r--r--chrome/browser/ui/views/location_bar/click_handler.cc6
-rw-r--r--chrome/browser/ui/views/location_bar/click_handler.h4
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.cc7
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.h18
-rw-r--r--chrome/browser/ui/views/location_bar/ev_bubble_view.cc6
-rw-r--r--chrome/browser/ui/views/location_bar/ev_bubble_view.h4
-rw-r--r--chrome/browser/ui/views/location_bar/icon_label_bubble_view.h8
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc24
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.h7
-rw-r--r--chrome/browser/ui/views/location_bar/location_icon_view.cc5
-rw-r--r--chrome/browser/ui/views/location_bar/location_icon_view.h4
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.cc10
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.h14
-rw-r--r--chrome/browser/ui/views/location_bar/star_view.cc9
-rw-r--r--chrome/browser/ui/views/location_bar/star_view.h9
-rw-r--r--chrome/browser/ui/views/tabs/base_tab.cc9
-rw-r--r--chrome/browser/ui/views/tabs/base_tab.h4
-rw-r--r--chrome/browser/ui/views/tabs/base_tab_strip.cc9
-rw-r--r--chrome/browser/ui/views/tabs/base_tab_strip.h4
-rw-r--r--chrome/browser/ui/views/tabs/side_tab_strip.cc13
-rw-r--r--ui/views/view.cc5
-rw-r--r--views/controls/button/button_dropdown.cc13
-rw-r--r--views/controls/button/button_dropdown.h4
-rw-r--r--views/controls/button/checkbox.cc10
-rw-r--r--views/controls/button/checkbox.h3
-rw-r--r--views/controls/button/custom_button.cc13
-rw-r--r--views/controls/button/custom_button.h3
-rw-r--r--views/controls/button/image_button.h6
-rw-r--r--views/controls/button/menu_button.cc8
-rw-r--r--views/controls/button/menu_button.h2
-rw-r--r--views/controls/button/radio_button.cc12
-rw-r--r--views/controls/button/radio_button.h8
-rw-r--r--views/controls/link.cc41
-rw-r--r--views/controls/link.h10
-rw-r--r--views/controls/menu/menu_controller.cc33
-rw-r--r--views/controls/menu/menu_controller.h8
-rw-r--r--views/controls/menu/menu_host_root_view.cc33
-rw-r--r--views/controls/menu/menu_host_root_view.h10
-rw-r--r--views/controls/resize_area.cc11
-rw-r--r--views/controls/resize_area.h6
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.cc36
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.h3
-rw-r--r--views/controls/single_split_view.cc6
-rw-r--r--views/controls/single_split_view.h4
-rw-r--r--views/controls/single_split_view_unittest.cc13
-rw-r--r--views/controls/textfield/native_textfield_views.cc18
-rw-r--r--views/controls/textfield/native_textfield_views.h10
-rw-r--r--views/focus/accelerator_handler_touch.cc4
-rw-r--r--views/touchui/gesture_manager.cc4
-rw-r--r--views/view.cc13
-rw-r--r--views/view.h11
-rw-r--r--views/view_unittest.cc16
-rw-r--r--views/widget/root_view.cc31
-rw-r--r--views/widget/root_view.h7
-rw-r--r--views/widget/widget_gtk.cc4
-rw-r--r--views/widget/widget_win.cc4
73 files changed, 385 insertions, 402 deletions
diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc
index 9047ed7..6cc06d9 100644
--- a/chrome/browser/automation/automation_provider_win.cc
+++ b/chrome/browser/automation/automation_provider_win.cc
@@ -107,7 +107,7 @@ class MouseEventTask : public Task {
break;
case ui::ET_MOUSE_RELEASED:
- view_->OnMouseReleased(event, false);
+ view_->OnMouseReleased(event);
break;
default:
diff --git a/chrome/browser/chromeos/frame/panel_controller.cc b/chrome/browser/chromeos/frame/panel_controller.cc
index 93a2756..90a38d2 100644
--- a/chrome/browser/chromeos/frame/panel_controller.cc
+++ b/chrome/browser/chromeos/frame/panel_controller.cc
@@ -159,16 +159,14 @@ void PanelController::Init(bool initial_focus,
void PanelController::UpdateTitleBar() {
if (!delegate_ || !title_window_)
return;
- DCHECK(title_content_);
title_content_->title_label()->SetText(
UTF16ToWideHack(delegate_->GetPanelTitle()));
title_content_->title_icon()->SetImage(delegate_->GetPanelIcon());
}
bool PanelController::TitleMousePressed(const views::MouseEvent& event) {
- if (!event.IsOnlyLeftMouseButton()) {
+ if (!event.IsOnlyLeftMouseButton())
return false;
- }
GdkEvent* gdk_event = gtk_get_current_event();
if (gdk_event->type != GDK_BUTTON_PRESS) {
gdk_event_free(gdk_event);
@@ -194,15 +192,15 @@ bool PanelController::TitleMousePressed(const views::MouseEvent& event) {
return true;
}
-void PanelController::TitleMouseReleased(
- const views::MouseEvent& event, bool canceled) {
- if (!event.IsLeftMouseButton()) {
- return;
- }
+void PanelController::TitleMouseReleased(const views::MouseEvent& event) {
+ if (event.IsLeftMouseButton())
+ TitleMouseCaptureLost();
+}
+
+void PanelController::TitleMouseCaptureLost() {
// Only handle clicks that started in our window.
- if (!mouse_down_) {
+ if (!mouse_down_)
return;
- }
mouse_down_ = false;
if (!dragging_) {
@@ -224,10 +222,8 @@ void PanelController::SetState(State state) {
}
bool PanelController::TitleMouseDragged(const views::MouseEvent& event) {
- if (!mouse_down_) {
+ if (!mouse_down_)
return false;
- }
-
GdkEvent* gdk_event = gtk_get_current_event();
if (gdk_event->type != GDK_MOTION_NOTIFY) {
gdk_event_free(gdk_event);
@@ -363,19 +359,20 @@ void PanelController::TitleContentView::Layout() {
bool PanelController::TitleContentView::OnMousePressed(
const views::MouseEvent& event) {
- DCHECK(panel_controller_) << "OnMousePressed after Close";
return panel_controller_->TitleMousePressed(event);
}
void PanelController::TitleContentView::OnMouseReleased(
- const views::MouseEvent& event, bool canceled) {
- DCHECK(panel_controller_) << "MouseReleased after Close";
- return panel_controller_->TitleMouseReleased(event, canceled);
+ const views::MouseEvent& event) {
+ panel_controller_->TitleMouseReleased(event);
+}
+
+void PanelController::TitleContentView::OnMouseCaptureLost() {
+ panel_controller_->TitleMouseCaptureLost();
}
bool PanelController::TitleContentView::OnMouseDragged(
const views::MouseEvent& event) {
- DCHECK(panel_controller_) << "MouseDragged after Close";
return panel_controller_->TitleMouseDragged(event);
}
diff --git a/chrome/browser/chromeos/frame/panel_controller.h b/chrome/browser/chromeos/frame/panel_controller.h
index ff23cfa..49a9950 100644
--- a/chrome/browser/chromeos/frame/panel_controller.h
+++ b/chrome/browser/chromeos/frame/panel_controller.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.
@@ -62,7 +62,8 @@ class PanelController {
WmIpcPanelUserResizeType resize_type);
bool TitleMousePressed(const views::MouseEvent& event);
- void TitleMouseReleased(const views::MouseEvent& event, bool canceled);
+ void TitleMouseReleased(const views::MouseEvent& event);
+ void TitleMouseCaptureLost();
bool TitleMouseDragged(const views::MouseEvent& event);
bool PanelClientEvent(GdkEventClient* event);
void OnFocusIn();
@@ -79,10 +80,14 @@ class PanelController {
public:
explicit TitleContentView(PanelController* panelController);
virtual ~TitleContentView();
- virtual void Layout();
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
- virtual bool OnMouseDragged(const views::MouseEvent& event);
+
+ // Overridden from View:
+ virtual void Layout() OVERRIDE;
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
+ virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
+
void OnFocusIn();
void OnFocusOut();
void OnClose();
@@ -93,7 +98,7 @@ class PanelController {
// ButtonListener methods.
virtual void ButtonPressed(views::Button* sender,
- const views::Event& event);
+ const views::Event& event) OVERRIDE;
private:
views::ImageView* title_icon_;
views::Label* title_label_;
diff --git a/chrome/browser/chromeos/input_method/candidate_window.cc b/chrome/browser/chromeos/input_method/candidate_window.cc
index 5146a7c..9199ecc 100644
--- a/chrome/browser/chromeos/input_method/candidate_window.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window.cc
@@ -528,15 +528,11 @@ class CandidateView : public views::View {
gfx::Point GetCandidateLabelPosition() const;
private:
- // View::OnMousePressed() implementation.
- virtual bool OnMousePressed(const views::MouseEvent& event);
-
- // View::OnMouseDragged() implementation.
- virtual bool OnMouseDragged(const views::MouseEvent& event);
-
- // View::OnMouseReleased() implementation.
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled);
+ // Overridden from View:
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
// Zero-origin index in the current page.
int index_in_page_;
@@ -735,12 +731,13 @@ bool CandidateView::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void CandidateView::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- // Commit the current candidate unless it's canceled.
- if (!canceled) {
- parent_candidate_window_->CommitCandidate();
- }
+void CandidateView::OnMouseReleased(const views::MouseEvent& event) {
+ // Commit the current candidate.
+ parent_candidate_window_->CommitCandidate();
+ OnMouseCaptureLost();
+}
+
+void CandidateView::OnMouseCaptureLost() {
parent_candidate_window_->OnMouseReleased();
}
diff --git a/chrome/browser/chromeos/panels/panel_scroller.cc b/chrome/browser/chromeos/panels/panel_scroller.cc
index 233fc96..70e72e9 100644
--- a/chrome/browser/chromeos/panels/panel_scroller.cc
+++ b/chrome/browser/chromeos/panels/panel_scroller.cc
@@ -162,10 +162,6 @@ bool PanelScroller::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void PanelScroller::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
-}
-
void PanelScroller::HeaderClicked(PanelScrollerHeader* source) {
for (size_t i = 0; i < panels_.size(); i++) {
if (panels_[i]->header == source) {
diff --git a/chrome/browser/chromeos/panels/panel_scroller.h b/chrome/browser/chromeos/panels/panel_scroller.h
index e4d7eab..109bef7 100644
--- a/chrome/browser/chromeos/panels/panel_scroller.h
+++ b/chrome/browser/chromeos/panels/panel_scroller.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.
@@ -22,15 +22,14 @@ class PanelScroller : public views::View, public ui::AnimationDelegate {
static PanelScroller* CreateWindow();
- // View overrides.
+ // Overridden from View:
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
- views::View* child);
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual bool OnMouseDragged(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ views::View* child) OVERRIDE;
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+ virtual void Layout() OVERRIDE;
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
// Called when a panel header is clicked with the affected container. This
// function will make sure the panel is fully visible.
diff --git a/chrome/browser/chromeos/panels/panel_scroller_header.cc b/chrome/browser/chromeos/panels/panel_scroller_header.cc
index 6257447..12de46e 100644
--- a/chrome/browser/chromeos/panels/panel_scroller_header.cc
+++ b/chrome/browser/chromeos/panels/panel_scroller_header.cc
@@ -26,8 +26,11 @@ bool PanelScrollerHeader::OnMouseDragged(const views::MouseEvent& event) {
return false;
}
-void PanelScrollerHeader::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
+void PanelScrollerHeader::OnMouseReleased(const views::MouseEvent& event) {
+ OnMouseCaptureLost();
+}
+
+void PanelScrollerHeader::OnMouseCaptureLost() {
scroller_->HeaderClicked(this);
}
diff --git a/chrome/browser/chromeos/panels/panel_scroller_header.h b/chrome/browser/chromeos/panels/panel_scroller_header.h
index 50c816e..f00f3ff 100644
--- a/chrome/browser/chromeos/panels/panel_scroller_header.h
+++ b/chrome/browser/chromeos/panels/panel_scroller_header.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.
@@ -20,9 +20,10 @@ class PanelScrollerHeader : public views::View {
void set_title(const string16& title) { title_ = title; }
// views::View overrides.
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual bool OnMouseDragged(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual gfx::Size GetPreferredSize();
virtual void OnPaint(gfx::Canvas* canvas);
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc
index e848e0e..977f877 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
@@ -662,8 +662,8 @@ bool RenderWidgetHostViewViews::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void RenderWidgetHostViewViews::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
+void RenderWidgetHostViewViews::OnMouseReleased(
+ const views::MouseEvent& event) {
WebKit::WebMouseEvent e = WebMouseEventFromViewsEvent(event);
e.type = WebKit::WebInputEvent::MouseUp;
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h
index 8471535..203e639 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.h
@@ -100,8 +100,7 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
const gfx::Point& point) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index a3ba14b..d657e80 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -444,10 +444,9 @@ bool AutocompletePopupContentsView::OnMouseDragged(
}
void AutocompletePopupContentsView::OnMouseReleased(
- const views::MouseEvent& event,
- bool canceled) {
- if (canceled || ignore_mouse_drag_) {
- ignore_mouse_drag_ = false;
+ const views::MouseEvent& event) {
+ if (ignore_mouse_drag_) {
+ OnMouseCaptureLost();
return;
}
@@ -458,6 +457,10 @@ void AutocompletePopupContentsView::OnMouseReleased(
OpenIndex(index, CURRENT_TAB);
}
+void AutocompletePopupContentsView::OnMouseCaptureLost() {
+ ignore_mouse_drag_ = false;
+}
+
void AutocompletePopupContentsView::OnMouseMoved(
const views::MouseEvent& event) {
model_->SetHoveredLine(GetIndexForPoint(event.location()));
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
index 23d9c7c..85df1ad 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
@@ -75,8 +75,8 @@ class AutocompletePopupContentsView : public views::View,
const gfx::Point& point) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc
index 24795ba..cc90cc1 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -226,14 +226,13 @@ bool BrowserActionButton::OnMousePressed(const views::MouseEvent& event) {
return false;
}
-void BrowserActionButton::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
+void BrowserActionButton::OnMouseReleased(const views::MouseEvent& event) {
if (IsPopup() || showing_context_menu_) {
// TODO(erikkay) this never actually gets called (probably because of the
// loss of focus).
- MenuButton::OnMouseReleased(event, canceled);
+ MenuButton::OnMouseReleased(event);
} else {
- TextButton::OnMouseReleased(event, canceled);
+ TextButton::OnMouseReleased(event);
}
}
diff --git a/chrome/browser/ui/views/browser_actions_container.h b/chrome/browser/ui/views/browser_actions_container.h
index 2eb831f..07713d3 100644
--- a/chrome/browser/ui/views/browser_actions_container.h
+++ b/chrome/browser/ui/views/browser_actions_container.h
@@ -99,8 +99,7 @@ class BrowserActionButton : public views::MenuButton,
// case) is dismissed.
virtual bool Activate() OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE;
virtual void ShowContextMenu(const gfx::Point& p,
diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc
index 8c2a381..a4031e5 100644
--- a/chrome/browser/ui/views/content_setting_bubble_contents.cc
+++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc
@@ -55,10 +55,10 @@ class ContentSettingBubbleContents::Favicon : public views::ImageView {
#endif
// views::View overrides:
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
- const gfx::Point& p);
+ const gfx::Point& p) OVERRIDE;
ContentSettingBubbleContents* parent_;
views::Link* link_;
@@ -86,12 +86,11 @@ bool ContentSettingBubbleContents::Favicon::OnMousePressed(
}
void ContentSettingBubbleContents::Favicon::OnMouseReleased(
- const views::MouseEvent& event,
- bool canceled) {
- if (!canceled &&
- (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
- HitTest(event.location()))
+ const views::MouseEvent& event) {
+ if ((event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
+ HitTest(event.location())) {
parent_->LinkActivated(link_, event.flags());
+ }
}
gfx::NativeCursor ContentSettingBubbleContents::Favicon::GetCursorForPoint(
diff --git a/chrome/browser/ui/views/download_item_view.cc b/chrome/browser/ui/views/download_item_view.cc
index d119264..2b47e9e 100644
--- a/chrome/browser/ui/views/download_item_view.cc
+++ b/chrome/browser/ui/views/download_item_view.cc
@@ -541,18 +541,11 @@ bool DownloadItemView::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void DownloadItemView::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
+void DownloadItemView::OnMouseReleased(const views::MouseEvent& event) {
// Mouse should not activate us in dangerous mode.
if (IsDangerousMode())
return;
- if (dragging_) {
- // Starting a drag results in a MouseReleased, we need to ignore it.
- dragging_ = false;
- starting_drag_ = false;
- return;
- }
if (event.IsOnlyLeftMouseButton() &&
!InDropDownButtonXCoordinateRange(event.x())) {
OpenDownload();
@@ -561,6 +554,20 @@ void DownloadItemView::OnMouseReleased(const views::MouseEvent& event,
SetState(NORMAL, NORMAL);
}
+void DownloadItemView::OnMouseCaptureLost() {
+ // Mouse should not activate us in dangerous mode.
+ if (IsDangerousMode())
+ return;
+
+ if (dragging_) {
+ // Starting a drag results in a MouseCaptureLost.
+ dragging_ = false;
+ starting_drag_ = false;
+ } else {
+ SetState(NORMAL, NORMAL);
+ }
+}
+
void DownloadItemView::OnMouseMoved(const views::MouseEvent& event) {
// Mouse should not activate us in dangerous mode.
if (IsDangerousMode())
diff --git a/chrome/browser/ui/views/download_item_view.h b/chrome/browser/ui/views/download_item_view.h
index b0c6e78..1ba44b4 100644
--- a/chrome/browser/ui/views/download_item_view.h
+++ b/chrome/browser/ui/views/download_item_view.h
@@ -82,8 +82,8 @@ class DownloadItemView : public views::ButtonListener,
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
diff --git a/chrome/browser/ui/views/location_bar/click_handler.cc b/chrome/browser/ui/views/location_bar/click_handler.cc
index 8833998..87b5bfc 100644
--- a/chrome/browser/ui/views/location_bar/click_handler.cc
+++ b/chrome/browser/ui/views/location_bar/click_handler.cc
@@ -16,9 +16,8 @@ ClickHandler::ClickHandler(const views::View* owner,
location_bar_(location_bar) {
}
-void ClickHandler::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- if (canceled || !owner_->HitTest(event.location()))
+void ClickHandler::OnMouseReleased(const views::MouseEvent& event) {
+ if (!owner_->HitTest(event.location()))
return;
// Do not show page info if the user has been editing the location
@@ -34,4 +33,3 @@ void ClickHandler::OnMouseReleased(const views::MouseEvent& event,
}
tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
}
-
diff --git a/chrome/browser/ui/views/location_bar/click_handler.h b/chrome/browser/ui/views/location_bar/click_handler.h
index a4395c4..ce7dc32 100644
--- a/chrome/browser/ui/views/location_bar/click_handler.h
+++ b/chrome/browser/ui/views/location_bar/click_handler.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.
@@ -21,7 +21,7 @@ class ClickHandler {
public:
ClickHandler(const views::View* owner, LocationBarView* location_bar);
- void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ void OnMouseReleased(const views::MouseEvent& event);
private:
const views::View* owner_;
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
index b342465..f975b3c 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.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.
@@ -124,9 +124,8 @@ bool ContentSettingImageView::OnMousePressed(const views::MouseEvent& event) {
return true;
}
-void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- if (canceled || !HitTest(event.location()))
+void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) {
+ if (!HitTest(event.location()))
return;
TabContents* tab_contents = parent_->GetTabContentsWrapper()->tab_contents();
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.h b/chrome/browser/ui/views/location_bar/content_setting_image_view.h
index 9fd4de7..128122f 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.h
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.h
@@ -42,20 +42,20 @@ class ContentSettingImageView : public views::ImageView,
private:
// views::ImageView overrides:
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
- virtual void VisibilityChanged(View* starting_from, bool is_visible);
- virtual void OnPaint(gfx::Canvas* canvas);
- virtual void OnPaintBackground(gfx::Canvas* canvas);
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE;
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE;
// InfoBubbleDelegate overrides:
virtual void InfoBubbleClosing(InfoBubble* info_bubble,
- bool closed_by_escape);
- virtual bool CloseOnEscape();
- virtual bool FadeInOnShow();
+ bool closed_by_escape) OVERRIDE;
+ virtual bool CloseOnEscape() OVERRIDE;
+ virtual bool FadeInOnShow() OVERRIDE;
// ui::LinearAnimation override:
- virtual void AnimateToState(double state);
+ virtual void AnimateToState(double state) OVERRIDE;
scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
diff --git a/chrome/browser/ui/views/location_bar/ev_bubble_view.cc b/chrome/browser/ui/views/location_bar/ev_bubble_view.cc
index 577210a..02288d7 100644
--- a/chrome/browser/ui/views/location_bar/ev_bubble_view.cc
+++ b/chrome/browser/ui/views/location_bar/ev_bubble_view.cc
@@ -22,8 +22,6 @@ bool EVBubbleView::OnMousePressed(const views::MouseEvent& event) {
return true;
}
-void EVBubbleView::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- click_handler_.OnMouseReleased(event, canceled);
+void EVBubbleView::OnMouseReleased(const views::MouseEvent& event) {
+ click_handler_.OnMouseReleased(event);
}
-
diff --git a/chrome/browser/ui/views/location_bar/ev_bubble_view.h b/chrome/browser/ui/views/location_bar/ev_bubble_view.h
index e577313..9c9bfb3 100644
--- a/chrome/browser/ui/views/location_bar/ev_bubble_view.h
+++ b/chrome/browser/ui/views/location_bar/ev_bubble_view.h
@@ -25,8 +25,8 @@ class EVBubbleView : public IconLabelBubbleView {
virtual ~EVBubbleView();
// Overridden from view.
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
private:
ClickHandler click_handler_;
diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
index c60e872..861edb1 100644
--- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
+++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_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.
@@ -38,9 +38,9 @@ class IconLabelBubbleView : public views::View {
void SetImage(const SkBitmap& bitmap);
void SetItemPadding(int padding) { item_padding_ = padding; }
- virtual void OnPaint(gfx::Canvas* canvas);
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+ virtual void Layout() OVERRIDE;
protected:
void SetElideInMiddle(bool elide_in_middle);
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 72a0034..8ab84c2 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -741,12 +741,9 @@ bool LocationBarView::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void LocationBarView::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
+void LocationBarView::OnMouseReleased(const views::MouseEvent& event) {
UINT msg;
- if (canceled) {
- msg = WM_CAPTURECHANGED;
- } else if (event.IsLeftMouseButton()) {
+ if (event.IsLeftMouseButton()) {
msg = WM_LBUTTONUP;
} else if (event.IsMiddleMouseButton()) {
msg = WM_MBUTTONUP;
@@ -758,6 +755,10 @@ void LocationBarView::OnMouseReleased(const views::MouseEvent& event,
}
OnMouseEvent(event, msg);
}
+
+void LocationBarView::OnMouseCaptureLost() {
+ location_entry_->HandleExternalMsg(WM_CAPTURECHANGED, 0, CPoint());
+}
#endif
void LocationBarView::OnAutocompleteAccept(
@@ -946,18 +947,7 @@ void LocationBarView::RefreshPageActionViews() {
#if defined(OS_WIN)
void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) {
- UINT flags = 0;
- if (event.IsControlDown())
- flags |= MK_CONTROL;
- if (event.IsShiftDown())
- flags |= MK_SHIFT;
- if (event.IsLeftMouseButton())
- flags |= MK_LBUTTON;
- if (event.IsMiddleMouseButton())
- flags |= MK_MBUTTON;
- if (event.IsRightMouseButton())
- flags |= MK_RBUTTON;
-
+ UINT flags = event.GetWindowsFlags();
gfx::Point screen_point(event.location());
ConvertPointToScreen(this, &screen_point);
location_entry_->HandleExternalMsg(msg, flags, screen_point.ToPOINT());
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h
index bb41bad..cc05e2d 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.h
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.h
@@ -184,8 +184,8 @@ class LocationBarView : public LocationBar,
// Event Handlers
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
#endif
const LocationIconView* location_icon_view() const {
@@ -209,7 +209,8 @@ class LocationBarView : public LocationBar,
// Overridden from views::View:
virtual std::string GetClassName() const OVERRIDE;
- virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) OVERRIDE;
+ virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& event)
+ OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
// Overridden from views::DragController:
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.cc b/chrome/browser/ui/views/location_bar/location_icon_view.cc
index 328537d..2846337 100644
--- a/chrome/browser/ui/views/location_bar/location_icon_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_icon_view.cc
@@ -23,9 +23,8 @@ bool LocationIconView::OnMousePressed(const views::MouseEvent& event) {
return true;
}
-void LocationIconView::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- click_handler_.OnMouseReleased(event, canceled);
+void LocationIconView::OnMouseReleased(const views::MouseEvent& event) {
+ click_handler_.OnMouseReleased(event);
}
void LocationIconView::ShowTooltip(bool show) {
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.h b/chrome/browser/ui/views/location_bar/location_icon_view.h
index 3bb80c7..66a9d03 100644
--- a/chrome/browser/ui/views/location_bar/location_icon_view.h
+++ b/chrome/browser/ui/views/location_bar/location_icon_view.h
@@ -23,8 +23,8 @@ class LocationIconView : public views::ImageView {
virtual ~LocationIconView();
// Overridden from views::ImageView:
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
// Whether we should show the tooltip for this icon or not.
void ShowTooltip(bool show);
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
index 376eddd..6e7981d 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
@@ -113,9 +113,8 @@ bool PageActionImageView::OnMousePressed(const views::MouseEvent& event) {
return true;
}
-void PageActionImageView::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- if (canceled || !HitTest(event.location()))
+void PageActionImageView::OnMouseReleased(const views::MouseEvent& event) {
+ if (!HitTest(event.location()))
return;
int button = -1;
@@ -136,8 +135,9 @@ void PageActionImageView::OnMouseReleased(const views::MouseEvent& event,
ExecuteAction(button, false); // inspect_with_devtools
}
-bool PageActionImageView::OnKeyPressed(const views::KeyEvent& e) {
- if (e.key_code() == ui::VKEY_SPACE || e.key_code() == ui::VKEY_RETURN) {
+bool PageActionImageView::OnKeyPressed(const views::KeyEvent& event) {
+ if (event.key_code() == ui::VKEY_SPACE ||
+ event.key_code() == ui::VKEY_RETURN) {
ExecuteAction(1, false);
return true;
}
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.h b/chrome/browser/ui/views/location_bar/page_action_image_view.h
index e0ef5b9..90f50e1 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.h
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.h
@@ -43,15 +43,15 @@ class PageActionImageView : public views::ImageView,
// Overridden from view.
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled)
- OVERRIDE;
- virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE;
- virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture)
- OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
+ virtual void ShowContextMenu(const gfx::Point& p,
+ bool is_mouse_gesture) OVERRIDE;
// Overridden from ImageLoadingTracker.
- virtual void OnImageLoaded(
- SkBitmap* image, const ExtensionResource& resource, int index);
+ virtual void OnImageLoaded(SkBitmap* image,
+ const ExtensionResource& resource,
+ int index) OVERRIDE;
// Overridden from ExtensionContextMenuModelModel::Delegate
virtual void InspectPopup(ExtensionAction* action) OVERRIDE;
diff --git a/chrome/browser/ui/views/location_bar/star_view.cc b/chrome/browser/ui/views/location_bar/star_view.cc
index 6b499c5..77cee7b8 100644
--- a/chrome/browser/ui/views/location_bar/star_view.cc
+++ b/chrome/browser/ui/views/location_bar/star_view.cc
@@ -51,13 +51,14 @@ bool StarView::OnMousePressed(const views::MouseEvent& event) {
return true;
}
-void StarView::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
- if (!canceled && HitTest(event.location()))
+void StarView::OnMouseReleased(const views::MouseEvent& event) {
+ if (HitTest(event.location()))
command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE);
}
-bool StarView::OnKeyPressed(const views::KeyEvent& e) {
- if (e.key_code() == ui::VKEY_SPACE || e.key_code() == ui::VKEY_RETURN) {
+bool StarView::OnKeyPressed(const views::KeyEvent& event) {
+ if (event.key_code() == ui::VKEY_SPACE ||
+ event.key_code() == ui::VKEY_RETURN) {
command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE);
return true;
}
diff --git a/chrome/browser/ui/views/location_bar/star_view.h b/chrome/browser/ui/views/location_bar/star_view.h
index 6785336..ddd0cce 100644
--- a/chrome/browser/ui/views/location_bar/star_view.h
+++ b/chrome/browser/ui/views/location_bar/star_view.h
@@ -28,12 +28,11 @@ class StarView : public views::ImageView, public InfoBubbleDelegate {
private:
// views::ImageView overrides:
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
- virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip)
- OVERRIDE;
+ virtual bool GetTooltipText(const gfx::Point& p,
+ std::wstring* tooltip) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled)
- OVERRIDE;
- virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
// InfoBubbleDelegate overrides:
virtual void InfoBubbleClosing(InfoBubble* info_bubble,
diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc
index 4810411..81a7262 100644
--- a/chrome/browser/ui/views/tabs/base_tab.cc
+++ b/chrome/browser/ui/views/tabs/base_tab.cc
@@ -311,7 +311,7 @@ bool BaseTab::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void BaseTab::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
+void BaseTab::OnMouseReleased(const views::MouseEvent& event) {
if (!controller())
return;
@@ -320,7 +320,7 @@ void BaseTab::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
// In some cases, ending the drag will schedule the tab for destruction; if
// so, bail immediately, since our members are already dead and we shouldn't
// do anything else except drop the tab where it is.
- if (controller()->EndDrag(canceled))
+ if (controller()->EndDrag(false))
return;
// Close tab on middle click, but only if the button is released over the tab
@@ -347,6 +347,11 @@ void BaseTab::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
}
}
+void BaseTab::OnMouseCaptureLost() {
+ if (controller())
+ controller()->EndDrag(true);
+}
+
void BaseTab::OnMouseEntered(const views::MouseEvent& event) {
if (!hover_animation_.get()) {
hover_animation_.reset(new ui::SlideAnimation(this));
diff --git a/chrome/browser/ui/views/tabs/base_tab.h b/chrome/browser/ui/views/tabs/base_tab.h
index 8152468..6da8266 100644
--- a/chrome/browser/ui/views/tabs/base_tab.h
+++ b/chrome/browser/ui/views/tabs/base_tab.h
@@ -86,8 +86,8 @@ class BaseTab : public ui::AnimationDelegate,
virtual ThemeProvider* GetThemeProvider() const OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual bool GetTooltipText(const gfx::Point& p,
diff --git a/chrome/browser/ui/views/tabs/base_tab_strip.cc b/chrome/browser/ui/views/tabs/base_tab_strip.cc
index b86b14d..fba2c23 100644
--- a/chrome/browser/ui/views/tabs/base_tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/base_tab_strip.cc
@@ -407,9 +407,12 @@ bool BaseTabStrip::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void BaseTabStrip::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- EndDrag(canceled);
+void BaseTabStrip::OnMouseReleased(const views::MouseEvent& event) {
+ EndDrag(false);
+}
+
+void BaseTabStrip::OnMouseCaptureLost() {
+ EndDrag(true);
}
void BaseTabStrip::StartMoveTabAnimation() {
diff --git a/chrome/browser/ui/views/tabs/base_tab_strip.h b/chrome/browser/ui/views/tabs/base_tab_strip.h
index 9865dec..b3ef426 100644
--- a/chrome/browser/ui/views/tabs/base_tab_strip.h
+++ b/chrome/browser/ui/views/tabs/base_tab_strip.h
@@ -155,8 +155,8 @@ class BaseTabStrip : public AbstractTabStripView,
// View overrides.
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
// Creates and returns a new tab. The caller owners the returned tab.
virtual BaseTab* CreateTab() = 0;
diff --git a/chrome/browser/ui/views/tabs/side_tab_strip.cc b/chrome/browser/ui/views/tabs/side_tab_strip.cc
index f82720f..f7b2d5e 100644
--- a/chrome/browser/ui/views/tabs/side_tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/side_tab_strip.cc
@@ -29,10 +29,10 @@ class SideTabNewTabButton : public SideTab {
public:
explicit SideTabNewTabButton(TabStripController* controller);
- virtual bool ShouldPaintHighlight() const { return false; }
- virtual bool IsSelected() const { return false; }
- bool OnMousePressed(const views::MouseEvent& event);
- void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ virtual bool ShouldPaintHighlight() const OVERRIDE { return false; }
+ virtual bool IsSelected() const OVERRIDE { return false; }
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
private:
TabStripController* controller_;
@@ -56,9 +56,8 @@ bool SideTabNewTabButton::OnMousePressed(const views::MouseEvent& event) {
return true;
}
-void SideTabNewTabButton::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- if (!canceled && event.IsOnlyLeftMouseButton() && HitTest(event.location()))
+void SideTabNewTabButton::OnMouseReleased(const views::MouseEvent& event) {
+ if (event.IsOnlyLeftMouseButton() && HitTest(event.location()))
controller_->CreateNewTab();
}
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 5742af1..7530608 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -440,23 +440,18 @@ bool View::OnMouseDragged(const MouseEvent& event) {
}
void View::OnMouseReleased(const MouseEvent& event) {
-
}
void View::OnMouseCaptureLost() {
-
}
void View::OnMouseMoved(const MouseEvent& event) {
-
}
void View::OnMouseEntered(const MouseEvent& event) {
-
}
void View::OnMouseExited(const MouseEvent& event) {
-
}
// Accelerators ----------------------------------------------------------------
diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc
index c2da598..7afdbd5 100644
--- a/views/controls/button/button_dropdown.cc
+++ b/views/controls/button/button_dropdown.cc
@@ -73,17 +73,12 @@ bool ButtonDropDown::OnMouseDragged(const MouseEvent& event) {
return result;
}
-void ButtonDropDown::OnMouseReleased(const MouseEvent& event, bool canceled) {
- // Showing the drop down results in a MouseReleased with a canceled drag, we
- // need to ignore it.
- if (!canceled && (IsTriggerableEvent(event) ||
- (event.IsRightMouseButton() && !HitTest(event.location())))) {
- ImageButton::OnMouseReleased(event, canceled);
+void ButtonDropDown::OnMouseReleased(const MouseEvent& event) {
+ if (IsTriggerableEvent(event) ||
+ (event.IsRightMouseButton() && !HitTest(event.location()))) {
+ ImageButton::OnMouseReleased(event);
}
- if (canceled)
- return;
-
if (IsTriggerableEvent(event))
show_menu_factory_.RevokeAll();
diff --git a/views/controls/button/button_dropdown.h b/views/controls/button/button_dropdown.h
index 0a62584..9e8785c 100644
--- a/views/controls/button/button_dropdown.h
+++ b/views/controls/button/button_dropdown.h
@@ -28,7 +28,9 @@ class ButtonDropDown : public ImageButton {
// Overridden from views::View
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ // Showing the drop down results in a MouseCaptureLost, we need to ignore it.
+ virtual void OnMouseCaptureLost() OVERRIDE {}
virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
// Display the right-click menu, as triggered by the keyboard, for instance.
// Using the member function ShowDropDownMenu for the actual display.
diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc
index 693e282..0cb01f6 100644
--- a/views/controls/button/checkbox.cc
+++ b/views/controls/button/checkbox.cc
@@ -131,14 +131,18 @@ bool Checkbox::OnMouseDragged(const MouseEvent& event) {
return false;
}
-void Checkbox::OnMouseReleased(const MouseEvent& event, bool canceled) {
- native_wrapper_->SetPushed(false);
- if (!canceled && HitTestLabel(event)) {
+void Checkbox::OnMouseReleased(const MouseEvent& event) {
+ OnMouseCaptureLost();
+ if (HitTestLabel(event)) {
SetChecked(!checked());
ButtonPressed();
}
}
+void Checkbox::OnMouseCaptureLost() {
+ native_wrapper_->SetPushed(false);
+}
+
void Checkbox::OnMouseMoved(const MouseEvent& event) {
native_wrapper_->SetPushed(HitTestLabel(event));
}
diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h
index 19491e9..4451217 100644
--- a/views/controls/button/checkbox.h
+++ b/views/controls/button/checkbox.h
@@ -49,7 +49,8 @@ class Checkbox : public NativeButton {
virtual std::string GetClassName() const OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index 5f8e82e..55acba8 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.cc
@@ -129,9 +129,8 @@ bool CustomButton::OnMouseDragged(const MouseEvent& event) {
return true;
}
-void CustomButton::OnMouseReleased(const MouseEvent& event, bool canceled) {
- // Starting a drag results in a MouseReleased, we need to ignore it.
- if ((state_ == BS_DISABLED) || InDrag())
+void CustomButton::OnMouseReleased(const MouseEvent& event) {
+ if (state_ == BS_DISABLED)
return;
if (!HitTest(event.location())) {
@@ -140,13 +139,19 @@ void CustomButton::OnMouseReleased(const MouseEvent& event, bool canceled) {
}
SetState(BS_HOT);
- if (!canceled && IsTriggerableEvent(event)) {
+ if (IsTriggerableEvent(event)) {
NotifyClick(event);
// NOTE: We may be deleted at this point (by the listener's notification
// handler).
}
}
+void CustomButton::OnMouseCaptureLost() {
+ // Starting a drag results in a MouseCaptureLost, we need to ignore it.
+ if (state_ != BS_DISABLED && !InDrag())
+ SetState(BS_NORMAL);
+}
+
void CustomButton::OnMouseEntered(const MouseEvent& event) {
if (state_ != BS_DISABLED)
SetState(BS_HOT);
diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h
index 8b4008c..b898483 100644
--- a/views/controls/button/custom_button.h
+++ b/views/controls/button/custom_button.h
@@ -80,7 +80,8 @@ class CustomButton : public Button,
virtual std::string GetClassName() const OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE;
diff --git a/views/controls/button/image_button.h b/views/controls/button/image_button.h
index 7ac6a29..1b09d5f 100644
--- a/views/controls/button/image_button.h
+++ b/views/controls/button/image_button.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.
@@ -43,8 +43,8 @@ class ImageButton : public CustomButton {
VerticalAlignment v_align);
// Overridden from View:
- virtual gfx::Size GetPreferredSize();
- virtual void OnPaint(gfx::Canvas* canvas);
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
// Sets preferred size, so it could be correctly positioned in layout even if
// it is NULL.
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc
index 3ada964..3451434 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -198,17 +198,17 @@ bool MenuButton::OnMousePressed(const MouseEvent& event) {
return true;
}
-void MenuButton::OnMouseReleased(const MouseEvent& event, bool canceled) {
+void MenuButton::OnMouseReleased(const MouseEvent& event) {
// Explicitly test for left mouse button to show the menu. If we tested for
// !IsTriggerableEvent it could lead to a situation where we end up showing
// the menu and context menu (this would happen if the right button is not
// triggerable and there's a context menu).
if (GetDragOperations(event.location()) != ui::DragDropTypes::DRAG_NONE &&
- state() != BS_DISABLED && !canceled && !InDrag() &&
- event.IsOnlyLeftMouseButton() && HitTest(event.location())) {
+ state() != BS_DISABLED && !InDrag() && event.IsOnlyLeftMouseButton() &&
+ HitTest(event.location())) {
Activate();
} else {
- TextButton::OnMouseReleased(event, canceled);
+ TextButton::OnMouseReleased(event);
}
}
diff --git a/views/controls/button/menu_button.h b/views/controls/button/menu_button.h
index b564b1c..edab18b 100644
--- a/views/controls/button/menu_button.h
+++ b/views/controls/button/menu_button.h
@@ -55,7 +55,7 @@ class MenuButton : public TextButton {
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual std::string GetClassName() const OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE;
diff --git a/views/controls/button/radio_button.cc b/views/controls/button/radio_button.cc
index f162f2c..46133be 100644
--- a/views/controls/button/radio_button.cc
+++ b/views/controls/button/radio_button.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.
@@ -87,13 +87,17 @@ bool RadioButton::IsGroupFocusTraversable() const {
return false;
}
-void RadioButton::OnMouseReleased(const MouseEvent& event, bool canceled) {
- native_wrapper_->SetPushed(false);
+void RadioButton::OnMouseReleased(const MouseEvent& event) {
// Set the checked state to true only if we are unchecked, since we can't
// be toggled on and off like a checkbox.
- if (!checked() && !canceled && HitTestLabel(event))
+ if (!checked() && HitTestLabel(event))
SetChecked(true);
+ OnMouseCaptureLost();
+}
+
+void RadioButton::OnMouseCaptureLost() {
+ native_wrapper_->SetPushed(false);
ButtonPressed();
}
diff --git a/views/controls/button/radio_button.h b/views/controls/button/radio_button.h
index 5ff6f76..7df8387 100644
--- a/views/controls/button/radio_button.h
+++ b/views/controls/button/radio_button.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.
@@ -28,15 +28,15 @@ class RadioButton : public Checkbox {
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual View* GetSelectedViewForGroup(int group_id) OVERRIDE;
virtual bool IsGroupFocusTraversable() const OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled)
- OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
protected:
// Overridden from View:
virtual std::string GetClassName() const OVERRIDE;
// Overridden from NativeButton:
- virtual NativeButtonWrapper* CreateWrapper();
+ virtual NativeButtonWrapper* CreateWrapper() OVERRIDE;
private:
friend class NativeRadioButtonGtk;
diff --git a/views/controls/link.cc b/views/controls/link.cc
index c6e22f1..0112952 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.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.
@@ -97,38 +97,41 @@ const LinkController* Link::GetController() {
return controller_;
}
-bool Link::OnMousePressed(const MouseEvent& e) {
- if (!enabled_ || (!e.IsLeftMouseButton() && !e.IsMiddleMouseButton()))
+bool Link::OnMousePressed(const MouseEvent& event) {
+ if (!enabled_ || (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
return false;
SetHighlighted(true);
return true;
}
-bool Link::OnMouseDragged(const MouseEvent& e) {
+bool Link::OnMouseDragged(const MouseEvent& event) {
SetHighlighted(enabled_ &&
- (e.IsLeftMouseButton() || e.IsMiddleMouseButton()) &&
- HitTest(e.location()));
+ (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
+ HitTest(event.location()));
return true;
}
-void Link::OnMouseReleased(const MouseEvent& e, bool canceled) {
+void Link::OnMouseReleased(const MouseEvent& event) {
// Change the highlight first just in case this instance is deleted
// while calling the controller
- SetHighlighted(false);
- if (enabled_ && !canceled &&
- (e.IsLeftMouseButton() || e.IsMiddleMouseButton()) &&
- HitTest(e.location())) {
+ OnMouseCaptureLost();
+ if (enabled_ && (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
+ HitTest(event.location())) {
// Focus the link on click.
RequestFocus();
if (controller_)
- controller_->LinkActivated(this, e.flags());
+ controller_->LinkActivated(this, event.flags());
}
}
-bool Link::OnKeyPressed(const KeyEvent& e) {
- bool activate = ((e.key_code() == ui::VKEY_SPACE) ||
- (e.key_code() == ui::VKEY_RETURN));
+void Link::OnMouseCaptureLost() {
+ SetHighlighted(false);
+}
+
+bool Link::OnKeyPressed(const KeyEvent& event) {
+ bool activate = ((event.key_code() == ui::VKEY_SPACE) ||
+ (event.key_code() == ui::VKEY_RETURN));
if (!activate)
return false;
@@ -138,15 +141,15 @@ bool Link::OnKeyPressed(const KeyEvent& e) {
RequestFocus();
if (controller_)
- controller_->LinkActivated(this, e.flags());
+ controller_->LinkActivated(this, event.flags());
return true;
}
-bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
+bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& event) {
// Make sure we don't process space or enter as accelerators.
- return (e.key_code() == ui::VKEY_SPACE) ||
- (e.key_code() == ui::VKEY_RETURN);
+ return (event.key_code() == ui::VKEY_SPACE) ||
+ (event.key_code() == ui::VKEY_RETURN);
}
void Link::GetAccessibleState(ui::AccessibleViewState* state) {
diff --git a/views/controls/link.h b/views/controls/link.h
index e616317..7bdfe7a 100644
--- a/views/controls/link.h
+++ b/views/controls/link.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.
@@ -48,10 +48,10 @@ class Link : public Label {
// Overridden from View:
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event,
- bool canceled) OVERRIDE;
- virtual bool OnKeyPressed(const KeyEvent& e) OVERRIDE;
- virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
+ virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
+ virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& event) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
// Overridden from Label:
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index 4e9ba38..59ba744 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -377,7 +377,7 @@ void MenuController::Cancel(ExitType type) {
MenuItemView* selected = state_.item;
exit_type_ = type;
- SendMouseReleaseToActiveView();
+ SendMouseCaptureLostToActiveView();
// Hide windows immediately.
SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
@@ -518,7 +518,7 @@ void MenuController::OnMouseReleased(SubmenuView* source,
// If we open a context menu just return now
if (part.menu->GetDelegate()->ShowContextMenu(
part.menu, part.menu->GetCommand(), loc, true)) {
- SendMouseReleaseToActiveView(source, event, true);
+ SendMouseCaptureLostToActiveView();
return;
}
}
@@ -530,7 +530,7 @@ void MenuController::OnMouseReleased(SubmenuView* source,
!(part.menu->HasSubmenu() &&
(event.flags() == ui::EF_LEFT_BUTTON_DOWN))) {
if (active_mouse_view_) {
- SendMouseReleaseToActiveView(source, event, false);
+ SendMouseReleaseToActiveView(source, event);
return;
}
if (part.menu->GetDelegate()->IsTriggerableEvent(event)) {
@@ -542,7 +542,7 @@ void MenuController::OnMouseReleased(SubmenuView* source,
SetSelection(part.menu ? part.menu : state_.item,
SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
}
- SendMouseReleaseToActiveView(source, event, true);
+ SendMouseCaptureLostToActiveView();
}
void MenuController::OnMouseMoved(SubmenuView* source,
@@ -1796,12 +1796,7 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
target = NULL;
}
if (target != active_mouse_view_) {
- if (active_mouse_view_) {
- // TODO(msw): Revise api and uses with OnMouseCaptureLost (like ui/views).
- // Send a mouse release with cancel set to true.
- active_mouse_view_->OnMouseReleased(event, true);
- active_mouse_view_ = NULL;
- }
+ SendMouseCaptureLostToActiveView();
active_mouse_view_ = target;
if (active_mouse_view_) {
gfx::Point target_point(target_menu_loc);
@@ -1828,8 +1823,7 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
}
void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source,
- const MouseEvent& event,
- bool cancel) {
+ const MouseEvent& event) {
if (!active_mouse_view_)
return;
@@ -1839,23 +1833,22 @@ void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source,
View::ConvertPointToView(NULL, active_mouse_view_, &target_loc);
MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc.x(),
target_loc.y(), event.flags());
- // Reset the active_mouse_view_ before sending mouse released. That way if if
- // calls back to use we aren't in a weird state.
+ // Reset the active_mouse_view_ before sending mouse released. That way if it
+ // calls back to us, we aren't in a weird state.
View* active_view = active_mouse_view_;
active_mouse_view_ = NULL;
- active_view->OnMouseReleased(release_event, cancel);
+ active_view->OnMouseReleased(release_event);
}
-void MenuController::SendMouseReleaseToActiveView() {
+void MenuController::SendMouseCaptureLostToActiveView() {
if (!active_mouse_view_)
return;
- MouseEvent release_event(ui::ET_MOUSE_RELEASED, -1, -1, 0);
- // Reset the active_mouse_view_ before sending mouse released. That way if if
- // calls back to use we aren't in a weird state.
+ // Reset the active_mouse_view_ before sending mouse capture lost. That way if
+ // it calls back to us, we aren't in a weird state.
View* active_view = active_mouse_view_;
active_mouse_view_ = NULL;
- active_view->OnMouseReleased(release_event, true);
+ active_view->OnMouseCaptureLost();
}
} // namespace views
diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h
index 8458a30..177a460 100644
--- a/views/controls/menu/menu_controller.h
+++ b/views/controls/menu/menu_controller.h
@@ -394,11 +394,11 @@ class MenuController : public MessageLoopForUI::Dispatcher {
// Sends a mouse release event to the current |active_mouse_view_| and sets
// it to null.
void SendMouseReleaseToActiveView(SubmenuView* event_source,
- const MouseEvent& event,
- bool cancel);
+ const MouseEvent& event);
- // Variant of above that sends a cancel mouse release.
- void SendMouseReleaseToActiveView();
+ // Sends a mouse capture lost event to the current |active_mouse_view_| and
+ // sets it to null.
+ void SendMouseCaptureLostToActiveView();
// The active instance.
static MenuController* active_instance_;
diff --git a/views/controls/menu/menu_host_root_view.cc b/views/controls/menu/menu_host_root_view.cc
index 0372261..dee5472 100644
--- a/views/controls/menu/menu_host_root_view.cc
+++ b/views/controls/menu/menu_host_root_view.cc
@@ -13,14 +13,10 @@ MenuHostRootView::MenuHostRootView(Widget* widget,
SubmenuView* submenu)
: RootView(widget),
submenu_(submenu),
- forward_drag_to_menu_controller_(true),
- suspend_events_(false) {
+ forward_drag_to_menu_controller_(true) {
}
bool MenuHostRootView::OnMousePressed(const MouseEvent& event) {
- if (suspend_events_)
- return true;
-
forward_drag_to_menu_controller_ =
((event.x() < 0 || event.y() < 0 || event.x() >= width() ||
event.y() >= height()) ||
@@ -31,9 +27,6 @@ bool MenuHostRootView::OnMousePressed(const MouseEvent& event) {
}
bool MenuHostRootView::OnMouseDragged(const MouseEvent& event) {
- if (suspend_events_)
- return true;
-
if (forward_drag_to_menu_controller_ && GetMenuController()) {
GetMenuController()->OnMouseDragged(submenu_, event);
return true;
@@ -41,38 +34,20 @@ bool MenuHostRootView::OnMouseDragged(const MouseEvent& event) {
return RootView::OnMouseDragged(event);
}
-void MenuHostRootView::OnMouseReleased(const MouseEvent& event,
- bool canceled) {
- if (suspend_events_)
- return;
-
- RootView::OnMouseReleased(event, canceled);
+void MenuHostRootView::OnMouseReleased(const MouseEvent& event) {
+ RootView::OnMouseReleased(event);
if (forward_drag_to_menu_controller_ && GetMenuController()) {
forward_drag_to_menu_controller_ = false;
- if (canceled) {
- GetMenuController()->Cancel(MenuController::EXIT_ALL);
- } else {
- GetMenuController()->OnMouseReleased(submenu_, event);
- }
+ GetMenuController()->OnMouseReleased(submenu_, event);
}
}
void MenuHostRootView::OnMouseMoved(const MouseEvent& event) {
- if (suspend_events_)
- return;
-
RootView::OnMouseMoved(event);
if (GetMenuController())
GetMenuController()->OnMouseMoved(submenu_, event);
}
-void MenuHostRootView::OnMouseExited(const MouseEvent& event) {
- if (suspend_events_)
- return;
-
- RootView::OnMouseExited(event);
-}
-
bool MenuHostRootView::OnMouseWheel(const MouseWheelEvent& event) {
#if defined(OS_LINUX)
// ChromeOS uses MenuController to forward events like other
diff --git a/views/controls/menu/menu_host_root_view.h b/views/controls/menu/menu_host_root_view.h
index b8b8e34..ccd5247 100644
--- a/views/controls/menu/menu_host_root_view.h
+++ b/views/controls/menu/menu_host_root_view.h
@@ -23,15 +23,11 @@ class MenuHostRootView : public RootView {
public:
MenuHostRootView(Widget* widget, SubmenuView* submenu);
- // When invoked subsequent events are NOT forwarded to the MenuController.
- void suspend_events() { suspend_events_ = true; }
-
// Overridden from View:
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE;
private:
@@ -44,10 +40,6 @@ class MenuHostRootView : public RootView {
// Whether mouse dragged/released should be forwarded to the MenuController.
bool forward_drag_to_menu_controller_;
- // Whether events are suspended. If true, no events are forwarded to the
- // MenuController.
- bool suspend_events_;
-
DISALLOW_COPY_AND_ASSIGN(MenuHostRootView);
};
diff --git a/views/controls/resize_area.cc b/views/controls/resize_area.cc
index 0769cf9..c04a537 100644
--- a/views/controls/resize_area.cc
+++ b/views/controls/resize_area.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.
@@ -70,9 +70,12 @@ bool ResizeArea::OnMouseDragged(const views::MouseEvent& event) {
return true;
}
-void ResizeArea::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- ReportResizeAmount(canceled ? initial_position_ : event.x(), true);
+void ResizeArea::OnMouseReleased(const views::MouseEvent& event) {
+ ReportResizeAmount(event.x(), true);
+}
+
+void ResizeArea::OnMouseCaptureLost() {
+ ReportResizeAmount(initial_position_, true);
}
void ResizeArea::GetAccessibleState(ui::AccessibleViewState* state) {
diff --git a/views/controls/resize_area.h b/views/controls/resize_area.h
index cf9bea7..6c0f66d 100644
--- a/views/controls/resize_area.h
+++ b/views/controls/resize_area.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.
@@ -46,8 +46,8 @@ class ResizeArea : public View {
const gfx::Point& p) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled)
- OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
private:
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc
index beef8c4..20a1a96 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/views/controls/scrollbar/bitmap_scroll_bar.cc
@@ -54,15 +54,18 @@ class AutorepeatButton : public ImageButton {
virtual ~AutorepeatButton() {}
protected:
- virtual bool OnMousePressed(const MouseEvent& event) {
+ virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE {
Button::NotifyClick(event);
repeater_.Start();
return true;
}
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) {
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE {
+ OnMouseCaptureLost();
+ }
+
+ virtual void OnMouseCaptureLost() OVERRIDE {
repeater_.Stop();
- View::OnMouseReleased(event, canceled);
}
private:
@@ -149,7 +152,7 @@ class BitmapScrollBarThumb : public View {
}
// View overrides:
- virtual gfx::Size GetPreferredSize() {
+ virtual gfx::Size GetPreferredSize() OVERRIDE {
return gfx::Size(background_bitmap()->width(),
start_cap_bitmap()->height() +
end_cap_bitmap()->height() +
@@ -158,7 +161,7 @@ class BitmapScrollBarThumb : public View {
protected:
// View overrides:
- virtual void Paint(gfx::Canvas* canvas) {
+ virtual void Paint(gfx::Canvas* canvas) OVERRIDE {
canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0);
int top_cap_height = start_cap_bitmap()->height();
int bottom_cap_height = end_cap_bitmap()->height();
@@ -174,22 +177,22 @@ class BitmapScrollBarThumb : public View {
canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y);
}
- virtual void OnMouseEntered(const MouseEvent& event) {
+ virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE {
SetState(CustomButton::BS_HOT);
}
- virtual void OnMouseExited(const MouseEvent& event) {
+ virtual void OnMouseExited(const MouseEvent& event) OVERRIDE {
SetState(CustomButton::BS_NORMAL);
}
- virtual bool OnMousePressed(const MouseEvent& event) {
+ virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE {
mouse_offset_ = scroll_bar_->IsHorizontal() ? event.x() : event.y();
drag_start_position_ = GetPosition();
SetState(CustomButton::BS_PUSHED);
return true;
}
- virtual bool OnMouseDragged(const MouseEvent& event) {
+ virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE {
// If the user moves the mouse more than |kScrollThumbDragOutSnap| outside
// the bounds of the thumb, the scrollbar will snap the scroll back to the
// point it was at before the drag began.
@@ -216,10 +219,12 @@ class BitmapScrollBarThumb : public View {
return true;
}
- virtual void OnMouseReleased(const MouseEvent& event,
- bool canceled) {
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE {
+ OnMouseCaptureLost();
+ }
+
+ virtual void OnMouseCaptureLost() OVERRIDE {
SetState(CustomButton::BS_HOT);
- View::OnMouseReleased(event, canceled);
}
private:
@@ -471,10 +476,13 @@ bool BitmapScrollBar::OnMousePressed(const MouseEvent& event) {
return true;
}
-void BitmapScrollBar::OnMouseReleased(const MouseEvent& event, bool canceled) {
+void BitmapScrollBar::OnMouseReleased(const MouseEvent& event) {
+ OnMouseCaptureLost();
+}
+
+void BitmapScrollBar::OnMouseCaptureLost() {
SetThumbTrackState(CustomButton::BS_NORMAL);
repeater_.Stop();
- View::OnMouseReleased(event, canceled);
}
bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) {
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.h b/views/controls/scrollbar/bitmap_scroll_bar.h
index 8357fd1..833a045 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.h
+++ b/views/controls/scrollbar/bitmap_scroll_bar.h
@@ -98,7 +98,8 @@ class BitmapScrollBar : public ScrollBar,
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void Layout() OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE;
diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc
index 76e924e..d9f8912 100644
--- a/views/controls/single_split_view.cc
+++ b/views/controls/single_split_view.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.
@@ -182,11 +182,11 @@ bool SingleSplitView::OnMouseDragged(const MouseEvent& event) {
return true;
}
-void SingleSplitView::OnMouseReleased(const MouseEvent& event, bool canceled) {
+void SingleSplitView::OnMouseCaptureLost() {
if (child_count() < 2)
return;
- if (canceled && drag_info_.initial_divider_offset != divider_offset_) {
+ if (drag_info_.initial_divider_offset != divider_offset_) {
set_divider_offset(drag_info_.initial_divider_offset);
if (!observer_ || observer_->SplitHandleMoved(this))
Layout();
diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h
index de4ccf5..63fd702 100644
--- a/views/controls/single_split_view.h
+++ b/views/controls/single_split_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.
@@ -80,7 +80,7 @@ class SingleSplitView : public views::View {
// View overrides.
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
private:
diff --git a/views/controls/single_split_view_unittest.cc b/views/controls/single_split_view_unittest.cc
index 65fbb00..f880528 100644
--- a/views/controls/single_split_view_unittest.cc
+++ b/views/controls/single_split_view_unittest.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.
@@ -133,9 +133,9 @@ TEST(SingleSplitViewTest, MouseDrag) {
ON_CALL(observer, SplitHandleMoved(_))
.WillByDefault(Return(true));
- // SplitHandleMoved is expected to be called once for every mouse move.
+ // SplitHandleMoved is called for two mouse moves and one mouse capture loss.
EXPECT_CALL(observer, SplitHandleMoved(_))
- .Times(2);
+ .Times(3);
split.SetBounds(0, 0, 10, 100);
const int kInitialDividerOffset = 33;
@@ -166,9 +166,14 @@ TEST(SingleSplitViewTest, MouseDrag) {
MouseEvent mouse_released(
ui::ET_MOUSE_RELEASED, 7,
kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2, 0);
- split.OnMouseReleased(mouse_released, false);
+ split.OnMouseReleased(mouse_released);
EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2,
split.divider_offset());
+
+ // Expect intial offset after a system/user gesture cancels the drag.
+ // This shouldn't occur after mouse release, but it's sufficient for testing.
+ split.OnMouseCaptureLost();
+ EXPECT_EQ(kInitialDividerOffset, split.divider_offset());
}
} // namespace views
diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc
index 48bdea9..e1b8ccc 100644
--- a/views/controls/textfield/native_textfield_views.cc
+++ b/views/controls/textfield/native_textfield_views.cc
@@ -85,17 +85,17 @@ NativeTextfieldViews::~NativeTextfieldViews() {
////////////////////////////////////////////////////////////////////////////////
// NativeTextfieldViews, View overrides:
-bool NativeTextfieldViews::OnMousePressed(const views::MouseEvent& e) {
+bool NativeTextfieldViews::OnMousePressed(const views::MouseEvent& event) {
OnBeforeUserAction();
- if (HandleMousePressed(e))
+ if (HandleMousePressed(event))
SchedulePaint();
OnAfterUserAction();
return true;
}
-bool NativeTextfieldViews::OnMouseDragged(const views::MouseEvent& e) {
+bool NativeTextfieldViews::OnMouseDragged(const views::MouseEvent& event) {
OnBeforeUserAction();
- size_t pos = FindCursorPosition(e.location());
+ size_t pos = FindCursorPosition(event.location());
if (model_->MoveCursorTo(pos, true)) {
UpdateCursorBoundsAndTextOffset();
SchedulePaint();
@@ -104,18 +104,14 @@ bool NativeTextfieldViews::OnMouseDragged(const views::MouseEvent& e) {
return true;
}
-void NativeTextfieldViews::OnMouseReleased(const views::MouseEvent& e,
- bool canceled) {
-}
-
-bool NativeTextfieldViews::OnKeyPressed(const views::KeyEvent& e) {
+bool NativeTextfieldViews::OnKeyPressed(const views::KeyEvent& event) {
// OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on
// NativeTextfieldViews as it will never gain focus.
NOTREACHED();
return false;
}
-bool NativeTextfieldViews::OnKeyReleased(const views::KeyEvent& e) {
+bool NativeTextfieldViews::OnKeyReleased(const views::KeyEvent& event) {
NOTREACHED();
return false;
}
@@ -470,7 +466,7 @@ void NativeTextfieldViews::UpdateCursorBoundsAndTextOffset() {
} else if (x_left < 0) {
// when the cursor overflows to the left
text_offset_ = -cursor_bounds_.x();
- } else if(full_width > width && text_offset_ + full_width < width) {
+ } else if (full_width > width && text_offset_ + full_width < width) {
// when the cursor moves within the textfield with the text
// longer than the field.
text_offset_ = width - full_width;
diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h
index 7cc8317f..c91281b 100644
--- a/views/controls/textfield/native_textfield_views.h
+++ b/views/controls/textfield/native_textfield_views.h
@@ -47,12 +47,10 @@ class NativeTextfieldViews : public views::View,
~NativeTextfieldViews();
// views::View overrides:
- virtual bool OnMousePressed(const views::MouseEvent& e) OVERRIDE;
- virtual bool OnMouseDragged(const views::MouseEvent& e) OVERRIDE;
- virtual void OnMouseReleased(const views::MouseEvent& e,
- bool canceled) OVERRIDE;
- virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE;
- virtual bool OnKeyReleased(const views::KeyEvent& e) OVERRIDE;
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
+ virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
+ virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index ce15c51..3755e76 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -130,7 +130,7 @@ bool DispatchX2Event(RootView* root, XEvent* xev) {
case XI_ButtonPress:
return root->OnMousePressed(mouseev);
case XI_ButtonRelease:
- root->OnMouseReleased(mouseev, false);
+ root->OnMouseReleased(mouseev);
return true;
case XI_Motion: {
if (mouseev.type() == ui::ET_MOUSE_DRAGGED) {
@@ -185,7 +185,7 @@ bool DispatchXEvent(XEvent* xev) {
if (xev->type == ButtonPress) {
return root->OnMousePressed(mouseev);
} else {
- root->OnMouseReleased(mouseev, false);
+ root->OnMouseReleased(mouseev);
return true; // Assume the event has been processed to make sure we
// don't process it twice.
}
diff --git a/views/touchui/gesture_manager.cc b/views/touchui/gesture_manager.cc
index 2442469..18efe5f 100644
--- a/views/touchui/gesture_manager.cc
+++ b/views/touchui/gesture_manager.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.
@@ -52,7 +52,7 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
DVLOG(1) << "GestureManager::ProcessTouchEventForGesture: TouchReleased";
MouseEvent mouse_event(ui::ET_MOUSE_RELEASED, location.x(), location.y(),
event.flags());
- source->OnMouseReleased(mouse_event, false);
+ source->OnMouseReleased(mouse_event);
return true;
}
diff --git a/views/view.cc b/views/view.cc
index 6770d6d..70299cc 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -801,7 +801,10 @@ bool View::OnMouseDragged(const MouseEvent& event) {
return false;
}
-void View::OnMouseReleased(const MouseEvent& event, bool canceled) {
+void View::OnMouseReleased(const MouseEvent& event) {
+}
+
+void View::OnMouseCaptureLost() {
}
void View::OnMouseMoved(const MouseEvent& event) {
@@ -1557,18 +1560,18 @@ bool View::ProcessMouseDragged(const MouseEvent& event, DragInfo* drag_info) {
return (context_menu_controller != NULL) || possible_drag;
}
-void View::ProcessMouseReleased(const MouseEvent& event, bool canceled) {
- if (!canceled && context_menu_controller_ && event.IsOnlyRightMouseButton()) {
+void View::ProcessMouseReleased(const MouseEvent& event) {
+ if (context_menu_controller_ && event.IsOnlyRightMouseButton()) {
// Assume that if there is a context menu controller we won't be deleted
// from mouse released.
gfx::Point location(event.location());
- OnMouseReleased(event, canceled);
+ OnMouseReleased(event);
if (HitTest(location)) {
ConvertPointToScreen(this, &location);
ShowContextMenu(location, true);
}
} else {
- OnMouseReleased(event, canceled);
+ OnMouseReleased(event);
}
// WARNING: we may have been deleted.
}
diff --git a/views/view.h b/views/view.h
index 4f845dd..f34e555 100644
--- a/views/view.h
+++ b/views/view.h
@@ -621,13 +621,14 @@ class View : public AcceleratorTarget {
// This method is invoked when the user releases the mouse
// button. The event is in the receiver's coordinate system.
//
- // If canceled is true it indicates the mouse press/drag was canceled by a
- // system/user gesture.
- //
// Default implementation notifies the ContextMenuController is appropriate.
// Subclasses that wish to honor the ContextMenuController should invoke
// super.
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled);
+ virtual void OnMouseReleased(const MouseEvent& event);
+
+ // This method is invoked when the mouse press/drag was canceled by a
+ // system/user gesture.
+ virtual void OnMouseCaptureLost();
// This method is invoked when the mouse is above this control
// The event is in the receiver's coordinate system.
@@ -1230,7 +1231,7 @@ class View : public AcceleratorTarget {
// method. If a drag is detected, DoDrag is invoked.
bool ProcessMousePressed(const MouseEvent& event, DragInfo* drop_info);
bool ProcessMouseDragged(const MouseEvent& event, DragInfo* drop_info);
- void ProcessMouseReleased(const MouseEvent& event, bool canceled);
+ void ProcessMouseReleased(const MouseEvent& event);
#if defined(TOUCH_UI)
// RootView will invoke this with incoming TouchEvents. Returns the
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 08666b5..f2791c7 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.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.
@@ -154,7 +154,7 @@ class TestView : public View {
bool is_add, View *parent, View *child) OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
#if defined(TOUCH_UI)
virtual TouchStatus OnTouchEvent(const TouchEvent& event);
#endif
@@ -354,7 +354,7 @@ bool TestView::OnMouseDragged(const MouseEvent& event) {
return true;
}
-void TestView::OnMouseReleased(const MouseEvent& event, bool canceled) {
+void TestView::OnMouseReleased(const MouseEvent& event) {
last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
}
@@ -1475,7 +1475,7 @@ TEST_F(ButtonDropDownTest, RegularClickTest) {
MouseEvent release_event(ui::ET_MOUSE_RELEASED, 1, 1,
ui::EF_LEFT_BUTTON_DOWN);
button_as_view_->OnMousePressed(press_event);
- button_as_view_->OnMouseReleased(release_event, false);
+ button_as_view_->OnMouseReleased(release_event);
EXPECT_EQ(test_dialog_->last_pressed_button_, test_dialog_->button_drop_);
}
@@ -1750,7 +1750,7 @@ TEST_F(ViewTest, TransformEvent) {
EXPECT_EQ(10, v2->location_.y());
MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0);
- root->OnMouseReleased(released, false);
+ root->OnMouseReleased(released);
// Now rotate |v2| inside |v1| clockwise.
v2->SetRotation(90.0);
@@ -1771,7 +1771,7 @@ TEST_F(ViewTest, TransformEvent) {
EXPECT_EQ(10, v2->location_.x());
EXPECT_EQ(20, v2->location_.y());
- root->OnMouseReleased(released, false);
+ root->OnMouseReleased(released);
v1->ResetTransform();
v2->ResetTransform();
@@ -1802,7 +1802,7 @@ TEST_F(ViewTest, TransformEvent) {
EXPECT_EQ(10, v3->location_.x());
EXPECT_EQ(25, v3->location_.y());
- root->OnMouseReleased(released, false);
+ root->OnMouseReleased(released);
v1->ResetTransform();
v2->ResetTransform();
@@ -1834,7 +1834,7 @@ TEST_F(ViewTest, TransformEvent) {
EXPECT_EQ(10, v3->location_.x());
EXPECT_EQ(25, v3->location_.y());
- root->OnMouseReleased(released, false);
+ root->OnMouseReleased(released);
widget->CloseNow();
}
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index fed3f01..aae04b7 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -82,15 +82,6 @@ void RootView::NotifyNativeViewHierarchyChanged(bool attached,
// Input -----------------------------------------------------------------------
-void RootView::ProcessMouseDragCanceled() {
- if (mouse_pressed_handler_) {
- // Synthesize a release event.
- MouseEvent release_event(ui::ET_MOUSE_RELEASED, last_mouse_event_x_,
- last_mouse_event_y_, last_mouse_event_flags_);
- OnMouseReleased(release_event, true);
- }
-}
-
bool RootView::ProcessKeyEvent(const KeyEvent& event) {
bool consumed = false;
@@ -261,7 +252,7 @@ bool RootView::OnMouseDragged(const MouseEvent& event) {
return false;
}
-void RootView::OnMouseReleased(const MouseEvent& event, bool canceled) {
+void RootView::OnMouseReleased(const MouseEvent& event) {
MouseEvent e(event, this);
UpdateCursor(e);
@@ -272,9 +263,23 @@ void RootView::OnMouseReleased(const MouseEvent& event, bool canceled) {
// We allow the view to delete us from ProcessMouseReleased. As such,
// configure state such that we're done first, then call View.
View* mouse_pressed_handler = mouse_pressed_handler_;
- mouse_pressed_handler_ = NULL;
- explicit_mouse_handler_ = false;
- mouse_pressed_handler->ProcessMouseReleased(mouse_released, canceled);
+ SetMouseHandler(NULL);
+ mouse_pressed_handler->ProcessMouseReleased(mouse_released);
+ // WARNING: we may have been deleted.
+ }
+}
+
+void RootView::OnMouseCaptureLost() {
+ if (mouse_pressed_handler_) {
+ // Synthesize a release event for UpdateCursor and OnMouseReleased.
+ MouseEvent release_event(ui::ET_MOUSE_RELEASED, last_mouse_event_x_,
+ last_mouse_event_y_, last_mouse_event_flags_);
+ UpdateCursor(release_event);
+ // We allow the view to delete us from OnMouseCaptureLost. As such,
+ // configure state such that we're done first, then call View.
+ View* mouse_pressed_handler = mouse_pressed_handler_;
+ SetMouseHandler(NULL);
+ mouse_pressed_handler->OnMouseCaptureLost();
// WARNING: we may have been deleted.
}
}
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index 6be5f4e..3465312 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.h
@@ -59,10 +59,6 @@ class RootView : public View,
// Input ---------------------------------------------------------------------
- // Invoked By the Widget if the mouse drag is interrupted by
- // the system. Invokes OnMouseReleased with a value of true for canceled.
- void ProcessMouseDragCanceled();
-
// Process a key event. Send the event to the focused view and up the focus
// path, and finally to the default keyboard handler, until someone consumes
// it. Returns whether anyone consumed the event.
@@ -106,7 +102,8 @@ class RootView : public View,
virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE;
+ virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE;
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 0e07b4e..dd44ced 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -1279,7 +1279,7 @@ void WidgetGtk::HandleXGrabBroke() {
void WidgetGtk::HandleGtkGrabBroke() {
if (is_mouse_down_)
- GetRootView()->ProcessMouseDragCanceled();
+ GetRootView()->OnMouseCaptureLost();
is_mouse_down_ = false;
}
@@ -1350,7 +1350,7 @@ void WidgetGtk::ProcessMouseReleased(GdkEventButton* event) {
is_mouse_down_ = false;
// GTK generates a mouse release at the end of dnd. We need to ignore it.
if (!drag_data_)
- GetRootView()->OnMouseReleased(mouse_up, false);
+ GetRootView()->OnMouseReleased(mouse_up);
}
bool WidgetGtk::ProcessScroll(GdkEventScroll* event) {
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index ebf3129..f57e43b 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -567,7 +567,7 @@ void WidgetWin::OnCancelMode() {
void WidgetWin::OnCaptureChanged(HWND hwnd) {
if (is_mouse_down_)
- GetRootView()->ProcessMouseDragCanceled();
+ GetRootView()->OnMouseCaptureLost();
is_mouse_down_ = false;
}
@@ -1024,7 +1024,7 @@ bool WidgetWin::ProcessMouseReleased(UINT message,
MSG msg;
MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param),
GET_Y_LPARAM(l_param));
- GetRootView()->OnMouseReleased(MouseEvent(msg), false);
+ GetRootView()->OnMouseReleased(MouseEvent(msg));
return true;
}