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

Side by Side Diff: ui/views/widget/widget.cc

Issue 375593002: Do not set the mouse event handler if Widget::SetCapture() fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 931
932 const NativeWidget* Widget::native_widget() const { 932 const NativeWidget* Widget::native_widget() const {
933 return native_widget_; 933 return native_widget_;
934 } 934 }
935 935
936 NativeWidget* Widget::native_widget() { 936 NativeWidget* Widget::native_widget() {
937 return native_widget_; 937 return native_widget_;
938 } 938 }
939 939
940 void Widget::SetCapture(View* view) { 940 void Widget::SetCapture(View* view) {
941 if (!native_widget_->HasCapture()) {
942 native_widget_->SetCapture();
943
944 // Early return if setting capture was unsuccessful.
945 if (!native_widget_->HasCapture())
946 return;
947 }
948
941 if (internal::NativeWidgetPrivate::IsMouseButtonDown()) 949 if (internal::NativeWidgetPrivate::IsMouseButtonDown())
942 is_mouse_button_pressed_ = true; 950 is_mouse_button_pressed_ = true;
943 root_view_->SetMouseHandler(view); 951 root_view_->SetMouseHandler(view);
944 if (!native_widget_->HasCapture())
945 native_widget_->SetCapture();
946 } 952 }
947 953
948 void Widget::ReleaseCapture() { 954 void Widget::ReleaseCapture() {
949 if (native_widget_->HasCapture()) 955 if (native_widget_->HasCapture())
950 native_widget_->ReleaseCapture(); 956 native_widget_->ReleaseCapture();
951 } 957 }
952 958
953 bool Widget::HasCapture() { 959 bool Widget::HasCapture() {
954 return native_widget_->HasCapture(); 960 return native_widget_->HasCapture();
955 } 961 }
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1499
1494 //////////////////////////////////////////////////////////////////////////////// 1500 ////////////////////////////////////////////////////////////////////////////////
1495 // internal::NativeWidgetPrivate, NativeWidget implementation: 1501 // internal::NativeWidgetPrivate, NativeWidget implementation:
1496 1502
1497 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1503 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1498 return this; 1504 return this;
1499 } 1505 }
1500 1506
1501 } // namespace internal 1507 } // namespace internal
1502 } // namespace views 1508 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698