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