OLD | NEW |
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 Loading... |
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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 } | 1351 } |
1351 | 1352 |
1352 void RenderWidget::willBeginCompositorFrame() { | 1353 void RenderWidget::willBeginCompositorFrame() { |
1353 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1354 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
1354 | 1355 |
1355 DCHECK(RenderThreadImpl::current()->compositor_thread()); | 1356 DCHECK(RenderThreadImpl::current()->compositor_thread()); |
1356 | 1357 |
1357 // The following two can result in further layout and possibly | 1358 // The following two can result in further layout and possibly |
1358 // enable GPU acceleration so they need to be called before any painting | 1359 // enable GPU acceleration so they need to be called before any painting |
1359 // is done. | 1360 // is done. |
1360 #if !defined(OS_ANDROID) | |
1361 UpdateTextInputState(DO_NOT_SHOW_IME); | 1361 UpdateTextInputState(DO_NOT_SHOW_IME); |
1362 #endif // OS_ANDROID | |
1363 UpdateSelectionBounds(); | 1362 UpdateSelectionBounds(); |
1364 | 1363 |
1365 WillInitiatePaint(); | 1364 WillInitiatePaint(); |
1366 } | 1365 } |
1367 | 1366 |
1368 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1367 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1369 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1368 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1370 if (pending_input_event_ack_.get()) | 1369 if (pending_input_event_ack_.get()) |
1371 Send(pending_input_event_ack_.release()); | 1370 Send(pending_input_event_ack_.release()); |
1372 } | 1371 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 Send(new ViewHostMsg_ImeCompositionRangeChanged( | 1569 Send(new ViewHostMsg_ImeCompositionRangeChanged( |
1571 routing_id(), composition_range_, composition_character_bounds_)); | 1570 routing_id(), composition_range_, composition_character_bounds_)); |
1572 } | 1571 } |
1573 | 1572 |
1574 void RenderWidget::OnImeSetComposition( | 1573 void RenderWidget::OnImeSetComposition( |
1575 const string16& text, | 1574 const string16& text, |
1576 const std::vector<WebCompositionUnderline>& underlines, | 1575 const std::vector<WebCompositionUnderline>& underlines, |
1577 int selection_start, int selection_end) { | 1576 int selection_start, int selection_end) { |
1578 if (!webwidget_) | 1577 if (!webwidget_) |
1579 return; | 1578 return; |
| 1579 DCHECK(!handling_ime_event_); |
| 1580 handling_ime_event_ = true; |
1580 if (webwidget_->setComposition( | 1581 if (webwidget_->setComposition( |
1581 text, WebVector<WebCompositionUnderline>(underlines), | 1582 text, WebVector<WebCompositionUnderline>(underlines), |
1582 selection_start, selection_end)) { | 1583 selection_start, selection_end)) { |
1583 // Setting the IME composition was successful. Send the new composition | 1584 // Setting the IME composition was successful. Send the new composition |
1584 // range to the browser. | 1585 // range to the browser. |
1585 ui::Range range(ui::Range::InvalidRange()); | 1586 ui::Range range(ui::Range::InvalidRange()); |
1586 size_t location, length; | 1587 size_t location, length; |
1587 if (webwidget_->compositionRange(&location, &length)) { | 1588 if (webwidget_->compositionRange(&location, &length)) { |
1588 range.set_start(location); | 1589 range.set_start(location); |
1589 range.set_end(location + length); | 1590 range.set_end(location + length); |
(...skipping 14 matching lines...) Expand all Loading... |
1604 | 1605 |
1605 // Send an updated IME range with just the caret range. | 1606 // Send an updated IME range with just the caret range. |
1606 ui::Range range(ui::Range::InvalidRange()); | 1607 ui::Range range(ui::Range::InvalidRange()); |
1607 size_t location, length; | 1608 size_t location, length; |
1608 if (webwidget_->caretOrSelectionRange(&location, &length)) { | 1609 if (webwidget_->caretOrSelectionRange(&location, &length)) { |
1609 range.set_start(location); | 1610 range.set_start(location); |
1610 range.set_end(location + length); | 1611 range.set_end(location + length); |
1611 } | 1612 } |
1612 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); | 1613 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); |
1613 } | 1614 } |
| 1615 handling_ime_event_ = false; |
| 1616 UpdateTextInputState(DO_NOT_SHOW_IME); |
1614 } | 1617 } |
1615 | 1618 |
1616 void RenderWidget::OnImeConfirmComposition( | 1619 void RenderWidget::OnImeConfirmComposition( |
1617 const string16& text, const ui::Range& replacement_range) { | 1620 const string16& text, const ui::Range& replacement_range) { |
1618 if (!webwidget_) | 1621 if (!webwidget_) |
1619 return; | 1622 return; |
1620 | 1623 DCHECK(!handling_ime_event_); |
| 1624 handling_ime_event_ = true; |
1621 handling_input_event_ = true; | 1625 handling_input_event_ = true; |
1622 webwidget_->confirmComposition(text); | 1626 webwidget_->confirmComposition(text); |
1623 handling_input_event_ = false; | 1627 handling_input_event_ = false; |
1624 | 1628 |
1625 // Send an updated IME range with just the caret range. | 1629 // Send an updated IME range with just the caret range. |
1626 ui::Range range(ui::Range::InvalidRange()); | 1630 ui::Range range(ui::Range::InvalidRange()); |
1627 size_t location, length; | 1631 size_t location, length; |
1628 if (webwidget_->caretOrSelectionRange(&location, &length)) { | 1632 if (webwidget_->caretOrSelectionRange(&location, &length)) { |
1629 range.set_start(location); | 1633 range.set_start(location); |
1630 range.set_end(location + length); | 1634 range.set_end(location + length); |
1631 } | 1635 } |
1632 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); | 1636 UpdateCompositionInfo(range, std::vector<gfx::Rect>()); |
| 1637 handling_ime_event_ = false; |
| 1638 UpdateTextInputState(DO_NOT_SHOW_IME); |
1633 } | 1639 } |
1634 | 1640 |
1635 // This message causes the renderer to render an image of the | 1641 // This message causes the renderer to render an image of the |
1636 // desired_size, regardless of whether the tab is hidden or not. | 1642 // desired_size, regardless of whether the tab is hidden or not. |
1637 void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle, | 1643 void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle, |
1638 int tag, | 1644 int tag, |
1639 const gfx::Size& page_size, | 1645 const gfx::Size& page_size, |
1640 const gfx::Size& desired_size) { | 1646 const gfx::Size& desired_size) { |
1641 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) { | 1647 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) { |
1642 if (TransportDIB::is_valid_handle(dib_handle)) { | 1648 if (TransportDIB::is_valid_handle(dib_handle)) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 return type == ui::TEXT_INPUT_TYPE_DATE || | 1854 return type == ui::TEXT_INPUT_TYPE_DATE || |
1849 type == ui::TEXT_INPUT_TYPE_DATE_TIME || | 1855 type == ui::TEXT_INPUT_TYPE_DATE_TIME || |
1850 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || | 1856 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || |
1851 type == ui::TEXT_INPUT_TYPE_MONTH || | 1857 type == ui::TEXT_INPUT_TYPE_MONTH || |
1852 type == ui::TEXT_INPUT_TYPE_TIME || | 1858 type == ui::TEXT_INPUT_TYPE_TIME || |
1853 type == ui::TEXT_INPUT_TYPE_WEEK; | 1859 type == ui::TEXT_INPUT_TYPE_WEEK; |
1854 } | 1860 } |
1855 | 1861 |
1856 | 1862 |
1857 void RenderWidget::UpdateTextInputState(ShowIme show_ime) { | 1863 void RenderWidget::UpdateTextInputState(ShowIme show_ime) { |
| 1864 if (handling_ime_event_) |
| 1865 return; |
1858 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); | 1866 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); |
1859 if (!show_ime_if_needed && !input_method_is_active_) | 1867 if (!show_ime_if_needed && !input_method_is_active_) |
1860 return; | 1868 return; |
1861 ui::TextInputType new_type = GetTextInputType(); | 1869 ui::TextInputType new_type = GetTextInputType(); |
1862 if (IsDateTimeInput(new_type)) | 1870 if (IsDateTimeInput(new_type)) |
1863 return; // Not considered as a text input field in WebKit/Chromium. | 1871 return; // Not considered as a text input field in WebKit/Chromium. |
1864 | 1872 |
1865 WebKit::WebTextInputInfo new_info; | 1873 WebKit::WebTextInputInfo new_info; |
1866 if (webwidget_) | 1874 if (webwidget_) |
1867 new_info = webwidget_->textInputInfo(); | 1875 new_info = webwidget_->textInputInfo(); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 bool RenderWidget::WillHandleGestureEvent( | 2124 bool RenderWidget::WillHandleGestureEvent( |
2117 const WebKit::WebGestureEvent& event) { | 2125 const WebKit::WebGestureEvent& event) { |
2118 return false; | 2126 return false; |
2119 } | 2127 } |
2120 | 2128 |
2121 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2129 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
2122 return true; | 2130 return true; |
2123 } | 2131 } |
2124 | 2132 |
2125 } // namespace content | 2133 } // namespace content |
OLD | NEW |