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 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, | 1330 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
1331 OnScrollFocusedEditableNodeIntoRect) | 1331 OnScrollFocusedEditableNodeIntoRect) |
1332 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 1332 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
1333 OnSetEditCommandsForNextKeyEvent) | 1333 OnSetEditCommandsForNextKeyEvent) |
1334 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 1334 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
1335 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) | 1335 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) |
1336 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) | 1336 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
1337 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1337 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
1338 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 1338 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
1339 OnSetZoomLevelForLoadingURL) | 1339 OnSetZoomLevelForLoadingURL) |
1340 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForView, | |
1341 OnSetZoomLevelForView) | |
1342 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 1340 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
1343 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 1341 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
1344 OnResetPageEncodingToDefault) | 1342 OnResetPageEncodingToDefault) |
1345 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 1343 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
1346 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 1344 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
1347 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 1345 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
1348 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 1346 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
1349 IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded) | 1347 IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded) |
1350 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, | 1348 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
1351 OnDragSourceSystemDragEnded) | 1349 OnDragSourceSystemDragEnded) |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 } | 1723 } |
1726 } | 1724 } |
1727 | 1725 |
1728 void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) { | 1726 void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) { |
1729 // The previous WebFrameWidget must already be detached by CloseForFrame(). | 1727 // The previous WebFrameWidget must already be detached by CloseForFrame(). |
1730 DCHECK(!frame_widget_); | 1728 DCHECK(!frame_widget_); |
1731 frame_widget_ = frame_widget; | 1729 frame_widget_ = frame_widget; |
1732 } | 1730 } |
1733 | 1731 |
1734 void RenderViewImpl::SetZoomLevel(double zoom_level) { | 1732 void RenderViewImpl::SetZoomLevel(double zoom_level) { |
1735 webview()->setZoomLevel(zoom_level); | 1733 // This function may get called multiple times if our page has multiple |
| 1734 // frames, so we early out on subsequent calls so as to only send one |
| 1735 // notification. |
| 1736 if (zoom_level == webview()->zoomLevel()) |
| 1737 return; |
| 1738 |
1736 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); | 1739 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); |
1737 } | 1740 } |
1738 | 1741 |
1739 void RenderViewImpl::didCancelCompositionOnSelectionChange() { | 1742 void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
1740 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); | 1743 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); |
1741 } | 1744 } |
1742 | 1745 |
1743 bool RenderViewImpl::handleCurrentKeyboardEvent() { | 1746 bool RenderViewImpl::handleCurrentKeyboardEvent() { |
1744 if (edit_commands_.empty()) | 1747 if (edit_commands_.empty()) |
1745 return false; | 1748 return false; |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2337 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, | 2340 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
2338 double zoom_level) { | 2341 double zoom_level) { |
2339 #if !defined(OS_ANDROID) | 2342 #if !defined(OS_ANDROID) |
2340 // On Android, page zoom isn't used, and in case of WebView, text zoom is used | 2343 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
2341 // for legacy WebView text scaling emulation. Thus, the code that resets | 2344 // for legacy WebView text scaling emulation. Thus, the code that resets |
2342 // the zoom level from this map will be effectively resetting text zoom level. | 2345 // the zoom level from this map will be effectively resetting text zoom level. |
2343 host_zoom_levels_[url] = zoom_level; | 2346 host_zoom_levels_[url] = zoom_level; |
2344 #endif | 2347 #endif |
2345 } | 2348 } |
2346 | 2349 |
2347 void RenderViewImpl::OnSetZoomLevelForView(bool uses_temporary_zoom_level, | |
2348 double level) { | |
2349 uses_temporary_zoom_level_ = uses_temporary_zoom_level; | |
2350 | |
2351 webview()->hidePopups(); | |
2352 SetZoomLevel(level); | |
2353 } | |
2354 | |
2355 void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { | 2350 void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
2356 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); | 2351 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
2357 } | 2352 } |
2358 | 2353 |
2359 void RenderViewImpl::OnResetPageEncodingToDefault() { | 2354 void RenderViewImpl::OnResetPageEncodingToDefault() { |
2360 WebString no_encoding; | 2355 WebString no_encoding; |
2361 webview()->setPageEncoding(no_encoding); | 2356 webview()->setPageEncoding(no_encoding); |
2362 } | 2357 } |
2363 | 2358 |
2364 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { | 2359 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2532 didUpdateLayout(); | 2527 didUpdateLayout(); |
2533 } | 2528 } |
2534 | 2529 |
2535 void RenderViewImpl::OnDisableScrollbarsForSmallWindows( | 2530 void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
2536 const gfx::Size& disable_scrollbar_size_limit) { | 2531 const gfx::Size& disable_scrollbar_size_limit) { |
2537 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; | 2532 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
2538 } | 2533 } |
2539 | 2534 |
2540 void RenderViewImpl::OnSetRendererPrefs( | 2535 void RenderViewImpl::OnSetRendererPrefs( |
2541 const RendererPreferences& renderer_prefs) { | 2536 const RendererPreferences& renderer_prefs) { |
2542 double old_zoom_level = renderer_preferences_.default_zoom_level; | |
2543 std::string old_accept_languages = renderer_preferences_.accept_languages; | 2537 std::string old_accept_languages = renderer_preferences_.accept_languages; |
2544 | 2538 |
2545 renderer_preferences_ = renderer_prefs; | 2539 renderer_preferences_ = renderer_prefs; |
2546 | 2540 |
2547 UpdateFontRenderingFromRendererPrefs(); | 2541 UpdateFontRenderingFromRendererPrefs(); |
2548 UpdateThemePrefs(); | 2542 UpdateThemePrefs(); |
2549 | 2543 |
2550 #if defined(USE_DEFAULT_RENDER_THEME) | 2544 #if defined(USE_DEFAULT_RENDER_THEME) |
2551 if (renderer_prefs.use_custom_colors) { | 2545 if (renderer_prefs.use_custom_colors) { |
2552 blink::setFocusRingColor(renderer_prefs.focus_ring_color); | 2546 blink::setFocusRingColor(renderer_prefs.focus_ring_color); |
2553 blink::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); | 2547 blink::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
2554 | 2548 |
2555 if (webview()) { | 2549 if (webview()) { |
2556 webview()->setSelectionColors( | 2550 webview()->setSelectionColors( |
2557 renderer_prefs.active_selection_bg_color, | 2551 renderer_prefs.active_selection_bg_color, |
2558 renderer_prefs.active_selection_fg_color, | 2552 renderer_prefs.active_selection_fg_color, |
2559 renderer_prefs.inactive_selection_bg_color, | 2553 renderer_prefs.inactive_selection_bg_color, |
2560 renderer_prefs.inactive_selection_fg_color); | 2554 renderer_prefs.inactive_selection_fg_color); |
2561 webview()->themeChanged(); | 2555 webview()->themeChanged(); |
2562 } | 2556 } |
2563 } | 2557 } |
2564 #endif // defined(USE_DEFAULT_RENDER_THEME) | 2558 #endif // defined(USE_DEFAULT_RENDER_THEME) |
2565 | 2559 |
2566 // If the zoom level for this page matches the old zoom default, and this | |
2567 // is not a plugin, update the zoom level to match the new default. | |
2568 if (webview() && webview()->mainFrame()->isWebLocalFrame() && | |
2569 !webview()->mainFrame()->document().isPluginDocument() && | |
2570 !ZoomValuesEqual(old_zoom_level, | |
2571 renderer_preferences_.default_zoom_level) && | |
2572 ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { | |
2573 SetZoomLevel(renderer_preferences_.default_zoom_level); | |
2574 zoomLevelChanged(); | |
2575 } | |
2576 | |
2577 if (webview() && | 2560 if (webview() && |
2578 old_accept_languages != renderer_preferences_.accept_languages) { | 2561 old_accept_languages != renderer_preferences_.accept_languages) { |
2579 webview()->acceptLanguagesChanged(); | 2562 webview()->acceptLanguagesChanged(); |
2580 } | 2563 } |
2581 } | 2564 } |
2582 | 2565 |
2583 void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, | 2566 void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
2584 const WebMediaPlayerAction& action) { | 2567 const WebMediaPlayerAction& action) { |
2585 if (webview()) | 2568 if (webview()) |
2586 webview()->performMediaPlayerAction(action, location); | 2569 webview()->performMediaPlayerAction(action, location); |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3441 if (IsUseZoomForDSFEnabled()) { | 3424 if (IsUseZoomForDSFEnabled()) { |
3442 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3425 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
3443 } else { | 3426 } else { |
3444 webview()->setDeviceScaleFactor(device_scale_factor_); | 3427 webview()->setDeviceScaleFactor(device_scale_factor_); |
3445 } | 3428 } |
3446 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3429 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3447 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3430 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
3448 } | 3431 } |
3449 | 3432 |
3450 } // namespace content | 3433 } // namespace content |
OLD | NEW |