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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // RenderWidget --------------------------------------------------------------- | 215 // RenderWidget --------------------------------------------------------------- |
216 | 216 |
217 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, | 217 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, |
218 blink::WebPopupType popup_type, | 218 blink::WebPopupType popup_type, |
219 const ScreenInfo& screen_info, | 219 const ScreenInfo& screen_info, |
220 bool swapped_out, | 220 bool swapped_out, |
221 bool hidden, | 221 bool hidden, |
222 bool never_visible) | 222 bool never_visible) |
223 : routing_id_(MSG_ROUTING_NONE), | 223 : routing_id_(MSG_ROUTING_NONE), |
224 compositor_deps_(compositor_deps), | 224 compositor_deps_(compositor_deps), |
225 webwidget_(nullptr), | 225 webwidget_internal_(nullptr), |
226 owner_delegate_(nullptr), | 226 owner_delegate_(nullptr), |
227 opener_id_(MSG_ROUTING_NONE), | 227 opener_id_(MSG_ROUTING_NONE), |
228 next_paint_flags_(0), | 228 next_paint_flags_(0), |
229 auto_resize_mode_(false), | 229 auto_resize_mode_(false), |
230 need_update_rect_for_auto_resize_(false), | 230 need_update_rect_for_auto_resize_(false), |
231 did_show_(false), | 231 did_show_(false), |
232 is_hidden_(hidden), | 232 is_hidden_(hidden), |
233 compositor_never_visible_(never_visible), | 233 compositor_never_visible_(never_visible), |
234 is_fullscreen_granted_(false), | 234 is_fullscreen_granted_(false), |
235 display_mode_(blink::WebDisplayModeUndefined), | 235 display_mode_(blink::WebDisplayModeUndefined), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // In tests there may not be a RenderThreadImpl. | 267 // In tests there may not be a RenderThreadImpl. |
268 if (RenderThreadImpl::current()) { | 268 if (RenderThreadImpl::current()) { |
269 render_widget_scheduling_state_ = RenderThreadImpl::current() | 269 render_widget_scheduling_state_ = RenderThreadImpl::current() |
270 ->GetRendererScheduler() | 270 ->GetRendererScheduler() |
271 ->NewRenderWidgetSchedulingState(); | 271 ->NewRenderWidgetSchedulingState(); |
272 render_widget_scheduling_state_->SetHidden(is_hidden_); | 272 render_widget_scheduling_state_->SetHidden(is_hidden_); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 RenderWidget::~RenderWidget() { | 276 RenderWidget::~RenderWidget() { |
277 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 277 DCHECK(!webwidget_internal_) << "Leaking our WebWidget!"; |
278 | 278 |
279 // If we are swapped out, we have released already. | 279 // If we are swapped out, we have released already. |
280 if (!is_swapped_out_ && RenderProcess::current()) | 280 if (!is_swapped_out_ && RenderProcess::current()) |
281 RenderProcess::current()->ReleaseProcess(); | 281 RenderProcess::current()->ReleaseProcess(); |
282 } | 282 } |
283 | 283 |
284 // static | 284 // static |
285 void RenderWidget::InstallCreateHook( | 285 void RenderWidget::InstallCreateHook( |
286 CreateRenderWidgetFunction create_render_widget, | 286 CreateRenderWidgetFunction create_render_widget, |
287 RenderWidgetInitializedCallback render_widget_initialized) { | 287 RenderWidgetInitializedCallback render_widget_initialized) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 if (success) { | 383 if (success) { |
384 SetRoutingID(routing_id_); | 384 SetRoutingID(routing_id_); |
385 return true; | 385 return true; |
386 } | 386 } |
387 return false; | 387 return false; |
388 } | 388 } |
389 | 389 |
390 bool RenderWidget::DoInit(int32_t opener_id, | 390 bool RenderWidget::DoInit(int32_t opener_id, |
391 WebWidget* web_widget, | 391 WebWidget* web_widget, |
392 IPC::SyncMessage* create_widget_message) { | 392 IPC::SyncMessage* create_widget_message) { |
393 DCHECK(!webwidget_); | 393 DCHECK(!webwidget_internal_); |
394 | 394 |
395 if (opener_id != MSG_ROUTING_NONE) | 395 if (opener_id != MSG_ROUTING_NONE) |
396 opener_id_ = opener_id; | 396 opener_id_ = opener_id; |
397 | 397 |
398 webwidget_ = web_widget; | 398 webwidget_internal_ = web_widget; |
399 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); | 399 webwidget_mouse_lock_target_.reset( |
| 400 new WebWidgetLockTarget(webwidget_internal_)); |
400 mouse_lock_dispatcher_.reset(new RenderWidgetMouseLockDispatcher(this)); | 401 mouse_lock_dispatcher_.reset(new RenderWidgetMouseLockDispatcher(this)); |
401 | 402 |
402 bool result = true; | 403 bool result = true; |
403 if (create_widget_message) | 404 if (create_widget_message) |
404 result = RenderThread::Get()->Send(create_widget_message); | 405 result = RenderThread::Get()->Send(create_widget_message); |
405 | 406 |
406 if (result) { | 407 if (result) { |
407 RenderThread::Get()->AddRoute(routing_id_, this); | 408 RenderThread::Get()->AddRoute(routing_id_, this); |
408 // Take a reference on behalf of the RenderThread. This will be balanced | 409 // Take a reference on behalf of the RenderThread. This will be balanced |
409 // when we receive ViewMsg_Close. | 410 // when we receive ViewMsg_Close. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } | 625 } |
625 | 626 |
626 void RenderWidget::OnDisableDeviceEmulation() { | 627 void RenderWidget::OnDisableDeviceEmulation() { |
627 screen_metrics_emulator_.reset(); | 628 screen_metrics_emulator_.reset(); |
628 } | 629 } |
629 | 630 |
630 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { | 631 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { |
631 if (resizer_rect_ == resizer_rect) | 632 if (resizer_rect_ == resizer_rect) |
632 return; | 633 return; |
633 resizer_rect_ = resizer_rect; | 634 resizer_rect_ = resizer_rect; |
634 if (webwidget_) | 635 if (GetWebWidget()) |
635 webwidget_->didChangeWindowResizerRect(); | 636 GetWebWidget()->didChangeWindowResizerRect(); |
636 } | 637 } |
637 | 638 |
638 void RenderWidget::OnWasHidden() { | 639 void RenderWidget::OnWasHidden() { |
639 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); | 640 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); |
640 // Go into a mode where we stop generating paint and scrolling events. | 641 // Go into a mode where we stop generating paint and scrolling events. |
641 SetHidden(true); | 642 SetHidden(true); |
642 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 643 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
643 WasHidden()); | 644 WasHidden()); |
644 } | 645 } |
645 | 646 |
646 void RenderWidget::OnWasShown(bool needs_repainting, | 647 void RenderWidget::OnWasShown(bool needs_repainting, |
647 const ui::LatencyInfo& latency_info) { | 648 const ui::LatencyInfo& latency_info) { |
648 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); | 649 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); |
649 // During shutdown we can just ignore this message. | 650 // During shutdown we can just ignore this message. |
650 if (!webwidget_) | 651 if (!GetWebWidget()) |
651 return; | 652 return; |
652 | 653 |
653 // See OnWasHidden | 654 // See OnWasHidden |
654 SetHidden(false); | 655 SetHidden(false); |
655 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 656 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
656 WasShown()); | 657 WasShown()); |
657 | 658 |
658 if (!needs_repainting) | 659 if (!needs_repainting) |
659 return; | 660 return; |
660 | 661 |
(...skipping 20 matching lines...) Expand all Loading... |
681 | 682 |
682 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, | 683 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
683 const ui::LatencyInfo& latency_info, | 684 const ui::LatencyInfo& latency_info, |
684 InputEventDispatchType dispatch_type) { | 685 InputEventDispatchType dispatch_type) { |
685 if (!input_event) | 686 if (!input_event) |
686 return; | 687 return; |
687 input_handler_->HandleInputEvent(*input_event, latency_info, dispatch_type); | 688 input_handler_->HandleInputEvent(*input_event, latency_info, dispatch_type); |
688 } | 689 } |
689 | 690 |
690 void RenderWidget::OnCursorVisibilityChange(bool is_visible) { | 691 void RenderWidget::OnCursorVisibilityChange(bool is_visible) { |
691 if (webwidget_) | 692 if (GetWebWidget()) |
692 webwidget_->setCursorVisibilityState(is_visible); | 693 GetWebWidget()->setCursorVisibilityState(is_visible); |
693 } | 694 } |
694 | 695 |
695 void RenderWidget::OnMouseCaptureLost() { | 696 void RenderWidget::OnMouseCaptureLost() { |
696 if (webwidget_) | 697 if (GetWebWidget()) |
697 webwidget_->mouseCaptureLost(); | 698 GetWebWidget()->mouseCaptureLost(); |
698 } | 699 } |
699 | 700 |
700 void RenderWidget::OnSetEditCommandsForNextKeyEvent( | 701 void RenderWidget::OnSetEditCommandsForNextKeyEvent( |
701 const EditCommands& edit_commands) { | 702 const EditCommands& edit_commands) { |
702 edit_commands_ = edit_commands; | 703 edit_commands_ = edit_commands; |
703 } | 704 } |
704 | 705 |
705 void RenderWidget::OnSetFocus(bool enable) { | 706 void RenderWidget::OnSetFocus(bool enable) { |
706 has_focus_ = enable; | 707 has_focus_ = enable; |
707 | 708 |
708 if (webwidget_) | 709 if (GetWebWidget()) |
709 webwidget_->setFocus(enable); | 710 GetWebWidget()->setFocus(enable); |
710 | 711 |
711 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 712 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
712 RenderWidgetSetFocus(enable)); | 713 RenderWidgetSetFocus(enable)); |
713 } | 714 } |
714 | 715 |
715 void RenderWidget::SetNeedsMainFrame() { | 716 void RenderWidget::SetNeedsMainFrame() { |
716 RenderWidgetCompositor* rwc = compositor(); | 717 RenderWidgetCompositor* rwc = compositor(); |
717 if (!rwc) | 718 if (!rwc) |
718 return; | 719 return; |
719 rwc->setNeedsBeginFrame(); | 720 rwc->setNeedsBeginFrame(); |
720 } | 721 } |
721 | 722 |
722 /////////////////////////////////////////////////////////////////////////////// | 723 /////////////////////////////////////////////////////////////////////////////// |
723 // RenderWidgetCompositorDelegate | 724 // RenderWidgetCompositorDelegate |
724 | 725 |
725 void RenderWidget::ApplyViewportDeltas( | 726 void RenderWidget::ApplyViewportDeltas( |
726 const gfx::Vector2dF& inner_delta, | 727 const gfx::Vector2dF& inner_delta, |
727 const gfx::Vector2dF& outer_delta, | 728 const gfx::Vector2dF& outer_delta, |
728 const gfx::Vector2dF& elastic_overscroll_delta, | 729 const gfx::Vector2dF& elastic_overscroll_delta, |
729 float page_scale, | 730 float page_scale, |
730 float top_controls_delta) { | 731 float top_controls_delta) { |
731 webwidget_->applyViewportDeltas(inner_delta, outer_delta, | 732 GetWebWidget()->applyViewportDeltas(inner_delta, outer_delta, |
732 elastic_overscroll_delta, page_scale, | 733 elastic_overscroll_delta, page_scale, |
733 top_controls_delta); | 734 top_controls_delta); |
734 } | 735 } |
735 | 736 |
736 void RenderWidget::BeginMainFrame(double frame_time_sec) { | 737 void RenderWidget::BeginMainFrame(double frame_time_sec) { |
737 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 738 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
738 // render_thread may be NULL in tests. | 739 // render_thread may be NULL in tests. |
739 InputHandlerManager* input_handler_manager = | 740 InputHandlerManager* input_handler_manager = |
740 render_thread ? render_thread->input_handler_manager() : NULL; | 741 render_thread ? render_thread->input_handler_manager() : NULL; |
741 if (input_handler_manager) | 742 if (input_handler_manager) |
742 input_handler_manager->ProcessRafAlignedInputOnMainThread(routing_id_); | 743 input_handler_manager->ProcessRafAlignedInputOnMainThread(routing_id_); |
743 | 744 |
744 webwidget_->beginFrame(frame_time_sec); | 745 GetWebWidget()->beginFrame(frame_time_sec); |
745 } | 746 } |
746 | 747 |
747 std::unique_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface( | 748 std::unique_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface( |
748 bool fallback) { | 749 bool fallback) { |
749 DCHECK(webwidget_); | 750 DCHECK(GetWebWidget()); |
750 // For widgets that are never visible, we don't start the compositor, so we | 751 // For widgets that are never visible, we don't start the compositor, so we |
751 // never get a request for a cc::OutputSurface. | 752 // never get a request for a cc::OutputSurface. |
752 DCHECK(!compositor_never_visible_); | 753 DCHECK(!compositor_never_visible_); |
753 return RenderThreadImpl::current()->CreateCompositorOutputSurface( | 754 return RenderThreadImpl::current()->CreateCompositorOutputSurface( |
754 fallback, routing_id_, frame_swap_message_queue_, | 755 fallback, routing_id_, frame_swap_message_queue_, |
755 GetURLForGraphicsContext3D()); | 756 GetURLForGraphicsContext3D()); |
756 } | 757 } |
757 | 758 |
758 void RenderWidget::DidCommitAndDrawCompositorFrame() { | 759 void RenderWidget::DidCommitAndDrawCompositorFrame() { |
759 // NOTE: Tests may break if this event is renamed or moved. See | 760 // NOTE: Tests may break if this event is renamed or moved. See |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 | 824 |
824 void RenderWidget::OnSwapBuffersPosted() { | 825 void RenderWidget::OnSwapBuffersPosted() { |
825 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); | 826 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); |
826 } | 827 } |
827 | 828 |
828 void RenderWidget::RequestScheduleAnimation() { | 829 void RenderWidget::RequestScheduleAnimation() { |
829 scheduleAnimation(); | 830 scheduleAnimation(); |
830 } | 831 } |
831 | 832 |
832 void RenderWidget::UpdateVisualState() { | 833 void RenderWidget::UpdateVisualState() { |
833 webwidget_->updateAllLifecyclePhases(); | 834 GetWebWidget()->updateAllLifecyclePhases(); |
834 } | 835 } |
835 | 836 |
836 void RenderWidget::WillBeginCompositorFrame() { | 837 void RenderWidget::WillBeginCompositorFrame() { |
837 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 838 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
838 | 839 |
839 // The UpdateTextInputState can result in further layout and possibly | 840 // The UpdateTextInputState can result in further layout and possibly |
840 // enable GPU acceleration so they need to be called before any painting | 841 // enable GPU acceleration so they need to be called before any painting |
841 // is done. | 842 // is done. |
842 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 843 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
843 UpdateSelectionBounds(); | 844 UpdateSelectionBounds(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); | 936 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); |
936 if (ime_event_guard_) { | 937 if (ime_event_guard_) { |
937 // show_ime should still be effective even if it was set inside the IME | 938 // show_ime should still be effective even if it was set inside the IME |
938 // event guard. | 939 // event guard. |
939 if (show_ime == ShowIme::IF_NEEDED) { | 940 if (show_ime == ShowIme::IF_NEEDED) { |
940 ime_event_guard_->set_show_ime(true); | 941 ime_event_guard_->set_show_ime(true); |
941 } | 942 } |
942 return; | 943 return; |
943 } | 944 } |
944 | 945 |
945 if (!webwidget_) | 946 if (!GetWebWidget()) |
946 return; | 947 return; |
947 | 948 |
948 blink::WebTextInputInfo new_info = webwidget_->textInputInfo(); | 949 blink::WebTextInputInfo new_info = GetWebWidget()->textInputInfo(); |
949 | 950 |
950 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | 951 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); |
951 | 952 |
952 bool new_can_compose_inline = CanComposeInline(); | 953 bool new_can_compose_inline = CanComposeInline(); |
953 | 954 |
954 // Only sends text input params if they are changed or if the ime should be | 955 // Only sends text input params if they are changed or if the ime should be |
955 // shown. | 956 // shown. |
956 if (show_ime == ShowIme::IF_NEEDED || | 957 if (show_ime == ShowIme::IF_NEEDED || |
957 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) || | 958 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) || |
958 (text_input_mode_ != new_mode || text_input_info_ != new_info || | 959 (text_input_mode_ != new_mode || text_input_info_ != new_info || |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 /////////////////////////////////////////////////////////////////////////////// | 1012 /////////////////////////////////////////////////////////////////////////////// |
1012 // RenderWidgetScreenMetricsDelegate | 1013 // RenderWidgetScreenMetricsDelegate |
1013 | 1014 |
1014 void RenderWidget::Redraw() { | 1015 void RenderWidget::Redraw() { |
1015 set_next_paint_is_resize_ack(); | 1016 set_next_paint_is_resize_ack(); |
1016 if (compositor_) | 1017 if (compositor_) |
1017 compositor_->SetNeedsRedrawRect(gfx::Rect(size_)); | 1018 compositor_->SetNeedsRedrawRect(gfx::Rect(size_)); |
1018 } | 1019 } |
1019 | 1020 |
1020 void RenderWidget::ResizeWebWidget() { | 1021 void RenderWidget::ResizeWebWidget() { |
1021 webwidget_->resize(GetSizeForWebWidget()); | 1022 GetWebWidget()->resize(GetSizeForWebWidget()); |
1022 } | 1023 } |
1023 | 1024 |
1024 gfx::Size RenderWidget::GetSizeForWebWidget() const { | 1025 gfx::Size RenderWidget::GetSizeForWebWidget() const { |
1025 if (IsUseZoomForDSFEnabled()) | 1026 if (IsUseZoomForDSFEnabled()) |
1026 return gfx::ScaleToCeiledSize(size_, GetOriginalDeviceScaleFactor()); | 1027 return gfx::ScaleToCeiledSize(size_, GetOriginalDeviceScaleFactor()); |
1027 | 1028 |
1028 return size_; | 1029 return size_; |
1029 } | 1030 } |
1030 | 1031 |
1031 void RenderWidget::Resize(const ResizeParams& params) { | 1032 void RenderWidget::Resize(const ResizeParams& params) { |
1032 bool orientation_changed = | 1033 bool orientation_changed = |
1033 screen_info_.orientation_angle != params.screen_info.orientation_angle || | 1034 screen_info_.orientation_angle != params.screen_info.orientation_angle || |
1034 screen_info_.orientation_type != params.screen_info.orientation_type; | 1035 screen_info_.orientation_type != params.screen_info.orientation_type; |
1035 | 1036 |
1036 screen_info_ = params.screen_info; | 1037 screen_info_ = params.screen_info; |
1037 | 1038 |
1038 if (device_scale_factor_ != screen_info_.device_scale_factor) { | 1039 if (device_scale_factor_ != screen_info_.device_scale_factor) { |
1039 device_scale_factor_ = screen_info_.device_scale_factor; | 1040 device_scale_factor_ = screen_info_.device_scale_factor; |
1040 OnDeviceScaleFactorChanged(); | 1041 OnDeviceScaleFactorChanged(); |
1041 ScheduleComposite(); | 1042 ScheduleComposite(); |
1042 } | 1043 } |
1043 | 1044 |
1044 if (resizing_mode_selector_->NeverUsesSynchronousResize()) { | 1045 if (resizing_mode_selector_->NeverUsesSynchronousResize()) { |
1045 // A resize ack shouldn't be requested if we have not ACK'd the previous | 1046 // A resize ack shouldn't be requested if we have not ACK'd the previous |
1046 // one. | 1047 // one. |
1047 DCHECK(!params.needs_resize_ack || !next_paint_is_resize_ack()); | 1048 DCHECK(!params.needs_resize_ack || !next_paint_is_resize_ack()); |
1048 } | 1049 } |
1049 | 1050 |
1050 // Ignore this during shutdown. | 1051 // Ignore this during shutdown. |
1051 if (!webwidget_) | 1052 if (!GetWebWidget()) |
1052 return; | 1053 return; |
1053 | 1054 |
1054 if (compositor_) { | 1055 if (compositor_) { |
1055 compositor_->setViewportSize(params.physical_backing_size); | 1056 compositor_->setViewportSize(params.physical_backing_size); |
1056 compositor_->setBottomControlsHeight(params.bottom_controls_height); | 1057 compositor_->setBottomControlsHeight(params.bottom_controls_height); |
1057 } | 1058 } |
1058 | 1059 |
1059 visible_viewport_size_ = params.visible_viewport_size; | 1060 visible_viewport_size_ = params.visible_viewport_size; |
1060 resizer_rect_ = params.resizer_rect; | 1061 resizer_rect_ = params.resizer_rect; |
1061 | 1062 |
(...skipping 11 matching lines...) Expand all Loading... |
1073 WebSize visual_viewport_size; | 1074 WebSize visual_viewport_size; |
1074 | 1075 |
1075 if (IsUseZoomForDSFEnabled()) { | 1076 if (IsUseZoomForDSFEnabled()) { |
1076 visual_viewport_size = gfx::ScaleToCeiledSize( | 1077 visual_viewport_size = gfx::ScaleToCeiledSize( |
1077 params.visible_viewport_size, | 1078 params.visible_viewport_size, |
1078 GetOriginalDeviceScaleFactor()); | 1079 GetOriginalDeviceScaleFactor()); |
1079 } else { | 1080 } else { |
1080 visual_viewport_size = visible_viewport_size_; | 1081 visual_viewport_size = visible_viewport_size_; |
1081 } | 1082 } |
1082 | 1083 |
1083 webwidget()->resizeVisualViewport(visual_viewport_size); | 1084 GetWebWidget()->resizeVisualViewport(visual_viewport_size); |
1084 | 1085 |
1085 // When resizing, we want to wait to paint before ACK'ing the resize. This | 1086 // When resizing, we want to wait to paint before ACK'ing the resize. This |
1086 // ensures that we only resize as fast as we can paint. We only need to | 1087 // ensures that we only resize as fast as we can paint. We only need to |
1087 // send an ACK if we are resized to a non-empty rect. | 1088 // send an ACK if we are resized to a non-empty rect. |
1088 if (params.new_size.IsEmpty() || params.physical_backing_size.IsEmpty()) { | 1089 if (params.new_size.IsEmpty() || params.physical_backing_size.IsEmpty()) { |
1089 // In this case there is no paint/composite and therefore no | 1090 // In this case there is no paint/composite and therefore no |
1090 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the | 1091 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the |
1091 // ack through a fake ViewHostMsg_UpdateRect or a different message. | 1092 // ack through a fake ViewHostMsg_UpdateRect or a different message. |
1092 DCHECK(!params.needs_resize_ack); | 1093 DCHECK(!params.needs_resize_ack); |
1093 } | 1094 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 | 1147 |
1147 void RenderWidget::WillCloseLayerTreeView() { | 1148 void RenderWidget::WillCloseLayerTreeView() { |
1148 if (host_closing_) | 1149 if (host_closing_) |
1149 return; | 1150 return; |
1150 | 1151 |
1151 // Prevent new compositors or output surfaces from being created. | 1152 // Prevent new compositors or output surfaces from being created. |
1152 host_closing_ = true; | 1153 host_closing_ = true; |
1153 | 1154 |
1154 // Always send this notification to prevent new layer tree views from | 1155 // Always send this notification to prevent new layer tree views from |
1155 // being created, even if one hasn't been created yet. | 1156 // being created, even if one hasn't been created yet. |
1156 if (webwidget_) | 1157 if (blink::WebWidget* widget = GetWebWidget()) |
1157 webwidget_->willCloseLayerTreeView(); | 1158 widget->willCloseLayerTreeView(); |
1158 } | 1159 } |
1159 | 1160 |
1160 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1161 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1161 return compositor_.get(); | 1162 return compositor_.get(); |
1162 } | 1163 } |
1163 | 1164 |
1164 void RenderWidget::didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) { | 1165 void RenderWidget::didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) { |
1165 if (layout_type == blink::WebMeaningfulLayout::VisuallyNonEmpty) { | 1166 if (layout_type == blink::WebMeaningfulLayout::VisuallyNonEmpty) { |
1166 QueueMessage(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_), | 1167 QueueMessage(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_), |
1167 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 1168 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 SyntheticGesturePacket gesture_packet; | 1309 SyntheticGesturePacket gesture_packet; |
1309 gesture_packet.set_gesture_params(std::move(gesture_params)); | 1310 gesture_packet.set_gesture_params(std::move(gesture_params)); |
1310 | 1311 |
1311 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); | 1312 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); |
1312 } | 1313 } |
1313 | 1314 |
1314 void RenderWidget::Close() { | 1315 void RenderWidget::Close() { |
1315 screen_metrics_emulator_.reset(); | 1316 screen_metrics_emulator_.reset(); |
1316 WillCloseLayerTreeView(); | 1317 WillCloseLayerTreeView(); |
1317 compositor_.reset(); | 1318 compositor_.reset(); |
1318 if (webwidget_) { | 1319 if (webwidget_internal_) { |
1319 webwidget_->close(); | 1320 webwidget_internal_->close(); |
1320 webwidget_ = nullptr; | 1321 webwidget_internal_ = nullptr; |
1321 } | 1322 } |
1322 } | 1323 } |
1323 | 1324 |
1324 WebRect RenderWidget::windowRect() { | 1325 WebRect RenderWidget::windowRect() { |
1325 if (pending_window_rect_count_) | 1326 if (pending_window_rect_count_) |
1326 return pending_window_rect_; | 1327 return pending_window_rect_; |
1327 | 1328 |
1328 return view_screen_rect_; | 1329 return view_screen_rect_; |
1329 } | 1330 } |
1330 | 1331 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 const gfx::Range& replacement_range, | 1384 const gfx::Range& replacement_range, |
1384 int selection_start, int selection_end) { | 1385 int selection_start, int selection_end) { |
1385 #if defined(ENABLE_PLUGINS) | 1386 #if defined(ENABLE_PLUGINS) |
1386 if (focused_pepper_plugin_) { | 1387 if (focused_pepper_plugin_) { |
1387 focused_pepper_plugin_->render_frame()->OnImeSetComposition( | 1388 focused_pepper_plugin_->render_frame()->OnImeSetComposition( |
1388 text, underlines, selection_start, selection_end); | 1389 text, underlines, selection_start, selection_end); |
1389 return; | 1390 return; |
1390 } | 1391 } |
1391 #endif | 1392 #endif |
1392 if (replacement_range.IsValid()) { | 1393 if (replacement_range.IsValid()) { |
1393 webwidget_->applyReplacementRange( | 1394 GetWebWidget()->applyReplacementRange( |
1394 WebRange(replacement_range.start(), replacement_range.length())); | 1395 WebRange(replacement_range.start(), replacement_range.length())); |
1395 } | 1396 } |
1396 | 1397 |
1397 if (!ShouldHandleImeEvent()) | 1398 if (!ShouldHandleImeEvent()) |
1398 return; | 1399 return; |
1399 ImeEventGuard guard(this); | 1400 ImeEventGuard guard(this); |
1400 if (!webwidget_->setComposition( | 1401 if (!GetWebWidget()->setComposition( |
1401 text, WebVector<WebCompositionUnderline>(underlines), | 1402 text, WebVector<WebCompositionUnderline>(underlines), selection_start, |
1402 selection_start, selection_end)) { | 1403 selection_end)) { |
1403 // If we failed to set the composition text, then we need to let the browser | 1404 // If we failed to set the composition text, then we need to let the browser |
1404 // process to cancel the input method's ongoing composition session, to make | 1405 // process to cancel the input method's ongoing composition session, to make |
1405 // sure we are in a consistent state. | 1406 // sure we are in a consistent state. |
1406 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1407 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
1407 } | 1408 } |
1408 UpdateCompositionInfo(false /* not an immediate request */); | 1409 UpdateCompositionInfo(false /* not an immediate request */); |
1409 } | 1410 } |
1410 | 1411 |
1411 void RenderWidget::OnImeConfirmComposition(const base::string16& text, | 1412 void RenderWidget::OnImeConfirmComposition(const base::string16& text, |
1412 const gfx::Range& replacement_range, | 1413 const gfx::Range& replacement_range, |
1413 bool keep_selection) { | 1414 bool keep_selection) { |
1414 #if defined(ENABLE_PLUGINS) | 1415 #if defined(ENABLE_PLUGINS) |
1415 if (focused_pepper_plugin_) { | 1416 if (focused_pepper_plugin_) { |
1416 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( | 1417 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( |
1417 text, replacement_range, keep_selection); | 1418 text, replacement_range, keep_selection); |
1418 return; | 1419 return; |
1419 } | 1420 } |
1420 #endif | 1421 #endif |
1421 if (replacement_range.IsValid()) { | 1422 if (replacement_range.IsValid()) { |
1422 webwidget_->applyReplacementRange( | 1423 GetWebWidget()->applyReplacementRange( |
1423 WebRange(replacement_range.start(), replacement_range.length())); | 1424 WebRange(replacement_range.start(), replacement_range.length())); |
1424 } | 1425 } |
1425 | 1426 |
1426 if (!ShouldHandleImeEvent()) | 1427 if (!ShouldHandleImeEvent()) |
1427 return; | 1428 return; |
1428 ImeEventGuard guard(this); | 1429 ImeEventGuard guard(this); |
1429 input_handler_->set_handling_input_event(true); | 1430 input_handler_->set_handling_input_event(true); |
1430 if (text.length()) | 1431 if (text.length()) |
1431 webwidget_->confirmComposition(text); | 1432 GetWebWidget()->confirmComposition(text); |
1432 else if (keep_selection) | 1433 else if (keep_selection) |
1433 webwidget_->confirmComposition(WebWidget::KeepSelection); | 1434 GetWebWidget()->confirmComposition(WebWidget::KeepSelection); |
1434 else | 1435 else |
1435 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); | 1436 GetWebWidget()->confirmComposition(WebWidget::DoNotKeepSelection); |
1436 input_handler_->set_handling_input_event(false); | 1437 input_handler_->set_handling_input_event(false); |
1437 UpdateCompositionInfo(false /* not an immediate request */); | 1438 UpdateCompositionInfo(false /* not an immediate request */); |
1438 } | 1439 } |
1439 | 1440 |
1440 void RenderWidget::OnDeviceScaleFactorChanged() { | 1441 void RenderWidget::OnDeviceScaleFactorChanged() { |
1441 if (!compositor_) | 1442 if (!compositor_) |
1442 return; | 1443 return; |
1443 if (IsUseZoomForDSFEnabled()) | 1444 if (IsUseZoomForDSFEnabled()) |
1444 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); | 1445 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); |
1445 else | 1446 else |
1446 compositor_->setDeviceScaleFactor(device_scale_factor_); | 1447 compositor_->setDeviceScaleFactor(device_scale_factor_); |
1447 } | 1448 } |
1448 | 1449 |
1449 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { | 1450 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { |
1450 // During shutdown we can just ignore this message. | 1451 // During shutdown we can just ignore this message. |
1451 if (!webwidget_) | 1452 if (!GetWebWidget()) |
1452 return; | 1453 return; |
1453 | 1454 |
1454 // Even if the browser provides an empty damage rect, it's still expecting to | 1455 // Even if the browser provides an empty damage rect, it's still expecting to |
1455 // receive a repaint ack so just damage the entire widget bounds. | 1456 // receive a repaint ack so just damage the entire widget bounds. |
1456 if (size_to_paint.IsEmpty()) { | 1457 if (size_to_paint.IsEmpty()) { |
1457 size_to_paint = size_; | 1458 size_to_paint = size_; |
1458 } | 1459 } |
1459 | 1460 |
1460 set_next_paint_is_repaint_ack(); | 1461 set_next_paint_is_repaint_ack(); |
1461 if (compositor_) | 1462 if (compositor_) |
1462 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint)); | 1463 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint)); |
1463 } | 1464 } |
1464 | 1465 |
1465 void RenderWidget::OnSyntheticGestureCompleted() { | 1466 void RenderWidget::OnSyntheticGestureCompleted() { |
1466 DCHECK(!pending_synthetic_gesture_callbacks_.empty()); | 1467 DCHECK(!pending_synthetic_gesture_callbacks_.empty()); |
1467 | 1468 |
1468 pending_synthetic_gesture_callbacks_.front().Run(); | 1469 pending_synthetic_gesture_callbacks_.front().Run(); |
1469 pending_synthetic_gesture_callbacks_.pop(); | 1470 pending_synthetic_gesture_callbacks_.pop(); |
1470 } | 1471 } |
1471 | 1472 |
1472 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 1473 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
1473 if (!webwidget_) | 1474 if (!GetWebWidget()) |
1474 return; | 1475 return; |
1475 webwidget_->setTextDirection(direction); | 1476 GetWebWidget()->setTextDirection(direction); |
1476 } | 1477 } |
1477 | 1478 |
1478 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, | 1479 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
1479 const gfx::Rect& window_screen_rect) { | 1480 const gfx::Rect& window_screen_rect) { |
1480 if (screen_metrics_emulator_) { | 1481 if (screen_metrics_emulator_) { |
1481 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, | 1482 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, |
1482 window_screen_rect); | 1483 window_screen_rect); |
1483 } else { | 1484 } else { |
1484 SetScreenRects(view_screen_rect, window_screen_rect); | 1485 SetScreenRects(view_screen_rect, window_screen_rect); |
1485 } | 1486 } |
(...skipping 21 matching lines...) Expand all Loading... |
1507 | 1508 |
1508 void RenderWidget::showImeIfNeeded() { | 1509 void RenderWidget::showImeIfNeeded() { |
1509 OnShowImeIfNeeded(); | 1510 OnShowImeIfNeeded(); |
1510 } | 1511 } |
1511 | 1512 |
1512 ui::TextInputType RenderWidget::GetTextInputType() { | 1513 ui::TextInputType RenderWidget::GetTextInputType() { |
1513 #if defined(ENABLE_PLUGINS) | 1514 #if defined(ENABLE_PLUGINS) |
1514 if (focused_pepper_plugin_) | 1515 if (focused_pepper_plugin_) |
1515 return focused_pepper_plugin_->text_input_type(); | 1516 return focused_pepper_plugin_->text_input_type(); |
1516 #endif | 1517 #endif |
1517 if (webwidget_) | 1518 if (GetWebWidget()) |
1518 return WebKitToUiTextInputType(webwidget_->textInputType()); | 1519 return WebKitToUiTextInputType(GetWebWidget()->textInputType()); |
1519 return ui::TEXT_INPUT_TYPE_NONE; | 1520 return ui::TEXT_INPUT_TYPE_NONE; |
1520 } | 1521 } |
1521 | 1522 |
1522 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { | 1523 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { |
1523 if (!monitor_composition_info_ && !immediate_request) | 1524 if (!monitor_composition_info_ && !immediate_request) |
1524 return; // Do not calculate composition info if not requested. | 1525 return; // Do not calculate composition info if not requested. |
1525 | 1526 |
1526 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); | 1527 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); |
1527 gfx::Range range; | 1528 gfx::Range range; |
1528 std::vector<gfx::Rect> character_bounds; | 1529 std::vector<gfx::Rect> character_bounds; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, | 1601 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, |
1601 bool monitor_request) { | 1602 bool monitor_request) { |
1602 monitor_composition_info_ = monitor_request; | 1603 monitor_composition_info_ = monitor_request; |
1603 if (!immediate_request) | 1604 if (!immediate_request) |
1604 return; | 1605 return; |
1605 UpdateCompositionInfo(true /* immediate request */); | 1606 UpdateCompositionInfo(true /* immediate request */); |
1606 } | 1607 } |
1607 | 1608 |
1608 bool RenderWidget::ShouldHandleImeEvent() { | 1609 bool RenderWidget::ShouldHandleImeEvent() { |
1609 #if defined(OS_ANDROID) | 1610 #if defined(OS_ANDROID) |
1610 if (!webwidget_) | 1611 if (!GetWebWidget()) |
1611 return false; | 1612 return false; |
1612 if (IsUsingImeThread()) | 1613 if (IsUsingImeThread()) |
1613 return true; | 1614 return true; |
1614 | 1615 |
1615 // We cannot handle IME events if there is any chance that the event we are | 1616 // We cannot handle IME events if there is any chance that the event we are |
1616 // receiving here from the browser is based on the state that is different | 1617 // receiving here from the browser is based on the state that is different |
1617 // from our current one as indicated by |text_input_info_|. | 1618 // from our current one as indicated by |text_input_info_|. |
1618 // The states the browser might be in are: | 1619 // The states the browser might be in are: |
1619 // text_input_info_history_[0] - current state ack'd by browser | 1620 // text_input_info_history_[0] - current state ack'd by browser |
1620 // text_input_info_history_[1...N] - pending state changes | 1621 // text_input_info_history_[1...N] - pending state changes |
1621 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { | 1622 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { |
1622 if (text_input_info_history_[i] != text_input_info_) | 1623 if (text_input_info_history_[i] != text_input_info_) |
1623 return false; | 1624 return false; |
1624 } | 1625 } |
1625 return true; | 1626 return true; |
1626 #else | 1627 #else |
1627 return !!webwidget_; | 1628 return !!GetWebWidget(); |
1628 #endif | 1629 #endif |
1629 } | 1630 } |
1630 | 1631 |
1631 void RenderWidget::OnSetDeviceScaleFactor(float device_scale_factor) { | 1632 void RenderWidget::OnSetDeviceScaleFactor(float device_scale_factor) { |
1632 if (device_scale_factor_ == device_scale_factor) | 1633 if (device_scale_factor_ == device_scale_factor) |
1633 return; | 1634 return; |
1634 | 1635 |
1635 device_scale_factor_ = device_scale_factor; | 1636 device_scale_factor_ = device_scale_factor; |
1636 | 1637 |
1637 OnDeviceScaleFactorChanged(); | 1638 OnDeviceScaleFactorChanged(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 if (is_hidden_) | 1674 if (is_hidden_) |
1674 RenderThreadImpl::current()->WidgetHidden(); | 1675 RenderThreadImpl::current()->WidgetHidden(); |
1675 else | 1676 else |
1676 RenderThreadImpl::current()->WidgetRestored(); | 1677 RenderThreadImpl::current()->WidgetRestored(); |
1677 | 1678 |
1678 if (render_widget_scheduling_state_) | 1679 if (render_widget_scheduling_state_) |
1679 render_widget_scheduling_state_->SetHidden(hidden); | 1680 render_widget_scheduling_state_->SetHidden(hidden); |
1680 } | 1681 } |
1681 | 1682 |
1682 void RenderWidget::DidToggleFullscreen() { | 1683 void RenderWidget::DidToggleFullscreen() { |
1683 if (!webwidget_) | 1684 if (!GetWebWidget()) |
1684 return; | 1685 return; |
1685 | 1686 |
1686 if (is_fullscreen_granted_) { | 1687 if (is_fullscreen_granted_) { |
1687 webwidget_->didEnterFullscreen(); | 1688 GetWebWidget()->didEnterFullscreen(); |
1688 } else { | 1689 } else { |
1689 webwidget_->didExitFullscreen(); | 1690 GetWebWidget()->didExitFullscreen(); |
1690 } | 1691 } |
1691 } | 1692 } |
1692 | 1693 |
1693 bool RenderWidget::next_paint_is_resize_ack() const { | 1694 bool RenderWidget::next_paint_is_resize_ack() const { |
1694 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); | 1695 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); |
1695 } | 1696 } |
1696 | 1697 |
1697 void RenderWidget::set_next_paint_is_resize_ack() { | 1698 void RenderWidget::set_next_paint_is_resize_ack() { |
1698 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; | 1699 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; |
1699 } | 1700 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 // after Pepper API equips features related to surrounding text retrieval. | 1751 // after Pepper API equips features related to surrounding text retrieval. |
1751 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); | 1752 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); |
1752 convertViewportToWindow(&caret); | 1753 convertViewportToWindow(&caret); |
1753 *focus = caret; | 1754 *focus = caret; |
1754 *anchor = caret; | 1755 *anchor = caret; |
1755 return; | 1756 return; |
1756 } | 1757 } |
1757 #endif | 1758 #endif |
1758 WebRect focus_webrect; | 1759 WebRect focus_webrect; |
1759 WebRect anchor_webrect; | 1760 WebRect anchor_webrect; |
1760 webwidget_->selectionBounds(focus_webrect, anchor_webrect); | 1761 GetWebWidget()->selectionBounds(focus_webrect, anchor_webrect); |
1761 convertViewportToWindow(&focus_webrect); | 1762 convertViewportToWindow(&focus_webrect); |
1762 convertViewportToWindow(&anchor_webrect); | 1763 convertViewportToWindow(&anchor_webrect); |
1763 *focus = focus_webrect; | 1764 *focus = focus_webrect; |
1764 *anchor = anchor_webrect; | 1765 *anchor = anchor_webrect; |
1765 } | 1766 } |
1766 | 1767 |
1767 void RenderWidget::UpdateSelectionBounds() { | 1768 void RenderWidget::UpdateSelectionBounds() { |
1768 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); | 1769 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); |
1769 if (!webwidget_) | 1770 if (!GetWebWidget()) |
1770 return; | 1771 return; |
1771 if (ime_event_guard_) | 1772 if (ime_event_guard_) |
1772 return; | 1773 return; |
1773 | 1774 |
1774 #if defined(USE_AURA) | 1775 #if defined(USE_AURA) |
1775 // TODO(mohsen): For now, always send explicit selection IPC notifications for | 1776 // TODO(mohsen): For now, always send explicit selection IPC notifications for |
1776 // Aura beucause composited selection updates are not working for webview tags | 1777 // Aura beucause composited selection updates are not working for webview tags |
1777 // which regresses IME inside webview. Remove this when composited selection | 1778 // which regresses IME inside webview. Remove this when composited selection |
1778 // updates are fixed for webviews. See, http://crbug.com/510568. | 1779 // updates are fixed for webviews. See, http://crbug.com/510568. |
1779 bool send_ipc = true; | 1780 bool send_ipc = true; |
1780 #else | 1781 #else |
1781 // With composited selection updates, the selection bounds will be reported | 1782 // With composited selection updates, the selection bounds will be reported |
1782 // directly by the compositor, in which case explicit IPC selection | 1783 // directly by the compositor, in which case explicit IPC selection |
1783 // notifications should be suppressed. | 1784 // notifications should be suppressed. |
1784 bool send_ipc = | 1785 bool send_ipc = |
1785 !blink::WebRuntimeFeatures::isCompositedSelectionUpdateEnabled(); | 1786 !blink::WebRuntimeFeatures::isCompositedSelectionUpdateEnabled(); |
1786 #endif | 1787 #endif |
1787 if (send_ipc) { | 1788 if (send_ipc) { |
1788 ViewHostMsg_SelectionBounds_Params params; | 1789 ViewHostMsg_SelectionBounds_Params params; |
1789 GetSelectionBounds(¶ms.anchor_rect, ¶ms.focus_rect); | 1790 GetSelectionBounds(¶ms.anchor_rect, ¶ms.focus_rect); |
1790 if (selection_anchor_rect_ != params.anchor_rect || | 1791 if (selection_anchor_rect_ != params.anchor_rect || |
1791 selection_focus_rect_ != params.focus_rect) { | 1792 selection_focus_rect_ != params.focus_rect) { |
1792 selection_anchor_rect_ = params.anchor_rect; | 1793 selection_anchor_rect_ = params.anchor_rect; |
1793 selection_focus_rect_ = params.focus_rect; | 1794 selection_focus_rect_ = params.focus_rect; |
1794 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); | 1795 GetWebWidget()->selectionTextDirection(params.focus_dir, |
1795 params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); | 1796 params.anchor_dir); |
| 1797 params.is_anchor_first = GetWebWidget()->isSelectionAnchorFirst(); |
1796 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); | 1798 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); |
1797 } | 1799 } |
1798 } | 1800 } |
1799 | 1801 |
1800 UpdateCompositionInfo(false /* not an immediate request */); | 1802 UpdateCompositionInfo(false /* not an immediate request */); |
1801 } | 1803 } |
1802 | 1804 |
1803 void RenderWidget::SetDeviceColorProfileForTesting( | 1805 void RenderWidget::SetDeviceColorProfileForTesting( |
1804 const std::vector<char>& color_profile) { | 1806 const std::vector<char>& color_profile) { |
1805 SetDeviceColorProfile(color_profile); | 1807 SetDeviceColorProfile(color_profile); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 void RenderWidget::GetCompositionCharacterBounds( | 1865 void RenderWidget::GetCompositionCharacterBounds( |
1864 std::vector<gfx::Rect>* bounds) { | 1866 std::vector<gfx::Rect>* bounds) { |
1865 DCHECK(bounds); | 1867 DCHECK(bounds); |
1866 bounds->clear(); | 1868 bounds->clear(); |
1867 | 1869 |
1868 #if defined(ENABLE_PLUGINS) | 1870 #if defined(ENABLE_PLUGINS) |
1869 if (focused_pepper_plugin_) | 1871 if (focused_pepper_plugin_) |
1870 return; | 1872 return; |
1871 #endif | 1873 #endif |
1872 | 1874 |
1873 if (!webwidget_) | 1875 if (!GetWebWidget()) |
1874 return; | 1876 return; |
1875 blink::WebVector<blink::WebRect> bounds_from_blink; | 1877 blink::WebVector<blink::WebRect> bounds_from_blink; |
1876 if (!webwidget_->getCompositionCharacterBounds(bounds_from_blink)) | 1878 if (!GetWebWidget()->getCompositionCharacterBounds(bounds_from_blink)) |
1877 return; | 1879 return; |
1878 | 1880 |
1879 for (size_t i = 0; i < bounds_from_blink.size(); ++i) { | 1881 for (size_t i = 0; i < bounds_from_blink.size(); ++i) { |
1880 convertViewportToWindow(&bounds_from_blink[i]); | 1882 convertViewportToWindow(&bounds_from_blink[i]); |
1881 bounds->push_back(bounds_from_blink[i]); | 1883 bounds->push_back(bounds_from_blink[i]); |
1882 } | 1884 } |
1883 } | 1885 } |
1884 | 1886 |
1885 void RenderWidget::GetCompositionRange(gfx::Range* range) { | 1887 void RenderWidget::GetCompositionRange(gfx::Range* range) { |
1886 #if defined(ENABLE_PLUGINS) | 1888 #if defined(ENABLE_PLUGINS) |
1887 if (focused_pepper_plugin_) | 1889 if (focused_pepper_plugin_) |
1888 return; | 1890 return; |
1889 #endif | 1891 #endif |
1890 WebRange web_range = webwidget_->compositionRange(); | 1892 WebRange web_range = GetWebWidget()->compositionRange(); |
1891 if (!web_range.isNull()) { | 1893 if (!web_range.isNull()) { |
1892 range->set_start(web_range.startOffset()); | 1894 range->set_start(web_range.startOffset()); |
1893 range->set_end(web_range.endOffset()); | 1895 range->set_end(web_range.endOffset()); |
1894 } else { | 1896 } else { |
1895 web_range = webwidget_->caretOrSelectionRange(); | 1897 web_range = GetWebWidget()->caretOrSelectionRange(); |
1896 range->set_start(web_range.startOffset()); | 1898 range->set_start(web_range.startOffset()); |
1897 range->set_end(web_range.endOffset()); | 1899 range->set_end(web_range.endOffset()); |
1898 } | 1900 } |
1899 } | 1901 } |
1900 | 1902 |
1901 bool RenderWidget::ShouldUpdateCompositionInfo( | 1903 bool RenderWidget::ShouldUpdateCompositionInfo( |
1902 const gfx::Range& range, | 1904 const gfx::Range& range, |
1903 const std::vector<gfx::Rect>& bounds) { | 1905 const std::vector<gfx::Rect>& bounds) { |
1904 if (composition_range_ != range) | 1906 if (composition_range_ != range) |
1905 return true; | 1907 return true; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 return web_screen_info; | 1956 return web_screen_info; |
1955 } | 1957 } |
1956 | 1958 |
1957 void RenderWidget::resetInputMethod() { | 1959 void RenderWidget::resetInputMethod() { |
1958 ImeEventGuard guard(this); | 1960 ImeEventGuard guard(this); |
1959 // If the last text input type is not None, then we should finish any | 1961 // If the last text input type is not None, then we should finish any |
1960 // ongoing composition regardless of the new text input type. | 1962 // ongoing composition regardless of the new text input type. |
1961 if (text_input_info_.type != blink::WebTextInputTypeNone) { | 1963 if (text_input_info_.type != blink::WebTextInputTypeNone) { |
1962 // If a composition text exists, then we need to let the browser process | 1964 // If a composition text exists, then we need to let the browser process |
1963 // to cancel the input method's ongoing composition session. | 1965 // to cancel the input method's ongoing composition session. |
1964 if (webwidget_->confirmComposition()) | 1966 if (GetWebWidget()->confirmComposition()) |
1965 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1967 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
1966 } | 1968 } |
1967 | 1969 |
1968 UpdateCompositionInfo(false /* not an immediate request */); | 1970 UpdateCompositionInfo(false /* not an immediate request */); |
1969 } | 1971 } |
1970 | 1972 |
1971 #if defined(OS_ANDROID) | 1973 #if defined(OS_ANDROID) |
1972 void RenderWidget::showUnhandledTapUIIfNeeded( | 1974 void RenderWidget::showUnhandledTapUIIfNeeded( |
1973 const WebPoint& tapped_position, | 1975 const WebPoint& tapped_position, |
1974 const WebNode& tapped_node, | 1976 const WebNode& tapped_node, |
(...skipping 11 matching lines...) Expand all Loading... |
1986 | 1988 |
1987 void RenderWidget::didHandleGestureEvent( | 1989 void RenderWidget::didHandleGestureEvent( |
1988 const WebGestureEvent& event, | 1990 const WebGestureEvent& event, |
1989 bool event_cancelled) { | 1991 bool event_cancelled) { |
1990 #if defined(OS_ANDROID) || defined(USE_AURA) | 1992 #if defined(OS_ANDROID) || defined(USE_AURA) |
1991 if (event_cancelled) | 1993 if (event_cancelled) |
1992 return; | 1994 return; |
1993 if (event.type == WebInputEvent::GestureTap) { | 1995 if (event.type == WebInputEvent::GestureTap) { |
1994 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 1996 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
1995 } else if (event.type == WebInputEvent::GestureLongPress) { | 1997 } else if (event.type == WebInputEvent::GestureLongPress) { |
1996 DCHECK(webwidget_); | 1998 DCHECK(GetWebWidget()); |
1997 if (webwidget_->textInputInfo().value.isEmpty()) | 1999 if (GetWebWidget()->textInputInfo().value.isEmpty()) |
1998 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 2000 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
1999 else | 2001 else |
2000 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 2002 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
2001 } | 2003 } |
2002 #endif | 2004 #endif |
2003 } | 2005 } |
2004 | 2006 |
2005 void RenderWidget::didOverscroll( | 2007 void RenderWidget::didOverscroll( |
2006 const blink::WebFloatSize& overscrollDelta, | 2008 const blink::WebFloatSize& overscrollDelta, |
2007 const blink::WebFloatSize& accumulatedOverscroll, | 2009 const blink::WebFloatSize& accumulatedOverscroll, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 | 2127 |
2126 void RenderWidget::requestPointerUnlock() { | 2128 void RenderWidget::requestPointerUnlock() { |
2127 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2129 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
2128 } | 2130 } |
2129 | 2131 |
2130 bool RenderWidget::isPointerLocked() { | 2132 bool RenderWidget::isPointerLocked() { |
2131 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2133 return mouse_lock_dispatcher_->IsMouseLockedTo( |
2132 webwidget_mouse_lock_target_.get()); | 2134 webwidget_mouse_lock_target_.get()); |
2133 } | 2135 } |
2134 | 2136 |
| 2137 blink::WebWidget* RenderWidget::GetWebWidget() const { |
| 2138 return webwidget_internal_; |
| 2139 } |
| 2140 |
2135 } // namespace content | 2141 } // namespace content |
OLD | NEW |