Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "content/browser/renderer_host/dip_util.h" 8 #include "content/browser/renderer_host/dip_util.h"
9 #include "content/browser/renderer_host/render_view_host_factory.h" 9 #include "content/browser/renderer_host/render_view_host_factory.h"
10 #include "content/browser/web_contents/interstitial_page_impl.h" 10 #include "content/browser/web_contents/interstitial_page_impl.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/render_widget_host.h" 13 #include "content/public/browser/render_widget_host.h"
14 #include "content/public/browser/render_widget_host_view.h" 14 #include "content/public/browser/render_widget_host_view.h"
15 #include "content/public/browser/web_contents_delegate.h" 15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/browser/web_contents_view_delegate.h" 16 #include "content/public/browser/web_contents_view_delegate.h"
17 #include "content/public/browser/web_drag_dest_delegate.h" 17 #include "content/public/browser/web_drag_dest_delegate.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
19 #include "ui/aura/client/drag_drop_client.h" 19 #include "ui/aura/client/drag_drop_client.h"
20 #include "ui/aura/client/drag_drop_delegate.h" 20 #include "ui/aura/client/drag_drop_delegate.h"
21 #include "ui/aura/event.h"
22 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
23 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
24 #include "ui/base/clipboard/custom_data_helper.h" 23 #include "ui/base/clipboard/custom_data_helper.h"
25 #include "ui/base/dragdrop/drag_drop_types.h" 24 #include "ui/base/dragdrop/drag_drop_types.h"
26 #include "ui/base/dragdrop/os_exchange_data.h" 25 #include "ui/base/dragdrop/os_exchange_data.h"
27 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h" 26 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
27 #include "ui/base/event.h"
28 #include "ui/base/hit_test.h" 28 #include "ui/base/hit_test.h"
29 #include "ui/compositor/layer.h" 29 #include "ui/compositor/layer.h"
30 #include "ui/gfx/screen.h" 30 #include "ui/gfx/screen.h"
31 #include "webkit/glue/webdropdata.h" 31 #include "webkit/glue/webdropdata.h"
32 32
33 namespace content { 33 namespace content {
34 WebContentsView* CreateWebContentsView( 34 WebContentsView* CreateWebContentsView(
35 WebContentsImpl* web_contents, 35 WebContentsImpl* web_contents,
36 WebContentsViewDelegate* delegate, 36 WebContentsViewDelegate* delegate,
37 RenderViewHostDelegateView** render_view_host_delegate_view) { 37 RenderViewHostDelegateView** render_view_host_delegate_view) {
(...skipping 28 matching lines...) Expand all
66 content::RenderViewHost* rvh = NULL; 66 content::RenderViewHost* rvh = NULL;
67 switch (type) { 67 switch (type) {
68 case ui::ET_MOUSE_DRAGGED: 68 case ui::ET_MOUSE_DRAGGED:
69 rvh = contents_->GetRenderViewHost(); 69 rvh = contents_->GetRenderViewHost();
70 if (rvh) { 70 if (rvh) {
71 gfx::Point screen_loc_in_pixel = ui::EventLocationFromNative(event); 71 gfx::Point screen_loc_in_pixel = ui::EventLocationFromNative(event);
72 gfx::Point screen_loc = content::ConvertPointToDIP(rvh->GetView(), 72 gfx::Point screen_loc = content::ConvertPointToDIP(rvh->GetView(),
73 screen_loc_in_pixel); 73 screen_loc_in_pixel);
74 gfx::Point client_loc = screen_loc; 74 gfx::Point client_loc = screen_loc;
75 aura::Window* window = rvh->GetView()->GetNativeView(); 75 aura::Window* window = rvh->GetView()->GetNativeView();
76 aura::Window::ConvertPointToWindow(window->GetRootWindow(), 76 aura::Window::ConvertPointToTarget(window->GetRootWindow(),
77 window, &client_loc); 77 window, &client_loc);
78 rvh->DragSourceMovedTo(client_loc.x(), client_loc.y(), 78 rvh->DragSourceMovedTo(client_loc.x(), client_loc.y(),
79 screen_loc.x(), screen_loc.y()); 79 screen_loc.x(), screen_loc.y());
80 } 80 }
81 break; 81 break;
82 default: 82 default:
83 break; 83 break;
84 } 84 }
85 } 85 }
86 86
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (rwhv) 234 if (rwhv)
235 rwhv->SetSize(size); 235 rwhv->SetSize(size);
236 } 236 }
237 237
238 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { 238 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) {
239 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 239 aura::RootWindow* root_window = GetNativeView()->GetRootWindow();
240 gfx::Point screen_loc = gfx::Screen::GetCursorScreenPoint(); 240 gfx::Point screen_loc = gfx::Screen::GetCursorScreenPoint();
241 gfx::Point client_loc = screen_loc; 241 gfx::Point client_loc = screen_loc;
242 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 242 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
243 aura::Window* window = rvh->GetView()->GetNativeView(); 243 aura::Window* window = rvh->GetView()->GetNativeView();
244 aura::Window::ConvertPointToWindow(root_window, window, &client_loc); 244 aura::Window::ConvertPointToTarget(root_window, window, &client_loc);
245 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), 245 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(),
246 screen_loc.y(), ops); 246 screen_loc.y(), ops);
247 } 247 }
248 248
249 //////////////////////////////////////////////////////////////////////////////// 249 ////////////////////////////////////////////////////////////////////////////////
250 // WebContentsViewAura, WebContentsView implementation: 250 // WebContentsViewAura, WebContentsView implementation:
251 251
252 void WebContentsViewAura::CreateView(const gfx::Size& initial_size) { 252 void WebContentsViewAura::CreateView(const gfx::Size& initial_size) {
253 initial_size_ = initial_size; 253 initial_size_ = initial_size;
254 254
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (delegate_.get()) 489 if (delegate_.get())
490 delegate_->SizeChanged(new_bounds.size()); 490 delegate_->SizeChanged(new_bounds.size());
491 } 491 }
492 492
493 void WebContentsViewAura::OnFocus(aura::Window* old_focused_window) { 493 void WebContentsViewAura::OnFocus(aura::Window* old_focused_window) {
494 } 494 }
495 495
496 void WebContentsViewAura::OnBlur() { 496 void WebContentsViewAura::OnBlur() {
497 } 497 }
498 498
499 bool WebContentsViewAura::OnKeyEvent(aura::KeyEvent* event) { 499 bool WebContentsViewAura::OnKeyEvent(ui::KeyEvent* event) {
500 return false; 500 return false;
501 } 501 }
502 502
503 gfx::NativeCursor WebContentsViewAura::GetCursor(const gfx::Point& point) { 503 gfx::NativeCursor WebContentsViewAura::GetCursor(const gfx::Point& point) {
504 return gfx::kNullCursor; 504 return gfx::kNullCursor;
505 } 505 }
506 506
507 int WebContentsViewAura::GetNonClientComponent(const gfx::Point& point) const { 507 int WebContentsViewAura::GetNonClientComponent(const gfx::Point& point) const {
508 return HTCLIENT; 508 return HTCLIENT;
509 } 509 }
510 510
511 bool WebContentsViewAura::ShouldDescendIntoChildForEventHandling( 511 bool WebContentsViewAura::ShouldDescendIntoChildForEventHandling(
512 aura::Window* child, 512 aura::Window* child,
513 const gfx::Point& location) { 513 const gfx::Point& location) {
514 return true; 514 return true;
515 } 515 }
516 516
517 bool WebContentsViewAura::OnMouseEvent(aura::MouseEvent* event) { 517 bool WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) {
518 if (!web_contents_->GetDelegate()) 518 if (!web_contents_->GetDelegate())
519 return false; 519 return false;
520 520
521 switch (event->type()) { 521 switch (event->type()) {
522 case ui::ET_MOUSE_PRESSED: 522 case ui::ET_MOUSE_PRESSED:
523 web_contents_->GetDelegate()->ActivateContents(web_contents_); 523 web_contents_->GetDelegate()->ActivateContents(web_contents_);
524 break; 524 break;
525 case ui::ET_MOUSE_MOVED: 525 case ui::ET_MOUSE_MOVED:
526 web_contents_->GetDelegate()->ContentsMouseEvent( 526 web_contents_->GetDelegate()->ContentsMouseEvent(
527 web_contents_, gfx::Screen::GetCursorScreenPoint(), true); 527 web_contents_, gfx::Screen::GetCursorScreenPoint(), true);
528 break; 528 break;
529 default: 529 default:
530 break; 530 break;
531 } 531 }
532 return false; 532 return false;
533 } 533 }
534 534
535 ui::TouchStatus WebContentsViewAura::OnTouchEvent(aura::TouchEvent* event) { 535 ui::TouchStatus WebContentsViewAura::OnTouchEvent(ui::TouchEventImpl* event) {
536 return ui::TOUCH_STATUS_UNKNOWN; 536 return ui::TOUCH_STATUS_UNKNOWN;
537 } 537 }
538 538
539 ui::GestureStatus WebContentsViewAura::OnGestureEvent( 539 ui::GestureStatus WebContentsViewAura::OnGestureEvent(
540 aura::GestureEvent* event) { 540 ui::GestureEventImpl* event) {
541 return ui::GESTURE_STATUS_UNKNOWN; 541 return ui::GESTURE_STATUS_UNKNOWN;
542 } 542 }
543 543
544 bool WebContentsViewAura::CanFocus() { 544 bool WebContentsViewAura::CanFocus() {
545 // Do not take the focus if |view_| is gone because neither the view window 545 // Do not take the focus if |view_| is gone because neither the view window
546 // nor this window can handle key events. 546 // nor this window can handle key events.
547 return view_ != NULL; 547 return view_ != NULL;
548 } 548 }
549 549
550 void WebContentsViewAura::OnCaptureLost() { 550 void WebContentsViewAura::OnCaptureLost() {
(...skipping 22 matching lines...) Expand all
573 bool WebContentsViewAura::HasHitTestMask() const { 573 bool WebContentsViewAura::HasHitTestMask() const {
574 return false; 574 return false;
575 } 575 }
576 576
577 void WebContentsViewAura::GetHitTestMask(gfx::Path* mask) const { 577 void WebContentsViewAura::GetHitTestMask(gfx::Path* mask) const {
578 } 578 }
579 579
580 //////////////////////////////////////////////////////////////////////////////// 580 ////////////////////////////////////////////////////////////////////////////////
581 // WebContentsViewAura, aura::client::DragDropDelegate implementation: 581 // WebContentsViewAura, aura::client::DragDropDelegate implementation:
582 582
583 void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) { 583 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) {
584 if (drag_dest_delegate_) 584 if (drag_dest_delegate_)
585 drag_dest_delegate_->DragInitialize(web_contents_); 585 drag_dest_delegate_->DragInitialize(web_contents_);
586 586
587 WebDropData drop_data; 587 WebDropData drop_data;
588 PrepareWebDropData(&drop_data, event.data()); 588 PrepareWebDropData(&drop_data, event.data());
589 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 589 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
590 590
591 gfx::Point screen_pt = gfx::Screen::GetCursorScreenPoint(); 591 gfx::Point screen_pt = gfx::Screen::GetCursorScreenPoint();
592 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); 592 current_rvh_for_drag_ = web_contents_->GetRenderViewHost();
593 web_contents_->GetRenderViewHost()->DragTargetDragEnter( 593 web_contents_->GetRenderViewHost()->DragTargetDragEnter(
594 drop_data, event.location(), screen_pt, op, 594 drop_data, event.location(), screen_pt, op,
595 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 595 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
596 596
597 if (drag_dest_delegate_) { 597 if (drag_dest_delegate_) {
598 drag_dest_delegate_->OnReceiveDragData(event.data()); 598 drag_dest_delegate_->OnReceiveDragData(event.data());
599 drag_dest_delegate_->OnDragEnter(); 599 drag_dest_delegate_->OnDragEnter();
600 } 600 }
601 } 601 }
602 602
603 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { 603 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) {
604 DCHECK(current_rvh_for_drag_); 604 DCHECK(current_rvh_for_drag_);
605 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) 605 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost())
606 OnDragEntered(event); 606 OnDragEntered(event);
607 607
608 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 608 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
609 gfx::Point screen_pt = gfx::Screen::GetCursorScreenPoint(); 609 gfx::Point screen_pt = gfx::Screen::GetCursorScreenPoint();
610 web_contents_->GetRenderViewHost()->DragTargetDragOver( 610 web_contents_->GetRenderViewHost()->DragTargetDragOver(
611 event.location(), screen_pt, op, 611 event.location(), screen_pt, op,
612 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 612 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
613 613
614 if (drag_dest_delegate_) 614 if (drag_dest_delegate_)
615 drag_dest_delegate_->OnDragOver(); 615 drag_dest_delegate_->OnDragOver();
616 616
617 return ConvertFromWeb(current_drag_op_); 617 return ConvertFromWeb(current_drag_op_);
618 } 618 }
619 619
620 void WebContentsViewAura::OnDragExited() { 620 void WebContentsViewAura::OnDragExited() {
621 DCHECK(current_rvh_for_drag_); 621 DCHECK(current_rvh_for_drag_);
622 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) 622 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost())
623 return; 623 return;
624 624
625 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); 625 web_contents_->GetRenderViewHost()->DragTargetDragLeave();
626 if (drag_dest_delegate_) 626 if (drag_dest_delegate_)
627 drag_dest_delegate_->OnDragLeave(); 627 drag_dest_delegate_->OnDragLeave();
628 } 628 }
629 629
630 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { 630 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) {
631 DCHECK(current_rvh_for_drag_); 631 DCHECK(current_rvh_for_drag_);
632 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) 632 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost())
633 OnDragEntered(event); 633 OnDragEntered(event);
634 634
635 web_contents_->GetRenderViewHost()->DragTargetDrop( 635 web_contents_->GetRenderViewHost()->DragTargetDrop(
636 event.location(), 636 event.location(),
637 gfx::Screen::GetCursorScreenPoint(), 637 gfx::Screen::GetCursorScreenPoint(),
638 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 638 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
639 if (drag_dest_delegate_) 639 if (drag_dest_delegate_)
640 drag_dest_delegate_->OnDrop(); 640 drag_dest_delegate_->OnDrop();
641 return current_drag_op_; 641 return current_drag_op_;
642 } 642 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698