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 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 | 1413 |
1414 Send(new InputHostMsg_MoveCaret_ACK(routing_id_)); | 1414 Send(new InputHostMsg_MoveCaret_ACK(routing_id_)); |
1415 | 1415 |
1416 webview()->focusedFrame()->moveCaretSelection(point); | 1416 webview()->focusedFrame()->moveCaretSelection(point); |
1417 } | 1417 } |
1418 | 1418 |
1419 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( | 1419 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
1420 const gfx::Rect& rect) { | 1420 const gfx::Rect& rect) { |
1421 if (has_scrolled_focused_editable_node_into_rect_ && | 1421 if (has_scrolled_focused_editable_node_into_rect_ && |
1422 rect == rect_for_scrolled_focused_editable_node_) { | 1422 rect == rect_for_scrolled_focused_editable_node_) { |
| 1423 FocusChangeComplete(); |
1423 return; | 1424 return; |
1424 } | 1425 } |
1425 | 1426 |
1426 blink::WebElement element = GetFocusedElement(); | 1427 blink::WebElement element = GetFocusedElement(); |
| 1428 bool will_animate = false; |
1427 if (!element.isNull() && IsEditableNode(element)) { | 1429 if (!element.isNull() && IsEditableNode(element)) { |
1428 rect_for_scrolled_focused_editable_node_ = rect; | 1430 rect_for_scrolled_focused_editable_node_ = rect; |
1429 has_scrolled_focused_editable_node_into_rect_ = true; | 1431 has_scrolled_focused_editable_node_into_rect_ = true; |
1430 webview()->scrollFocusedNodeIntoRect(rect); | 1432 will_animate = webview()->scrollFocusedNodeIntoRect(rect); |
1431 } | 1433 } |
| 1434 |
| 1435 if (!will_animate) |
| 1436 FocusChangeComplete(); |
1432 } | 1437 } |
1433 | 1438 |
1434 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( | 1439 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
1435 const EditCommands& edit_commands) { | 1440 const EditCommands& edit_commands) { |
1436 edit_commands_ = edit_commands; | 1441 edit_commands_ = edit_commands; |
1437 } | 1442 } |
1438 | 1443 |
1439 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, | 1444 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
1440 int history_length) { | 1445 int history_length) { |
1441 DCHECK_GE(history_offset, -1); | 1446 DCHECK_GE(history_offset, -1); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 WebNode web_node = const_cast<WebNode&>(node); | 1921 WebNode web_node = const_cast<WebNode&>(node); |
1917 node_bounds = gfx::Rect(web_node.to<WebElement>().boundsInViewportSpace()); | 1922 node_bounds = gfx::Rect(web_node.to<WebElement>().boundsInViewportSpace()); |
1918 } | 1923 } |
1919 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node), | 1924 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node), |
1920 node_bounds)); | 1925 node_bounds)); |
1921 | 1926 |
1922 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 1927 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
1923 | 1928 |
1924 // TODO(dmazzoni): this should be part of RenderFrameObserver. | 1929 // TODO(dmazzoni): this should be part of RenderFrameObserver. |
1925 GetMainRenderFrame()->FocusedNodeChanged(node); | 1930 GetMainRenderFrame()->FocusedNodeChanged(node); |
| 1931 |
| 1932 focused_element_bounds_ = node_bounds; |
1926 } | 1933 } |
1927 | 1934 |
1928 void RenderViewImpl::didUpdateLayout() { | 1935 void RenderViewImpl::didUpdateLayout() { |
1929 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); | 1936 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); |
1930 | 1937 |
1931 // We don't always want to set up a timer, only if we've been put in that | 1938 // We don't always want to set up a timer, only if we've been put in that |
1932 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 1939 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
1933 // message. | 1940 // message. |
1934 if (!send_preferred_size_changes_ || !webview()) | 1941 if (!send_preferred_size_changes_ || !webview()) |
1935 return; | 1942 return; |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3195 } | 3202 } |
3196 } | 3203 } |
3197 | 3204 |
3198 gfx::Size old_visible_viewport_size = visible_viewport_size_; | 3205 gfx::Size old_visible_viewport_size = visible_viewport_size_; |
3199 | 3206 |
3200 RenderWidget::OnResize(params); | 3207 RenderWidget::OnResize(params); |
3201 | 3208 |
3202 if (old_visible_viewport_size != visible_viewport_size_) | 3209 if (old_visible_viewport_size != visible_viewport_size_) |
3203 has_scrolled_focused_editable_node_into_rect_ = false; | 3210 has_scrolled_focused_editable_node_into_rect_ = false; |
3204 | 3211 |
3205 FOR_EACH_OBSERVER(RenderViewObserver, | 3212 blink::WebElement focused_element = GetFocusedElement(); |
3206 observers_, | 3213 blink::WebRect bounds = focused_element.isNull() |
3207 Resized()); | 3214 ? blink::WebRect() |
| 3215 : focused_element.boundsInViewportSpace(); |
| 3216 if (bounds != focused_element_bounds_) { |
| 3217 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3218 FocusedElementMovedOnResize()); |
| 3219 } |
| 3220 |
| 3221 focused_element_bounds_ = bounds; |
3208 } | 3222 } |
3209 | 3223 |
3210 void RenderViewImpl::DidInitiatePaint() { | 3224 void RenderViewImpl::DidInitiatePaint() { |
3211 #if defined(ENABLE_PLUGINS) | 3225 #if defined(ENABLE_PLUGINS) |
3212 // Notify all instances that we painted. The same caveats apply as for | 3226 // Notify all instances that we painted. The same caveats apply as for |
3213 // ViewFlushedPaint regarding instances closing themselves, so we take | 3227 // ViewFlushedPaint regarding instances closing themselves, so we take |
3214 // similar precautions. | 3228 // similar precautions. |
3215 PepperPluginSet plugins = active_pepper_instances_; | 3229 PepperPluginSet plugins = active_pepper_instances_; |
3216 for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { | 3230 for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { |
3217 if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) | 3231 if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 // after Pepper API equips features related to surrounding text retrieval. | 3637 // after Pepper API equips features related to surrounding text retrieval. |
3624 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); | 3638 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); |
3625 *start = caret; | 3639 *start = caret; |
3626 *end = caret; | 3640 *end = caret; |
3627 return; | 3641 return; |
3628 } | 3642 } |
3629 #endif | 3643 #endif |
3630 RenderWidget::GetSelectionBounds(start, end); | 3644 RenderWidget::GetSelectionBounds(start, end); |
3631 } | 3645 } |
3632 | 3646 |
| 3647 void RenderViewImpl::FocusChangeComplete() { |
| 3648 RenderWidget::FocusChangeComplete(); |
| 3649 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); |
| 3650 } |
| 3651 |
3633 void RenderViewImpl::GetCompositionCharacterBounds( | 3652 void RenderViewImpl::GetCompositionCharacterBounds( |
3634 std::vector<gfx::Rect>* bounds) { | 3653 std::vector<gfx::Rect>* bounds) { |
3635 DCHECK(bounds); | 3654 DCHECK(bounds); |
3636 bounds->clear(); | 3655 bounds->clear(); |
3637 | 3656 |
3638 #if defined(ENABLE_PLUGINS) | 3657 #if defined(ENABLE_PLUGINS) |
3639 if (focused_pepper_plugin_) { | 3658 if (focused_pepper_plugin_) { |
3640 return; | 3659 return; |
3641 } | 3660 } |
3642 #endif | 3661 #endif |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3709 } | 3728 } |
3710 | 3729 |
3711 void RenderViewImpl::InstrumentWillComposite() { | 3730 void RenderViewImpl::InstrumentWillComposite() { |
3712 if (!webview()) | 3731 if (!webview()) |
3713 return; | 3732 return; |
3714 if (!webview()->devToolsAgent()) | 3733 if (!webview()->devToolsAgent()) |
3715 return; | 3734 return; |
3716 webview()->devToolsAgent()->willComposite(); | 3735 webview()->devToolsAgent()->willComposite(); |
3717 } | 3736 } |
3718 | 3737 |
| 3738 void RenderViewImpl::DidCompletePageScaleAnimation() { |
| 3739 FocusChangeComplete(); |
| 3740 } |
| 3741 |
3719 void RenderViewImpl::SetScreenMetricsEmulationParameters( | 3742 void RenderViewImpl::SetScreenMetricsEmulationParameters( |
3720 float device_scale_factor, | 3743 float device_scale_factor, |
3721 const gfx::Point& root_layer_offset, | 3744 const gfx::Point& root_layer_offset, |
3722 float root_layer_scale) { | 3745 float root_layer_scale) { |
3723 if (webview() && compositor()) { | 3746 if (webview() && compositor()) { |
3724 webview()->setCompositorDeviceScaleFactorOverride(device_scale_factor); | 3747 webview()->setCompositorDeviceScaleFactorOverride(device_scale_factor); |
3725 webview()->setRootLayerTransform( | 3748 webview()->setRootLayerTransform( |
3726 blink::WebSize(root_layer_offset.x(), root_layer_offset.y()), | 3749 blink::WebSize(root_layer_offset.x(), root_layer_offset.y()), |
3727 root_layer_scale); | 3750 root_layer_scale); |
3728 } | 3751 } |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4100 std::vector<gfx::Size> sizes; | 4123 std::vector<gfx::Size> sizes; |
4101 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4124 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4102 if (!url.isEmpty()) | 4125 if (!url.isEmpty()) |
4103 urls.push_back( | 4126 urls.push_back( |
4104 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4127 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4105 } | 4128 } |
4106 SendUpdateFaviconURL(urls); | 4129 SendUpdateFaviconURL(urls); |
4107 } | 4130 } |
4108 | 4131 |
4109 } // namespace content | 4132 } // namespace content |
OLD | NEW |