| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 return; | 575 return; |
| 576 | 576 |
| 577 aura::Window* window = GetContentNativeView(); | 577 aura::Window* window = GetContentNativeView(); |
| 578 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); | 578 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 579 gfx::Point client_loc = screen_loc; | 579 gfx::Point client_loc = screen_loc; |
| 580 aura::client::ScreenPositionClient* screen_position_client = | 580 aura::client::ScreenPositionClient* screen_position_client = |
| 581 aura::client::GetScreenPositionClient(window->GetRootWindow()); | 581 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 582 if (screen_position_client) | 582 if (screen_position_client) |
| 583 screen_position_client->ConvertPointFromScreen(window, &client_loc); | 583 screen_position_client->ConvertPointFromScreen(window, &client_loc); |
| 584 | 584 |
| 585 // TODO(paulmeyer): In the OOPIF case, should |client_loc| be converted to the | 585 // |client_loc| and |screen_loc| are in the root coordinate space, for |
| 586 // coordinates local to |source_rwh|? See crbug.com/647249. | 586 // non-root RenderWidgetHosts they need to be transformed. |
| 587 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 587 gfx::Point transformed_point = client_loc; |
| 588 screen_loc.x(), screen_loc.y(), ops, | 588 gfx::Point transformed_screen_point = screen_loc; |
| 589 if (source_rwh && web_contents_->GetRenderWidgetHostView()) { |
| 590 static_cast<RenderWidgetHostViewBase*>( |
| 591 web_contents_->GetRenderWidgetHostView()) |
| 592 ->TransformPointToCoordSpaceForView( |
| 593 client_loc, |
| 594 static_cast<RenderWidgetHostViewBase*>(source_rwh->GetView()), |
| 595 &transformed_point); |
| 596 static_cast<RenderWidgetHostViewBase*>( |
| 597 web_contents_->GetRenderWidgetHostView()) |
| 598 ->TransformPointToCoordSpaceForView( |
| 599 screen_loc, |
| 600 static_cast<RenderWidgetHostViewBase*>(source_rwh->GetView()), |
| 601 &transformed_screen_point); |
| 602 } |
| 603 |
| 604 web_contents_->DragSourceEndedAt(transformed_point.x(), transformed_point.y(), |
| 605 transformed_screen_point.x(), |
| 606 transformed_screen_point.y(), ops, |
| 589 source_rwh); | 607 source_rwh); |
| 590 | 608 |
| 591 web_contents_->SystemDragEnded(source_rwh); | 609 web_contents_->SystemDragEnded(source_rwh); |
| 592 } | 610 } |
| 593 | 611 |
| 594 void WebContentsViewAura::InstallOverscrollControllerDelegate( | 612 void WebContentsViewAura::InstallOverscrollControllerDelegate( |
| 595 RenderWidgetHostViewAura* view) { | 613 RenderWidgetHostViewAura* view) { |
| 596 const std::string value = base::CommandLine::ForCurrentProcess()-> | 614 const std::string value = base::CommandLine::ForCurrentProcess()-> |
| 597 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); | 615 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); |
| 598 if (value == "0") { | 616 if (value == "0") { |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1219 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 1202 gfx::Point transformed_pt; | 1220 gfx::Point transformed_pt; |
| 1203 RenderWidgetHostImpl* target_rwh = | 1221 RenderWidgetHostImpl* target_rwh = |
| 1204 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( | 1222 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| 1205 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), | 1223 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), |
| 1206 event.location(), &transformed_pt); | 1224 event.location(), &transformed_pt); |
| 1207 | 1225 |
| 1208 if (!IsValidDragTarget(target_rwh)) | 1226 if (!IsValidDragTarget(target_rwh)) |
| 1209 return ui::DragDropTypes::DRAG_NONE; | 1227 return ui::DragDropTypes::DRAG_NONE; |
| 1210 | 1228 |
| 1229 gfx::Point screen_pt = event.root_location(); |
| 1211 if (target_rwh != current_rwh_for_drag_.get()) { | 1230 if (target_rwh != current_rwh_for_drag_.get()) { |
| 1212 if (current_rwh_for_drag_) | 1231 if (current_rwh_for_drag_) { |
| 1213 current_rwh_for_drag_->DragTargetDragLeave(); | 1232 gfx::Point transformed_leave_point = event.location(); |
| 1233 gfx::Point transformed_screen_point = screen_pt; |
| 1234 static_cast<RenderWidgetHostViewBase*>( |
| 1235 web_contents_->GetRenderWidgetHostView()) |
| 1236 ->TransformPointToCoordSpaceForView( |
| 1237 event.location(), static_cast<RenderWidgetHostViewBase*>( |
| 1238 current_rwh_for_drag_->GetView()), |
| 1239 &transformed_leave_point); |
| 1240 static_cast<RenderWidgetHostViewBase*>( |
| 1241 web_contents_->GetRenderWidgetHostView()) |
| 1242 ->TransformPointToCoordSpaceForView( |
| 1243 screen_pt, static_cast<RenderWidgetHostViewBase*>( |
| 1244 current_rwh_for_drag_->GetView()), |
| 1245 &transformed_screen_point); |
| 1246 current_rwh_for_drag_->DragTargetDragLeave(transformed_leave_point, |
| 1247 transformed_screen_point); |
| 1248 } |
| 1214 OnDragEntered(event); | 1249 OnDragEntered(event); |
| 1215 } | 1250 } |
| 1216 | 1251 |
| 1217 if (!current_drop_data_) | 1252 if (!current_drop_data_) |
| 1218 return ui::DragDropTypes::DRAG_NONE; | 1253 return ui::DragDropTypes::DRAG_NONE; |
| 1219 | 1254 |
| 1220 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1255 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 1221 gfx::Point screen_pt = event.root_location(); | |
| 1222 target_rwh->DragTargetDragOver( | 1256 target_rwh->DragTargetDragOver( |
| 1223 transformed_pt, screen_pt, op, | 1257 transformed_pt, screen_pt, op, |
| 1224 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1258 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1225 | 1259 |
| 1226 if (drag_dest_delegate_) | 1260 if (drag_dest_delegate_) |
| 1227 drag_dest_delegate_->OnDragOver(); | 1261 drag_dest_delegate_->OnDragOver(); |
| 1228 | 1262 |
| 1229 return ConvertFromWeb(current_drag_op_); | 1263 return ConvertFromWeb(current_drag_op_); |
| 1230 } | 1264 } |
| 1231 | 1265 |
| 1232 void WebContentsViewAura::OnDragExited() { | 1266 void WebContentsViewAura::OnDragExited() { |
| 1233 if (current_rvh_for_drag_ != | 1267 if (current_rvh_for_drag_ != |
| 1234 GetRenderViewHostID(web_contents_->GetRenderViewHost()) || | 1268 GetRenderViewHostID(web_contents_->GetRenderViewHost()) || |
| 1235 !current_drop_data_) { | 1269 !current_drop_data_) { |
| 1236 return; | 1270 return; |
| 1237 } | 1271 } |
| 1238 | 1272 |
| 1239 if (current_rwh_for_drag_) { | 1273 if (current_rwh_for_drag_) { |
| 1240 current_rwh_for_drag_->DragTargetDragLeave(); | 1274 current_rwh_for_drag_->DragTargetDragLeave(gfx::Point(), gfx::Point()); |
| 1241 current_rwh_for_drag_.reset(); | 1275 current_rwh_for_drag_.reset(); |
| 1242 } | 1276 } |
| 1243 | 1277 |
| 1244 if (drag_dest_delegate_) | 1278 if (drag_dest_delegate_) |
| 1245 drag_dest_delegate_->OnDragLeave(); | 1279 drag_dest_delegate_->OnDragLeave(); |
| 1246 | 1280 |
| 1247 current_drop_data_.reset(); | 1281 current_drop_data_.reset(); |
| 1248 } | 1282 } |
| 1249 | 1283 |
| 1250 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1284 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 1251 gfx::Point transformed_pt; | 1285 gfx::Point transformed_pt; |
| 1252 RenderWidgetHostImpl* target_rwh = | 1286 RenderWidgetHostImpl* target_rwh = |
| 1253 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( | 1287 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| 1254 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), | 1288 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), |
| 1255 event.location(), &transformed_pt); | 1289 event.location(), &transformed_pt); |
| 1256 | 1290 |
| 1257 if (!IsValidDragTarget(target_rwh)) | 1291 if (!IsValidDragTarget(target_rwh)) |
| 1258 return ui::DragDropTypes::DRAG_NONE; | 1292 return ui::DragDropTypes::DRAG_NONE; |
| 1259 | 1293 |
| 1294 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 1260 if (target_rwh != current_rwh_for_drag_.get()) { | 1295 if (target_rwh != current_rwh_for_drag_.get()) { |
| 1261 if (current_rwh_for_drag_) | 1296 if (current_rwh_for_drag_) |
| 1262 current_rwh_for_drag_->DragTargetDragLeave(); | 1297 current_rwh_for_drag_->DragTargetDragLeave(transformed_pt, screen_pt); |
| 1263 OnDragEntered(event); | 1298 OnDragEntered(event); |
| 1264 } | 1299 } |
| 1265 | 1300 |
| 1266 if (!current_drop_data_) | 1301 if (!current_drop_data_) |
| 1267 return ui::DragDropTypes::DRAG_NONE; | 1302 return ui::DragDropTypes::DRAG_NONE; |
| 1268 | 1303 |
| 1269 target_rwh->DragTargetDrop( | 1304 target_rwh->DragTargetDrop( |
| 1270 *current_drop_data_, transformed_pt, | 1305 *current_drop_data_, transformed_pt, |
| 1271 display::Screen::GetScreen()->GetCursorScreenPoint(), | 1306 display::Screen::GetScreen()->GetCursorScreenPoint(), |
| 1272 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1307 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1296 bool allow_multiple_selection) { | 1331 bool allow_multiple_selection) { |
| 1297 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; | 1332 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; |
| 1298 } | 1333 } |
| 1299 | 1334 |
| 1300 void WebContentsViewAura::HidePopupMenu() { | 1335 void WebContentsViewAura::HidePopupMenu() { |
| 1301 NOTIMPLEMENTED(); | 1336 NOTIMPLEMENTED(); |
| 1302 } | 1337 } |
| 1303 #endif | 1338 #endif |
| 1304 | 1339 |
| 1305 } // namespace content | 1340 } // namespace content |
| OLD | NEW |