| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 void RenderWidget::willBeginCompositorFrame() { | 1186 void RenderWidget::willBeginCompositorFrame() { |
| 1187 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1187 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
| 1188 | 1188 |
| 1189 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); | 1189 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); |
| 1190 | 1190 |
| 1191 // The following two can result in further layout and possibly | 1191 // The following two can result in further layout and possibly |
| 1192 // enable GPU acceleration so they need to be called before any painting | 1192 // enable GPU acceleration so they need to be called before any painting |
| 1193 // is done. | 1193 // is done. |
| 1194 UpdateTextInputType(); | |
| 1195 #if defined(OS_ANDROID) | |
| 1196 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1194 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
| 1197 #endif | |
| 1198 UpdateSelectionBounds(); | 1195 UpdateSelectionBounds(); |
| 1199 } | 1196 } |
| 1200 | 1197 |
| 1201 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1198 void RenderWidget::didBecomeReadyForAdditionalInput() { |
| 1202 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1199 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
| 1203 FlushPendingInputEventAck(); | 1200 FlushPendingInputEventAck(); |
| 1204 } | 1201 } |
| 1205 | 1202 |
| 1206 void RenderWidget::DidCommitCompositorFrame() { | 1203 void RenderWidget::DidCommitCompositorFrame() { |
| 1207 FOR_EACH_OBSERVER(RenderFrameImpl, swapped_out_frames_, | 1204 FOR_EACH_OBSERVER(RenderFrameImpl, swapped_out_frames_, |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 handling_ime_event_ = false; | 1634 handling_ime_event_ = false; |
| 1638 // While handling an ime event, text input state and selection bounds updates | 1635 // While handling an ime event, text input state and selection bounds updates |
| 1639 // are ignored. These must explicitly be updated once finished handling the | 1636 // are ignored. These must explicitly be updated once finished handling the |
| 1640 // ime event. | 1637 // ime event. |
| 1641 UpdateSelectionBounds(); | 1638 UpdateSelectionBounds(); |
| 1642 #if defined(OS_ANDROID) | 1639 #if defined(OS_ANDROID) |
| 1643 UpdateTextInputState(NO_SHOW_IME, FROM_IME); | 1640 UpdateTextInputState(NO_SHOW_IME, FROM_IME); |
| 1644 #endif | 1641 #endif |
| 1645 } | 1642 } |
| 1646 | 1643 |
| 1647 void RenderWidget::UpdateTextInputType() { | |
| 1648 // On Windows, not only an IME but also an on-screen keyboard relies on the | |
| 1649 // latest TextInputType to optimize its layout and functionality. Thus | |
| 1650 // |input_method_is_active_| is no longer an appropriate condition to suppress | |
| 1651 // TextInputTypeChanged IPC on Windows. | |
| 1652 // TODO(yukawa, yoichio): Consider to stop checking |input_method_is_active_| | |
| 1653 // on other platforms as well as Windows if the overhead is acceptable. | |
| 1654 #if !defined(OS_WIN) | |
| 1655 if (!input_method_is_active_) | |
| 1656 return; | |
| 1657 #endif | |
| 1658 | |
| 1659 ui::TextInputType new_type = GetTextInputType(); | |
| 1660 if (IsDateTimeInput(new_type)) | |
| 1661 return; // Not considered as a text input field in WebKit/Chromium. | |
| 1662 | |
| 1663 bool new_can_compose_inline = CanComposeInline(); | |
| 1664 | |
| 1665 blink::WebTextInputInfo new_info; | |
| 1666 if (webwidget_) | |
| 1667 new_info = webwidget_->textInputInfo(); | |
| 1668 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | |
| 1669 | |
| 1670 if (text_input_type_ != new_type | |
| 1671 || can_compose_inline_ != new_can_compose_inline | |
| 1672 || text_input_mode_ != new_mode) { | |
| 1673 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), | |
| 1674 new_type, | |
| 1675 new_mode, | |
| 1676 new_can_compose_inline)); | |
| 1677 text_input_type_ = new_type; | |
| 1678 can_compose_inline_ = new_can_compose_inline; | |
| 1679 text_input_mode_ = new_mode; | |
| 1680 } | |
| 1681 } | |
| 1682 | |
| 1683 #if defined(OS_ANDROID) || defined(USE_AURA) | |
| 1684 void RenderWidget::UpdateTextInputState(ShowIme show_ime, | 1644 void RenderWidget::UpdateTextInputState(ShowIme show_ime, |
| 1685 ChangeSource change_source) { | 1645 ChangeSource change_source) { |
| 1686 if (handling_ime_event_) | 1646 if (handling_ime_event_) |
| 1687 return; | 1647 return; |
| 1688 if (show_ime == NO_SHOW_IME && !input_method_is_active_) | 1648 if (show_ime == NO_SHOW_IME && !input_method_is_active_) |
| 1689 return; | 1649 return; |
| 1690 ui::TextInputType new_type = GetTextInputType(); | 1650 ui::TextInputType new_type = GetTextInputType(); |
| 1691 if (IsDateTimeInput(new_type)) | 1651 if (IsDateTimeInput(new_type)) |
| 1692 return; // Not considered as a text input field in WebKit/Chromium. | 1652 return; // Not considered as a text input field in WebKit/Chromium. |
| 1693 | 1653 |
| 1694 blink::WebTextInputInfo new_info; | 1654 blink::WebTextInputInfo new_info; |
| 1695 if (webwidget_) | 1655 if (webwidget_) |
| 1696 new_info = webwidget_->textInputInfo(); | 1656 new_info = webwidget_->textInputInfo(); |
| 1657 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); |
| 1697 | 1658 |
| 1698 bool new_can_compose_inline = CanComposeInline(); | 1659 bool new_can_compose_inline = CanComposeInline(); |
| 1699 | 1660 |
| 1700 // Only sends text input params if they are changed or if the ime should be | 1661 // Only sends text input params if they are changed or if the ime should be |
| 1701 // shown. | 1662 // shown. |
| 1702 if (show_ime == SHOW_IME_IF_NEEDED || | 1663 if (show_ime == SHOW_IME_IF_NEEDED || |
| 1703 (text_input_type_ != new_type || | 1664 (text_input_type_ != new_type || |
| 1665 text_input_mode_ != new_mode || |
| 1704 text_input_info_ != new_info || | 1666 text_input_info_ != new_info || |
| 1705 can_compose_inline_ != new_can_compose_inline) | 1667 can_compose_inline_ != new_can_compose_inline) |
| 1706 #if defined(OS_ANDROID) | 1668 #if defined(OS_ANDROID) |
| 1707 || text_field_is_dirty_ | 1669 || text_field_is_dirty_ |
| 1708 #endif | 1670 #endif |
| 1709 ) { | 1671 ) { |
| 1710 ViewHostMsg_TextInputState_Params p; | 1672 ViewHostMsg_TextInputState_Params p; |
| 1711 p.type = new_type; | 1673 p.type = new_type; |
| 1674 p.mode = new_mode; |
| 1712 p.value = new_info.value.utf8(); | 1675 p.value = new_info.value.utf8(); |
| 1713 p.selection_start = new_info.selectionStart; | 1676 p.selection_start = new_info.selectionStart; |
| 1714 p.selection_end = new_info.selectionEnd; | 1677 p.selection_end = new_info.selectionEnd; |
| 1715 p.composition_start = new_info.compositionStart; | 1678 p.composition_start = new_info.compositionStart; |
| 1716 p.composition_end = new_info.compositionEnd; | 1679 p.composition_end = new_info.compositionEnd; |
| 1717 p.can_compose_inline = new_can_compose_inline; | 1680 p.can_compose_inline = new_can_compose_inline; |
| 1718 p.show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); | 1681 p.show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); |
| 1719 #if defined(USE_AURA) | 1682 #if defined(USE_AURA) |
| 1720 p.is_non_ime_change = true; | 1683 p.is_non_ime_change = true; |
| 1721 #endif | 1684 #endif |
| 1722 #if defined(OS_ANDROID) | 1685 #if defined(OS_ANDROID) |
| 1723 p.is_non_ime_change = (change_source == FROM_NON_IME) || | 1686 p.is_non_ime_change = (change_source == FROM_NON_IME) || |
| 1724 text_field_is_dirty_; | 1687 text_field_is_dirty_; |
| 1725 if (p.is_non_ime_change) | 1688 if (p.is_non_ime_change) |
| 1726 IncrementOutstandingImeEventAcks(); | 1689 IncrementOutstandingImeEventAcks(); |
| 1727 text_field_is_dirty_ = false; | 1690 text_field_is_dirty_ = false; |
| 1728 #endif | 1691 #endif |
| 1729 #if defined(USE_AURA) | |
| 1730 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), | |
| 1731 new_type, | |
| 1732 text_input_mode_, | |
| 1733 new_can_compose_inline)); | |
| 1734 #endif | |
| 1735 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); | 1692 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); |
| 1736 | 1693 |
| 1737 text_input_info_ = new_info; | 1694 text_input_info_ = new_info; |
| 1738 text_input_type_ = new_type; | 1695 text_input_type_ = new_type; |
| 1696 text_input_mode_ = new_mode; |
| 1739 can_compose_inline_ = new_can_compose_inline; | 1697 can_compose_inline_ = new_can_compose_inline; |
| 1740 } | 1698 } |
| 1741 } | 1699 } |
| 1742 #endif | |
| 1743 | 1700 |
| 1744 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { | 1701 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { |
| 1745 WebRect focus_webrect; | 1702 WebRect focus_webrect; |
| 1746 WebRect anchor_webrect; | 1703 WebRect anchor_webrect; |
| 1747 webwidget_->selectionBounds(focus_webrect, anchor_webrect); | 1704 webwidget_->selectionBounds(focus_webrect, anchor_webrect); |
| 1748 *focus = focus_webrect; | 1705 *focus = focus_webrect; |
| 1749 *anchor = anchor_webrect; | 1706 *anchor = anchor_webrect; |
| 1750 } | 1707 } |
| 1751 | 1708 |
| 1752 void RenderWidget::UpdateSelectionBounds() { | 1709 void RenderWidget::UpdateSelectionBounds() { |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2070 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2114 video_hole_frames_.AddObserver(frame); | 2071 video_hole_frames_.AddObserver(frame); |
| 2115 } | 2072 } |
| 2116 | 2073 |
| 2117 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2074 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2118 video_hole_frames_.RemoveObserver(frame); | 2075 video_hole_frames_.RemoveObserver(frame); |
| 2119 } | 2076 } |
| 2120 #endif // defined(VIDEO_HOLE) | 2077 #endif // defined(VIDEO_HOLE) |
| 2121 | 2078 |
| 2122 } // namespace content | 2079 } // namespace content |
| OLD | NEW |