Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1655 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { | 1655 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { |
| 1656 text_input_info_history_.push_back(info); | 1656 text_input_info_history_.push_back(info); |
| 1657 } | 1657 } |
| 1658 | 1658 |
| 1659 void RenderWidget::OnImeEventAck() { | 1659 void RenderWidget::OnImeEventAck() { |
| 1660 DCHECK_GE(text_input_info_history_.size(), 1u); | 1660 DCHECK_GE(text_input_info_history_.size(), 1u); |
| 1661 text_input_info_history_.pop_front(); | 1661 text_input_info_history_.pop_front(); |
| 1662 } | 1662 } |
| 1663 | 1663 |
| 1664 void RenderWidget::OnRequestTextInputStateUpdate() { | 1664 void RenderWidget::OnRequestTextInputStateUpdate() { |
| 1665 DCHECK(!ime_event_guard_); | 1665 ImeEventGuard guard(this); |
|
Changwan Ryu
2016/04/07 11:48:18
FYI, this DCHECK was introduced in
https://codere
| |
| 1666 UpdateSelectionBounds(); | 1666 ime_event_guard_->set_from_ime(true); |
| 1667 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); | |
| 1668 } | 1667 } |
| 1669 #endif | 1668 #endif |
| 1670 | 1669 |
| 1671 bool RenderWidget::ShouldHandleImeEvent() { | 1670 bool RenderWidget::ShouldHandleImeEvent() { |
| 1672 #if defined(OS_ANDROID) | 1671 #if defined(OS_ANDROID) |
| 1673 if (!webwidget_) | 1672 if (!webwidget_) |
| 1674 return false; | 1673 return false; |
| 1675 if (IsUsingImeThread()) | 1674 if (IsUsingImeThread()) |
| 1676 return true; | 1675 return true; |
| 1677 | 1676 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1778 } | 1777 } |
| 1779 | 1778 |
| 1780 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { | 1779 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { |
| 1781 if (!ime_event_guard_) | 1780 if (!ime_event_guard_) |
| 1782 ime_event_guard_ = guard; | 1781 ime_event_guard_ = guard; |
| 1783 } | 1782 } |
| 1784 | 1783 |
| 1785 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { | 1784 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { |
| 1786 if (ime_event_guard_ != guard) { | 1785 if (ime_event_guard_ != guard) { |
| 1787 #if defined(OS_ANDROID) | 1786 #if defined(OS_ANDROID) |
| 1788 // In case a from-IME event (e.g. touch) ends up in not-from-IME event | 1787 if (IsUsingImeThread()) { |
| 1789 // (e.g. long press gesture), we want to treat it as not-from-IME event | 1788 // When a from-IME event (OnRequestTextInputStateUpdate) as nested by a |
| 1790 // so that ReplicaInputConnection can make changes to its Editable model. | 1789 // not-from-IME event (e.g. HandleInputEvent), then we still need to |
| 1791 // Therefore, we want to mark this text state update as 'from IME' only | 1790 // deliver the data. Otherwise, ThreadedInputConnection might hang. |
| 1792 // when all the nested events are all originating from IME. | 1791 ime_event_guard_->set_from_ime( |
| 1793 ime_event_guard_->set_from_ime( | 1792 ime_event_guard_->from_ime() || guard->from_ime()); |
| 1794 ime_event_guard_->from_ime() && guard->from_ime()); | 1793 } else { |
| 1794 // In case a from-IME event (e.g. touch) ends up in not-from-IME event | |
| 1795 // (e.g. long press gesture), we want to treat it as not-from-IME event | |
| 1796 // so that ReplicaInputConnection can make changes to its Editable model. | |
| 1797 // Therefore, we want to mark this text state update as 'from IME' only | |
| 1798 // when all the nested events are all originating from IME. | |
| 1799 ime_event_guard_->set_from_ime( | |
| 1800 ime_event_guard_->from_ime() && guard->from_ime()); | |
| 1801 } | |
| 1795 #endif | 1802 #endif |
| 1796 return; | 1803 return; |
| 1797 } | 1804 } |
| 1798 ime_event_guard_ = nullptr; | 1805 ime_event_guard_ = nullptr; |
| 1799 | 1806 |
| 1800 // While handling an ime event, text input state and selection bounds updates | 1807 // While handling an ime event, text input state and selection bounds updates |
| 1801 // are ignored. These must explicitly be updated once finished handling the | 1808 // are ignored. These must explicitly be updated once finished handling the |
| 1802 // ime event. | 1809 // ime event. |
| 1803 UpdateSelectionBounds(); | 1810 UpdateSelectionBounds(); |
| 1804 #if defined(OS_ANDROID) | 1811 #if defined(OS_ANDROID) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2148 } | 2155 } |
| 2149 | 2156 |
| 2150 float RenderWidget::GetOriginalDeviceScaleFactor() const { | 2157 float RenderWidget::GetOriginalDeviceScaleFactor() const { |
| 2151 return | 2158 return |
| 2152 screen_metrics_emulator_ ? | 2159 screen_metrics_emulator_ ? |
| 2153 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : | 2160 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : |
| 2154 device_scale_factor_; | 2161 device_scale_factor_; |
| 2155 } | 2162 } |
| 2156 | 2163 |
| 2157 } // namespace content | 2164 } // namespace content |
| OLD | NEW |