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

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

Issue 1934423002: [NOT FOR REVIEW] [reland] Browser Side Text Input State Tracking for OOPIF (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enhancing code Created 4 years, 7 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_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 bool is_guest_view_hack) 363 bool is_guest_view_hack)
364 : host_(RenderWidgetHostImpl::From(host)), 364 : host_(RenderWidgetHostImpl::From(host)),
365 window_(nullptr), 365 window_(nullptr),
366 delegated_frame_host_(new DelegatedFrameHost(this)), 366 delegated_frame_host_(new DelegatedFrameHost(this)),
367 in_shutdown_(false), 367 in_shutdown_(false),
368 in_bounds_changed_(false), 368 in_bounds_changed_(false),
369 is_fullscreen_(false), 369 is_fullscreen_(false),
370 popup_parent_host_view_(nullptr), 370 popup_parent_host_view_(nullptr),
371 popup_child_host_view_(nullptr), 371 popup_child_host_view_(nullptr),
372 is_loading_(false), 372 is_loading_(false),
373 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
374 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
375 text_input_flags_(0),
376 can_compose_inline_(true),
377 has_composition_text_(false), 373 has_composition_text_(false),
378 accept_return_character_(false), 374 accept_return_character_(false),
379 begin_frame_source_(nullptr), 375 begin_frame_source_(nullptr),
380 needs_begin_frames_(false), 376 needs_begin_frames_(false),
381 synthetic_move_sent_(false), 377 synthetic_move_sent_(false),
382 cursor_visibility_state_in_renderer_(UNKNOWN), 378 cursor_visibility_state_in_renderer_(UNKNOWN),
383 #if defined(OS_WIN) 379 #if defined(OS_WIN)
384 legacy_render_widget_host_HWND_(nullptr), 380 legacy_render_widget_host_HWND_(nullptr),
385 legacy_window_destroyed_(false), 381 legacy_window_destroyed_(false),
386 #endif 382 #endif
387 has_snapped_to_boundary_(false), 383 has_snapped_to_boundary_(false),
388 is_guest_view_hack_(is_guest_view_hack), 384 is_guest_view_hack_(is_guest_view_hack),
389 set_focus_on_mouse_down_or_key_event_(false), 385 set_focus_on_mouse_down_or_key_event_(false),
390 device_scale_factor_(0.0f), 386 device_scale_factor_(0.0f),
391 disable_input_event_router_for_testing_(false), 387 disable_input_event_router_for_testing_(false),
392 weak_ptr_factory_(this) { 388 weak_ptr_factory_(this) {
393 if (!is_guest_view_hack_) 389 if (!is_guest_view_hack_)
394 host_->SetView(this); 390 host_->SetView(this);
395 391
396 // Let the page-level input event router know about our surface ID 392 // Let the page-level input event router know about our surface ID
397 // namespace for surface-based hit testing. 393 // namespace for surface-based hit testing.
398 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 394 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) {
399 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( 395 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner(
400 GetSurfaceIdNamespace(), this); 396 GetSurfaceIdNamespace(), this);
397
398 text_input_manager_ = GetTextInputManager();
399 DCHECK(text_input_manager_);
401 } 400 }
402 401
403 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> 402 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()->
404 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 403 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
405 SetOverscrollControllerEnabled(overscroll_enabled); 404 SetOverscrollControllerEnabled(overscroll_enabled);
406 405
407 selection_controller_client_.reset( 406 selection_controller_client_.reset(
408 new TouchSelectionControllerClientAura(this)); 407 new TouchSelectionControllerClientAura(this));
409 CreateSelectionController(); 408 CreateSelectionController();
410 } 409 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); 869 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
871 current_cursor_.SetDisplayInfo(display); 870 current_cursor_.SetDisplayInfo(display);
872 UpdateCursorIfOverSelf(); 871 UpdateCursorIfOverSelf();
873 } 872 }
874 873
875 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { 874 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) {
876 is_loading_ = is_loading; 875 is_loading_ = is_loading;
877 UpdateCursorIfOverSelf(); 876 UpdateCursorIfOverSelf();
878 } 877 }
879 878
880 void RenderWidgetHostViewAura::TextInputStateChanged(
881 const TextInputState& params) {
882 if (text_input_type_ != params.type ||
883 text_input_mode_ != params.mode ||
884 can_compose_inline_ != params.can_compose_inline ||
885 text_input_flags_ != params.flags) {
886 text_input_type_ = params.type;
887 text_input_mode_ = params.mode;
888 can_compose_inline_ = params.can_compose_inline;
889 text_input_flags_ = params.flags;
890 if (GetInputMethod())
891 GetInputMethod()->OnTextInputTypeChanged(this);
892 }
893 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
894 if (GetInputMethod())
895 GetInputMethod()->ShowImeIfNeeded();
896 }
897 }
898
899 void RenderWidgetHostViewAura::ImeCancelComposition() { 879 void RenderWidgetHostViewAura::ImeCancelComposition() {
900 if (GetInputMethod()) 880 if (GetInputMethod())
901 GetInputMethod()->CancelComposition(this); 881 GetInputMethod()->CancelComposition(this);
902 has_composition_text_ = false; 882 has_composition_text_ = false;
903 } 883 }
904 884
905 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( 885 void RenderWidgetHostViewAura::ImeCompositionRangeChanged(
906 const gfx::Range& range, 886 const gfx::Range& range,
907 const std::vector<gfx::Rect>& character_bounds) { 887 const std::vector<gfx::Rect>& character_bounds) {
908 composition_character_bounds_ = character_bounds; 888 composition_character_bounds_ = character_bounds;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 } 1470 }
1491 1471
1492 void RenderWidgetHostViewAura::ClearCompositionText() { 1472 void RenderWidgetHostViewAura::ClearCompositionText() {
1493 // TODO(wjmaclean): can host_ ever be null? 1473 // TODO(wjmaclean): can host_ ever be null?
1494 if (host_ && has_composition_text_) 1474 if (host_ && has_composition_text_)
1495 host_->ImeCancelComposition(); 1475 host_->ImeCancelComposition();
1496 has_composition_text_ = false; 1476 has_composition_text_ = false;
1497 } 1477 }
1498 1478
1499 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { 1479 void RenderWidgetHostViewAura::InsertText(const base::string16& text) {
1500 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); 1480 DCHECK(GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE);
1481
1501 // TODO(wjmaclean): can host_ ever be null? 1482 // TODO(wjmaclean): can host_ ever be null?
1502 if (host_) 1483 if (host_)
1503 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); 1484 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false);
1504 has_composition_text_ = false; 1485 has_composition_text_ = false;
1505 } 1486 }
1506 1487
1507 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { 1488 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) {
1508 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1489 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1509 popup_child_host_view_->InsertChar(event); 1490 popup_child_host_view_->InsertChar(event);
1510 return; 1491 return;
1511 } 1492 }
1512 1493
1513 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 1494 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547
1514 // TODO(wjmaclean): can host_ ever be null? 1495 // TODO(wjmaclean): can host_ ever be null?
1515 if (host_ && 1496 if (host_ &&
1516 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) { 1497 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) {
1517 // Send a blink::WebInputEvent::Char event to |host_|. 1498 // Send a blink::WebInputEvent::Char event to |host_|.
1518 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter())); 1499 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter()));
1519 } 1500 }
1520 } 1501 }
1521 1502
1522 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { 1503 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const {
1523 return text_input_type_; 1504 if (text_input_manager_ && text_input_manager_->GetTextInputState())
1505 return text_input_manager_->GetTextInputState()->type;
1506 return ui::TEXT_INPUT_TYPE_NONE;
1524 } 1507 }
1525 1508
1526 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const { 1509 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const {
1527 return text_input_mode_; 1510 if (text_input_manager_ && text_input_manager_->GetTextInputState())
1511 return text_input_manager_->GetTextInputState()->mode;
1512 return ui::TEXT_INPUT_MODE_DEFAULT;
1528 } 1513 }
1529 1514
1530 int RenderWidgetHostViewAura::GetTextInputFlags() const { 1515 int RenderWidgetHostViewAura::GetTextInputFlags() const {
1531 return text_input_flags_; 1516 if (text_input_manager_ && text_input_manager_->GetTextInputState())
1517 return text_input_manager_->GetTextInputState()->flags;
1518 return 0;
1532 } 1519 }
1533 1520
1534 bool RenderWidgetHostViewAura::CanComposeInline() const { 1521 bool RenderWidgetHostViewAura::CanComposeInline() const {
1535 return can_compose_inline_; 1522 if (text_input_manager_ && text_input_manager_->GetTextInputState())
1523 return text_input_manager_->GetTextInputState()->can_compose_inline;
1524 return true;
1536 } 1525 }
1537 1526
1538 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( 1527 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(
1539 const gfx::Rect& rect) const { 1528 const gfx::Rect& rect) const {
1540 gfx::Point origin = rect.origin(); 1529 gfx::Point origin = rect.origin();
1541 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 1530 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
1542 1531
1543 aura::Window* root_window = window_->GetRootWindow(); 1532 aura::Window* root_window = window_->GetRootWindow();
1544 if (!root_window) 1533 if (!root_window)
1545 return rect; 1534 return rect;
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 } 2935 }
2947 2936
2948 uint32_t RenderWidgetHostViewAura::GetSurfaceIdNamespace() { 2937 uint32_t RenderWidgetHostViewAura::GetSurfaceIdNamespace() {
2949 return delegated_frame_host_->GetSurfaceIdNamespace(); 2938 return delegated_frame_host_->GetSurfaceIdNamespace();
2950 } 2939 }
2951 2940
2952 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { 2941 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const {
2953 return delegated_frame_host_->SurfaceIdForTesting(); 2942 return delegated_frame_host_->SurfaceIdForTesting();
2954 } 2943 }
2955 2944
2945 void RenderWidgetHostViewAura::OnTextInputStateUpdated(
2946 TextInputManager* text_input_manager,
2947 RenderWidgetHostViewBase* updated_view,
2948 bool changed) {
2949 DCHECK(GetTextInputManager() == text_input_manager);
2950 if (!GetInputMethod())
2951 return;
2952
2953 if (changed)
2954 GetInputMethod()->OnTextInputTypeChanged(this);
2955
2956 const TextInputState* state = GetTextInputManager()->GetTextInputState();
2957
2958 if (state && state->show_ime_if_needed &&
2959 state->type != ui::TEXT_INPUT_TYPE_NONE)
2960 GetInputMethod()->ShowImeIfNeeded();
2961 }
2962
2956 //////////////////////////////////////////////////////////////////////////////// 2963 ////////////////////////////////////////////////////////////////////////////////
2957 // RenderWidgetHostViewBase, public: 2964 // RenderWidgetHostViewBase, public:
2958 2965
2959 // static 2966 // static
2960 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2967 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2961 GetScreenInfoForWindow(results, NULL); 2968 GetScreenInfoForWindow(results, NULL);
2962 } 2969 }
2963 2970
2964 } // namespace content 2971 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698