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

Side by Side Diff: content/renderer/render_widget.cc

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed ImeTest#testDoesNotHang_rendererCrashes which does not test anything 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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) 470 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
471 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 471 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
472 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 472 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
473 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 473 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
474 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 474 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
475 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace) 475 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace)
476 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests, 476 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests,
477 OnWaitNextFrameForTests) 477 OnWaitNextFrameForTests)
478 #if defined(OS_ANDROID) 478 #if defined(OS_ANDROID)
479 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) 479 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck)
480 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate,
481 OnRequestTextInputStateUpdate)
480 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) 482 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
481 #endif 483 #endif
482 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto) 484 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
483 IPC_MESSAGE_UNHANDLED(handled = false) 485 IPC_MESSAGE_UNHANDLED(handled = false)
484 IPC_END_MESSAGE_MAP() 486 IPC_END_MESSAGE_MAP()
485 return handled; 487 return handled;
486 } 488 }
487 489
488 bool RenderWidget::Send(IPC::Message* message) { 490 bool RenderWidget::Send(IPC::Message* message) {
489 // Don't send any messages after the browser has told us to close, and filter 491 // Don't send any messages after the browser has told us to close, and filter
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 blink::WebTextInputInfo new_info; 993 blink::WebTextInputInfo new_info;
992 if (webwidget_) 994 if (webwidget_)
993 new_info = webwidget_->textInputInfo(); 995 new_info = webwidget_->textInputInfo();
994 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); 996 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode);
995 997
996 bool new_can_compose_inline = CanComposeInline(); 998 bool new_can_compose_inline = CanComposeInline();
997 999
998 // Only sends text input params if they are changed or if the ime should be 1000 // Only sends text input params if they are changed or if the ime should be
999 // shown. 1001 // shown.
1000 if (show_ime == ShowIme::IF_NEEDED || 1002 if (show_ime == ShowIme::IF_NEEDED ||
1003 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) ||
1001 (text_input_type_ != new_type || text_input_mode_ != new_mode || 1004 (text_input_type_ != new_type || text_input_mode_ != new_mode ||
1002 text_input_info_ != new_info || 1005 text_input_info_ != new_info ||
1003 can_compose_inline_ != new_can_compose_inline) 1006 can_compose_inline_ != new_can_compose_inline)
1004 #if defined(OS_ANDROID) 1007 #if defined(OS_ANDROID)
1005 || text_field_is_dirty_ 1008 || text_field_is_dirty_
1006 #endif 1009 #endif
1007 ) { 1010 ) {
1008 ViewHostMsg_TextInputState_Params params; 1011 ViewHostMsg_TextInputState_Params params;
1009 params.type = new_type; 1012 params.type = new_type;
1010 params.mode = new_mode; 1013 params.mode = new_mode;
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 1604
1602 #if defined(OS_ANDROID) 1605 #if defined(OS_ANDROID)
1603 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { 1606 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) {
1604 text_input_info_history_.push_back(info); 1607 text_input_info_history_.push_back(info);
1605 } 1608 }
1606 1609
1607 void RenderWidget::OnImeEventAck() { 1610 void RenderWidget::OnImeEventAck() {
1608 DCHECK_GE(text_input_info_history_.size(), 1u); 1611 DCHECK_GE(text_input_info_history_.size(), 1u);
1609 text_input_info_history_.pop_front(); 1612 text_input_info_history_.pop_front();
1610 } 1613 }
1614
1615 void RenderWidget::OnRequestTextInputStateUpdate() {
1616 DCHECK(!ime_event_guard_);
1617 UpdateSelectionBounds();
1618 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME);
1619 }
1611 #endif 1620 #endif
1612 1621
1613 bool RenderWidget::ShouldHandleImeEvent() { 1622 bool RenderWidget::ShouldHandleImeEvent() {
1614 #if defined(OS_ANDROID) 1623 #if defined(OS_ANDROID)
1615 if (!webwidget_) 1624 if (!webwidget_)
1616 return false; 1625 return false;
1626 if (IsUsingImeThread())
1627 return true;
1617 1628
1618 // We cannot handle IME events if there is any chance that the event we are 1629 // We cannot handle IME events if there is any chance that the event we are
1619 // receiving here from the browser is based on the state that is different 1630 // receiving here from the browser is based on the state that is different
1620 // from our current one as indicated by |text_input_info_|. 1631 // from our current one as indicated by |text_input_info_|.
1621 // The states the browser might be in are: 1632 // The states the browser might be in are:
1622 // text_input_info_history_[0] - current state ack'd by browser 1633 // text_input_info_history_[0] - current state ack'd by browser
1623 // text_input_info_history_[1...N] - pending state changes 1634 // text_input_info_history_[1...N] - pending state changes
1624 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { 1635 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) {
1625 if (text_input_info_history_[i] != text_input_info_) 1636 if (text_input_info_history_[i] != text_input_info_)
1626 return false; 1637 return false;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 } 1710 }
1700 1711
1701 void RenderWidget::set_next_paint_is_resize_ack() { 1712 void RenderWidget::set_next_paint_is_resize_ack() {
1702 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; 1713 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
1703 } 1714 }
1704 1715
1705 void RenderWidget::set_next_paint_is_repaint_ack() { 1716 void RenderWidget::set_next_paint_is_repaint_ack() {
1706 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; 1717 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
1707 } 1718 }
1708 1719
1720 bool RenderWidget::IsUsingImeThread() {
1721 #if defined(OS_ANDROID)
1722 return base::CommandLine::ForCurrentProcess()->HasSwitch(
1723 switches::kEnableImeThread) &&
1724 !base::CommandLine::ForCurrentProcess()->HasSwitch(
1725 switches::kDisableImeThread);
1726 #else
1727 return false;
1728 #endif
1729 }
1730
1709 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { 1731 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) {
1710 if (!ime_event_guard_) 1732 if (!ime_event_guard_)
1711 ime_event_guard_ = guard; 1733 ime_event_guard_ = guard;
1712 } 1734 }
1713 1735
1714 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { 1736 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
1715 if (ime_event_guard_ != guard) { 1737 if (ime_event_guard_ != guard) {
1716 #if defined(OS_ANDROID) 1738 #if defined(OS_ANDROID)
1717 // In case a from-IME event (e.g. touch) ends up in not-from-IME event 1739 // In case a from-IME event (e.g. touch) ends up in not-from-IME event
1718 // (e.g. long press gesture), we want to treat it as not-from-IME event 1740 // (e.g. long press gesture), we want to treat it as not-from-IME event
1719 // so that AdapterInputConnection can make changes to its Editable model. 1741 // so that ReplicaInputConnection can make changes to its Editable model.
1720 // Therefore, we want to mark this text state update as 'from IME' only 1742 // Therefore, we want to mark this text state update as 'from IME' only
1721 // when all the nested events are all originating from IME. 1743 // when all the nested events are all originating from IME.
1722 ime_event_guard_->set_from_ime( 1744 ime_event_guard_->set_from_ime(
1723 ime_event_guard_->from_ime() && guard->from_ime()); 1745 ime_event_guard_->from_ime() && guard->from_ime());
1724 #endif 1746 #endif
1725 return; 1747 return;
1726 } 1748 }
1727 ime_event_guard_ = nullptr; 1749 ime_event_guard_ = nullptr;
1728 1750
1729 // While handling an ime event, text input state and selection bounds updates 1751 // While handling an ime event, text input state and selection bounds updates
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) 2016 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart)
1995 return; 2017 return;
1996 2018
1997 content::TouchAction content_touch_action = 2019 content::TouchAction content_touch_action =
1998 static_cast<content::TouchAction>(web_touch_action); 2020 static_cast<content::TouchAction>(web_touch_action);
1999 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); 2021 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action));
2000 } 2022 }
2001 2023
2002 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { 2024 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() {
2003 #if defined(OS_ANDROID) 2025 #if defined(OS_ANDROID)
2004 text_field_is_dirty_ = true; 2026 if (!IsUsingImeThread())
2027 text_field_is_dirty_ = true;
2005 #endif 2028 #endif
2006 } 2029 }
2007 2030
2008 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 2031 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
2009 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { 2032 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) {
2010 // Explicitly disable antialiasing for the compositor. As of the time of 2033 // Explicitly disable antialiasing for the compositor. As of the time of
2011 // this writing, the only platform that supported antialiasing for the 2034 // this writing, the only platform that supported antialiasing for the
2012 // compositor was Mac OS X, because the on-screen OpenGL context creation 2035 // compositor was Mac OS X, because the on-screen OpenGL context creation
2013 // code paths on Windows and Linux didn't yet have multisampling support. 2036 // code paths on Windows and Linux didn't yet have multisampling support.
2014 // Mac OS X essentially always behaves as though it's rendering offscreen. 2037 // Mac OS X essentially always behaves as though it's rendering offscreen.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 video_hole_frames_.RemoveObserver(frame); 2111 video_hole_frames_.RemoveObserver(frame);
2089 } 2112 }
2090 #endif // defined(VIDEO_HOLE) 2113 #endif // defined(VIDEO_HOLE)
2091 2114
2092 void RenderWidget::OnWaitNextFrameForTests(int routing_id) { 2115 void RenderWidget::OnWaitNextFrameForTests(int routing_id) {
2093 QueueMessage(new ViewHostMsg_WaitForNextFrameForTests_ACK(routing_id), 2116 QueueMessage(new ViewHostMsg_WaitForNextFrameForTests_ACK(routing_id),
2094 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); 2117 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
2095 } 2118 }
2096 2119
2097 } // namespace content 2120 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698