| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 1309 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 1310 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 1310 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 1311 OnEnumerateDirectoryResponse) | 1311 OnEnumerateDirectoryResponse) |
| 1312 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 1312 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
| 1313 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut, | 1313 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut, |
| 1314 OnSuppressDialogsUntilSwapOut) | 1314 OnSuppressDialogsUntilSwapOut) |
| 1315 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 1315 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 1316 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 1316 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
| 1317 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 1317 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
| 1318 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) | 1318 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) |
| 1319 IPC_MESSAGE_HANDLER(ViewMsg_FocusChangeComplete, FocusChangeComplete) |
| 1319 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) | 1320 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
| 1320 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, | 1321 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1321 OnEnablePreferredSizeChangedMode) | 1322 OnEnablePreferredSizeChangedMode) |
| 1322 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) | 1323 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
| 1323 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) | 1324 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
| 1324 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, | 1325 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1325 OnDisableScrollbarsForSmallWindows) | 1326 OnDisableScrollbarsForSmallWindows) |
| 1326 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) | 1327 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
| 1327 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) | 1328 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
| 1328 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) | 1329 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 | 1410 |
| 1410 Send(new InputHostMsg_MoveCaret_ACK(routing_id_)); | 1411 Send(new InputHostMsg_MoveCaret_ACK(routing_id_)); |
| 1411 | 1412 |
| 1412 webview()->focusedFrame()->moveCaretSelection(point); | 1413 webview()->focusedFrame()->moveCaretSelection(point); |
| 1413 } | 1414 } |
| 1414 | 1415 |
| 1415 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( | 1416 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1416 const gfx::Rect& rect) { | 1417 const gfx::Rect& rect) { |
| 1417 if (has_scrolled_focused_editable_node_into_rect_ && | 1418 if (has_scrolled_focused_editable_node_into_rect_ && |
| 1418 rect == rect_for_scrolled_focused_editable_node_) { | 1419 rect == rect_for_scrolled_focused_editable_node_) { |
| 1420 FocusChangeComplete(); |
| 1419 return; | 1421 return; |
| 1420 } | 1422 } |
| 1421 | 1423 |
| 1422 blink::WebElement element = GetFocusedElement(); | 1424 blink::WebElement element = GetFocusedElement(); |
| 1425 bool will_animate = false; |
| 1423 if (!element.isNull() && IsEditableNode(element)) { | 1426 if (!element.isNull() && IsEditableNode(element)) { |
| 1424 rect_for_scrolled_focused_editable_node_ = rect; | 1427 rect_for_scrolled_focused_editable_node_ = rect; |
| 1425 has_scrolled_focused_editable_node_into_rect_ = true; | 1428 has_scrolled_focused_editable_node_into_rect_ = true; |
| 1426 webview()->scrollFocusedNodeIntoRect(rect); | 1429 will_animate = webview()->scrollFocusedNodeIntoRect(rect); |
| 1427 } | 1430 } |
| 1431 |
| 1432 if (!will_animate) |
| 1433 FocusChangeComplete(); |
| 1428 } | 1434 } |
| 1429 | 1435 |
| 1430 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( | 1436 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
| 1431 const EditCommands& edit_commands) { | 1437 const EditCommands& edit_commands) { |
| 1432 edit_commands_ = edit_commands; | 1438 edit_commands_ = edit_commands; |
| 1433 } | 1439 } |
| 1434 | 1440 |
| 1435 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, | 1441 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
| 1436 int history_length) { | 1442 int history_length) { |
| 1437 DCHECK_GE(history_offset, -1); | 1443 DCHECK_GE(history_offset, -1); |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 | 1914 |
| 1909 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { | 1915 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
| 1910 has_scrolled_focused_editable_node_into_rect_ = false; | 1916 has_scrolled_focused_editable_node_into_rect_ = false; |
| 1911 | 1917 |
| 1912 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 1918 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
| 1913 | 1919 |
| 1914 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 1920 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
| 1915 | 1921 |
| 1916 // TODO(dmazzoni): this should be part of RenderFrameObserver. | 1922 // TODO(dmazzoni): this should be part of RenderFrameObserver. |
| 1917 GetMainRenderFrame()->FocusedNodeChanged(node); | 1923 GetMainRenderFrame()->FocusedNodeChanged(node); |
| 1924 |
| 1925 blink::WebElement focused_element = GetFocusedElement(); |
| 1926 focused_element_bounds_ = focused_element.isNull() |
| 1927 ? blink::WebRect() |
| 1928 : focused_element.boundsInViewportSpace(); |
| 1918 } | 1929 } |
| 1919 | 1930 |
| 1920 void RenderViewImpl::didUpdateLayout() { | 1931 void RenderViewImpl::didUpdateLayout() { |
| 1921 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); | 1932 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); |
| 1922 | 1933 |
| 1923 // We don't always want to set up a timer, only if we've been put in that | 1934 // We don't always want to set up a timer, only if we've been put in that |
| 1924 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 1935 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1925 // message. | 1936 // message. |
| 1926 if (!send_preferred_size_changes_ || !webview()) | 1937 if (!send_preferred_size_changes_ || !webview()) |
| 1927 return; | 1938 return; |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3204 } | 3215 } |
| 3205 } | 3216 } |
| 3206 | 3217 |
| 3207 gfx::Size old_visible_viewport_size = visible_viewport_size_; | 3218 gfx::Size old_visible_viewport_size = visible_viewport_size_; |
| 3208 | 3219 |
| 3209 RenderWidget::OnResize(params); | 3220 RenderWidget::OnResize(params); |
| 3210 | 3221 |
| 3211 if (old_visible_viewport_size != visible_viewport_size_) | 3222 if (old_visible_viewport_size != visible_viewport_size_) |
| 3212 has_scrolled_focused_editable_node_into_rect_ = false; | 3223 has_scrolled_focused_editable_node_into_rect_ = false; |
| 3213 | 3224 |
| 3214 FOR_EACH_OBSERVER(RenderViewObserver, | 3225 blink::WebElement focused_element = GetFocusedElement(); |
| 3215 observers_, | 3226 blink::WebRect bounds = focused_element.isNull() |
| 3216 Resized()); | 3227 ? blink::WebRect() |
| 3228 : focused_element.boundsInViewportSpace(); |
| 3229 if (bounds != focused_element_bounds_) { |
| 3230 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3231 FocusedElementMovedOnResize()); |
| 3232 } |
| 3233 |
| 3234 focused_element_bounds_ = bounds; |
| 3217 } | 3235 } |
| 3218 | 3236 |
| 3219 void RenderViewImpl::DidInitiatePaint() { | 3237 void RenderViewImpl::DidInitiatePaint() { |
| 3220 #if defined(ENABLE_PLUGINS) | 3238 #if defined(ENABLE_PLUGINS) |
| 3221 // Notify all instances that we painted. The same caveats apply as for | 3239 // Notify all instances that we painted. The same caveats apply as for |
| 3222 // ViewFlushedPaint regarding instances closing themselves, so we take | 3240 // ViewFlushedPaint regarding instances closing themselves, so we take |
| 3223 // similar precautions. | 3241 // similar precautions. |
| 3224 PepperPluginSet plugins = active_pepper_instances_; | 3242 PepperPluginSet plugins = active_pepper_instances_; |
| 3225 for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { | 3243 for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { |
| 3226 if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) | 3244 if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3632 // after Pepper API equips features related to surrounding text retrieval. | 3650 // after Pepper API equips features related to surrounding text retrieval. |
| 3633 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); | 3651 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); |
| 3634 *start = caret; | 3652 *start = caret; |
| 3635 *end = caret; | 3653 *end = caret; |
| 3636 return; | 3654 return; |
| 3637 } | 3655 } |
| 3638 #endif | 3656 #endif |
| 3639 RenderWidget::GetSelectionBounds(start, end); | 3657 RenderWidget::GetSelectionBounds(start, end); |
| 3640 } | 3658 } |
| 3641 | 3659 |
| 3660 void RenderViewImpl::FocusChangeComplete() { |
| 3661 RenderWidget::FocusChangeComplete(); |
| 3662 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); |
| 3663 } |
| 3664 |
| 3642 void RenderViewImpl::GetCompositionCharacterBounds( | 3665 void RenderViewImpl::GetCompositionCharacterBounds( |
| 3643 std::vector<gfx::Rect>* bounds) { | 3666 std::vector<gfx::Rect>* bounds) { |
| 3644 DCHECK(bounds); | 3667 DCHECK(bounds); |
| 3645 bounds->clear(); | 3668 bounds->clear(); |
| 3646 | 3669 |
| 3647 #if defined(ENABLE_PLUGINS) | 3670 #if defined(ENABLE_PLUGINS) |
| 3648 if (focused_pepper_plugin_) { | 3671 if (focused_pepper_plugin_) { |
| 3649 return; | 3672 return; |
| 3650 } | 3673 } |
| 3651 #endif | 3674 #endif |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3718 } | 3741 } |
| 3719 | 3742 |
| 3720 void RenderViewImpl::InstrumentWillComposite() { | 3743 void RenderViewImpl::InstrumentWillComposite() { |
| 3721 if (!webview()) | 3744 if (!webview()) |
| 3722 return; | 3745 return; |
| 3723 if (!webview()->devToolsAgent()) | 3746 if (!webview()->devToolsAgent()) |
| 3724 return; | 3747 return; |
| 3725 webview()->devToolsAgent()->willComposite(); | 3748 webview()->devToolsAgent()->willComposite(); |
| 3726 } | 3749 } |
| 3727 | 3750 |
| 3751 void RenderViewImpl::DidCompletePageScaleAnimation() { |
| 3752 FocusChangeComplete(); |
| 3753 } |
| 3754 |
| 3728 void RenderViewImpl::SetScreenMetricsEmulationParameters( | 3755 void RenderViewImpl::SetScreenMetricsEmulationParameters( |
| 3729 float device_scale_factor, | 3756 float device_scale_factor, |
| 3730 const gfx::Point& root_layer_offset, | 3757 const gfx::Point& root_layer_offset, |
| 3731 float root_layer_scale) { | 3758 float root_layer_scale) { |
| 3732 if (webview() && compositor()) { | 3759 if (webview() && compositor()) { |
| 3733 webview()->setCompositorDeviceScaleFactorOverride(device_scale_factor); | 3760 webview()->setCompositorDeviceScaleFactorOverride(device_scale_factor); |
| 3734 webview()->setRootLayerTransform( | 3761 webview()->setRootLayerTransform( |
| 3735 blink::WebSize(root_layer_offset.x(), root_layer_offset.y()), | 3762 blink::WebSize(root_layer_offset.x(), root_layer_offset.y()), |
| 3736 root_layer_scale); | 3763 root_layer_scale); |
| 3737 } | 3764 } |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4107 std::vector<gfx::Size> sizes; | 4134 std::vector<gfx::Size> sizes; |
| 4108 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4135 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 4109 if (!url.isEmpty()) | 4136 if (!url.isEmpty()) |
| 4110 urls.push_back( | 4137 urls.push_back( |
| 4111 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4138 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 4112 } | 4139 } |
| 4113 SendUpdateFaviconURL(urls); | 4140 SendUpdateFaviconURL(urls); |
| 4114 } | 4141 } |
| 4115 | 4142 |
| 4116 } // namespace content | 4143 } // namespace content |
| OLD | NEW |