Chromium Code Reviews| 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 static_cast<RenderWidgetHostViewBase*>( | |
| 590 web_contents_->GetRenderWidgetHostView()) | |
| 591 ->TransformPointToCoordSpaceForView( | |
| 592 client_loc, | |
| 593 static_cast<RenderWidgetHostViewBase*>(source_rwh->GetView()), | |
| 594 &transformed_point); | |
| 595 static_cast<RenderWidgetHostViewBase*>( | |
| 596 web_contents_->GetRenderWidgetHostView()) | |
| 597 ->TransformPointToCoordSpaceForView( | |
| 598 screen_loc, | |
| 599 static_cast<RenderWidgetHostViewBase*>(source_rwh->GetView()), | |
| 600 &transformed_screen_point); | |
| 601 | |
| 602 web_contents_->DragSourceEndedAt(transformed_point.x(), transformed_point.y(), | |
| 603 transformed_screen_point.x(), | |
| 604 transformed_screen_point.y(), ops, | |
| 589 source_rwh); | 605 source_rwh); |
| 590 | 606 |
| 591 web_contents_->SystemDragEnded(source_rwh); | 607 web_contents_->SystemDragEnded(source_rwh); |
| 592 } | 608 } |
| 593 | 609 |
| 594 void WebContentsViewAura::InstallOverscrollControllerDelegate( | 610 void WebContentsViewAura::InstallOverscrollControllerDelegate( |
| 595 RenderWidgetHostViewAura* view) { | 611 RenderWidgetHostViewAura* view) { |
| 596 const std::string value = base::CommandLine::ForCurrentProcess()-> | 612 const std::string value = base::CommandLine::ForCurrentProcess()-> |
| 597 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); | 613 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); |
| 598 if (value == "0") { | 614 if (value == "0") { |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1201 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1217 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 1202 gfx::Point transformed_pt; | 1218 gfx::Point transformed_pt; |
| 1203 RenderWidgetHostImpl* target_rwh = | 1219 RenderWidgetHostImpl* target_rwh = |
| 1204 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( | 1220 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| 1205 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), | 1221 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), |
| 1206 event.location(), &transformed_pt); | 1222 event.location(), &transformed_pt); |
| 1207 | 1223 |
| 1208 if (!IsValidDragTarget(target_rwh)) | 1224 if (!IsValidDragTarget(target_rwh)) |
| 1209 return ui::DragDropTypes::DRAG_NONE; | 1225 return ui::DragDropTypes::DRAG_NONE; |
| 1210 | 1226 |
| 1227 gfx::Point screen_pt = event.root_location(); | |
| 1211 if (target_rwh != current_rwh_for_drag_.get()) { | 1228 if (target_rwh != current_rwh_for_drag_.get()) { |
| 1212 if (current_rwh_for_drag_) | 1229 if (current_rwh_for_drag_) { |
| 1213 current_rwh_for_drag_->DragTargetDragLeave(); | 1230 gfx::Point transformed_leave_point = event.location(); |
| 1231 gfx::Point transformed_screen_point = screen_pt; | |
| 1232 static_cast<RenderWidgetHostViewBase*>( | |
| 1233 web_contents_->GetRenderWidgetHostView()) | |
| 1234 ->TransformPointToCoordSpaceForView( | |
| 1235 event.location(), static_cast<RenderWidgetHostViewBase*>( | |
| 1236 current_rwh_for_drag_->GetView()), | |
| 1237 &transformed_leave_point); | |
| 1238 static_cast<RenderWidgetHostViewBase*>( | |
| 1239 web_contents_->GetRenderWidgetHostView()) | |
| 1240 ->TransformPointToCoordSpaceForView( | |
| 1241 screen_pt, static_cast<RenderWidgetHostViewBase*>( | |
| 1242 current_rwh_for_drag_->GetView()), | |
| 1243 &transformed_screen_point); | |
| 1244 current_rwh_for_drag_->DragTargetDragLeave(transformed_leave_point, | |
| 1245 transformed_screen_point); | |
| 1246 } | |
| 1214 OnDragEntered(event); | 1247 OnDragEntered(event); |
| 1215 } | 1248 } |
| 1216 | 1249 |
| 1217 if (!current_drop_data_) | 1250 if (!current_drop_data_) |
| 1218 return ui::DragDropTypes::DRAG_NONE; | 1251 return ui::DragDropTypes::DRAG_NONE; |
| 1219 | 1252 |
| 1220 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1253 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 1221 gfx::Point screen_pt = event.root_location(); | |
| 1222 target_rwh->DragTargetDragOver( | 1254 target_rwh->DragTargetDragOver( |
| 1223 transformed_pt, screen_pt, op, | 1255 transformed_pt, screen_pt, op, |
| 1224 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1256 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1225 | 1257 |
| 1226 if (drag_dest_delegate_) | 1258 if (drag_dest_delegate_) |
| 1227 drag_dest_delegate_->OnDragOver(); | 1259 drag_dest_delegate_->OnDragOver(); |
| 1228 | 1260 |
| 1229 return ConvertFromWeb(current_drag_op_); | 1261 return ConvertFromWeb(current_drag_op_); |
| 1230 } | 1262 } |
| 1231 | 1263 |
| 1232 void WebContentsViewAura::OnDragExited() { | 1264 void WebContentsViewAura::OnDragExited() { |
| 1233 if (current_rvh_for_drag_ != | 1265 if (current_rvh_for_drag_ != |
| 1234 GetRenderViewHostID(web_contents_->GetRenderViewHost()) || | 1266 GetRenderViewHostID(web_contents_->GetRenderViewHost()) || |
| 1235 !current_drop_data_) { | 1267 !current_drop_data_) { |
| 1236 return; | 1268 return; |
| 1237 } | 1269 } |
| 1238 | 1270 |
| 1239 if (current_rwh_for_drag_) { | 1271 if (current_rwh_for_drag_) { |
| 1240 current_rwh_for_drag_->DragTargetDragLeave(); | 1272 current_rwh_for_drag_->DragTargetDragLeave(gfx::Point(), gfx::Point()); |
|
Łukasz Anforowicz
2017/02/01 18:12:04
Why do we need to grab and forward display::Screen
kenrb
2017/02/01 19:53:47
Just because it is behavior-preserving. ScreenPoin
| |
| 1241 current_rwh_for_drag_.reset(); | 1273 current_rwh_for_drag_.reset(); |
| 1242 } | 1274 } |
| 1243 | 1275 |
| 1244 if (drag_dest_delegate_) | 1276 if (drag_dest_delegate_) |
| 1245 drag_dest_delegate_->OnDragLeave(); | 1277 drag_dest_delegate_->OnDragLeave(); |
| 1246 | 1278 |
| 1247 current_drop_data_.reset(); | 1279 current_drop_data_.reset(); |
| 1248 } | 1280 } |
| 1249 | 1281 |
| 1250 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1282 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 1251 gfx::Point transformed_pt; | 1283 gfx::Point transformed_pt; |
| 1252 RenderWidgetHostImpl* target_rwh = | 1284 RenderWidgetHostImpl* target_rwh = |
| 1253 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( | 1285 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| 1254 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), | 1286 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), |
| 1255 event.location(), &transformed_pt); | 1287 event.location(), &transformed_pt); |
| 1256 | 1288 |
| 1257 if (!IsValidDragTarget(target_rwh)) | 1289 if (!IsValidDragTarget(target_rwh)) |
| 1258 return ui::DragDropTypes::DRAG_NONE; | 1290 return ui::DragDropTypes::DRAG_NONE; |
| 1259 | 1291 |
| 1292 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); | |
| 1260 if (target_rwh != current_rwh_for_drag_.get()) { | 1293 if (target_rwh != current_rwh_for_drag_.get()) { |
| 1261 if (current_rwh_for_drag_) | 1294 if (current_rwh_for_drag_) |
| 1262 current_rwh_for_drag_->DragTargetDragLeave(); | 1295 current_rwh_for_drag_->DragTargetDragLeave(transformed_pt, screen_pt); |
| 1263 OnDragEntered(event); | 1296 OnDragEntered(event); |
| 1264 } | 1297 } |
| 1265 | 1298 |
| 1266 if (!current_drop_data_) | 1299 if (!current_drop_data_) |
| 1267 return ui::DragDropTypes::DRAG_NONE; | 1300 return ui::DragDropTypes::DRAG_NONE; |
| 1268 | 1301 |
| 1269 target_rwh->DragTargetDrop( | 1302 target_rwh->DragTargetDrop( |
| 1270 *current_drop_data_, transformed_pt, | 1303 *current_drop_data_, transformed_pt, |
| 1271 display::Screen::GetScreen()->GetCursorScreenPoint(), | 1304 display::Screen::GetScreen()->GetCursorScreenPoint(), |
| 1272 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1305 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1296 bool allow_multiple_selection) { | 1329 bool allow_multiple_selection) { |
| 1297 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; | 1330 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; |
| 1298 } | 1331 } |
| 1299 | 1332 |
| 1300 void WebContentsViewAura::HidePopupMenu() { | 1333 void WebContentsViewAura::HidePopupMenu() { |
| 1301 NOTIMPLEMENTED(); | 1334 NOTIMPLEMENTED(); |
| 1302 } | 1335 } |
| 1303 #endif | 1336 #endif |
| 1304 | 1337 |
| 1305 } // namespace content | 1338 } // namespace content |
| OLD | NEW |