Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 715733002: [Android] Show autofill popup after animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on top of https://codereview.chromium.org/826713002/ Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) 1310 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
1311 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, 1311 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse,
1312 OnEnumerateDirectoryResponse) 1312 OnEnumerateDirectoryResponse)
1313 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) 1313 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse)
1314 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut, 1314 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut,
1315 OnSuppressDialogsUntilSwapOut) 1315 OnSuppressDialogsUntilSwapOut)
1316 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) 1316 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
1317 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) 1317 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged)
1318 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) 1318 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
1319 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) 1319 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement)
1320 IPC_MESSAGE_HANDLER(ViewMsg_FocusChangeComplete, FocusChangeComplete)
1320 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) 1321 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque)
1321 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, 1322 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode,
1322 OnEnablePreferredSizeChangedMode) 1323 OnEnablePreferredSizeChangedMode)
1323 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) 1324 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize)
1324 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) 1325 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize)
1325 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, 1326 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
1326 OnDisableScrollbarsForSmallWindows) 1327 OnDisableScrollbarsForSmallWindows)
1327 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) 1328 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs)
1328 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) 1329 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
1329 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) 1330 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 1411
1411 Send(new InputHostMsg_MoveCaret_ACK(routing_id_)); 1412 Send(new InputHostMsg_MoveCaret_ACK(routing_id_));
1412 1413
1413 webview()->focusedFrame()->moveCaretSelection(point); 1414 webview()->focusedFrame()->moveCaretSelection(point);
1414 } 1415 }
1415 1416
1416 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( 1417 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect(
1417 const gfx::Rect& rect) { 1418 const gfx::Rect& rect) {
1418 if (has_scrolled_focused_editable_node_into_rect_ && 1419 if (has_scrolled_focused_editable_node_into_rect_ &&
1419 rect == rect_for_scrolled_focused_editable_node_) { 1420 rect == rect_for_scrolled_focused_editable_node_) {
1421 FocusChangeComplete();
1420 return; 1422 return;
1421 } 1423 }
1422 1424
1423 blink::WebElement element = GetFocusedElement(); 1425 blink::WebElement element = GetFocusedElement();
1426 bool will_animate = false;
1424 if (!element.isNull() && IsEditableNode(element)) { 1427 if (!element.isNull() && IsEditableNode(element)) {
1425 rect_for_scrolled_focused_editable_node_ = rect; 1428 rect_for_scrolled_focused_editable_node_ = rect;
1426 has_scrolled_focused_editable_node_into_rect_ = true; 1429 has_scrolled_focused_editable_node_into_rect_ = true;
1427 webview()->scrollFocusedNodeIntoRect(rect); 1430 will_animate = webview()->scrollFocusedNodeIntoRect(rect);
1428 } 1431 }
1432
1433 if (!will_animate)
1434 FocusChangeComplete();
1429 } 1435 }
1430 1436
1431 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( 1437 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent(
1432 const EditCommands& edit_commands) { 1438 const EditCommands& edit_commands) {
1433 edit_commands_ = edit_commands; 1439 edit_commands_ = edit_commands;
1434 } 1440 }
1435 1441
1436 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, 1442 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset,
1437 int history_length) { 1443 int history_length) {
1438 DCHECK_GE(history_offset, -1); 1444 DCHECK_GE(history_offset, -1);
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 WebNode web_node = const_cast<WebNode&>(node); 1919 WebNode web_node = const_cast<WebNode&>(node);
1914 node_bounds = gfx::Rect(web_node.to<WebElement>().boundsInViewportSpace()); 1920 node_bounds = gfx::Rect(web_node.to<WebElement>().boundsInViewportSpace());
1915 } 1921 }
1916 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node), 1922 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node),
1917 node_bounds)); 1923 node_bounds));
1918 1924
1919 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); 1925 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node));
1920 1926
1921 // TODO(dmazzoni): this should be part of RenderFrameObserver. 1927 // TODO(dmazzoni): this should be part of RenderFrameObserver.
1922 GetMainRenderFrame()->FocusedNodeChanged(node); 1928 GetMainRenderFrame()->FocusedNodeChanged(node);
1929
1930 focused_element_bounds_ = node_bounds;
1923 } 1931 }
1924 1932
1925 void RenderViewImpl::didUpdateLayout() { 1933 void RenderViewImpl::didUpdateLayout() {
1926 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); 1934 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout());
1927 1935
1928 // We don't always want to set up a timer, only if we've been put in that 1936 // We don't always want to set up a timer, only if we've been put in that
1929 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| 1937 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
1930 // message. 1938 // message.
1931 if (!send_preferred_size_changes_ || !webview()) 1939 if (!send_preferred_size_changes_ || !webview())
1932 return; 1940 return;
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3191 } 3199 }
3192 } 3200 }
3193 3201
3194 gfx::Size old_visible_viewport_size = visible_viewport_size_; 3202 gfx::Size old_visible_viewport_size = visible_viewport_size_;
3195 3203
3196 RenderWidget::OnResize(params); 3204 RenderWidget::OnResize(params);
3197 3205
3198 if (old_visible_viewport_size != visible_viewport_size_) 3206 if (old_visible_viewport_size != visible_viewport_size_)
3199 has_scrolled_focused_editable_node_into_rect_ = false; 3207 has_scrolled_focused_editable_node_into_rect_ = false;
3200 3208
3201 FOR_EACH_OBSERVER(RenderViewObserver, 3209 blink::WebElement focused_element = GetFocusedElement();
3202 observers_, 3210 blink::WebRect bounds = focused_element.isNull()
3203 Resized()); 3211 ? blink::WebRect()
3212 : focused_element.boundsInViewportSpace();
3213 if (bounds != focused_element_bounds_) {
3214 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
3215 FocusedElementMovedOnResize());
3216 }
3217
3218 focused_element_bounds_ = bounds;
3204 } 3219 }
3205 3220
3206 void RenderViewImpl::DidInitiatePaint() { 3221 void RenderViewImpl::DidInitiatePaint() {
3207 #if defined(ENABLE_PLUGINS) 3222 #if defined(ENABLE_PLUGINS)
3208 // Notify all instances that we painted. The same caveats apply as for 3223 // Notify all instances that we painted. The same caveats apply as for
3209 // ViewFlushedPaint regarding instances closing themselves, so we take 3224 // ViewFlushedPaint regarding instances closing themselves, so we take
3210 // similar precautions. 3225 // similar precautions.
3211 PepperPluginSet plugins = active_pepper_instances_; 3226 PepperPluginSet plugins = active_pepper_instances_;
3212 for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { 3227 for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) {
3213 if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) 3228 if (active_pepper_instances_.find(*i) != active_pepper_instances_.end())
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 // after Pepper API equips features related to surrounding text retrieval. 3634 // after Pepper API equips features related to surrounding text retrieval.
3620 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); 3635 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds();
3621 *start = caret; 3636 *start = caret;
3622 *end = caret; 3637 *end = caret;
3623 return; 3638 return;
3624 } 3639 }
3625 #endif 3640 #endif
3626 RenderWidget::GetSelectionBounds(start, end); 3641 RenderWidget::GetSelectionBounds(start, end);
3627 } 3642 }
3628 3643
3644 void RenderViewImpl::FocusChangeComplete() {
3645 RenderWidget::FocusChangeComplete();
3646 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete());
3647 }
3648
3629 void RenderViewImpl::GetCompositionCharacterBounds( 3649 void RenderViewImpl::GetCompositionCharacterBounds(
3630 std::vector<gfx::Rect>* bounds) { 3650 std::vector<gfx::Rect>* bounds) {
3631 DCHECK(bounds); 3651 DCHECK(bounds);
3632 bounds->clear(); 3652 bounds->clear();
3633 3653
3634 #if defined(ENABLE_PLUGINS) 3654 #if defined(ENABLE_PLUGINS)
3635 if (focused_pepper_plugin_) { 3655 if (focused_pepper_plugin_) {
3636 return; 3656 return;
3637 } 3657 }
3638 #endif 3658 #endif
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 } 3725 }
3706 3726
3707 void RenderViewImpl::InstrumentWillComposite() { 3727 void RenderViewImpl::InstrumentWillComposite() {
3708 if (!webview()) 3728 if (!webview())
3709 return; 3729 return;
3710 if (!webview()->devToolsAgent()) 3730 if (!webview()->devToolsAgent())
3711 return; 3731 return;
3712 webview()->devToolsAgent()->willComposite(); 3732 webview()->devToolsAgent()->willComposite();
3713 } 3733 }
3714 3734
3735 void RenderViewImpl::DidCompletePageScaleAnimation() {
3736 FocusChangeComplete();
3737 }
3738
3715 void RenderViewImpl::SetScreenMetricsEmulationParameters( 3739 void RenderViewImpl::SetScreenMetricsEmulationParameters(
3716 float device_scale_factor, 3740 float device_scale_factor,
3717 const gfx::Point& root_layer_offset, 3741 const gfx::Point& root_layer_offset,
3718 float root_layer_scale) { 3742 float root_layer_scale) {
3719 if (webview() && compositor()) { 3743 if (webview() && compositor()) {
3720 webview()->setCompositorDeviceScaleFactorOverride(device_scale_factor); 3744 webview()->setCompositorDeviceScaleFactorOverride(device_scale_factor);
3721 webview()->setRootLayerTransform( 3745 webview()->setRootLayerTransform(
3722 blink::WebSize(root_layer_offset.x(), root_layer_offset.y()), 3746 blink::WebSize(root_layer_offset.x(), root_layer_offset.y()),
3723 root_layer_scale); 3747 root_layer_scale);
3724 } 3748 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
4096 std::vector<gfx::Size> sizes; 4120 std::vector<gfx::Size> sizes;
4097 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4121 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4098 if (!url.isEmpty()) 4122 if (!url.isEmpty())
4099 urls.push_back( 4123 urls.push_back(
4100 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4124 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4101 } 4125 }
4102 SendUpdateFaviconURL(urls); 4126 SendUpdateFaviconURL(urls);
4103 } 4127 }
4104 4128
4105 } // namespace content 4129 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698