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 #include "ui/views/view.h" | 5 #include "ui/views/view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 bool View::ProcessMouseDragged(const ui::MouseEvent& event, | 1955 bool View::ProcessMouseDragged(const ui::MouseEvent& event, |
1956 DragInfo* drag_info) { | 1956 DragInfo* drag_info) { |
1957 // Copy the field, that way if we're deleted after drag and drop no harm is | 1957 // Copy the field, that way if we're deleted after drag and drop no harm is |
1958 // done. | 1958 // done. |
1959 ContextMenuController* context_menu_controller = context_menu_controller_; | 1959 ContextMenuController* context_menu_controller = context_menu_controller_; |
1960 const bool possible_drag = drag_info->possible_drag; | 1960 const bool possible_drag = drag_info->possible_drag; |
1961 if (possible_drag && | 1961 if (possible_drag && |
1962 ExceededDragThreshold(drag_info->start_pt - event.location())) { | 1962 ExceededDragThreshold(drag_info->start_pt - event.location())) { |
1963 if (!drag_controller_ || | 1963 if (!drag_controller_ || |
1964 drag_controller_->CanStartDragForView( | 1964 drag_controller_->CanStartDragForView( |
1965 this, drag_info->start_pt, event.location())) | 1965 this, drag_info->start_pt, event.location())) { |
1966 DoDrag(event, drag_info->start_pt); | 1966 DoDrag(event, drag_info->start_pt, |
| 1967 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
| 1968 } |
1967 } else { | 1969 } else { |
1968 if (OnMouseDragged(event)) | 1970 if (OnMouseDragged(event)) |
1969 return true; | 1971 return true; |
1970 // Fall through to return value based on context menu controller. | 1972 // Fall through to return value based on context menu controller. |
1971 } | 1973 } |
1972 // WARNING: we may have been deleted. | 1974 // WARNING: we may have been deleted. |
1973 return (context_menu_controller != NULL) || possible_drag; | 1975 return (context_menu_controller != NULL) || possible_drag; |
1974 } | 1976 } |
1975 | 1977 |
1976 void View::ProcessMouseReleased(const ui::MouseEvent& event) { | 1978 void View::ProcessMouseReleased(const ui::MouseEvent& event) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 Widget* widget = GetWidget(); | 2126 Widget* widget = GetWidget(); |
2125 // TODO(beng): The TooltipManager NULL check can be removed when we | 2127 // TODO(beng): The TooltipManager NULL check can be removed when we |
2126 // consolidate Init() methods and make views_unittests Init() all | 2128 // consolidate Init() methods and make views_unittests Init() all |
2127 // Widgets that it uses. | 2129 // Widgets that it uses. |
2128 if (widget && widget->native_widget_private()->GetTooltipManager()) | 2130 if (widget && widget->native_widget_private()->GetTooltipManager()) |
2129 widget->native_widget_private()->GetTooltipManager()->UpdateTooltip(); | 2131 widget->native_widget_private()->GetTooltipManager()->UpdateTooltip(); |
2130 } | 2132 } |
2131 | 2133 |
2132 // Drag and drop --------------------------------------------------------------- | 2134 // Drag and drop --------------------------------------------------------------- |
2133 | 2135 |
2134 bool View::DoDrag(const ui::LocatedEvent& event, const gfx::Point& press_pt) { | 2136 bool View::DoDrag(const ui::LocatedEvent& event, |
| 2137 const gfx::Point& press_pt, |
| 2138 ui::DragDropTypes::DragEventSource source) { |
2135 #if !defined(OS_MACOSX) | 2139 #if !defined(OS_MACOSX) |
2136 int drag_operations = GetDragOperations(press_pt); | 2140 int drag_operations = GetDragOperations(press_pt); |
2137 if (drag_operations == ui::DragDropTypes::DRAG_NONE) | 2141 if (drag_operations == ui::DragDropTypes::DRAG_NONE) |
2138 return false; | 2142 return false; |
2139 | 2143 |
2140 OSExchangeData data; | 2144 OSExchangeData data; |
2141 WriteDragData(press_pt, &data); | 2145 WriteDragData(press_pt, &data); |
2142 | 2146 |
2143 // Message the RootView to do the drag and drop. That way if we're removed | 2147 // Message the RootView to do the drag and drop. That way if we're removed |
2144 // the RootView can detect it and avoid calling us back. | 2148 // the RootView can detect it and avoid calling us back. |
2145 gfx::Point widget_location(event.location()); | 2149 gfx::Point widget_location(event.location()); |
2146 ConvertPointToWidget(this, &widget_location); | 2150 ConvertPointToWidget(this, &widget_location); |
2147 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); | 2151 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, |
| 2152 source); |
2148 return true; | 2153 return true; |
2149 #else | 2154 #else |
2150 return false; | 2155 return false; |
2151 #endif // !defined(OS_MACOSX) | 2156 #endif // !defined(OS_MACOSX) |
2152 } | 2157 } |
2153 | 2158 |
2154 } // namespace views | 2159 } // namespace views |
OLD | NEW |