| 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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "content/browser/renderer_host/dip_util.h" | 10 #include "content/browser/renderer_host/dip_util.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 case ui::ET_MOUSE_DRAGGED: | 284 case ui::ET_MOUSE_DRAGGED: |
| 285 rvh = contents_->GetRenderViewHost(); | 285 rvh = contents_->GetRenderViewHost(); |
| 286 if (rvh) { | 286 if (rvh) { |
| 287 gfx::Point screen_loc_in_pixel = ui::EventLocationFromNative(event); | 287 gfx::Point screen_loc_in_pixel = ui::EventLocationFromNative(event); |
| 288 gfx::Point screen_loc = ConvertPointToDIP(rvh->GetView(), | 288 gfx::Point screen_loc = ConvertPointToDIP(rvh->GetView(), |
| 289 screen_loc_in_pixel); | 289 screen_loc_in_pixel); |
| 290 gfx::Point client_loc = screen_loc; | 290 gfx::Point client_loc = screen_loc; |
| 291 aura::Window* window = rvh->GetView()->GetNativeView(); | 291 aura::Window* window = rvh->GetView()->GetNativeView(); |
| 292 aura::Window::ConvertPointToTarget(window->GetRootWindow(), | 292 aura::Window::ConvertPointToTarget(window->GetRootWindow(), |
| 293 window, &client_loc); | 293 window, &client_loc); |
| 294 rvh->DragSourceMovedTo(client_loc.x(), client_loc.y(), | 294 contents_->DragSourceMovedTo(client_loc.x(), client_loc.y(), |
| 295 screen_loc.x(), screen_loc.y()); | 295 screen_loc.x(), screen_loc.y()); |
| 296 } | 296 } |
| 297 break; | 297 break; |
| 298 default: | 298 default: |
| 299 break; | 299 break; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 virtual void Observe(int type, | 303 virtual void Observe(int type, |
| 304 const NotificationSource& source, | 304 const NotificationSource& source, |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 } | 895 } |
| 896 | 896 |
| 897 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { | 897 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { |
| 898 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); | 898 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); |
| 899 gfx::Point screen_loc = | 899 gfx::Point screen_loc = |
| 900 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 900 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
| 901 gfx::Point client_loc = screen_loc; | 901 gfx::Point client_loc = screen_loc; |
| 902 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 902 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 903 aura::Window* window = rvh->GetView()->GetNativeView(); | 903 aura::Window* window = rvh->GetView()->GetNativeView(); |
| 904 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); | 904 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); |
| 905 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), | 905 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
| 906 screen_loc.y(), ops); | 906 screen_loc.x(), screen_loc.y(), ops); |
| 907 } | 907 } |
| 908 | 908 |
| 909 void WebContentsViewAura::PrepareOverscrollWindow() { | 909 void WebContentsViewAura::PrepareOverscrollWindow() { |
| 910 // If there is an existing |overscroll_window_| which is in the middle of an | 910 // If there is an existing |overscroll_window_| which is in the middle of an |
| 911 // animation, then destroying the window here causes the animation to be | 911 // animation, then destroying the window here causes the animation to be |
| 912 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| | 912 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| |
| 913 // callback, and that tries to reset |overscroll_window_| again, causing a | 913 // callback, and that tries to reset |overscroll_window_| again, causing a |
| 914 // double-free. So use a temporary variable here. | 914 // double-free. So use a temporary variable here. |
| 915 if (overscroll_window_.get()) { | 915 if (overscroll_window_.get()) { |
| 916 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, | 916 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 | 1350 |
| 1351 // Bail out immediately if the contents view window is gone. Note that it is | 1351 // Bail out immediately if the contents view window is gone. Note that it is |
| 1352 // not safe to access any class members after system drag-and-drop returns | 1352 // not safe to access any class members after system drag-and-drop returns |
| 1353 // since the class instance might be gone. The local variable |drag_source| | 1353 // since the class instance might be gone. The local variable |drag_source| |
| 1354 // is still valid and we can check its window property that is set to NULL | 1354 // is still valid and we can check its window property that is set to NULL |
| 1355 // when the contents are gone. | 1355 // when the contents are gone. |
| 1356 if (!drag_source->window()) | 1356 if (!drag_source->window()) |
| 1357 return; | 1357 return; |
| 1358 | 1358 |
| 1359 EndDrag(ConvertToWeb(result_op)); | 1359 EndDrag(ConvertToWeb(result_op)); |
| 1360 web_contents_->GetRenderViewHost()->DragSourceSystemDragEnded(); | 1360 web_contents_->SystemDragEnded(); |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 void WebContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) { | 1363 void WebContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) { |
| 1364 current_drag_op_ = operation; | 1364 current_drag_op_ = operation; |
| 1365 } | 1365 } |
| 1366 | 1366 |
| 1367 void WebContentsViewAura::GotFocus() { | 1367 void WebContentsViewAura::GotFocus() { |
| 1368 if (web_contents_->GetDelegate()) | 1368 if (web_contents_->GetDelegate()) |
| 1369 web_contents_->GetDelegate()->WebContentsFocused(web_contents_); | 1369 web_contents_->GetDelegate()->WebContentsFocused(web_contents_); |
| 1370 } | 1370 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 event.location(), | 1644 event.location(), |
| 1645 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1645 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
| 1646 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1646 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1647 if (drag_dest_delegate_) | 1647 if (drag_dest_delegate_) |
| 1648 drag_dest_delegate_->OnDrop(); | 1648 drag_dest_delegate_->OnDrop(); |
| 1649 current_drop_data_.reset(); | 1649 current_drop_data_.reset(); |
| 1650 return current_drag_op_; | 1650 return current_drag_op_; |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 } // namespace content | 1653 } // namespace content |
| OLD | NEW |