| 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_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) | 1188 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
| 1189 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1189 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 1190 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 1190 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
| 1191 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 1191 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
| 1192 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 1192 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 1193 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 1193 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 1194 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 1194 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 1195 OnEnumerateDirectoryResponse) | 1195 OnEnumerateDirectoryResponse) |
| 1196 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 1196 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 1197 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 1197 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
| 1198 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) | |
| 1199 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) | 1198 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
| 1200 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, | 1199 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1201 OnEnablePreferredSizeChangedMode) | 1200 OnEnablePreferredSizeChangedMode) |
| 1202 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) | 1201 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
| 1203 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) | 1202 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
| 1204 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, | 1203 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1205 OnDisableScrollbarsForSmallWindows) | 1204 OnDisableScrollbarsForSmallWindows) |
| 1206 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) | 1205 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
| 1207 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) | 1206 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
| 1208 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) | 1207 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 | 1691 |
| 1693 void RenderViewImpl::focusPrevious() { | 1692 void RenderViewImpl::focusPrevious() { |
| 1694 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); | 1693 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); |
| 1695 } | 1694 } |
| 1696 | 1695 |
| 1697 // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. | 1696 // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. |
| 1698 void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, | 1697 void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, |
| 1699 const WebNode& toNode) { | 1698 const WebNode& toNode) { |
| 1700 has_scrolled_focused_editable_node_into_rect_ = false; | 1699 has_scrolled_focused_editable_node_into_rect_ = false; |
| 1701 | 1700 |
| 1702 gfx::Rect node_bounds; | |
| 1703 bool is_editable = false; | |
| 1704 if (!toNode.isNull() && toNode.isElementNode()) { | |
| 1705 WebElement element = const_cast<WebNode&>(toNode).to<WebElement>(); | |
| 1706 blink::WebRect rect = element.boundsInViewport(); | |
| 1707 ConvertViewportToWindowViaWidget(&rect); | |
| 1708 node_bounds = gfx::Rect(rect); | |
| 1709 is_editable = element.isEditable(); | |
| 1710 } | |
| 1711 Send(new ViewHostMsg_FocusedNodeChanged(GetRoutingID(), is_editable, | |
| 1712 node_bounds)); | |
| 1713 | |
| 1714 // TODO(estade): remove. | 1701 // TODO(estade): remove. |
| 1715 for (auto& observer : observers_) | 1702 for (auto& observer : observers_) |
| 1716 observer.FocusedNodeChanged(toNode); | 1703 observer.FocusedNodeChanged(toNode); |
| 1717 | 1704 |
| 1718 RenderFrameImpl* previous_frame = nullptr; | 1705 RenderFrameImpl* previous_frame = nullptr; |
| 1719 if (!fromNode.isNull()) | 1706 if (!fromNode.isNull()) |
| 1720 previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame()); | 1707 previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame()); |
| 1721 RenderFrameImpl* new_frame = nullptr; | 1708 RenderFrameImpl* new_frame = nullptr; |
| 1722 if (!toNode.isNull()) | 1709 if (!toNode.isNull()) |
| 1723 new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame()); | 1710 new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 | 1795 |
| 1809 void RenderViewImpl::didHandleGestureEvent( | 1796 void RenderViewImpl::didHandleGestureEvent( |
| 1810 const WebGestureEvent& event, | 1797 const WebGestureEvent& event, |
| 1811 bool event_cancelled) { | 1798 bool event_cancelled) { |
| 1812 RenderWidget::didHandleGestureEvent(event, event_cancelled); | 1799 RenderWidget::didHandleGestureEvent(event, event_cancelled); |
| 1813 | 1800 |
| 1814 if (!event_cancelled) { | 1801 if (!event_cancelled) { |
| 1815 for (auto& observer : observers_) | 1802 for (auto& observer : observers_) |
| 1816 observer.DidHandleGestureEvent(event); | 1803 observer.DidHandleGestureEvent(event); |
| 1817 } | 1804 } |
| 1818 | |
| 1819 // TODO(ananta): Piggyback off existing IPCs to communicate this information, | |
| 1820 // crbug/420130. | |
| 1821 #if defined(OS_WIN) | |
| 1822 if (event.type != blink::WebGestureEvent::GestureTap) | |
| 1823 return; | |
| 1824 | |
| 1825 // TODO(estade): hit test the event against focused node to make sure | |
| 1826 // the tap actually hit the focused node. | |
| 1827 blink::WebTextInputType text_input_type = GetWebView()->textInputType(); | |
| 1828 | |
| 1829 Send(new ViewHostMsg_FocusedNodeTouched( | |
| 1830 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone)); | |
| 1831 #endif | |
| 1832 } | 1805 } |
| 1833 | 1806 |
| 1834 void RenderViewImpl::initializeLayerTreeView() { | 1807 void RenderViewImpl::initializeLayerTreeView() { |
| 1835 RenderWidget::initializeLayerTreeView(); | 1808 RenderWidget::initializeLayerTreeView(); |
| 1836 RenderWidgetCompositor* rwc = compositor(); | 1809 RenderWidgetCompositor* rwc = compositor(); |
| 1837 if (!rwc) | 1810 if (!rwc) |
| 1838 return; | 1811 return; |
| 1839 | 1812 |
| 1840 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 1813 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1841 // render_thread may be NULL in tests. | 1814 // render_thread may be NULL in tests. |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 browser_controls_shrink_blink_size_ = | 2262 browser_controls_shrink_blink_size_ = |
| 2290 params.browser_controls_shrink_blink_size; | 2263 params.browser_controls_shrink_blink_size; |
| 2291 top_controls_height_ = params.top_controls_height; | 2264 top_controls_height_ = params.top_controls_height; |
| 2292 | 2265 |
| 2293 RenderWidget::OnResize(params); | 2266 RenderWidget::OnResize(params); |
| 2294 | 2267 |
| 2295 if (old_visible_viewport_size != visible_viewport_size_) | 2268 if (old_visible_viewport_size != visible_viewport_size_) |
| 2296 has_scrolled_focused_editable_node_into_rect_ = false; | 2269 has_scrolled_focused_editable_node_into_rect_ = false; |
| 2297 } | 2270 } |
| 2298 | 2271 |
| 2299 void RenderViewImpl::OnClearFocusedElement() { | |
| 2300 if (webview()) | |
| 2301 webview()->clearFocusedElement(); | |
| 2302 } | |
| 2303 | |
| 2304 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { | 2272 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
| 2305 if (frame_widget_) | 2273 if (frame_widget_) |
| 2306 frame_widget_->setIsTransparent(!opaque); | 2274 frame_widget_->setIsTransparent(!opaque); |
| 2307 if (compositor_) | 2275 if (compositor_) |
| 2308 compositor_->setHasTransparentBackground(!opaque); | 2276 compositor_->setHasTransparentBackground(!opaque); |
| 2309 } | 2277 } |
| 2310 | 2278 |
| 2311 void RenderViewImpl::OnSetActive(bool active) { | 2279 void RenderViewImpl::OnSetActive(bool active) { |
| 2312 if (webview()) | 2280 if (webview()) |
| 2313 webview()->setIsActive(active); | 2281 webview()->setIsActive(active); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2777 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2745 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2778 } | 2746 } |
| 2779 | 2747 |
| 2780 std::unique_ptr<InputEventAck> ack( | 2748 std::unique_ptr<InputEventAck> ack( |
| 2781 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, | 2749 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, |
| 2782 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 2750 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
| 2783 OnInputEventAck(std::move(ack)); | 2751 OnInputEventAck(std::move(ack)); |
| 2784 } | 2752 } |
| 2785 | 2753 |
| 2786 } // namespace content | 2754 } // namespace content |
| OLD | NEW |