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

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: Fixed Ted's nits 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 update_reply_pending_(false), 138 update_reply_pending_(false),
139 need_update_rect_for_auto_resize_(false), 139 need_update_rect_for_auto_resize_(false),
140 using_asynchronous_swapbuffers_(false), 140 using_asynchronous_swapbuffers_(false),
141 num_swapbuffers_complete_pending_(0), 141 num_swapbuffers_complete_pending_(0),
142 did_show_(false), 142 did_show_(false),
143 is_hidden_(false), 143 is_hidden_(false),
144 is_fullscreen_(false), 144 is_fullscreen_(false),
145 needs_repainting_on_restore_(false), 145 needs_repainting_on_restore_(false),
146 has_focus_(false), 146 has_focus_(false),
147 handling_input_event_(false), 147 handling_input_event_(false),
148 handling_ime_event_(false),
148 closing_(false), 149 closing_(false),
149 is_swapped_out_(swapped_out), 150 is_swapped_out_(swapped_out),
150 input_method_is_active_(false), 151 input_method_is_active_(false),
151 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 152 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
152 can_compose_inline_(true), 153 can_compose_inline_(true),
153 popup_type_(popup_type), 154 popup_type_(popup_type),
154 pending_window_rect_count_(0), 155 pending_window_rect_count_(0),
155 suppress_next_char_events_(false), 156 suppress_next_char_events_(false),
156 is_accelerated_compositing_active_(false), 157 is_accelerated_compositing_active_(false),
157 animation_update_pending_(false), 158 animation_update_pending_(false),
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 Send(new ViewHostMsg_ImeCompositionRangeChanged( 1560 Send(new ViewHostMsg_ImeCompositionRangeChanged(
1560 routing_id(), composition_range_, composition_character_bounds_)); 1561 routing_id(), composition_range_, composition_character_bounds_));
1561 } 1562 }
1562 1563
1563 void RenderWidget::OnImeSetComposition( 1564 void RenderWidget::OnImeSetComposition(
1564 const string16& text, 1565 const string16& text,
1565 const std::vector<WebCompositionUnderline>& underlines, 1566 const std::vector<WebCompositionUnderline>& underlines,
1566 int selection_start, int selection_end) { 1567 int selection_start, int selection_end) {
1567 if (!webwidget_) 1568 if (!webwidget_)
1568 return; 1569 return;
1570 handling_ime_event_ = true;
1569 if (webwidget_->setComposition( 1571 if (webwidget_->setComposition(
1570 text, WebVector<WebCompositionUnderline>(underlines), 1572 text, WebVector<WebCompositionUnderline>(underlines),
1571 selection_start, selection_end)) { 1573 selection_start, selection_end)) {
1572 // Setting the IME composition was successful. Send the new composition 1574 // Setting the IME composition was successful. Send the new composition
1573 // range to the browser. 1575 // range to the browser.
1574 ui::Range range(ui::Range::InvalidRange()); 1576 ui::Range range(ui::Range::InvalidRange());
1575 size_t location, length; 1577 size_t location, length;
1576 if (webwidget_->compositionRange(&location, &length)) { 1578 if (webwidget_->compositionRange(&location, &length)) {
1577 range.set_start(location); 1579 range.set_start(location);
1578 range.set_end(location + length); 1580 range.set_end(location + length);
(...skipping 14 matching lines...) Expand all
1593 1595
1594 // Send an updated IME range with just the caret range. 1596 // Send an updated IME range with just the caret range.
1595 ui::Range range(ui::Range::InvalidRange()); 1597 ui::Range range(ui::Range::InvalidRange());
1596 size_t location, length; 1598 size_t location, length;
1597 if (webwidget_->caretOrSelectionRange(&location, &length)) { 1599 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1598 range.set_start(location); 1600 range.set_start(location);
1599 range.set_end(location + length); 1601 range.set_end(location + length);
1600 } 1602 }
1601 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); 1603 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
1602 } 1604 }
1605 handling_ime_event_ = false;
1606 UpdateTextInputState(DO_NOT_SHOW_IME);
1603 } 1607 }
1604 1608
1605 void RenderWidget::OnImeConfirmComposition( 1609 void RenderWidget::OnImeConfirmComposition(
1606 const string16& text, const ui::Range& replacement_range) { 1610 const string16& text, const ui::Range& replacement_range) {
1607 if (!webwidget_) 1611 if (!webwidget_)
1608 return; 1612 return;
1609 1613 handling_ime_event_ = true;
1610 handling_input_event_ = true; 1614 handling_input_event_ = true;
1611 webwidget_->confirmComposition(text); 1615 webwidget_->confirmComposition(text);
1612 handling_input_event_ = false; 1616 handling_input_event_ = false;
1613 1617
1614 // Send an updated IME range with just the caret range. 1618 // Send an updated IME range with just the caret range.
1615 ui::Range range(ui::Range::InvalidRange()); 1619 ui::Range range(ui::Range::InvalidRange());
1616 size_t location, length; 1620 size_t location, length;
1617 if (webwidget_->caretOrSelectionRange(&location, &length)) { 1621 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1618 range.set_start(location); 1622 range.set_start(location);
1619 range.set_end(location + length); 1623 range.set_end(location + length);
1620 } 1624 }
1625 handling_ime_event_ = false;
1621 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); 1626 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
1627 UpdateTextInputState(DO_NOT_SHOW_IME);
1622 } 1628 }
1623 1629
1624 // This message causes the renderer to render an image of the 1630 // This message causes the renderer to render an image of the
1625 // desired_size, regardless of whether the tab is hidden or not. 1631 // desired_size, regardless of whether the tab is hidden or not.
1626 void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle, 1632 void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle,
1627 int tag, 1633 int tag,
1628 const gfx::Size& page_size, 1634 const gfx::Size& page_size,
1629 const gfx::Size& desired_size) { 1635 const gfx::Size& desired_size) {
1630 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) { 1636 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
1631 if (TransportDIB::is_valid_handle(dib_handle)) { 1637 if (TransportDIB::is_valid_handle(dib_handle)) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 return type == ui::TEXT_INPUT_TYPE_DATE || 1843 return type == ui::TEXT_INPUT_TYPE_DATE ||
1838 type == ui::TEXT_INPUT_TYPE_DATE_TIME || 1844 type == ui::TEXT_INPUT_TYPE_DATE_TIME ||
1839 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || 1845 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL ||
1840 type == ui::TEXT_INPUT_TYPE_MONTH || 1846 type == ui::TEXT_INPUT_TYPE_MONTH ||
1841 type == ui::TEXT_INPUT_TYPE_TIME || 1847 type == ui::TEXT_INPUT_TYPE_TIME ||
1842 type == ui::TEXT_INPUT_TYPE_WEEK; 1848 type == ui::TEXT_INPUT_TYPE_WEEK;
1843 } 1849 }
1844 1850
1845 1851
1846 void RenderWidget::UpdateTextInputState(ShowIme show_ime) { 1852 void RenderWidget::UpdateTextInputState(ShowIme show_ime) {
1853 if (handling_ime_event_)
1854 return;
1847 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); 1855 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED);
1848 if (!show_ime_if_needed && !input_method_is_active_) 1856 if (!show_ime_if_needed && !input_method_is_active_)
1849 return; 1857 return;
1850 ui::TextInputType new_type = GetTextInputType(); 1858 ui::TextInputType new_type = GetTextInputType();
1851 if (IsDateTimeInput(new_type)) 1859 if (IsDateTimeInput(new_type))
1852 return; // Not considered as a text input field in WebKit/Chromium. 1860 return; // Not considered as a text input field in WebKit/Chromium.
1853 1861
1854 WebKit::WebTextInputInfo new_info; 1862 WebKit::WebTextInputInfo new_info;
1855 if (webwidget_) 1863 if (webwidget_)
1856 new_info = webwidget_->textInputInfo(); 1864 new_info = webwidget_->textInputInfo();
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 bool RenderWidget::WillHandleGestureEvent( 2112 bool RenderWidget::WillHandleGestureEvent(
2105 const WebKit::WebGestureEvent& event) { 2113 const WebKit::WebGestureEvent& event) {
2106 return false; 2114 return false;
2107 } 2115 }
2108 2116
2109 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { 2117 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
2110 return true; 2118 return true;
2111 } 2119 }
2112 2120
2113 } // namespace content 2121 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698