| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 case ui::ET_MOUSE_DRAGGED: | 289 case ui::ET_MOUSE_DRAGGED: |
| 290 rvh = contents_->GetRenderViewHost(); | 290 rvh = contents_->GetRenderViewHost(); |
| 291 if (rvh) { | 291 if (rvh) { |
| 292 gfx::Point screen_loc_in_pixel = ui::EventLocationFromNative(event); | 292 gfx::Point screen_loc_in_pixel = ui::EventLocationFromNative(event); |
| 293 gfx::Point screen_loc = ConvertPointToDIP(rvh->GetView(), | 293 gfx::Point screen_loc = ConvertPointToDIP(rvh->GetView(), |
| 294 screen_loc_in_pixel); | 294 screen_loc_in_pixel); |
| 295 gfx::Point client_loc = screen_loc; | 295 gfx::Point client_loc = screen_loc; |
| 296 aura::Window* window = rvh->GetView()->GetNativeView(); | 296 aura::Window* window = rvh->GetView()->GetNativeView(); |
| 297 aura::Window::ConvertPointToTarget(window->GetRootWindow(), | 297 aura::Window::ConvertPointToTarget(window->GetRootWindow(), |
| 298 window, &client_loc); | 298 window, &client_loc); |
| 299 rvh->DragSourceMovedTo(client_loc.x(), client_loc.y(), | 299 contents_->DragSourceMovedTo(client_loc.x(), client_loc.y(), |
| 300 screen_loc.x(), screen_loc.y()); | 300 screen_loc.x(), screen_loc.y()); |
| 301 } | 301 } |
| 302 break; | 302 break; |
| 303 default: | 303 default: |
| 304 break; | 304 break; |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 virtual void Observe(int type, | 308 virtual void Observe(int type, |
| 309 const NotificationSource& source, | 309 const NotificationSource& source, |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 } | 910 } |
| 911 | 911 |
| 912 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { | 912 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { |
| 913 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); | 913 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); |
| 914 gfx::Point screen_loc = | 914 gfx::Point screen_loc = |
| 915 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 915 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
| 916 gfx::Point client_loc = screen_loc; | 916 gfx::Point client_loc = screen_loc; |
| 917 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 917 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 918 aura::Window* window = rvh->GetView()->GetNativeView(); | 918 aura::Window* window = rvh->GetView()->GetNativeView(); |
| 919 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); | 919 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); |
| 920 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), | 920 if (!web_contents_) |
| 921 screen_loc.y(), ops); | 921 return; |
| 922 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
| 923 screen_loc.x(), screen_loc.y(), ops); |
| 922 } | 924 } |
| 923 | 925 |
| 924 void WebContentsViewAura::PrepareOverscrollWindow() { | 926 void WebContentsViewAura::PrepareOverscrollWindow() { |
| 925 // If there is an existing |overscroll_window_| which is in the middle of an | 927 // If there is an existing |overscroll_window_| which is in the middle of an |
| 926 // animation, then destroying the window here causes the animation to be | 928 // animation, then destroying the window here causes the animation to be |
| 927 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| | 929 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| |
| 928 // callback, and that tries to reset |overscroll_window_| again, causing a | 930 // callback, and that tries to reset |overscroll_window_| again, causing a |
| 929 // double-free. So use a temporary variable here. | 931 // double-free. So use a temporary variable here. |
| 930 if (overscroll_window_) { | 932 if (overscroll_window_) { |
| 931 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, | 933 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 event.location(), | 1664 event.location(), |
| 1663 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1665 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
| 1664 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1666 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1665 if (drag_dest_delegate_) | 1667 if (drag_dest_delegate_) |
| 1666 drag_dest_delegate_->OnDrop(); | 1668 drag_dest_delegate_->OnDrop(); |
| 1667 current_drop_data_.reset(); | 1669 current_drop_data_.reset(); |
| 1668 return current_drag_op_; | 1670 return current_drag_op_; |
| 1669 } | 1671 } |
| 1670 | 1672 |
| 1671 } // namespace content | 1673 } // namespace content |
| OLD | NEW |