| 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 } |
| 1409 break; |
| 1410 case ui::AX_ACTION_DO_DEFAULT: { |
| 1411 const gfx::Point center = GetLocalBounds().CenterPoint(); |
| 1412 OnMousePressed(ui::MouseEvent( |
| 1413 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 1414 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1415 OnMouseReleased(ui::MouseEvent( |
| 1416 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), |
| 1417 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1418 return true; |
| 1419 } |
| 1420 case ui::AX_ACTION_FOCUS: |
| 1421 if (IsAccessibilityFocusable()) { |
| 1422 RequestFocus(); |
| 1423 return true; |
| 1424 } |
| 1425 break; |
| 1426 case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: |
| 1427 ScrollRectToVisible(GetLocalBounds()); |
| 1428 return true; |
| 1429 case ui::AX_ACTION_SHOW_CONTEXT_MENU: |
| 1430 ShowContextMenu(GetBoundsInScreen().CenterPoint(), |
| 1431 ui::MENU_SOURCE_KEYBOARD); |
| 1432 return true; |
| 1433 default: |
| 1434 // Some actions are handled by subclasses of View. |
| 1435 break; |
| 1436 } |
| 1437 |
| 1401 return false; | 1438 return false; |
| 1402 } | 1439 } |
| 1403 | 1440 |
| 1404 gfx::NativeViewAccessible View::GetNativeViewAccessible() { | 1441 gfx::NativeViewAccessible View::GetNativeViewAccessible() { |
| 1405 if (!native_view_accessibility_) | 1442 if (!native_view_accessibility_) |
| 1406 native_view_accessibility_ = NativeViewAccessibility::Create(this); | 1443 native_view_accessibility_ = NativeViewAccessibility::Create(this); |
| 1407 if (native_view_accessibility_) | 1444 if (native_view_accessibility_) |
| 1408 return native_view_accessibility_->GetNativeObject(); | 1445 return native_view_accessibility_->GetNativeObject(); |
| 1409 return nullptr; | 1446 return nullptr; |
| 1410 } | 1447 } |
| (...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 | 2644 // 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. | 2645 // the RootView can detect it and avoid calling us back. |
| 2609 gfx::Point widget_location(event.location()); | 2646 gfx::Point widget_location(event.location()); |
| 2610 ConvertPointToWidget(this, &widget_location); | 2647 ConvertPointToWidget(this, &widget_location); |
| 2611 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2648 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2612 // WARNING: we may have been deleted. | 2649 // WARNING: we may have been deleted. |
| 2613 return true; | 2650 return true; |
| 2614 } | 2651 } |
| 2615 | 2652 |
| 2616 } // namespace views | 2653 } // namespace views |
| OLD | NEW |