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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 1652483002: Browser Side Text Input State Tracking for OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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/renderer_host/render_widget_host_view_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 9 #include "content/browser/accessibility/browser_accessibility_manager.h"
10 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 11 #include "content/browser/gpu/gpu_data_manager_impl.h"
11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" 12 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 13 #include "content/browser/renderer_host/render_process_host_impl.h"
14 #include "content/browser/renderer_host/render_view_host_delegate.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h" 16 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/common/content_switches_internal.h" 17 #include "content/common/content_switches_internal.h"
18 #include "content/common/view_messages.h"
15 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 19 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
20 #include "content/public/common/browser_plugin_guest_mode.h"
16 #include "ui/gfx/display.h" 21 #include "ui/gfx/display.h"
17 #include "ui/gfx/geometry/point_conversions.h" 22 #include "ui/gfx/geometry/point_conversions.h"
18 #include "ui/gfx/geometry/size_conversions.h" 23 #include "ui/gfx/geometry/size_conversions.h"
19 #include "ui/gfx/geometry/size_f.h" 24 #include "ui/gfx/geometry/size_f.h"
20 #include "ui/gfx/screen.h" 25 #include "ui/gfx/screen.h"
21 26
22 #if defined(OS_WIN) 27 #if defined(OS_WIN)
23 #include "base/command_line.h" 28 #include "base/command_line.h"
24 #include "base/message_loop/message_loop.h" 29 #include "base/message_loop/message_loop.h"
25 #include "base/win/wrapped_window_proc.h" 30 #include "base/win/wrapped_window_proc.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 : popup_type_(blink::WebPopupTypeNone), 375 : popup_type_(blink::WebPopupTypeNone),
371 background_color_(SK_ColorWHITE), 376 background_color_(SK_ColorWHITE),
372 mouse_locked_(false), 377 mouse_locked_(false),
373 showing_context_menu_(false), 378 showing_context_menu_(false),
374 selection_text_offset_(0), 379 selection_text_offset_(0),
375 selection_range_(gfx::Range::InvalidRange()), 380 selection_range_(gfx::Range::InvalidRange()),
376 current_device_scale_factor_(0), 381 current_device_scale_factor_(0),
377 current_display_rotation_(gfx::Display::ROTATE_0), 382 current_display_rotation_(gfx::Display::ROTATE_0),
378 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), 383 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()),
379 renderer_frame_number_(0), 384 renderer_frame_number_(0),
385 text_input_state_(new TextInputState),
386 cached_text_input_state_(text_input_state_.get()),
387 focused_guest_rwhv_(nullptr),
380 weak_factory_(this) { 388 weak_factory_(this) {
389 text_input_state_->can_compose_inline = true;
381 } 390 }
382 391
383 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { 392 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() {
384 DCHECK(!mouse_locked_); 393 DCHECK(!mouse_locked_);
385 } 394 }
386 395
387 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ 396 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){
388 return false; 397 return false;
389 } 398 }
390 399
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 current_display_rotation_ == display.rotation()) { 549 current_display_rotation_ == display.rotation()) {
541 return false; 550 return false;
542 } 551 }
543 552
544 current_display_area_ = display.work_area(); 553 current_display_area_ = display.work_area();
545 current_device_scale_factor_ = display.device_scale_factor(); 554 current_device_scale_factor_ = display.device_scale_factor();
546 current_display_rotation_ = display.rotation(); 555 current_display_rotation_ = display.rotation();
547 return true; 556 return true;
548 } 557 }
549 558
559 RenderFrameHostImpl* RenderWidgetHostViewBase::GetFocusedFrame() const {
560 RenderViewHost* rvh =
561 RenderViewHost::From(RenderWidgetHostImpl::From(GetRenderWidgetHost()));
562 if (!rvh)
563 return nullptr;
564
565 FrameTreeNode* focused_frame =
566 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame();
567 if (!focused_frame)
568 return nullptr;
569
570 return focused_frame->current_frame_host();
571 }
572
550 base::WeakPtr<RenderWidgetHostViewBase> RenderWidgetHostViewBase::GetWeakPtr() { 573 base::WeakPtr<RenderWidgetHostViewBase> RenderWidgetHostViewBase::GetWeakPtr() {
551 return weak_factory_.GetWeakPtr(); 574 return weak_factory_.GetWeakPtr();
552 } 575 }
553 576
554 scoped_ptr<SyntheticGestureTarget> 577 scoped_ptr<SyntheticGestureTarget>
555 RenderWidgetHostViewBase::CreateSyntheticGestureTarget() { 578 RenderWidgetHostViewBase::CreateSyntheticGestureTarget() {
556 RenderWidgetHostImpl* host = 579 RenderWidgetHostImpl* host =
557 RenderWidgetHostImpl::From(GetRenderWidgetHost()); 580 RenderWidgetHostImpl::From(GetRenderWidgetHost());
558 return scoped_ptr<SyntheticGestureTarget>( 581 return scoped_ptr<SyntheticGestureTarget>(
559 new SyntheticGestureTargetBase(host)); 582 new SyntheticGestureTargetBase(host));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 gfx::ToRoundedPoint(point))); 717 gfx::ToRoundedPoint(point)));
695 } 718 }
696 719
697 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( 720 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace(
698 const gfx::Point& point, 721 const gfx::Point& point,
699 cc::SurfaceId original_surface, 722 cc::SurfaceId original_surface,
700 gfx::Point* transformed_point) { 723 gfx::Point* transformed_point) {
701 *transformed_point = point; 724 *transformed_point = point;
702 } 725 }
703 726
727 void RenderWidgetHostViewBase::TextInputStateChanged(
728 const ViewHostMsg_TextInputState_Params& params) {
729 if (text_input_state_->type != params.type ||
730 #ifndef OS_MACOSX
731 text_input_state_->mode != params.mode ||
732 text_input_state_->flags != params.flags ||
733 #endif
734 text_input_state_->can_compose_inline != params.can_compose_inline) {
735 *text_input_state_ = params;
736 NotifyTextInputStateChanged();
737 }
738 }
739
740 const TextInputState* RenderWidgetHostViewBase::FindCurrentTextInputState() {
741 if (!ShouldObtainTextInputStateFromSubFrameViews())
kenrb 2016/02/01 20:12:43 Why is this needed? Can't you just compare GetFocu
EhsanK 2016/02/12 15:46:59 Good point! I removed this part and all other code
742 return text_input_state_.get();
743
744 // TODO(ekaramad): This is for out of process contents based on BrowserPlugin.
745 // Remove this block when BrowserPlugin is removed.
746 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests())
747 if (focused_guest_rwhv_)
748 return focused_guest_rwhv_->current_text_input_state();
749
750 const TextInputState* state = text_input_state_.get();
751 RenderFrameHostImpl* rfhi = GetFocusedFrame();
752 // TODO(ekaramd): Remove the RVH part when it goes away.
753 if (rfhi) {
754 RenderWidgetHostViewBase* focused_view = nullptr;
755 if (rfhi->GetRenderWidgetHost())
756 focused_view = rfhi->GetRenderWidgetHost()->GetView();
757 else if (rfhi->GetRenderViewHost())
758 focused_view =
759 RenderWidgetHostImpl::From(rfhi->GetRenderViewHost()->GetWidget())
760 ->GetView();
761 if (focused_view && focused_view != this) {
762 DCHECK(!focused_view->ShouldObtainTextInputStateFromSubFrameViews());
763 state = focused_view->FindCurrentTextInputState();
764 }
765 }
766 return state;
767 }
768
769 void RenderWidgetHostViewBase::NotifyGuestTextInputStateChanged(
770 RenderWidgetHostViewBase* guest_rwhv) {
771 if (guest_rwhv->current_text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE)
772 focused_guest_rwhv_ = guest_rwhv;
773 else if (focused_guest_rwhv_ == guest_rwhv)
774 focused_guest_rwhv_ = nullptr;
775 NotifyTextInputStateChanged();
776 }
777
778 void RenderWidgetHostViewBase::NotifyTextInputStateChanged() {
kenrb 2016/02/01 20:12:43 Does this need to be called when the focused frame
EhsanK 2016/02/12 15:46:59 This is called whenever after a ViewHostMsg_TextIn
779 cached_text_input_state_ = FindCurrentTextInputState();
780 }
781
782 bool RenderWidgetHostViewBase::ShouldObtainTextInputStateFromSubFrameViews()
783 const {
784 return true;
785 }
786
704 } // namespace content 787 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698