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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 enabled_bindings_(0), | 673 enabled_bindings_(0), |
674 send_preferred_size_changes_(false), | 674 send_preferred_size_changes_(false), |
675 navigation_gesture_(NavigationGestureUnknown), | 675 navigation_gesture_(NavigationGestureUnknown), |
676 opened_by_user_gesture_(true), | 676 opened_by_user_gesture_(true), |
677 history_list_offset_(-1), | 677 history_list_offset_(-1), |
678 history_list_length_(0), | 678 history_list_length_(0), |
679 frames_in_progress_(0), | 679 frames_in_progress_(0), |
680 target_url_status_(TARGET_NONE), | 680 target_url_status_(TARGET_NONE), |
681 uses_temporary_zoom_level_(false), | 681 uses_temporary_zoom_level_(false), |
682 #if defined(OS_ANDROID) | 682 #if defined(OS_ANDROID) |
683 top_controls_constraints_(TOP_CONTROLS_STATE_BOTH), | 683 top_controls_constraints_(BROWSER_CONTROLS_STATE_BOTH), |
684 #endif | 684 #endif |
685 top_controls_shrink_blink_size_(false), | 685 browser_controls_shrink_blink_size_(false), |
686 top_controls_height_(0.f), | 686 top_controls_height_(0.f), |
687 webview_(nullptr), | 687 webview_(nullptr), |
688 has_scrolled_focused_editable_node_into_rect_(false), | 688 has_scrolled_focused_editable_node_into_rect_(false), |
689 page_zoom_level_(params.page_zoom_level), | 689 page_zoom_level_(params.page_zoom_level), |
690 main_render_frame_(nullptr), | 690 main_render_frame_(nullptr), |
691 frame_widget_(nullptr), | 691 frame_widget_(nullptr), |
692 speech_recognition_dispatcher_(NULL), | 692 speech_recognition_dispatcher_(NULL), |
693 #if defined(OS_ANDROID) | 693 #if defined(OS_ANDROID) |
694 expected_content_intent_id_(0), | 694 expected_content_intent_id_(0), |
695 #endif | 695 #endif |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, | 1355 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, |
1356 OnUpdateWindowScreenRect) | 1356 OnUpdateWindowScreenRect) |
1357 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) | 1357 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) |
1358 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor); | 1358 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor); |
1359 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) | 1359 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) |
1360 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) | 1360 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) |
1361 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, | 1361 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, |
1362 OnSetHistoryOffsetAndLength) | 1362 OnSetHistoryOffsetAndLength) |
1363 | 1363 |
1364 #if defined(OS_ANDROID) | 1364 #if defined(OS_ANDROID) |
1365 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1365 IPC_MESSAGE_HANDLER(ViewMsg_UpdateBrowserControlsState, |
1366 OnUpdateTopControlsState) | 1366 OnUpdateBrowserControlsState) |
1367 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1367 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
1368 #elif defined(OS_MACOSX) | 1368 #elif defined(OS_MACOSX) |
1369 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, | 1369 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
1370 OnGetRenderedText) | 1370 OnGetRenderedText) |
1371 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 1371 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
1372 #endif | 1372 #endif |
1373 // Adding a new message? Add platform independent ones first, then put the | 1373 // Adding a new message? Add platform independent ones first, then put the |
1374 // platform specific ones at the end. | 1374 // platform specific ones at the end. |
1375 | 1375 |
1376 // Have the super handle all other messages. | 1376 // Have the super handle all other messages. |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 if (!webview()) | 2387 if (!webview()) |
2388 return; | 2388 return; |
2389 auto_resize_mode_ = false; | 2389 auto_resize_mode_ = false; |
2390 webview()->disableAutoResizeMode(); | 2390 webview()->disableAutoResizeMode(); |
2391 | 2391 |
2392 if (!new_size.IsEmpty()) { | 2392 if (!new_size.IsEmpty()) { |
2393 ResizeParams resize_params; | 2393 ResizeParams resize_params; |
2394 resize_params.screen_info = screen_info_; | 2394 resize_params.screen_info = screen_info_; |
2395 resize_params.new_size = new_size; | 2395 resize_params.new_size = new_size; |
2396 resize_params.physical_backing_size = physical_backing_size_; | 2396 resize_params.physical_backing_size = physical_backing_size_; |
2397 resize_params.top_controls_shrink_blink_size = | 2397 resize_params.browser_controls_shrink_blink_size = |
2398 top_controls_shrink_blink_size_; | 2398 browser_controls_shrink_blink_size_; |
2399 resize_params.top_controls_height = top_controls_height_; | 2399 resize_params.top_controls_height = top_controls_height_; |
2400 resize_params.visible_viewport_size = visible_viewport_size_; | 2400 resize_params.visible_viewport_size = visible_viewport_size_; |
2401 resize_params.is_fullscreen_granted = is_fullscreen_granted(); | 2401 resize_params.is_fullscreen_granted = is_fullscreen_granted(); |
2402 resize_params.display_mode = display_mode_; | 2402 resize_params.display_mode = display_mode_; |
2403 resize_params.needs_resize_ack = false; | 2403 resize_params.needs_resize_ack = false; |
2404 Resize(resize_params); | 2404 Resize(resize_params); |
2405 } | 2405 } |
2406 } | 2406 } |
2407 | 2407 |
2408 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { | 2408 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); | 2488 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); |
2489 RenderWidget::OnClose(); | 2489 RenderWidget::OnClose(); |
2490 } | 2490 } |
2491 | 2491 |
2492 void RenderViewImpl::OnMoveOrResizeStarted() { | 2492 void RenderViewImpl::OnMoveOrResizeStarted() { |
2493 if (webview()) | 2493 if (webview()) |
2494 webview()->hidePopups(); | 2494 webview()->hidePopups(); |
2495 } | 2495 } |
2496 | 2496 |
2497 void RenderViewImpl::ResizeWebWidget() { | 2497 void RenderViewImpl::ResizeWebWidget() { |
2498 webview()->resizeWithTopControls(GetSizeForWebWidget(), | 2498 webview()->resizeWithBrowserControls(GetSizeForWebWidget(), |
2499 top_controls_height_, | 2499 top_controls_height_, |
2500 top_controls_shrink_blink_size_); | 2500 browser_controls_shrink_blink_size_); |
2501 } | 2501 } |
2502 | 2502 |
2503 void RenderViewImpl::OnResize(const ResizeParams& params) { | 2503 void RenderViewImpl::OnResize(const ResizeParams& params) { |
2504 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); | 2504 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); |
2505 if (webview()) { | 2505 if (webview()) { |
2506 webview()->hidePopups(); | 2506 webview()->hidePopups(); |
2507 if (send_preferred_size_changes_ && | 2507 if (send_preferred_size_changes_ && |
2508 webview()->mainFrame()->isWebLocalFrame()) { | 2508 webview()->mainFrame()->isWebLocalFrame()) { |
2509 webview()->mainFrame()->setCanHaveScrollbars( | 2509 webview()->mainFrame()->setCanHaveScrollbars( |
2510 ShouldDisplayScrollbars(params.new_size.width(), | 2510 ShouldDisplayScrollbars(params.new_size.width(), |
2511 params.new_size.height())); | 2511 params.new_size.height())); |
2512 } | 2512 } |
2513 if (display_mode_ != params.display_mode) { | 2513 if (display_mode_ != params.display_mode) { |
2514 display_mode_ = params.display_mode; | 2514 display_mode_ = params.display_mode; |
2515 webview()->setDisplayMode(display_mode_); | 2515 webview()->setDisplayMode(display_mode_); |
2516 } | 2516 } |
2517 } | 2517 } |
2518 | 2518 |
2519 gfx::Size old_visible_viewport_size = visible_viewport_size_; | 2519 gfx::Size old_visible_viewport_size = visible_viewport_size_; |
2520 | 2520 |
2521 top_controls_shrink_blink_size_ = params.top_controls_shrink_blink_size; | 2521 browser_controls_shrink_blink_size_ = |
| 2522 params.browser_controls_shrink_blink_size; |
2522 top_controls_height_ = params.top_controls_height; | 2523 top_controls_height_ = params.top_controls_height; |
2523 | 2524 |
2524 RenderWidget::OnResize(params); | 2525 RenderWidget::OnResize(params); |
2525 | 2526 |
2526 if (old_visible_viewport_size != visible_viewport_size_) | 2527 if (old_visible_viewport_size != visible_viewport_size_) |
2527 has_scrolled_focused_editable_node_into_rect_ = false; | 2528 has_scrolled_focused_editable_node_into_rect_ = false; |
2528 } | 2529 } |
2529 | 2530 |
2530 void RenderViewImpl::RenderWidgetDidFlushPaint() { | 2531 void RenderViewImpl::RenderWidgetDidFlushPaint() { |
2531 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. | 2532 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2947 } | 2948 } |
2948 } | 2949 } |
2949 | 2950 |
2950 void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) { | 2951 void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) { |
2951 ResizeParams params; | 2952 ResizeParams params; |
2952 params.screen_info = screen_info_; | 2953 params.screen_info = screen_info_; |
2953 params.screen_info.device_scale_factor = factor; | 2954 params.screen_info.device_scale_factor = factor; |
2954 params.new_size = size(); | 2955 params.new_size = size(); |
2955 params.visible_viewport_size = visible_viewport_size_; | 2956 params.visible_viewport_size = visible_viewport_size_; |
2956 params.physical_backing_size = gfx::ScaleToCeiledSize(size(), factor); | 2957 params.physical_backing_size = gfx::ScaleToCeiledSize(size(), factor); |
2957 params.top_controls_shrink_blink_size = false; | 2958 params.browser_controls_shrink_blink_size = false; |
2958 params.top_controls_height = 0.f; | 2959 params.top_controls_height = 0.f; |
2959 params.is_fullscreen_granted = is_fullscreen_granted(); | 2960 params.is_fullscreen_granted = is_fullscreen_granted(); |
2960 params.display_mode = display_mode_; | 2961 params.display_mode = display_mode_; |
2961 OnResize(params); | 2962 OnResize(params); |
2962 } | 2963 } |
2963 | 2964 |
2964 void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { | 2965 void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { |
2965 gfx::Rect new_window_rect(rootWindowRect().x, | 2966 gfx::Rect new_window_rect(rootWindowRect().x, |
2966 rootWindowRect().y, | 2967 rootWindowRect().y, |
2967 new_size.width(), | 2968 new_size.width(), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 if (IsUseZoomForDSFEnabled()) { | 3032 if (IsUseZoomForDSFEnabled()) { |
3032 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3033 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
3033 } else { | 3034 } else { |
3034 webview()->setDeviceScaleFactor(device_scale_factor_); | 3035 webview()->setDeviceScaleFactor(device_scale_factor_); |
3035 } | 3036 } |
3036 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3037 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3037 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3038 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
3038 } | 3039 } |
3039 | 3040 |
3040 } // namespace content | 3041 } // namespace content |
OLD | NEW |