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