Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
| 6 | 6 |
| 7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/containers/adapters.h" | 15 #include "base/containers/adapters.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
| 24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "third_party/skia/include/core/SkRect.h" | 25 #include "third_party/skia/include/core/SkRect.h" |
| 26 #include "ui/accessibility/ax_action_data.h" | |
| 26 #include "ui/accessibility/ax_enums.h" | 27 #include "ui/accessibility/ax_enums.h" |
| 27 #include "ui/base/cursor/cursor.h" | 28 #include "ui/base/cursor/cursor.h" |
| 28 #include "ui/base/dragdrop/drag_drop_types.h" | 29 #include "ui/base/dragdrop/drag_drop_types.h" |
| 29 #include "ui/base/ime/input_method.h" | 30 #include "ui/base/ime/input_method.h" |
| 30 #include "ui/compositor/clip_recorder.h" | 31 #include "ui/compositor/clip_recorder.h" |
| 31 #include "ui/compositor/compositor.h" | 32 #include "ui/compositor/compositor.h" |
| 32 #include "ui/compositor/dip_util.h" | 33 #include "ui/compositor/dip_util.h" |
| 33 #include "ui/compositor/layer.h" | 34 #include "ui/compositor/layer.h" |
| 34 #include "ui/compositor/layer_animator.h" | 35 #include "ui/compositor/layer_animator.h" |
| 35 #include "ui/compositor/paint_context.h" | 36 #include "ui/compositor/paint_context.h" |
| 36 #include "ui/compositor/paint_recorder.h" | 37 #include "ui/compositor/paint_recorder.h" |
| 37 #include "ui/compositor/transform_recorder.h" | 38 #include "ui/compositor/transform_recorder.h" |
| 38 #include "ui/display/screen.h" | 39 #include "ui/display/screen.h" |
| 40 #include "ui/events/base_event_utils.h" | |
| 39 #include "ui/events/event_target_iterator.h" | 41 #include "ui/events/event_target_iterator.h" |
| 40 #include "ui/gfx/canvas.h" | 42 #include "ui/gfx/canvas.h" |
| 41 #include "ui/gfx/geometry/point3_f.h" | 43 #include "ui/gfx/geometry/point3_f.h" |
| 42 #include "ui/gfx/geometry/point_conversions.h" | 44 #include "ui/gfx/geometry/point_conversions.h" |
| 43 #include "ui/gfx/interpolated_transform.h" | 45 #include "ui/gfx/interpolated_transform.h" |
| 44 #include "ui/gfx/path.h" | 46 #include "ui/gfx/path.h" |
| 45 #include "ui/gfx/scoped_canvas.h" | 47 #include "ui/gfx/scoped_canvas.h" |
| 46 #include "ui/gfx/skia_util.h" | 48 #include "ui/gfx/skia_util.h" |
| 47 #include "ui/gfx/transform.h" | 49 #include "ui/gfx/transform.h" |
| 48 #include "ui/native_theme/native_theme.h" | 50 #include "ui/native_theme/native_theme.h" |
| (...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1391 | 1393 |
| 1392 // static | 1394 // static |
| 1393 bool View::ExceededDragThreshold(const gfx::Vector2d& delta) { | 1395 bool View::ExceededDragThreshold(const gfx::Vector2d& delta) { |
| 1394 return (abs(delta.x()) > GetHorizontalDragThreshold() || | 1396 return (abs(delta.x()) > GetHorizontalDragThreshold() || |
| 1395 abs(delta.y()) > GetVerticalDragThreshold()); | 1397 abs(delta.y()) > GetVerticalDragThreshold()); |
| 1396 } | 1398 } |
| 1397 | 1399 |
| 1398 // Accessibility---------------------------------------------------------------- | 1400 // Accessibility---------------------------------------------------------------- |
| 1399 | 1401 |
| 1400 bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { | 1402 bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { |
| 1403 switch (action_data.action) { | |
| 1404 case ui::AX_ACTION_BLUR: | |
| 1405 if (HasFocus()) | |
| 1406 GetFocusManager()->ClearFocus(); | |
| 1407 return true; | |
| 1408 case ui::AX_ACTION_DO_DEFAULT: { | |
| 1409 gfx::Rect rect = GetLocalBounds(); | |
| 1410 gfx::Point center = rect.CenterPoint(); | |
|
tapted
2017/04/03 23:28:23
nit: const gfx::Point center = GetLocalBounds().Ce
dmazzoni
2017/04/03 23:55:16
Done.
| |
| 1411 OnMousePressed(ui::MouseEvent( | |
| 1412 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | |
| 1413 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | |
| 1414 OnMouseReleased(ui::MouseEvent( | |
| 1415 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), | |
| 1416 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | |
| 1417 return true; | |
| 1418 } | |
| 1419 case ui::AX_ACTION_FOCUS: | |
| 1420 if (IsAccessibilityFocusable()) | |
| 1421 RequestFocus(); | |
| 1422 return true; | |
| 1423 case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: | |
| 1424 ScrollRectToVisible(GetLocalBounds()); | |
| 1425 return true; | |
| 1426 case ui::AX_ACTION_SHOW_CONTEXT_MENU: | |
| 1427 ShowContextMenu(bounds().CenterPoint(), ui::MENU_SOURCE_KEYBOARD); | |
|
tapted
2017/04/03 23:28:23
I think ShowContextMenu expects screen coordinates
dmazzoni
2017/04/03 23:55:16
Good catch! That was a bug from before, I guess no
| |
| 1428 return true; | |
| 1429 default: | |
| 1430 // Some actions are handled by subclasses of View. | |
| 1431 break; | |
| 1432 } | |
| 1433 | |
| 1401 return false; | 1434 return false; |
| 1402 } | 1435 } |
| 1403 | 1436 |
| 1404 gfx::NativeViewAccessible View::GetNativeViewAccessible() { | 1437 gfx::NativeViewAccessible View::GetNativeViewAccessible() { |
| 1405 if (!native_view_accessibility_) | 1438 if (!native_view_accessibility_) |
| 1406 native_view_accessibility_ = NativeViewAccessibility::Create(this); | 1439 native_view_accessibility_ = NativeViewAccessibility::Create(this); |
| 1407 if (native_view_accessibility_) | 1440 if (native_view_accessibility_) |
| 1408 return native_view_accessibility_->GetNativeObject(); | 1441 return native_view_accessibility_->GetNativeObject(); |
| 1409 return nullptr; | 1442 return nullptr; |
| 1410 } | 1443 } |
| (...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2607 // Message the RootView to do the drag and drop. That way if we're removed | 2640 // Message the RootView to do the drag and drop. That way if we're removed |
| 2608 // the RootView can detect it and avoid calling us back. | 2641 // the RootView can detect it and avoid calling us back. |
| 2609 gfx::Point widget_location(event.location()); | 2642 gfx::Point widget_location(event.location()); |
| 2610 ConvertPointToWidget(this, &widget_location); | 2643 ConvertPointToWidget(this, &widget_location); |
| 2611 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2644 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2612 // WARNING: we may have been deleted. | 2645 // WARNING: we may have been deleted. |
| 2613 return true; | 2646 return true; |
| 2614 } | 2647 } |
| 2615 | 2648 |
| 2616 } // namespace views | 2649 } // namespace views |
| OLD | NEW |