| 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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) | 1213 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
| 1214 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1214 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 1215 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 1215 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
| 1216 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 1216 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
| 1217 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 1217 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 1218 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 1218 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 1219 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 1219 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 1220 OnEnumerateDirectoryResponse) | 1220 OnEnumerateDirectoryResponse) |
| 1221 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 1221 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 1222 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 1222 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
| 1223 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) | |
| 1224 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) | 1223 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
| 1225 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, | 1224 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1226 OnEnablePreferredSizeChangedMode) | 1225 OnEnablePreferredSizeChangedMode) |
| 1227 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) | 1226 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
| 1228 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) | 1227 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
| 1229 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, | 1228 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1230 OnDisableScrollbarsForSmallWindows) | 1229 OnDisableScrollbarsForSmallWindows) |
| 1231 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) | 1230 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
| 1232 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) | 1231 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
| 1233 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) | 1232 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1749 | 1748 |
| 1750 void RenderViewImpl::focusPrevious() { | 1749 void RenderViewImpl::focusPrevious() { |
| 1751 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); | 1750 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); |
| 1752 } | 1751 } |
| 1753 | 1752 |
| 1754 // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. | 1753 // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. |
| 1755 void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, | 1754 void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, |
| 1756 const WebNode& toNode) { | 1755 const WebNode& toNode) { |
| 1757 has_scrolled_focused_editable_node_into_rect_ = false; | 1756 has_scrolled_focused_editable_node_into_rect_ = false; |
| 1758 | 1757 |
| 1759 gfx::Rect node_bounds; | |
| 1760 bool is_editable = false; | |
| 1761 if (!toNode.isNull() && toNode.isElementNode()) { | |
| 1762 WebElement element = const_cast<WebNode&>(toNode).to<WebElement>(); | |
| 1763 blink::WebRect rect = element.boundsInViewport(); | |
| 1764 ConvertViewportToWindowViaWidget(&rect); | |
| 1765 node_bounds = gfx::Rect(rect); | |
| 1766 is_editable = element.isEditable(); | |
| 1767 } | |
| 1768 Send(new ViewHostMsg_FocusedNodeChanged(GetRoutingID(), is_editable, | |
| 1769 node_bounds)); | |
| 1770 | |
| 1771 // TODO(estade): remove. | 1758 // TODO(estade): remove. |
| 1772 for (auto& observer : observers_) | 1759 for (auto& observer : observers_) |
| 1773 observer.FocusedNodeChanged(toNode); | 1760 observer.FocusedNodeChanged(toNode); |
| 1774 | 1761 |
| 1775 RenderFrameImpl* previous_frame = nullptr; | 1762 RenderFrameImpl* previous_frame = nullptr; |
| 1776 if (!fromNode.isNull()) | 1763 if (!fromNode.isNull()) |
| 1777 previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame()); | 1764 previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame()); |
| 1778 RenderFrameImpl* new_frame = nullptr; | 1765 RenderFrameImpl* new_frame = nullptr; |
| 1779 if (!toNode.isNull()) | 1766 if (!toNode.isNull()) |
| 1780 new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame()); | 1767 new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 | 1841 |
| 1855 void RenderViewImpl::didHandleGestureEvent( | 1842 void RenderViewImpl::didHandleGestureEvent( |
| 1856 const WebGestureEvent& event, | 1843 const WebGestureEvent& event, |
| 1857 bool event_cancelled) { | 1844 bool event_cancelled) { |
| 1858 RenderWidget::didHandleGestureEvent(event, event_cancelled); | 1845 RenderWidget::didHandleGestureEvent(event, event_cancelled); |
| 1859 | 1846 |
| 1860 if (!event_cancelled) { | 1847 if (!event_cancelled) { |
| 1861 for (auto& observer : observers_) | 1848 for (auto& observer : observers_) |
| 1862 observer.DidHandleGestureEvent(event); | 1849 observer.DidHandleGestureEvent(event); |
| 1863 } | 1850 } |
| 1864 | |
| 1865 // TODO(ananta): Piggyback off existing IPCs to communicate this information, | |
| 1866 // crbug/420130. | |
| 1867 #if defined(OS_WIN) | |
| 1868 if (event.type != blink::WebGestureEvent::GestureTap) | |
| 1869 return; | |
| 1870 | |
| 1871 // TODO(estade): hit test the event against focused node to make sure | |
| 1872 // the tap actually hit the focused node. | |
| 1873 blink::WebTextInputType text_input_type = GetWebView()->textInputType(); | |
| 1874 | |
| 1875 Send(new ViewHostMsg_FocusedNodeTouched( | |
| 1876 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone)); | |
| 1877 #endif | |
| 1878 } | 1851 } |
| 1879 | 1852 |
| 1880 void RenderViewImpl::initializeLayerTreeView() { | 1853 void RenderViewImpl::initializeLayerTreeView() { |
| 1881 RenderWidget::initializeLayerTreeView(); | 1854 RenderWidget::initializeLayerTreeView(); |
| 1882 RenderWidgetCompositor* rwc = compositor(); | 1855 RenderWidgetCompositor* rwc = compositor(); |
| 1883 if (!rwc) | 1856 if (!rwc) |
| 1884 return; | 1857 return; |
| 1885 | 1858 |
| 1886 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 1859 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1887 // render_thread may be NULL in tests. | 1860 // render_thread may be NULL in tests. |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2335 browser_controls_shrink_blink_size_ = | 2308 browser_controls_shrink_blink_size_ = |
| 2336 params.browser_controls_shrink_blink_size; | 2309 params.browser_controls_shrink_blink_size; |
| 2337 top_controls_height_ = params.top_controls_height; | 2310 top_controls_height_ = params.top_controls_height; |
| 2338 | 2311 |
| 2339 RenderWidget::OnResize(params); | 2312 RenderWidget::OnResize(params); |
| 2340 | 2313 |
| 2341 if (old_visible_viewport_size != visible_viewport_size_) | 2314 if (old_visible_viewport_size != visible_viewport_size_) |
| 2342 has_scrolled_focused_editable_node_into_rect_ = false; | 2315 has_scrolled_focused_editable_node_into_rect_ = false; |
| 2343 } | 2316 } |
| 2344 | 2317 |
| 2345 void RenderViewImpl::OnClearFocusedElement() { | |
| 2346 if (webview()) | |
| 2347 webview()->clearFocusedElement(); | |
| 2348 } | |
| 2349 | |
| 2350 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { | 2318 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
| 2351 if (frame_widget_) | 2319 if (frame_widget_) |
| 2352 frame_widget_->setIsTransparent(!opaque); | 2320 frame_widget_->setIsTransparent(!opaque); |
| 2353 if (compositor_) | 2321 if (compositor_) |
| 2354 compositor_->setHasTransparentBackground(!opaque); | 2322 compositor_->setHasTransparentBackground(!opaque); |
| 2355 } | 2323 } |
| 2356 | 2324 |
| 2357 void RenderViewImpl::OnSetActive(bool active) { | 2325 void RenderViewImpl::OnSetActive(bool active) { |
| 2358 if (webview()) | 2326 if (webview()) |
| 2359 webview()->setIsActive(active); | 2327 webview()->setIsActive(active); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2823 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2791 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2824 } | 2792 } |
| 2825 | 2793 |
| 2826 std::unique_ptr<InputEventAck> ack( | 2794 std::unique_ptr<InputEventAck> ack( |
| 2827 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, | 2795 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, |
| 2828 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 2796 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
| 2829 OnInputEventAck(std::move(ack)); | 2797 OnInputEventAck(std::move(ack)); |
| 2830 } | 2798 } |
| 2831 | 2799 |
| 2832 } // namespace content | 2800 } // namespace content |
| OLD | NEW |