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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "content/renderer/render_frame_impl.h" | 52 #include "content/renderer/render_frame_impl.h" |
53 #include "content/renderer/render_frame_proxy.h" | 53 #include "content/renderer/render_frame_proxy.h" |
54 #include "content/renderer/render_process.h" | 54 #include "content/renderer/render_process.h" |
55 #include "content/renderer/render_thread_impl.h" | 55 #include "content/renderer/render_thread_impl.h" |
56 #include "content/renderer/render_view_impl.h" | 56 #include "content/renderer/render_view_impl.h" |
57 #include "content/renderer/render_widget_owner_delegate.h" | 57 #include "content/renderer/render_widget_owner_delegate.h" |
58 #include "content/renderer/renderer_blink_platform_impl.h" | 58 #include "content/renderer/renderer_blink_platform_impl.h" |
59 #include "content/renderer/resizing_mode_selector.h" | 59 #include "content/renderer/resizing_mode_selector.h" |
60 #include "ipc/ipc_message_start.h" | 60 #include "ipc/ipc_message_start.h" |
61 #include "ipc/ipc_sync_message.h" | 61 #include "ipc/ipc_sync_message.h" |
| 62 #include "ppapi/features/features.h" |
62 #include "skia/ext/platform_canvas.h" | 63 #include "skia/ext/platform_canvas.h" |
63 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 64 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
64 #include "third_party/WebKit/public/platform/WebDragData.h" | 65 #include "third_party/WebKit/public/platform/WebDragData.h" |
65 #include "third_party/WebKit/public/platform/WebDragOperation.h" | 66 #include "third_party/WebKit/public/platform/WebDragOperation.h" |
66 #include "third_party/WebKit/public/platform/WebPoint.h" | 67 #include "third_party/WebKit/public/platform/WebPoint.h" |
67 #include "third_party/WebKit/public/platform/WebRect.h" | 68 #include "third_party/WebKit/public/platform/WebRect.h" |
68 #include "third_party/WebKit/public/platform/WebSize.h" | 69 #include "third_party/WebKit/public/platform/WebSize.h" |
69 #include "third_party/WebKit/public/platform/WebString.h" | 70 #include "third_party/WebKit/public/platform/WebString.h" |
70 #include "third_party/WebKit/public/platform/scheduler/renderer/render_widget_sc
heduling_state.h" | 71 #include "third_party/WebKit/public/platform/scheduler/renderer/render_widget_sc
heduling_state.h" |
71 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" | 72 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 window_screen_rect_ = rect; | 1510 window_screen_rect_ = rect; |
1510 view_screen_rect_ = rect; | 1511 view_screen_rect_ = rect; |
1511 } | 1512 } |
1512 } | 1513 } |
1513 | 1514 |
1514 void RenderWidget::OnImeSetComposition( | 1515 void RenderWidget::OnImeSetComposition( |
1515 const base::string16& text, | 1516 const base::string16& text, |
1516 const std::vector<WebCompositionUnderline>& underlines, | 1517 const std::vector<WebCompositionUnderline>& underlines, |
1517 const gfx::Range& replacement_range, | 1518 const gfx::Range& replacement_range, |
1518 int selection_start, int selection_end) { | 1519 int selection_start, int selection_end) { |
1519 #if defined(ENABLE_PLUGINS) | 1520 #if BUILDFLAG(ENABLE_PLUGINS) |
1520 if (focused_pepper_plugin_) { | 1521 if (focused_pepper_plugin_) { |
1521 focused_pepper_plugin_->render_frame()->OnImeSetComposition( | 1522 focused_pepper_plugin_->render_frame()->OnImeSetComposition( |
1522 text, underlines, selection_start, selection_end); | 1523 text, underlines, selection_start, selection_end); |
1523 return; | 1524 return; |
1524 } | 1525 } |
1525 #endif | 1526 #endif |
1526 if (replacement_range.IsValid()) { | 1527 if (replacement_range.IsValid()) { |
1527 GetWebWidget()->applyReplacementRange( | 1528 GetWebWidget()->applyReplacementRange( |
1528 WebRange(replacement_range.start(), replacement_range.length())); | 1529 WebRange(replacement_range.start(), replacement_range.length())); |
1529 } | 1530 } |
(...skipping 11 matching lines...) Expand all Loading... |
1541 // process to cancel the input method's ongoing composition session, to make | 1542 // process to cancel the input method's ongoing composition session, to make |
1542 // sure we are in a consistent state. | 1543 // sure we are in a consistent state. |
1543 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1544 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
1544 } | 1545 } |
1545 UpdateCompositionInfo(false /* not an immediate request */); | 1546 UpdateCompositionInfo(false /* not an immediate request */); |
1546 } | 1547 } |
1547 | 1548 |
1548 void RenderWidget::OnImeCommitText(const base::string16& text, | 1549 void RenderWidget::OnImeCommitText(const base::string16& text, |
1549 const gfx::Range& replacement_range, | 1550 const gfx::Range& replacement_range, |
1550 int relative_cursor_pos) { | 1551 int relative_cursor_pos) { |
1551 #if defined(ENABLE_PLUGINS) | 1552 #if BUILDFLAG(ENABLE_PLUGINS) |
1552 if (focused_pepper_plugin_) { | 1553 if (focused_pepper_plugin_) { |
1553 focused_pepper_plugin_->render_frame()->OnImeCommitText( | 1554 focused_pepper_plugin_->render_frame()->OnImeCommitText( |
1554 text, replacement_range, relative_cursor_pos); | 1555 text, replacement_range, relative_cursor_pos); |
1555 return; | 1556 return; |
1556 } | 1557 } |
1557 #endif | 1558 #endif |
1558 if (replacement_range.IsValid()) { | 1559 if (replacement_range.IsValid()) { |
1559 GetWebWidget()->applyReplacementRange( | 1560 GetWebWidget()->applyReplacementRange( |
1560 WebRange(replacement_range.start(), replacement_range.length())); | 1561 WebRange(replacement_range.start(), replacement_range.length())); |
1561 } | 1562 } |
1562 | 1563 |
1563 if (!ShouldHandleImeEvent()) | 1564 if (!ShouldHandleImeEvent()) |
1564 return; | 1565 return; |
1565 ImeEventGuard guard(this); | 1566 ImeEventGuard guard(this); |
1566 input_handler_->set_handling_input_event(true); | 1567 input_handler_->set_handling_input_event(true); |
1567 if (auto* controller = GetInputMethodController()) | 1568 if (auto* controller = GetInputMethodController()) |
1568 controller->commitText(text, relative_cursor_pos); | 1569 controller->commitText(text, relative_cursor_pos); |
1569 input_handler_->set_handling_input_event(false); | 1570 input_handler_->set_handling_input_event(false); |
1570 UpdateCompositionInfo(false /* not an immediate request */); | 1571 UpdateCompositionInfo(false /* not an immediate request */); |
1571 } | 1572 } |
1572 | 1573 |
1573 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { | 1574 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { |
1574 #if defined(ENABLE_PLUGINS) | 1575 #if BUILDFLAG(ENABLE_PLUGINS) |
1575 if (focused_pepper_plugin_) { | 1576 if (focused_pepper_plugin_) { |
1576 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( | 1577 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( |
1577 keep_selection); | 1578 keep_selection); |
1578 return; | 1579 return; |
1579 } | 1580 } |
1580 #endif | 1581 #endif |
1581 | 1582 |
1582 if (!ShouldHandleImeEvent()) | 1583 if (!ShouldHandleImeEvent()) |
1583 return; | 1584 return; |
1584 ImeEventGuard guard(this); | 1585 ImeEventGuard guard(this); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 #endif | 1732 #endif |
1732 | 1733 |
1733 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with | 1734 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with |
1734 // virtual keyboard. | 1735 // virtual keyboard. |
1735 #if !defined(OS_ANDROID) | 1736 #if !defined(OS_ANDROID) |
1736 FocusChangeComplete(); | 1737 FocusChangeComplete(); |
1737 #endif | 1738 #endif |
1738 } | 1739 } |
1739 | 1740 |
1740 ui::TextInputType RenderWidget::GetTextInputType() { | 1741 ui::TextInputType RenderWidget::GetTextInputType() { |
1741 #if defined(ENABLE_PLUGINS) | 1742 #if BUILDFLAG(ENABLE_PLUGINS) |
1742 if (focused_pepper_plugin_) | 1743 if (focused_pepper_plugin_) |
1743 return focused_pepper_plugin_->text_input_type(); | 1744 return focused_pepper_plugin_->text_input_type(); |
1744 #endif | 1745 #endif |
1745 if (GetWebWidget()) | 1746 if (GetWebWidget()) |
1746 return ConvertWebTextInputType(GetWebWidget()->textInputType()); | 1747 return ConvertWebTextInputType(GetWebWidget()->textInputType()); |
1747 return ui::TEXT_INPUT_TYPE_NONE; | 1748 return ui::TEXT_INPUT_TYPE_NONE; |
1748 } | 1749 } |
1749 | 1750 |
1750 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { | 1751 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { |
1751 if (!monitor_composition_info_ && !immediate_request) | 1752 if (!monitor_composition_info_ && !immediate_request) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 // ime event. | 1946 // ime event. |
1946 UpdateSelectionBounds(); | 1947 UpdateSelectionBounds(); |
1947 #if defined(OS_ANDROID) | 1948 #if defined(OS_ANDROID) |
1948 UpdateTextInputState( | 1949 UpdateTextInputState( |
1949 guard->show_ime() ? ShowIme::IF_NEEDED : ShowIme::HIDE_IME, | 1950 guard->show_ime() ? ShowIme::IF_NEEDED : ShowIme::HIDE_IME, |
1950 guard->from_ime() ? ChangeSource::FROM_IME : ChangeSource::FROM_NON_IME); | 1951 guard->from_ime() ? ChangeSource::FROM_IME : ChangeSource::FROM_NON_IME); |
1951 #endif | 1952 #endif |
1952 } | 1953 } |
1953 | 1954 |
1954 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { | 1955 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { |
1955 #if defined(ENABLE_PLUGINS) | 1956 #if BUILDFLAG(ENABLE_PLUGINS) |
1956 if (focused_pepper_plugin_) { | 1957 if (focused_pepper_plugin_) { |
1957 // TODO(kinaba) http://crbug.com/101101 | 1958 // TODO(kinaba) http://crbug.com/101101 |
1958 // Current Pepper IME API does not handle selection bounds. So we simply | 1959 // Current Pepper IME API does not handle selection bounds. So we simply |
1959 // use the caret position as an empty range for now. It will be updated | 1960 // use the caret position as an empty range for now. It will be updated |
1960 // after Pepper API equips features related to surrounding text retrieval. | 1961 // after Pepper API equips features related to surrounding text retrieval. |
1961 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); | 1962 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); |
1962 convertViewportToWindow(&caret); | 1963 convertViewportToWindow(&caret); |
1963 *focus = caret; | 1964 *focus = caret; |
1964 *anchor = caret; | 1965 *anchor = caret; |
1965 return; | 1966 return; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 if (!resizing_mode_selector_->is_synchronous_mode()) | 2036 if (!resizing_mode_selector_->is_synchronous_mode()) |
2036 need_update_rect_for_auto_resize_ = true; | 2037 need_update_rect_for_auto_resize_ = true; |
2037 } | 2038 } |
2038 } | 2039 } |
2039 | 2040 |
2040 void RenderWidget::GetCompositionCharacterBounds( | 2041 void RenderWidget::GetCompositionCharacterBounds( |
2041 std::vector<gfx::Rect>* bounds) { | 2042 std::vector<gfx::Rect>* bounds) { |
2042 DCHECK(bounds); | 2043 DCHECK(bounds); |
2043 bounds->clear(); | 2044 bounds->clear(); |
2044 | 2045 |
2045 #if defined(ENABLE_PLUGINS) | 2046 #if BUILDFLAG(ENABLE_PLUGINS) |
2046 if (focused_pepper_plugin_) | 2047 if (focused_pepper_plugin_) |
2047 return; | 2048 return; |
2048 #endif | 2049 #endif |
2049 | 2050 |
2050 if (!GetWebWidget()) | 2051 if (!GetWebWidget()) |
2051 return; | 2052 return; |
2052 blink::WebVector<blink::WebRect> bounds_from_blink; | 2053 blink::WebVector<blink::WebRect> bounds_from_blink; |
2053 if (!GetWebWidget()->getCompositionCharacterBounds(bounds_from_blink)) | 2054 if (!GetWebWidget()->getCompositionCharacterBounds(bounds_from_blink)) |
2054 return; | 2055 return; |
2055 | 2056 |
2056 for (size_t i = 0; i < bounds_from_blink.size(); ++i) { | 2057 for (size_t i = 0; i < bounds_from_blink.size(); ++i) { |
2057 convertViewportToWindow(&bounds_from_blink[i]); | 2058 convertViewportToWindow(&bounds_from_blink[i]); |
2058 bounds->push_back(bounds_from_blink[i]); | 2059 bounds->push_back(bounds_from_blink[i]); |
2059 } | 2060 } |
2060 } | 2061 } |
2061 | 2062 |
2062 void RenderWidget::GetCompositionRange(gfx::Range* range) { | 2063 void RenderWidget::GetCompositionRange(gfx::Range* range) { |
2063 #if defined(ENABLE_PLUGINS) | 2064 #if BUILDFLAG(ENABLE_PLUGINS) |
2064 if (focused_pepper_plugin_) | 2065 if (focused_pepper_plugin_) |
2065 return; | 2066 return; |
2066 #endif | 2067 #endif |
2067 WebRange web_range = GetWebWidget()->compositionRange(); | 2068 WebRange web_range = GetWebWidget()->compositionRange(); |
2068 if (web_range.isNull()) { | 2069 if (web_range.isNull()) { |
2069 *range = gfx::Range::InvalidRange(); | 2070 *range = gfx::Range::InvalidRange(); |
2070 return; | 2071 return; |
2071 } | 2072 } |
2072 range->set_start(web_range.startOffset()); | 2073 range->set_start(web_range.startOffset()); |
2073 range->set_end(web_range.endOffset()); | 2074 range->set_end(web_range.endOffset()); |
2074 } | 2075 } |
2075 | 2076 |
2076 bool RenderWidget::ShouldUpdateCompositionInfo( | 2077 bool RenderWidget::ShouldUpdateCompositionInfo( |
2077 const gfx::Range& range, | 2078 const gfx::Range& range, |
2078 const std::vector<gfx::Rect>& bounds) { | 2079 const std::vector<gfx::Rect>& bounds) { |
2079 if (composition_range_ != range) | 2080 if (composition_range_ != range) |
2080 return true; | 2081 return true; |
2081 if (bounds.size() != composition_character_bounds_.size()) | 2082 if (bounds.size() != composition_character_bounds_.size()) |
2082 return true; | 2083 return true; |
2083 for (size_t i = 0; i < bounds.size(); ++i) { | 2084 for (size_t i = 0; i < bounds.size(); ++i) { |
2084 if (bounds[i] != composition_character_bounds_[i]) | 2085 if (bounds[i] != composition_character_bounds_[i]) |
2085 return true; | 2086 return true; |
2086 } | 2087 } |
2087 return false; | 2088 return false; |
2088 } | 2089 } |
2089 | 2090 |
2090 bool RenderWidget::CanComposeInline() { | 2091 bool RenderWidget::CanComposeInline() { |
2091 #if defined(ENABLE_PLUGINS) | 2092 #if BUILDFLAG(ENABLE_PLUGINS) |
2092 if (focused_pepper_plugin_) | 2093 if (focused_pepper_plugin_) |
2093 return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents(); | 2094 return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents(); |
2094 #endif | 2095 #endif |
2095 return true; | 2096 return true; |
2096 } | 2097 } |
2097 | 2098 |
2098 blink::WebScreenInfo RenderWidget::screenInfo() { | 2099 blink::WebScreenInfo RenderWidget::screenInfo() { |
2099 blink::WebScreenInfo web_screen_info; | 2100 blink::WebScreenInfo web_screen_info; |
2100 web_screen_info.deviceScaleFactor = screen_info_.device_scale_factor; | 2101 web_screen_info.deviceScaleFactor = screen_info_.device_scale_factor; |
2101 web_screen_info.depth = screen_info_.depth; | 2102 web_screen_info.depth = screen_info_.depth; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 blink::WebInputMethodController* RenderWidget::GetInputMethodController() | 2306 blink::WebInputMethodController* RenderWidget::GetInputMethodController() |
2306 const { | 2307 const { |
2307 // TODO(ekaramad): Remove this CHECK when GetWebWidget() is | 2308 // TODO(ekaramad): Remove this CHECK when GetWebWidget() is |
2308 // always a WebFrameWidget. | 2309 // always a WebFrameWidget. |
2309 CHECK(GetWebWidget()->isWebFrameWidget()); | 2310 CHECK(GetWebWidget()->isWebFrameWidget()); |
2310 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2311 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
2311 ->getActiveWebInputMethodController(); | 2312 ->getActiveWebInputMethodController(); |
2312 } | 2313 } |
2313 | 2314 |
2314 } // namespace content | 2315 } // namespace content |
OLD | NEW |