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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 if (web_contents_->GetInterstitialPage()) | 681 if (web_contents_->GetInterstitialPage()) |
682 web_contents_->GetInterstitialPage()->SetSize(size); | 682 web_contents_->GetInterstitialPage()->SetSize(size); |
683 RenderWidgetHostView* rwhv = | 683 RenderWidgetHostView* rwhv = |
684 web_contents_->GetRenderWidgetHostView(); | 684 web_contents_->GetRenderWidgetHostView(); |
685 if (rwhv) | 685 if (rwhv) |
686 rwhv->SetSize(size); | 686 rwhv->SetSize(size); |
687 } | 687 } |
688 | 688 |
689 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { | 689 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { |
690 aura::Window* root_window = GetNativeView()->GetRootWindow(); | 690 aura::Window* root_window = GetNativeView()->GetRootWindow(); |
691 gfx::Point screen_loc = | 691 gfx::Point screen_loc = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
692 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | |
693 gfx::Point client_loc = screen_loc; | 692 gfx::Point client_loc = screen_loc; |
694 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 693 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
695 aura::Window* window = rvh->GetWidget()->GetView()->GetNativeView(); | 694 aura::Window* window = rvh->GetWidget()->GetView()->GetNativeView(); |
696 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); | 695 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); |
697 if (!web_contents_) | 696 if (!web_contents_) |
698 return; | 697 return; |
699 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 698 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
700 screen_loc.x(), screen_loc.y(), ops); | 699 screen_loc.x(), screen_loc.y(), ops); |
701 } | 700 } |
702 | 701 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 | 1189 |
1191 void WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) { | 1190 void WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) { |
1192 if (!web_contents_->GetDelegate()) | 1191 if (!web_contents_->GetDelegate()) |
1193 return; | 1192 return; |
1194 | 1193 |
1195 ui::EventType type = event->type(); | 1194 ui::EventType type = event->type(); |
1196 if (type == ui::ET_MOUSE_PRESSED) | 1195 if (type == ui::ET_MOUSE_PRESSED) |
1197 web_contents_->GetDelegate()->ActivateContents(web_contents_); | 1196 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
1198 | 1197 |
1199 web_contents_->GetDelegate()->ContentsMouseEvent( | 1198 web_contents_->GetDelegate()->ContentsMouseEvent( |
1200 web_contents_, | 1199 web_contents_, gfx::Screen::GetScreen()->GetCursorScreenPoint(), |
1201 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | |
1202 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); | 1200 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); |
1203 } | 1201 } |
1204 | 1202 |
1205 //////////////////////////////////////////////////////////////////////////////// | 1203 //////////////////////////////////////////////////////////////////////////////// |
1206 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 1204 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
1207 | 1205 |
1208 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1206 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { |
1209 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 1207 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
1210 current_drop_data_.reset(new DropData()); | 1208 current_drop_data_.reset(new DropData()); |
1211 | 1209 |
1212 PrepareDropData(current_drop_data_.get(), event.data()); | 1210 PrepareDropData(current_drop_data_.get(), event.data()); |
1213 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1211 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
1214 | 1212 |
1215 // Give the delegate an opportunity to cancel the drag. | 1213 // Give the delegate an opportunity to cancel the drag. |
1216 if (web_contents_->GetDelegate() && | 1214 if (web_contents_->GetDelegate() && |
1217 !web_contents_->GetDelegate()->CanDragEnter( | 1215 !web_contents_->GetDelegate()->CanDragEnter( |
1218 web_contents_, *current_drop_data_.get(), op)) { | 1216 web_contents_, *current_drop_data_.get(), op)) { |
1219 current_drop_data_.reset(NULL); | 1217 current_drop_data_.reset(NULL); |
1220 return; | 1218 return; |
1221 } | 1219 } |
1222 | 1220 |
1223 if (drag_dest_delegate_) | 1221 if (drag_dest_delegate_) |
1224 drag_dest_delegate_->DragInitialize(web_contents_); | 1222 drag_dest_delegate_->DragInitialize(web_contents_); |
1225 | 1223 |
1226 gfx::Point screen_pt = | 1224 gfx::Point screen_pt = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
1227 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | |
1228 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 1225 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
1229 *current_drop_data_.get(), event.location(), screen_pt, op, | 1226 *current_drop_data_.get(), event.location(), screen_pt, op, |
1230 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1227 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1231 | 1228 |
1232 if (drag_dest_delegate_) { | 1229 if (drag_dest_delegate_) { |
1233 drag_dest_delegate_->OnReceiveDragData(event.data()); | 1230 drag_dest_delegate_->OnReceiveDragData(event.data()); |
1234 drag_dest_delegate_->OnDragEnter(); | 1231 drag_dest_delegate_->OnDragEnter(); |
1235 } | 1232 } |
1236 } | 1233 } |
1237 | 1234 |
1238 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1235 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
1239 DCHECK(current_rvh_for_drag_); | 1236 DCHECK(current_rvh_for_drag_); |
1240 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1237 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
1241 OnDragEntered(event); | 1238 OnDragEntered(event); |
1242 | 1239 |
1243 if (!current_drop_data_) | 1240 if (!current_drop_data_) |
1244 return ui::DragDropTypes::DRAG_NONE; | 1241 return ui::DragDropTypes::DRAG_NONE; |
1245 | 1242 |
1246 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1243 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
1247 gfx::Point screen_pt = | 1244 gfx::Point screen_pt = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
1248 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | |
1249 web_contents_->GetRenderViewHost()->DragTargetDragOver( | 1245 web_contents_->GetRenderViewHost()->DragTargetDragOver( |
1250 event.location(), screen_pt, op, | 1246 event.location(), screen_pt, op, |
1251 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1247 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1252 | 1248 |
1253 if (drag_dest_delegate_) | 1249 if (drag_dest_delegate_) |
1254 drag_dest_delegate_->OnDragOver(); | 1250 drag_dest_delegate_->OnDragOver(); |
1255 | 1251 |
1256 return ConvertFromWeb(current_drag_op_); | 1252 return ConvertFromWeb(current_drag_op_); |
1257 } | 1253 } |
1258 | 1254 |
(...skipping 14 matching lines...) Expand all Loading... |
1273 | 1269 |
1274 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1270 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
1275 DCHECK(current_rvh_for_drag_); | 1271 DCHECK(current_rvh_for_drag_); |
1276 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1272 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
1277 OnDragEntered(event); | 1273 OnDragEntered(event); |
1278 | 1274 |
1279 if (!current_drop_data_) | 1275 if (!current_drop_data_) |
1280 return ui::DragDropTypes::DRAG_NONE; | 1276 return ui::DragDropTypes::DRAG_NONE; |
1281 | 1277 |
1282 web_contents_->GetRenderViewHost()->DragTargetDrop( | 1278 web_contents_->GetRenderViewHost()->DragTargetDrop( |
1283 event.location(), | 1279 event.location(), gfx::Screen::GetScreen()->GetCursorScreenPoint(), |
1284 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | |
1285 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1280 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1286 if (drag_dest_delegate_) | 1281 if (drag_dest_delegate_) |
1287 drag_dest_delegate_->OnDrop(); | 1282 drag_dest_delegate_->OnDrop(); |
1288 current_drop_data_.reset(); | 1283 current_drop_data_.reset(); |
1289 return ConvertFromWeb(current_drag_op_); | 1284 return ConvertFromWeb(current_drag_op_); |
1290 } | 1285 } |
1291 | 1286 |
1292 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | 1287 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
1293 bool visible) { | 1288 bool visible) { |
1294 // Ignore any visibility changes in the hierarchy below. | 1289 // Ignore any visibility changes in the hierarchy below. |
(...skipping 20 matching lines...) Expand all Loading... |
1315 if (visible) { | 1310 if (visible) { |
1316 if (!web_contents_->should_normally_be_visible()) | 1311 if (!web_contents_->should_normally_be_visible()) |
1317 web_contents_->WasShown(); | 1312 web_contents_->WasShown(); |
1318 } else { | 1313 } else { |
1319 if (web_contents_->should_normally_be_visible()) | 1314 if (web_contents_->should_normally_be_visible()) |
1320 web_contents_->WasHidden(); | 1315 web_contents_->WasHidden(); |
1321 } | 1316 } |
1322 } | 1317 } |
1323 | 1318 |
1324 } // namespace content | 1319 } // namespace content |
OLD | NEW |