| 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/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "ui/base/hit_test.h" | 41 #include "ui/base/hit_test.h" |
| 42 #include "ui/base/ime/input_method.h" | 42 #include "ui/base/ime/input_method.h" |
| 43 #include "ui/base/ui_base_types.h" | 43 #include "ui/base/ui_base_types.h" |
| 44 #include "ui/compositor/compositor.h" | 44 #include "ui/compositor/compositor.h" |
| 45 #include "ui/compositor/layer.h" | 45 #include "ui/compositor/layer.h" |
| 46 #include "ui/gfx/canvas.h" | 46 #include "ui/gfx/canvas.h" |
| 47 #include "ui/gfx/display.h" | 47 #include "ui/gfx/display.h" |
| 48 #include "ui/gfx/screen.h" | 48 #include "ui/gfx/screen.h" |
| 49 #include "ui/gfx/skia_util.h" | 49 #include "ui/gfx/skia_util.h" |
| 50 | 50 |
| 51 using content::BrowserThread; | 51 using WebKit::WebScreenInfo; |
| 52 using content::NativeWebKeyboardEvent; | |
| 53 using content::RenderViewHost; | |
| 54 using content::RenderViewHostDelegate; | |
| 55 using content::RenderWidgetHost; | |
| 56 using content::RenderWidgetHostImpl; | |
| 57 using content::RenderWidgetHostView; | |
| 58 using WebKit::WebTouchEvent; | 52 using WebKit::WebTouchEvent; |
| 59 | 53 |
| 54 namespace content { |
| 60 namespace { | 55 namespace { |
| 61 | 56 |
| 62 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting | 57 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting |
| 63 // the border of the view, in order to get valid movement information. However, | 58 // the border of the view, in order to get valid movement information. However, |
| 64 // forcing the cursor back to the center of the view after each mouse move | 59 // forcing the cursor back to the center of the view after each mouse move |
| 65 // doesn't work well. It reduces the frequency of useful mouse move messages | 60 // doesn't work well. It reduces the frequency of useful mouse move messages |
| 66 // significantly. Therefore, we move the cursor to the center of the view only | 61 // significantly. Therefore, we move the cursor to the center of the view only |
| 67 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width | 62 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width |
| 68 // of the border area, in percentage of the corresponding dimension. | 63 // of the border area, in percentage of the corresponding dimension. |
| 69 const int kMouseLockBorderPercentage = 15; | 64 const int kMouseLockBorderPercentage = 15; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 case WM_NCXBUTTONUP: | 104 case WM_NCXBUTTONUP: |
| 110 case WM_NCXBUTTONDBLCLK: | 105 case WM_NCXBUTTONDBLCLK: |
| 111 return false; | 106 return false; |
| 112 default: | 107 default: |
| 113 break; | 108 break; |
| 114 } | 109 } |
| 115 #endif | 110 #endif |
| 116 return true; | 111 return true; |
| 117 } | 112 } |
| 118 | 113 |
| 119 void GetScreenInfoForWindow(WebKit::WebScreenInfo* results, | 114 void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) { |
| 120 aura::Window* window) { | |
| 121 const gfx::Display display = window ? | 115 const gfx::Display display = window ? |
| 122 gfx::Screen::GetDisplayNearestWindow(window) : | 116 gfx::Screen::GetDisplayNearestWindow(window) : |
| 123 gfx::Screen::GetPrimaryDisplay(); | 117 gfx::Screen::GetPrimaryDisplay(); |
| 124 const gfx::Size size = display.size(); | 118 const gfx::Size size = display.size(); |
| 125 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 119 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
| 126 results->availableRect = results->rect; | 120 results->availableRect = results->rect; |
| 127 // TODO(derat|oshima): Don't hardcode this. Get this from display object. | 121 // TODO(derat|oshima): Don't hardcode this. Get this from display object. |
| 128 results->depth = 24; | 122 results->depth = 24; |
| 129 results->depthPerComponent = 8; | 123 results->depthPerComponent = 8; |
| 130 int default_dpi = display.device_scale_factor() * 160; | 124 int default_dpi = display.device_scale_factor() * 160; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 return; | 449 return; |
| 456 | 450 |
| 457 std::map<uint64, scoped_refptr<ui::Texture> >::iterator it = | 451 std::map<uint64, scoped_refptr<ui::Texture> >::iterator it = |
| 458 image_transport_clients_.find(current_surface_); | 452 image_transport_clients_.find(current_surface_); |
| 459 if (it == image_transport_clients_.end()) | 453 if (it == image_transport_clients_.end()) |
| 460 return; | 454 return; |
| 461 | 455 |
| 462 ui::Texture* container = it->second; | 456 ui::Texture* container = it->second; |
| 463 DCHECK(container); | 457 DCHECK(container); |
| 464 | 458 |
| 465 gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size); | 459 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); |
| 466 if (!output->initialize( | 460 if (!output->initialize( |
| 467 size_in_pixel.width(), size_in_pixel.height(), true)) | 461 size_in_pixel.width(), size_in_pixel.height(), true)) |
| 468 return; | 462 return; |
| 469 | 463 |
| 470 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 464 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 471 content::GLHelper* gl_helper = factory->GetGLHelper(compositor); | 465 GLHelper* gl_helper = factory->GetGLHelper(compositor); |
| 472 if (!gl_helper) | 466 if (!gl_helper) |
| 473 return; | 467 return; |
| 474 | 468 |
| 475 unsigned char* addr = static_cast<unsigned char*>( | 469 unsigned char* addr = static_cast<unsigned char*>( |
| 476 output->getTopDevice()->accessBitmap(true).getPixels()); | 470 output->getTopDevice()->accessBitmap(true).getPixels()); |
| 477 scoped_callback_runner.Release(); | 471 scoped_callback_runner.Release(); |
| 478 gl_helper->CopyTextureTo(container->texture_id(), | 472 gl_helper->CopyTextureTo(container->texture_id(), |
| 479 container->size(), | 473 container->size(), |
| 480 size_in_pixel, | 474 size_in_pixel, |
| 481 addr, | 475 addr, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 window_->SetExternalTexture(container); | 508 window_->SetExternalTexture(container); |
| 515 | 509 |
| 516 released_front_lock_ = NULL; | 510 released_front_lock_ = NULL; |
| 517 | 511 |
| 518 if (!container) { | 512 if (!container) { |
| 519 resize_locks_.clear(); | 513 resize_locks_.clear(); |
| 520 } else { | 514 } else { |
| 521 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; | 515 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; |
| 522 ResizeLockList::iterator it = resize_locks_.begin(); | 516 ResizeLockList::iterator it = resize_locks_.begin(); |
| 523 while (it != resize_locks_.end()) { | 517 while (it != resize_locks_.end()) { |
| 524 gfx::Size container_size = content::ConvertSizeToDIP(this, | 518 gfx::Size container_size = ConvertSizeToDIP(this, |
| 525 container->size()); | 519 container->size()); |
| 526 if ((*it)->expected_size() == container_size) | 520 if ((*it)->expected_size() == container_size) |
| 527 break; | 521 break; |
| 528 ++it; | 522 ++it; |
| 529 } | 523 } |
| 530 if (it != resize_locks_.end()) { | 524 if (it != resize_locks_.end()) { |
| 531 ++it; | 525 ++it; |
| 532 ui::Compositor* compositor = GetCompositor(); | 526 ui::Compositor* compositor = GetCompositor(); |
| 533 if (compositor) { | 527 if (compositor) { |
| 534 // Delay the release of the lock until we've kicked a frame with the | 528 // Delay the release of the lock until we've kicked a frame with the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 561 UpdateExternalTexture(); | 555 UpdateExternalTexture(); |
| 562 | 556 |
| 563 ui::Compositor* compositor = GetCompositor(); | 557 ui::Compositor* compositor = GetCompositor(); |
| 564 if (!compositor) { | 558 if (!compositor) { |
| 565 // We have no compositor, so we have no way to display the surface. | 559 // We have no compositor, so we have no way to display the surface. |
| 566 // Must still send the ACK. | 560 // Must still send the ACK. |
| 567 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); | 561 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); |
| 568 } else { | 562 } else { |
| 569 gfx::Size surface_size_in_pixel = | 563 gfx::Size surface_size_in_pixel = |
| 570 image_transport_clients_[params_in_pixel.surface_handle]->size(); | 564 image_transport_clients_[params_in_pixel.surface_handle]->size(); |
| 571 gfx::Size surface_size = content::ConvertSizeToDIP(this, | 565 gfx::Size surface_size = ConvertSizeToDIP(this, |
| 572 surface_size_in_pixel); | 566 surface_size_in_pixel); |
| 573 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 567 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
| 574 | 568 |
| 575 if (!resize_locks_.empty()) { | 569 if (!resize_locks_.empty()) { |
| 576 // If we are waiting for the resize, fast-track the ACK. | 570 // If we are waiting for the resize, fast-track the ACK. |
| 577 if (compositor->IsThreaded()) { | 571 if (compositor->IsThreaded()) { |
| 578 // We need the compositor thread to pick up the active buffer before | 572 // We need the compositor thread to pick up the active buffer before |
| 579 // ACKing. | 573 // ACKing. |
| 580 on_compositing_did_commit_callbacks_.push_back( | 574 on_compositing_did_commit_callbacks_.push_back( |
| 581 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, | 575 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 611 if (!compositor) { | 605 if (!compositor) { |
| 612 // We have no compositor, so we have no way to display the surface | 606 // We have no compositor, so we have no way to display the surface |
| 613 // Must still send the ACK | 607 // Must still send the ACK |
| 614 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); | 608 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); |
| 615 } else { | 609 } else { |
| 616 gfx::Size surface_size_in_pixel = | 610 gfx::Size surface_size_in_pixel = |
| 617 image_transport_clients_[params_in_pixel.surface_handle]->size(); | 611 image_transport_clients_[params_in_pixel.surface_handle]->size(); |
| 618 | 612 |
| 619 // Co-ordinates come in OpenGL co-ordinate space. | 613 // Co-ordinates come in OpenGL co-ordinate space. |
| 620 // We need to convert to layer space. | 614 // We need to convert to layer space. |
| 621 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect( | 615 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( |
| 622 params_in_pixel.x, | 616 params_in_pixel.x, |
| 623 surface_size_in_pixel.height() - params_in_pixel.y - | 617 surface_size_in_pixel.height() - params_in_pixel.y - |
| 624 params_in_pixel.height, | 618 params_in_pixel.height, |
| 625 params_in_pixel.width, | 619 params_in_pixel.width, |
| 626 params_in_pixel.height)); | 620 params_in_pixel.height)); |
| 627 window_->SchedulePaintInRect(rect_to_paint); | 621 window_->SchedulePaintInRect(rect_to_paint); |
| 628 | 622 |
| 629 if (!resize_locks_.empty()) { | 623 if (!resize_locks_.empty()) { |
| 630 // If we are waiting for the resize, fast-track the ACK. | 624 // If we are waiting for the resize, fast-track the ACK. |
| 631 if (compositor->IsThreaded()) { | 625 if (compositor->IsThreaded()) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( | 681 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( |
| 688 uint64 surface_handle) { | 682 uint64 surface_handle) { |
| 689 if (current_surface_ == surface_handle) { | 683 if (current_surface_ == surface_handle) { |
| 690 current_surface_ = 0; | 684 current_surface_ = 0; |
| 691 UpdateExternalTexture(); | 685 UpdateExternalTexture(); |
| 692 } | 686 } |
| 693 image_transport_clients_.erase(surface_handle); | 687 image_transport_clients_.erase(surface_handle); |
| 694 } | 688 } |
| 695 | 689 |
| 696 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 690 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
| 697 content::RenderWidgetHostViewBase::SetBackground(background); | 691 RenderWidgetHostViewBase::SetBackground(background); |
| 698 host_->SetBackground(background); | 692 host_->SetBackground(background); |
| 699 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 693 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
| 700 } | 694 } |
| 701 | 695 |
| 702 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { | 696 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { |
| 703 GetScreenInfoForWindow(results, window_); | 697 GetScreenInfoForWindow(results, window_); |
| 704 } | 698 } |
| 705 | 699 |
| 706 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { | 700 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { |
| 707 return window_->GetToplevelWindow()->bounds(); | 701 return window_->GetToplevelWindow()->bounds(); |
| 708 } | 702 } |
| 709 | 703 |
| 710 void RenderWidgetHostViewAura::ProcessTouchAck( | 704 void RenderWidgetHostViewAura::ProcessTouchAck( |
| 711 WebKit::WebInputEvent::Type type, bool processed) { | 705 WebKit::WebInputEvent::Type type, bool processed) { |
| 712 // The ACKs for the touch-events arrive in the same sequence as they were | 706 // The ACKs for the touch-events arrive in the same sequence as they were |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 | 1034 |
| 1041 bool RenderWidgetHostViewAura::ShouldDescendIntoChildForEventHandling( | 1035 bool RenderWidgetHostViewAura::ShouldDescendIntoChildForEventHandling( |
| 1042 aura::Window* child, | 1036 aura::Window* child, |
| 1043 const gfx::Point& location) { | 1037 const gfx::Point& location) { |
| 1044 return true; | 1038 return true; |
| 1045 } | 1039 } |
| 1046 | 1040 |
| 1047 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { | 1041 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { |
| 1048 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); | 1042 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); |
| 1049 if (mouse_locked_) { | 1043 if (mouse_locked_) { |
| 1050 WebKit::WebMouseEvent mouse_event = content::MakeWebMouseEvent(event); | 1044 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
| 1051 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); | 1045 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); |
| 1052 | 1046 |
| 1053 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || | 1047 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || |
| 1054 event->type() == ui::ET_MOUSE_DRAGGED) && | 1048 event->type() == ui::ET_MOUSE_DRAGGED) && |
| 1055 mouse_event.x == center.x() && mouse_event.y == center.y(); | 1049 mouse_event.x == center.x() && mouse_event.y == center.y(); |
| 1056 | 1050 |
| 1057 ModifyEventMovementAndCoords(&mouse_event); | 1051 ModifyEventMovementAndCoords(&mouse_event); |
| 1058 | 1052 |
| 1059 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; | 1053 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; |
| 1060 if (should_not_forward) { | 1054 if (should_not_forward) { |
| 1061 synthetic_move_sent_ = false; | 1055 synthetic_move_sent_ = false; |
| 1062 } else { | 1056 } else { |
| 1063 // Check if the mouse has reached the border and needs to be centered. | 1057 // Check if the mouse has reached the border and needs to be centered. |
| 1064 if (ShouldMoveToCenter()) { | 1058 if (ShouldMoveToCenter()) { |
| 1065 synthetic_move_sent_ = true; | 1059 synthetic_move_sent_ = true; |
| 1066 window_->MoveCursorTo(center); | 1060 window_->MoveCursorTo(center); |
| 1067 } | 1061 } |
| 1068 | 1062 |
| 1069 // Forward event to renderer. | 1063 // Forward event to renderer. |
| 1070 if (CanRendererHandleEvent(event)) | 1064 if (CanRendererHandleEvent(event)) |
| 1071 host_->ForwardMouseEvent(mouse_event); | 1065 host_->ForwardMouseEvent(mouse_event); |
| 1072 } | 1066 } |
| 1073 | 1067 |
| 1074 return false; | 1068 return false; |
| 1075 } | 1069 } |
| 1076 | 1070 |
| 1077 if (event->type() == ui::ET_MOUSEWHEEL) { | 1071 if (event->type() == ui::ET_MOUSEWHEEL) { |
| 1078 WebKit::WebMouseWheelEvent mouse_wheel_event = | 1072 WebKit::WebMouseWheelEvent mouse_wheel_event = |
| 1079 content::MakeWebMouseWheelEvent(event); | 1073 MakeWebMouseWheelEvent(event); |
| 1080 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 1074 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
| 1081 host_->ForwardWheelEvent(mouse_wheel_event); | 1075 host_->ForwardWheelEvent(mouse_wheel_event); |
| 1082 } else if (event->type() == ui::ET_SCROLL) { | 1076 } else if (event->type() == ui::ET_SCROLL) { |
| 1083 WebKit::WebGestureEvent gesture_event = | 1077 WebKit::WebGestureEvent gesture_event = |
| 1084 content::MakeWebGestureEventFlingCancel(); | 1078 MakeWebGestureEventFlingCancel(); |
| 1085 host_->ForwardGestureEvent(gesture_event); | 1079 host_->ForwardGestureEvent(gesture_event); |
| 1086 WebKit::WebMouseWheelEvent mouse_wheel_event = | 1080 WebKit::WebMouseWheelEvent mouse_wheel_event = |
| 1087 content::MakeWebMouseWheelEvent(static_cast<aura::ScrollEvent*>(event)); | 1081 MakeWebMouseWheelEvent(static_cast<aura::ScrollEvent*>(event)); |
| 1088 host_->ForwardWheelEvent(mouse_wheel_event); | 1082 host_->ForwardWheelEvent(mouse_wheel_event); |
| 1089 content::RecordAction(content::UserMetricsAction("TrackpadScroll")); | 1083 RecordAction(UserMetricsAction("TrackpadScroll")); |
| 1090 } else if (event->type() == ui::ET_SCROLL_FLING_START || | 1084 } else if (event->type() == ui::ET_SCROLL_FLING_START || |
| 1091 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 1085 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
| 1092 WebKit::WebGestureEvent gesture_event = | 1086 WebKit::WebGestureEvent gesture_event = |
| 1093 content::MakeWebGestureEvent(static_cast<aura::ScrollEvent*>(event)); | 1087 MakeWebGestureEvent(static_cast<aura::ScrollEvent*>(event)); |
| 1094 host_->ForwardGestureEvent(gesture_event); | 1088 host_->ForwardGestureEvent(gesture_event); |
| 1095 if (event->type() == ui::ET_SCROLL_FLING_START) | 1089 if (event->type() == ui::ET_SCROLL_FLING_START) |
| 1096 content::RecordAction(content::UserMetricsAction("TrackpadScrollFling")); | 1090 RecordAction(UserMetricsAction("TrackpadScrollFling")); |
| 1097 } else if (CanRendererHandleEvent(event)) { | 1091 } else if (CanRendererHandleEvent(event)) { |
| 1098 WebKit::WebMouseEvent mouse_event = content::MakeWebMouseEvent(event); | 1092 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
| 1099 ModifyEventMovementAndCoords(&mouse_event); | 1093 ModifyEventMovementAndCoords(&mouse_event); |
| 1100 host_->ForwardMouseEvent(mouse_event); | 1094 host_->ForwardMouseEvent(mouse_event); |
| 1101 } | 1095 } |
| 1102 | 1096 |
| 1103 switch (event->type()) { | 1097 switch (event->type()) { |
| 1104 case ui::ET_MOUSE_PRESSED: | 1098 case ui::ET_MOUSE_PRESSED: |
| 1105 window_->SetCapture(); | 1099 window_->SetCapture(); |
| 1106 // Confirm existing composition text on mouse click events, to make sure | 1100 // Confirm existing composition text on mouse click events, to make sure |
| 1107 // the input caret won't be moved with an ongoing composition text. | 1101 // the input caret won't be moved with an ongoing composition text. |
| 1108 FinishImeCompositionSession(); | 1102 FinishImeCompositionSession(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1120 window_->parent()->delegate()->OnMouseEvent(event); | 1114 window_->parent()->delegate()->OnMouseEvent(event); |
| 1121 | 1115 |
| 1122 // Return true so that we receive released/drag events. | 1116 // Return true so that we receive released/drag events. |
| 1123 return true; | 1117 return true; |
| 1124 } | 1118 } |
| 1125 | 1119 |
| 1126 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( | 1120 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( |
| 1127 aura::TouchEvent* event) { | 1121 aura::TouchEvent* event) { |
| 1128 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent"); | 1122 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent"); |
| 1129 // Update the touch event first. | 1123 // Update the touch event first. |
| 1130 WebKit::WebTouchPoint* point = content::UpdateWebTouchEvent(event, | 1124 WebKit::WebTouchPoint* point = UpdateWebTouchEvent(event, |
| 1131 &touch_event_); | 1125 &touch_event_); |
| 1132 | 1126 |
| 1133 // Forward the touch event only if a touch point was updated, and there's a | 1127 // Forward the touch event only if a touch point was updated, and there's a |
| 1134 // touch-event handler in the page. | 1128 // touch-event handler in the page. |
| 1135 if (point && host_->has_touch_handler()) { | 1129 if (point && host_->has_touch_handler()) { |
| 1136 host_->ForwardTouchEvent(touch_event_); | 1130 host_->ForwardTouchEvent(touch_event_); |
| 1137 UpdateWebTouchEventAfterDispatch(&touch_event_, point); | 1131 UpdateWebTouchEventAfterDispatch(&touch_event_, point); |
| 1138 return DecideTouchStatus(touch_event_, point); | 1132 return DecideTouchStatus(touch_event_, point); |
| 1139 } | 1133 } |
| 1140 | 1134 |
| 1141 return ui::TOUCH_STATUS_UNKNOWN; | 1135 return ui::TOUCH_STATUS_UNKNOWN; |
| 1142 } | 1136 } |
| 1143 | 1137 |
| 1144 ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( | 1138 ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( |
| 1145 aura::GestureEvent* event) { | 1139 aura::GestureEvent* event) { |
| 1146 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); | 1140 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); |
| 1147 // Pinch gestures are currently disabled by default. See crbug.com/128477. | 1141 // Pinch gestures are currently disabled by default. See crbug.com/128477. |
| 1148 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 1142 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
| 1149 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 1143 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
| 1150 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { | 1144 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { |
| 1151 return ui::GESTURE_STATUS_CONSUMED; | 1145 return ui::GESTURE_STATUS_CONSUMED; |
| 1152 } | 1146 } |
| 1153 | 1147 |
| 1154 RenderViewHostDelegate* delegate = RenderViewHost::From(host_)->GetDelegate(); | 1148 RenderViewHostDelegate* delegate = RenderViewHost::From(host_)->GetDelegate(); |
| 1155 if (event->type() == ui::ET_GESTURE_BEGIN && | 1149 if (event->type() == ui::ET_GESTURE_BEGIN && |
| 1156 event->details().touch_points() == 1) { | 1150 event->details().touch_points() == 1) { |
| 1157 delegate->HandleGestureBegin(); | 1151 delegate->HandleGestureBegin(); |
| 1158 } | 1152 } |
| 1159 | 1153 |
| 1160 WebKit::WebGestureEvent gesture = content::MakeWebGestureEvent(event); | 1154 WebKit::WebGestureEvent gesture = MakeWebGestureEvent(event); |
| 1161 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 1155 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 1162 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 1156 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
| 1163 // event to stop any in-progress flings. | 1157 // event to stop any in-progress flings. |
| 1164 WebKit::WebGestureEvent fling_cancel = gesture; | 1158 WebKit::WebGestureEvent fling_cancel = gesture; |
| 1165 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; | 1159 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; |
| 1166 host_->ForwardGestureEvent(fling_cancel); | 1160 host_->ForwardGestureEvent(fling_cancel); |
| 1167 } | 1161 } |
| 1168 | 1162 |
| 1169 if (gesture.type != WebKit::WebInputEvent::Undefined) { | 1163 if (gesture.type != WebKit::WebInputEvent::Undefined) { |
| 1170 host_->ForwardGestureEvent(gesture); | 1164 host_->ForwardGestureEvent(gesture); |
| 1171 | 1165 |
| 1172 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 1166 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 1173 event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 1167 event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 1174 event->type() == ui::ET_GESTURE_SCROLL_END) { | 1168 event->type() == ui::ET_GESTURE_SCROLL_END) { |
| 1175 content::RecordAction(content::UserMetricsAction("TouchscreenScroll")); | 1169 RecordAction(UserMetricsAction("TouchscreenScroll")); |
| 1176 } else if (event->type() == ui::ET_SCROLL_FLING_START) { | 1170 } else if (event->type() == ui::ET_SCROLL_FLING_START) { |
| 1177 content::RecordAction( | 1171 RecordAction(UserMetricsAction("TouchscreenScrollFling")); |
| 1178 content::UserMetricsAction("TouchscreenScrollFling")); | |
| 1179 } | 1172 } |
| 1180 } | 1173 } |
| 1181 | 1174 |
| 1182 if (event->type() == ui::ET_GESTURE_END && | 1175 if (event->type() == ui::ET_GESTURE_END && |
| 1183 event->details().touch_points() == 1) { | 1176 event->details().touch_points() == 1) { |
| 1184 delegate->HandleGestureEnd(); | 1177 delegate->HandleGestureEnd(); |
| 1185 } | 1178 } |
| 1186 | 1179 |
| 1187 // If a gesture is not processed by the webpage, then WebKit processes it | 1180 // If a gesture is not processed by the webpage, then WebKit processes it |
| 1188 // (e.g. generates synthetic mouse events). So CONSUMED should be returned | 1181 // (e.g. generates synthetic mouse events). So CONSUMED should be returned |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 //////////////////////////////////////////////////////////////////////////////// | 1485 //////////////////////////////////////////////////////////////////////////////// |
| 1493 // RenderWidgetHostView, public: | 1486 // RenderWidgetHostView, public: |
| 1494 | 1487 |
| 1495 // static | 1488 // static |
| 1496 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 1489 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
| 1497 RenderWidgetHost* widget) { | 1490 RenderWidgetHost* widget) { |
| 1498 return new RenderWidgetHostViewAura(widget); | 1491 return new RenderWidgetHostViewAura(widget); |
| 1499 } | 1492 } |
| 1500 | 1493 |
| 1501 // static | 1494 // static |
| 1502 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1495 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 1503 WebKit::WebScreenInfo* results) { | |
| 1504 GetScreenInfoForWindow(results, NULL); | 1496 GetScreenInfoForWindow(results, NULL); |
| 1505 } | 1497 } |
| 1498 |
| 1499 } // namespace content |
| OLD | NEW |