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

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

Issue 12093068: Adding missing UpdateTextInputState calls after each ime event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt to fix testKeyboardDismissedAfterClickingGo Created 7 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 | Annotate | Revision Log
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 update_reply_pending_(false), 139 update_reply_pending_(false),
140 need_update_rect_for_auto_resize_(false), 140 need_update_rect_for_auto_resize_(false),
141 using_asynchronous_swapbuffers_(false), 141 using_asynchronous_swapbuffers_(false),
142 num_swapbuffers_complete_pending_(0), 142 num_swapbuffers_complete_pending_(0),
143 did_show_(false), 143 did_show_(false),
144 is_hidden_(false), 144 is_hidden_(false),
145 is_fullscreen_(false), 145 is_fullscreen_(false),
146 needs_repainting_on_restore_(false), 146 needs_repainting_on_restore_(false),
147 has_focus_(false), 147 has_focus_(false),
148 handling_input_event_(false), 148 handling_input_event_(false),
149 handling_ime_event_(false),
149 closing_(false), 150 closing_(false),
150 is_swapped_out_(swapped_out), 151 is_swapped_out_(swapped_out),
151 input_method_is_active_(false), 152 input_method_is_active_(false),
152 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 153 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
153 can_compose_inline_(true), 154 can_compose_inline_(true),
154 popup_type_(popup_type), 155 popup_type_(popup_type),
155 pending_window_rect_count_(0), 156 pending_window_rect_count_(0),
156 suppress_next_char_events_(false), 157 suppress_next_char_events_(false),
157 is_accelerated_compositing_active_(false), 158 is_accelerated_compositing_active_(false),
158 animation_update_pending_(false), 159 animation_update_pending_(false),
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 } 1335 }
1335 1336
1336 void RenderWidget::willBeginCompositorFrame() { 1337 void RenderWidget::willBeginCompositorFrame() {
1337 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 1338 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
1338 1339
1339 DCHECK(RenderThreadImpl::current()->compositor_thread()); 1340 DCHECK(RenderThreadImpl::current()->compositor_thread());
1340 1341
1341 // The following two can result in further layout and possibly 1342 // The following two can result in further layout and possibly
1342 // enable GPU acceleration so they need to be called before any painting 1343 // enable GPU acceleration so they need to be called before any painting
1343 // is done. 1344 // is done.
1344 #if !defined(OS_ANDROID)
1345 UpdateTextInputState(DO_NOT_SHOW_IME); 1345 UpdateTextInputState(DO_NOT_SHOW_IME);
1346 #endif // OS_ANDROID
1347 UpdateSelectionBounds(); 1346 UpdateSelectionBounds();
1348 1347
1349 WillInitiatePaint(); 1348 WillInitiatePaint();
1350 } 1349 }
1351 1350
1352 void RenderWidget::didBecomeReadyForAdditionalInput() { 1351 void RenderWidget::didBecomeReadyForAdditionalInput() {
1353 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); 1352 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput");
1354 if (pending_input_event_ack_.get()) 1353 if (pending_input_event_ack_.get())
1355 Send(pending_input_event_ack_.release()); 1354 Send(pending_input_event_ack_.release());
1356 } 1355 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 Send(new ViewHostMsg_ImeCompositionRangeChanged( 1553 Send(new ViewHostMsg_ImeCompositionRangeChanged(
1555 routing_id(), composition_range_, composition_character_bounds_)); 1554 routing_id(), composition_range_, composition_character_bounds_));
1556 } 1555 }
1557 1556
1558 void RenderWidget::OnImeSetComposition( 1557 void RenderWidget::OnImeSetComposition(
1559 const string16& text, 1558 const string16& text,
1560 const std::vector<WebCompositionUnderline>& underlines, 1559 const std::vector<WebCompositionUnderline>& underlines,
1561 int selection_start, int selection_end) { 1560 int selection_start, int selection_end) {
1562 if (!webwidget_) 1561 if (!webwidget_)
1563 return; 1562 return;
1563 handling_ime_event_ = true;
jamesr 2013/02/12 22:54:34 can you put an RAII object on the stack to be resp
aurimas (slooooooooow) 2013/02/13 00:35:51 Done.
1564 if (webwidget_->setComposition( 1564 if (webwidget_->setComposition(
1565 text, WebVector<WebCompositionUnderline>(underlines), 1565 text, WebVector<WebCompositionUnderline>(underlines),
1566 selection_start, selection_end)) { 1566 selection_start, selection_end)) {
1567 // Setting the IME composition was successful. Send the new composition 1567 // Setting the IME composition was successful. Send the new composition
1568 // range to the browser. 1568 // range to the browser.
1569 ui::Range range(ui::Range::InvalidRange()); 1569 ui::Range range(ui::Range::InvalidRange());
1570 size_t location, length; 1570 size_t location, length;
1571 if (webwidget_->compositionRange(&location, &length)) { 1571 if (webwidget_->compositionRange(&location, &length)) {
1572 range.set_start(location); 1572 range.set_start(location);
1573 range.set_end(location + length); 1573 range.set_end(location + length);
(...skipping 14 matching lines...) Expand all
1588 1588
1589 // Send an updated IME range with just the caret range. 1589 // Send an updated IME range with just the caret range.
1590 ui::Range range(ui::Range::InvalidRange()); 1590 ui::Range range(ui::Range::InvalidRange());
1591 size_t location, length; 1591 size_t location, length;
1592 if (webwidget_->caretOrSelectionRange(&location, &length)) { 1592 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1593 range.set_start(location); 1593 range.set_start(location);
1594 range.set_end(location + length); 1594 range.set_end(location + length);
1595 } 1595 }
1596 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); 1596 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
1597 } 1597 }
1598 handling_ime_event_ = false;
1599 UpdateTextInputState(DO_NOT_SHOW_IME);
1598 } 1600 }
1599 1601
1600 void RenderWidget::OnImeConfirmComposition( 1602 void RenderWidget::OnImeConfirmComposition(
1601 const string16& text, const ui::Range& replacement_range) { 1603 const string16& text, const ui::Range& replacement_range) {
1602 if (!webwidget_) 1604 if (!webwidget_)
1603 return; 1605 return;
1604 1606 handling_ime_event_ = true;
1605 handling_input_event_ = true; 1607 handling_input_event_ = true;
1606 webwidget_->confirmComposition(text); 1608 webwidget_->confirmComposition(text);
1607 handling_input_event_ = false; 1609 handling_input_event_ = false;
1608 1610
1609 // Send an updated IME range with just the caret range. 1611 // Send an updated IME range with just the caret range.
1610 ui::Range range(ui::Range::InvalidRange()); 1612 ui::Range range(ui::Range::InvalidRange());
1611 size_t location, length; 1613 size_t location, length;
1612 if (webwidget_->caretOrSelectionRange(&location, &length)) { 1614 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1613 range.set_start(location); 1615 range.set_start(location);
1614 range.set_end(location + length); 1616 range.set_end(location + length);
1615 } 1617 }
1618 handling_ime_event_ = false;
1616 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); 1619 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
1620 UpdateTextInputState(DO_NOT_SHOW_IME);
1617 } 1621 }
1618 1622
1619 // This message causes the renderer to render an image of the 1623 // This message causes the renderer to render an image of the
1620 // desired_size, regardless of whether the tab is hidden or not. 1624 // desired_size, regardless of whether the tab is hidden or not.
1621 void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle, 1625 void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle,
1622 int tag, 1626 int tag,
1623 const gfx::Size& page_size, 1627 const gfx::Size& page_size,
1624 const gfx::Size& desired_size) { 1628 const gfx::Size& desired_size) {
1625 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) { 1629 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
1626 if (TransportDIB::is_valid_handle(dib_handle)) { 1630 if (TransportDIB::is_valid_handle(dib_handle)) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 return type == ui::TEXT_INPUT_TYPE_DATE || 1836 return type == ui::TEXT_INPUT_TYPE_DATE ||
1833 type == ui::TEXT_INPUT_TYPE_DATE_TIME || 1837 type == ui::TEXT_INPUT_TYPE_DATE_TIME ||
1834 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || 1838 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL ||
1835 type == ui::TEXT_INPUT_TYPE_MONTH || 1839 type == ui::TEXT_INPUT_TYPE_MONTH ||
1836 type == ui::TEXT_INPUT_TYPE_TIME || 1840 type == ui::TEXT_INPUT_TYPE_TIME ||
1837 type == ui::TEXT_INPUT_TYPE_WEEK; 1841 type == ui::TEXT_INPUT_TYPE_WEEK;
1838 } 1842 }
1839 1843
1840 1844
1841 void RenderWidget::UpdateTextInputState(ShowIme show_ime) { 1845 void RenderWidget::UpdateTextInputState(ShowIme show_ime) {
1846 if (handling_ime_event_)
1847 return;
1842 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); 1848 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED);
1843 if (!show_ime_if_needed && !input_method_is_active_) 1849 if (!show_ime_if_needed && !input_method_is_active_)
1844 return; 1850 return;
1845 ui::TextInputType new_type = GetTextInputType(); 1851 ui::TextInputType new_type = GetTextInputType();
1846 if (IsDateTimeInput(new_type)) 1852 if (IsDateTimeInput(new_type))
1847 return; // Not considered as a text input field in WebKit/Chromium. 1853 return; // Not considered as a text input field in WebKit/Chromium.
1848 1854
1849 WebKit::WebTextInputInfo new_info; 1855 WebKit::WebTextInputInfo new_info;
1850 if (webwidget_) 1856 if (webwidget_)
1851 new_info = webwidget_->textInputInfo(); 1857 new_info = webwidget_->textInputInfo();
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 bool RenderWidget::WillHandleGestureEvent( 2105 bool RenderWidget::WillHandleGestureEvent(
2100 const WebKit::WebGestureEvent& event) { 2106 const WebKit::WebGestureEvent& event) {
2101 return false; 2107 return false;
2102 } 2108 }
2103 2109
2104 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { 2110 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
2105 return true; 2111 return true;
2106 } 2112 }
2107 2113
2108 } // namespace content 2114 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/shell/android/java/src/org/chromium/content_shell/Shell.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698