| 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 if (web_contents_->GetInterstitialPage()) | 688 if (web_contents_->GetInterstitialPage()) |
| 689 web_contents_->GetInterstitialPage()->SetSize(size); | 689 web_contents_->GetInterstitialPage()->SetSize(size); |
| 690 RenderWidgetHostView* rwhv = | 690 RenderWidgetHostView* rwhv = |
| 691 web_contents_->GetRenderWidgetHostView(); | 691 web_contents_->GetRenderWidgetHostView(); |
| 692 if (rwhv) | 692 if (rwhv) |
| 693 rwhv->SetSize(size); | 693 rwhv->SetSize(size); |
| 694 } | 694 } |
| 695 | 695 |
| 696 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { | 696 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { |
| 697 aura::Window* root_window = GetNativeView()->GetRootWindow(); | 697 aura::Window* root_window = GetNativeView()->GetRootWindow(); |
| 698 gfx::Point screen_loc = | 698 gfx::Point screen_loc = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
| 699 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | |
| 700 gfx::Point client_loc = screen_loc; | 699 gfx::Point client_loc = screen_loc; |
| 701 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 700 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 702 aura::Window* window = rvh->GetWidget()->GetView()->GetNativeView(); | 701 aura::Window* window = rvh->GetWidget()->GetView()->GetNativeView(); |
| 703 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); | 702 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); |
| 704 if (!web_contents_) | 703 if (!web_contents_) |
| 705 return; | 704 return; |
| 706 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 705 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
| 707 screen_loc.x(), screen_loc.y(), ops); | 706 screen_loc.x(), screen_loc.y(), ops); |
| 708 } | 707 } |
| 709 | 708 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 | 1197 |
| 1199 void WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) { | 1198 void WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) { |
| 1200 if (!web_contents_->GetDelegate()) | 1199 if (!web_contents_->GetDelegate()) |
| 1201 return; | 1200 return; |
| 1202 | 1201 |
| 1203 ui::EventType type = event->type(); | 1202 ui::EventType type = event->type(); |
| 1204 if (type == ui::ET_MOUSE_PRESSED) | 1203 if (type == ui::ET_MOUSE_PRESSED) |
| 1205 web_contents_->GetDelegate()->ActivateContents(web_contents_); | 1204 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
| 1206 | 1205 |
| 1207 web_contents_->GetDelegate()->ContentsMouseEvent( | 1206 web_contents_->GetDelegate()->ContentsMouseEvent( |
| 1208 web_contents_, | 1207 web_contents_, gfx::Screen::GetScreen()->GetCursorScreenPoint(), |
| 1209 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | |
| 1210 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); | 1208 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); |
| 1211 } | 1209 } |
| 1212 | 1210 |
| 1213 //////////////////////////////////////////////////////////////////////////////// | 1211 //////////////////////////////////////////////////////////////////////////////// |
| 1214 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 1212 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
| 1215 | 1213 |
| 1216 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1214 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { |
| 1217 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 1215 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
| 1218 current_drop_data_.reset(new DropData()); | 1216 current_drop_data_.reset(new DropData()); |
| 1219 | 1217 |
| 1220 PrepareDropData(current_drop_data_.get(), event.data()); | 1218 PrepareDropData(current_drop_data_.get(), event.data()); |
| 1221 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1219 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 1222 | 1220 |
| 1223 // Give the delegate an opportunity to cancel the drag. | 1221 // Give the delegate an opportunity to cancel the drag. |
| 1224 if (web_contents_->GetDelegate() && | 1222 if (web_contents_->GetDelegate() && |
| 1225 !web_contents_->GetDelegate()->CanDragEnter( | 1223 !web_contents_->GetDelegate()->CanDragEnter( |
| 1226 web_contents_, *current_drop_data_.get(), op)) { | 1224 web_contents_, *current_drop_data_.get(), op)) { |
| 1227 current_drop_data_.reset(NULL); | 1225 current_drop_data_.reset(NULL); |
| 1228 return; | 1226 return; |
| 1229 } | 1227 } |
| 1230 | 1228 |
| 1231 if (drag_dest_delegate_) | 1229 if (drag_dest_delegate_) |
| 1232 drag_dest_delegate_->DragInitialize(web_contents_); | 1230 drag_dest_delegate_->DragInitialize(web_contents_); |
| 1233 | 1231 |
| 1234 gfx::Point screen_pt = | 1232 gfx::Point screen_pt = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
| 1235 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | |
| 1236 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 1233 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
| 1237 *current_drop_data_.get(), event.location(), screen_pt, op, | 1234 *current_drop_data_.get(), event.location(), screen_pt, op, |
| 1238 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1235 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1239 | 1236 |
| 1240 if (drag_dest_delegate_) { | 1237 if (drag_dest_delegate_) { |
| 1241 drag_dest_delegate_->OnReceiveDragData(event.data()); | 1238 drag_dest_delegate_->OnReceiveDragData(event.data()); |
| 1242 drag_dest_delegate_->OnDragEnter(); | 1239 drag_dest_delegate_->OnDragEnter(); |
| 1243 } | 1240 } |
| 1244 } | 1241 } |
| 1245 | 1242 |
| 1246 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1243 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 1247 DCHECK(current_rvh_for_drag_); | 1244 DCHECK(current_rvh_for_drag_); |
| 1248 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1245 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 1249 OnDragEntered(event); | 1246 OnDragEntered(event); |
| 1250 | 1247 |
| 1251 if (!current_drop_data_) | 1248 if (!current_drop_data_) |
| 1252 return ui::DragDropTypes::DRAG_NONE; | 1249 return ui::DragDropTypes::DRAG_NONE; |
| 1253 | 1250 |
| 1254 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1251 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 1255 gfx::Point screen_pt = | 1252 gfx::Point screen_pt = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
| 1256 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | |
| 1257 web_contents_->GetRenderViewHost()->DragTargetDragOver( | 1253 web_contents_->GetRenderViewHost()->DragTargetDragOver( |
| 1258 event.location(), screen_pt, op, | 1254 event.location(), screen_pt, op, |
| 1259 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1255 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1260 | 1256 |
| 1261 if (drag_dest_delegate_) | 1257 if (drag_dest_delegate_) |
| 1262 drag_dest_delegate_->OnDragOver(); | 1258 drag_dest_delegate_->OnDragOver(); |
| 1263 | 1259 |
| 1264 return ConvertFromWeb(current_drag_op_); | 1260 return ConvertFromWeb(current_drag_op_); |
| 1265 } | 1261 } |
| 1266 | 1262 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1281 | 1277 |
| 1282 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1278 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 1283 DCHECK(current_rvh_for_drag_); | 1279 DCHECK(current_rvh_for_drag_); |
| 1284 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1280 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 1285 OnDragEntered(event); | 1281 OnDragEntered(event); |
| 1286 | 1282 |
| 1287 if (!current_drop_data_) | 1283 if (!current_drop_data_) |
| 1288 return ui::DragDropTypes::DRAG_NONE; | 1284 return ui::DragDropTypes::DRAG_NONE; |
| 1289 | 1285 |
| 1290 web_contents_->GetRenderViewHost()->DragTargetDrop( | 1286 web_contents_->GetRenderViewHost()->DragTargetDrop( |
| 1291 event.location(), | 1287 event.location(), gfx::Screen::GetScreen()->GetCursorScreenPoint(), |
| 1292 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | |
| 1293 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1288 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1294 if (drag_dest_delegate_) | 1289 if (drag_dest_delegate_) |
| 1295 drag_dest_delegate_->OnDrop(); | 1290 drag_dest_delegate_->OnDrop(); |
| 1296 current_drop_data_.reset(); | 1291 current_drop_data_.reset(); |
| 1297 return ConvertFromWeb(current_drag_op_); | 1292 return ConvertFromWeb(current_drag_op_); |
| 1298 } | 1293 } |
| 1299 | 1294 |
| 1300 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | 1295 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
| 1301 bool visible) { | 1296 bool visible) { |
| 1302 // Ignore any visibility changes in the hierarchy below. | 1297 // Ignore any visibility changes in the hierarchy below. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1323 if (visible) { | 1318 if (visible) { |
| 1324 if (!web_contents_->should_normally_be_visible()) | 1319 if (!web_contents_->should_normally_be_visible()) |
| 1325 web_contents_->WasShown(); | 1320 web_contents_->WasShown(); |
| 1326 } else { | 1321 } else { |
| 1327 if (web_contents_->should_normally_be_visible()) | 1322 if (web_contents_->should_normally_be_visible()) |
| 1328 web_contents_->WasHidden(); | 1323 web_contents_->WasHidden(); |
| 1329 } | 1324 } |
| 1330 } | 1325 } |
| 1331 | 1326 |
| 1332 } // namespace content | 1327 } // namespace content |
| OLD | NEW |