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

Unified Diff: trunk/src/ui/views/widget/widget.cc

Issue 13565004: Revert 192525 "Context menu on views must show on mouse down for..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/ui/views/widget/widget.h ('k') | trunk/src/ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ui/views/widget/widget.cc
===================================================================
--- trunk/src/ui/views/widget/widget.cc (revision 192531)
+++ trunk/src/ui/views/widget/widget.cc (working copy)
@@ -126,49 +126,6 @@
DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate);
};
-class Widget::PostMousePressedProcessor : public WidgetObserver {
- public:
- explicit PostMousePressedProcessor(views::Widget* owner) : owner_(owner) {
- owner_->AddObserver(this);
- }
-
- virtual ~PostMousePressedProcessor() {
- CleanupOwner();
- }
-
- void DoPostMousePressedProcessing() {
- // Make sure we're still visible before we attempt capture as the mouse
- // press processing may have made the window hide (as happens with menus).
- if (!owner_ || !owner_->IsVisible())
- return;
-
- owner_->is_mouse_button_pressed_ = true;
-
- // OnNativeWidgetDestroying also notifies all
- // WidgetObservers::OnWidgetDestroying. So we can be sure that if |owner_|
- // is non-NULL, |owner_->native_widget_| will also be non-NULL.
- if (!owner_->native_widget_private()->HasCapture())
- owner_->native_widget_private()->SetCapture();
- }
-
- // Overridden from WidgetObserver.
- virtual void OnWidgetDestroying(Widget* widget) OVERRIDE {
- CleanupOwner();
- }
-
- private:
- void CleanupOwner() {
- if (owner_) {
- owner_->RemoveObserver(this);
- owner_ = NULL;
- }
- }
-
- views::Widget* owner_;
-
- DISALLOW_COPY_AND_ASSIGN(PostMousePressedProcessor);
-};
-
////////////////////////////////////////////////////////////////////////////////
// Widget, InitParams:
@@ -1194,18 +1151,17 @@
ScopedEvent scoped(this, *event);
View* root_view = GetRootView();
switch (event->type()) {
- case ui::ET_MOUSE_PRESSED: {
+ case ui::ET_MOUSE_PRESSED:
last_mouse_event_was_move_ = false;
-
- // We may get deleted by the time we return from OnMousePressed. So we
- // use an observer to do capture after OnMousePressed in a safe way.
- PostMousePressedProcessor post_mouse_pressed_processor(this);
- if (root_view && root_view->OnMousePressed(*event)) {
- post_mouse_pressed_processor.DoPostMousePressedProcessing();
+ // Make sure we're still visible before we attempt capture as the mouse
+ // press processing may have made the window hide (as happens with menus).
+ if (root_view && root_view->OnMousePressed(*event) && IsVisible()) {
+ is_mouse_button_pressed_ = true;
+ if (!native_widget_->HasCapture())
+ native_widget_->SetCapture();
event->SetHandled();
}
return;
- }
case ui::ET_MOUSE_RELEASED:
last_mouse_event_was_move_ = false;
is_mouse_button_pressed_ = false;
« no previous file with comments | « trunk/src/ui/views/widget/widget.h ('k') | trunk/src/ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698