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

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

Issue 18750003: Require ACK for editor-related changes not originating from browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compile warning on windows Created 7 years, 5 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 can_compose_inline_(true), 173 can_compose_inline_(true),
174 popup_type_(popup_type), 174 popup_type_(popup_type),
175 pending_window_rect_count_(0), 175 pending_window_rect_count_(0),
176 suppress_next_char_events_(false), 176 suppress_next_char_events_(false),
177 is_accelerated_compositing_active_(false), 177 is_accelerated_compositing_active_(false),
178 animation_update_pending_(false), 178 animation_update_pending_(false),
179 invalidation_task_posted_(false), 179 invalidation_task_posted_(false),
180 screen_info_(screen_info), 180 screen_info_(screen_info),
181 device_scale_factor_(screen_info_.deviceScaleFactor), 181 device_scale_factor_(screen_info_.deviceScaleFactor),
182 is_threaded_compositing_enabled_(false), 182 is_threaded_compositing_enabled_(false),
183 #if defined(OS_ANDROID)
184 has_ordered_ime_processing_(false),
185 outstanding_ime_acks_(0),
186 #endif
183 weak_ptr_factory_(this) { 187 weak_ptr_factory_(this) {
184 if (!swapped_out) 188 if (!swapped_out)
185 RenderProcess::current()->AddRefProcess(); 189 RenderProcess::current()->AddRefProcess();
186 DCHECK(RenderThread::Get()); 190 DCHECK(RenderThread::Get());
187 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( 191 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
188 switches::kDisableGpuVsync); 192 switches::kDisableGpuVsync);
189 is_threaded_compositing_enabled_ = 193 is_threaded_compositing_enabled_ =
190 CommandLine::ForCurrentProcess()->HasSwitch( 194 CommandLine::ForCurrentProcess()->HasSwitch(
191 switches::kEnableThreadedCompositing); 195 switches::kEnableThreadedCompositing);
196 #if defined(OS_ANDROID)
197 has_ordered_ime_processing_ =
198 CommandLine::ForCurrentProcess()->HasSwitch(
199 switches::kEnableOrderedImeProcessing);
200 #endif
192 201
193 RenderProcessVisibilityManager::GetInstance()->WidgetVisibilityChanged(true); 202 RenderProcessVisibilityManager::GetInstance()->WidgetVisibilityChanged(true);
194 } 203 }
195 204
196 RenderWidget::~RenderWidget() { 205 RenderWidget::~RenderWidget() {
197 DCHECK(!webwidget_) << "Leaking our WebWidget!"; 206 DCHECK(!webwidget_) << "Leaking our WebWidget!";
198 STLDeleteElements(&updates_pending_swap_); 207 STLDeleteElements(&updates_pending_swap_);
199 if (current_paint_buf_) { 208 if (current_paint_buf_) {
200 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); 209 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
201 current_paint_buf_ = NULL; 210 current_paint_buf_ = NULL;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) 341 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
333 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize) 342 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize)
334 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 343 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
335 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted) 344 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted)
336 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 345 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
337 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 346 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
338 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 347 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
339 #if defined(OS_ANDROID) 348 #if defined(OS_ANDROID)
340 IPC_MESSAGE_HANDLER(ViewMsg_ImeBatchStateChanged, OnImeBatchStateChanged) 349 IPC_MESSAGE_HANDLER(ViewMsg_ImeBatchStateChanged, OnImeBatchStateChanged)
341 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) 350 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
351 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
342 #endif 352 #endif
343 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot) 353 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
344 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats, 354 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats,
345 OnSetBrowserRenderingStats) 355 OnSetBrowserRenderingStats)
346 IPC_MESSAGE_UNHANDLED(handled = false) 356 IPC_MESSAGE_UNHANDLED(handled = false)
347 IPC_END_MESSAGE_MAP() 357 IPC_END_MESSAGE_MAP()
348 return handled; 358 return handled;
349 } 359 }
350 360
351 bool RenderWidget::Send(IPC::Message* message) { 361 bool RenderWidget::Send(IPC::Message* message) {
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 void RenderWidget::willBeginCompositorFrame() { 1528 void RenderWidget::willBeginCompositorFrame() {
1519 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 1529 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
1520 1530
1521 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); 1531 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get());
1522 1532
1523 // The following two can result in further layout and possibly 1533 // The following two can result in further layout and possibly
1524 // enable GPU acceleration so they need to be called before any painting 1534 // enable GPU acceleration so they need to be called before any painting
1525 // is done. 1535 // is done.
1526 UpdateTextInputType(); 1536 UpdateTextInputType();
1527 #if defined(OS_ANDROID) 1537 #if defined(OS_ANDROID)
1528 UpdateTextInputState(DO_NOT_SHOW_IME); 1538 if (!has_ordered_ime_processing())
1539 UpdateTextInputState(DO_NOT_SHOW_IME);
1529 #endif 1540 #endif
1530 UpdateSelectionBounds(); 1541 UpdateSelectionBounds();
1531 1542
1532 WillInitiatePaint(); 1543 WillInitiatePaint();
1533 } 1544 }
1534 1545
1535 void RenderWidget::didBecomeReadyForAdditionalInput() { 1546 void RenderWidget::didBecomeReadyForAdditionalInput() {
1536 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); 1547 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput");
1537 if (pending_input_event_ack_) 1548 if (pending_input_event_ack_)
1538 Send(pending_input_event_ack_.release()); 1549 Send(pending_input_event_ack_.release());
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 composition_character_bounds_ = character_bounds; 1773 composition_character_bounds_ = character_bounds;
1763 composition_range_ = range; 1774 composition_range_ = range;
1764 Send(new ViewHostMsg_ImeCompositionRangeChanged( 1775 Send(new ViewHostMsg_ImeCompositionRangeChanged(
1765 routing_id(), composition_range_, composition_character_bounds_)); 1776 routing_id(), composition_range_, composition_character_bounds_));
1766 } 1777 }
1767 1778
1768 void RenderWidget::OnImeSetComposition( 1779 void RenderWidget::OnImeSetComposition(
1769 const string16& text, 1780 const string16& text,
1770 const std::vector<WebCompositionUnderline>& underlines, 1781 const std::vector<WebCompositionUnderline>& underlines,
1771 int selection_start, int selection_end) { 1782 int selection_start, int selection_end) {
1772 if (!webwidget_) 1783 if (!ShouldHandleImeEvent())
1773 return; 1784 return;
1774 ImeEventGuard guard(this); 1785 ImeEventGuard guard(this);
1775 if (!webwidget_->setComposition( 1786 if (!webwidget_->setComposition(
1776 text, WebVector<WebCompositionUnderline>(underlines), 1787 text, WebVector<WebCompositionUnderline>(underlines),
1777 selection_start, selection_end)) { 1788 selection_start, selection_end)) {
1778 // If we failed to set the composition text, then we need to let the browser 1789 // If we failed to set the composition text, then we need to let the browser
1779 // process to cancel the input method's ongoing composition session, to make 1790 // process to cancel the input method's ongoing composition session, to make
1780 // sure we are in a consistent state. 1791 // sure we are in a consistent state.
1781 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); 1792 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
1782 } 1793 }
1783 UpdateCompositionInfo(true); 1794 UpdateCompositionInfo(true);
1784 } 1795 }
1785 1796
1786 void RenderWidget::OnImeConfirmComposition( 1797 void RenderWidget::OnImeConfirmComposition(
1787 const string16& text, const ui::Range& replacement_range) { 1798 const string16& text, const ui::Range& replacement_range) {
1788 if (!webwidget_) 1799 if (!ShouldHandleImeEvent())
1789 return; 1800 return;
1790 ImeEventGuard guard(this); 1801 ImeEventGuard guard(this);
1791 handling_input_event_ = true; 1802 handling_input_event_ = true;
1792 webwidget_->confirmComposition(text); 1803 webwidget_->confirmComposition(text);
1793 handling_input_event_ = false; 1804 handling_input_event_ = false;
1794 UpdateCompositionInfo(true); 1805 UpdateCompositionInfo(true);
1795 } 1806 }
1796 1807
1797 // This message causes the renderer to render an image of the 1808 // This message causes the renderer to render an image of the
1798 // desired_size, regardless of whether the tab is hidden or not. 1809 // desired_size, regardless of whether the tab is hidden or not.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 } 1967 }
1957 1968
1958 #if defined(OS_ANDROID) 1969 #if defined(OS_ANDROID)
1959 void RenderWidget::OnImeBatchStateChanged(bool is_begin) { 1970 void RenderWidget::OnImeBatchStateChanged(bool is_begin) {
1960 Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin)); 1971 Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin));
1961 } 1972 }
1962 1973
1963 void RenderWidget::OnShowImeIfNeeded() { 1974 void RenderWidget::OnShowImeIfNeeded() {
1964 UpdateTextInputState(SHOW_IME_IF_NEEDED); 1975 UpdateTextInputState(SHOW_IME_IF_NEEDED);
1965 } 1976 }
1977
1978 void RenderWidget::IncrementOutstandingImeEventAcks() {
1979 if (has_ordered_ime_processing())
1980 ++outstanding_ime_acks_;
1981 }
1982
1983 void RenderWidget::OnImeEventAck() {
1984 if (has_ordered_ime_processing()) {
1985 --outstanding_ime_acks_;
1986 DCHECK(outstanding_ime_acks_ >= 0);
1987 }
1988 }
1989
1990 bool RenderWidget::HasOutstandingImeEventAcks() {
1991 return has_ordered_ime_processing() && outstanding_ime_acks_ > 0;
1992 }
1966 #endif 1993 #endif
1967 1994
1995 bool RenderWidget::ShouldHandleImeEvent() {
1996 #if defined(OS_ANDROID)
1997 return !!webwidget_ && !HasOutstandingImeEventAcks();
1998 #else
1999 return !!webwidget_;
2000 #endif
2001 }
2002
1968 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { 2003 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
1969 if (device_scale_factor_ == device_scale_factor) 2004 if (device_scale_factor_ == device_scale_factor)
1970 return; 2005 return;
1971 2006
1972 device_scale_factor_ = device_scale_factor; 2007 device_scale_factor_ = device_scale_factor;
1973 2008
1974 if (!is_accelerated_compositing_active_) { 2009 if (!is_accelerated_compositing_active_) {
1975 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); 2010 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
1976 } else { 2011 } else {
1977 scheduleComposite(); 2012 scheduleComposite();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 } 2105 }
2071 2106
2072 void RenderWidget::FinishHandlingImeEvent() { 2107 void RenderWidget::FinishHandlingImeEvent() {
2073 DCHECK(handling_ime_event_); 2108 DCHECK(handling_ime_event_);
2074 handling_ime_event_ = false; 2109 handling_ime_event_ = false;
2075 // While handling an ime event, text input state and selection bounds updates 2110 // While handling an ime event, text input state and selection bounds updates
2076 // are ignored. These must explicitly be updated once finished handling the 2111 // are ignored. These must explicitly be updated once finished handling the
2077 // ime event. 2112 // ime event.
2078 UpdateSelectionBounds(); 2113 UpdateSelectionBounds();
2079 #if defined(OS_ANDROID) 2114 #if defined(OS_ANDROID)
2080 UpdateTextInputState(DO_NOT_SHOW_IME); 2115 if (!has_ordered_ime_processing())
2116 UpdateTextInputState(DO_NOT_SHOW_IME);
2081 #endif 2117 #endif
2082 } 2118 }
2083 2119
2084 void RenderWidget::UpdateTextInputType() { 2120 void RenderWidget::UpdateTextInputType() {
2085 if (!input_method_is_active_) 2121 if (!input_method_is_active_)
2086 return; 2122 return;
2087 2123
2088 ui::TextInputType new_type = GetTextInputType(); 2124 ui::TextInputType new_type = GetTextInputType();
2089 if (IsDateTimeInput(new_type)) 2125 if (IsDateTimeInput(new_type))
2090 return; // Not considered as a text input field in WebKit/Chromium. 2126 return; // Not considered as a text input field in WebKit/Chromium.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 || can_compose_inline_ != new_can_compose_inline)) { 2161 || can_compose_inline_ != new_can_compose_inline)) {
2126 ViewHostMsg_TextInputState_Params p; 2162 ViewHostMsg_TextInputState_Params p;
2127 p.type = new_type; 2163 p.type = new_type;
2128 p.value = new_info.value.utf8(); 2164 p.value = new_info.value.utf8();
2129 p.selection_start = new_info.selectionStart; 2165 p.selection_start = new_info.selectionStart;
2130 p.selection_end = new_info.selectionEnd; 2166 p.selection_end = new_info.selectionEnd;
2131 p.composition_start = new_info.compositionStart; 2167 p.composition_start = new_info.compositionStart;
2132 p.composition_end = new_info.compositionEnd; 2168 p.composition_end = new_info.compositionEnd;
2133 p.can_compose_inline = new_can_compose_inline; 2169 p.can_compose_inline = new_can_compose_inline;
2134 p.show_ime_if_needed = show_ime_if_needed; 2170 p.show_ime_if_needed = show_ime_if_needed;
2171 IncrementOutstandingImeEventAcks();
2135 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); 2172 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p));
2136 2173
2137 text_input_info_ = new_info; 2174 text_input_info_ = new_info;
2138 text_input_type_ = new_type; 2175 text_input_type_ = new_type;
2139 can_compose_inline_ = new_can_compose_inline; 2176 can_compose_inline_ = new_can_compose_inline;
2140 } 2177 }
2141 } 2178 }
2142 #endif 2179 #endif
2143 2180
2144 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { 2181 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 2446
2410 if (!context->InitializeWithDefaultBufferSizes( 2447 if (!context->InitializeWithDefaultBufferSizes(
2411 attributes, 2448 attributes,
2412 false /* bind generates resources */, 2449 false /* bind generates resources */,
2413 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) 2450 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) )
2414 return NULL; 2451 return NULL;
2415 return context.release(); 2452 return context.release();
2416 } 2453 }
2417 2454
2418 } // namespace content 2455 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698