| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // content state is modified and not sent to session restore, but this is | 256 // content state is modified and not sent to session restore, but this is |
| 257 // better than having to wake up all renderers during shutdown. | 257 // better than having to wake up all renderers during shutdown. |
| 258 static const int kDelaySecondsForContentStateSyncHidden = 5; | 258 static const int kDelaySecondsForContentStateSyncHidden = 5; |
| 259 static const int kDelaySecondsForContentStateSync = 1; | 259 static const int kDelaySecondsForContentStateSync = 1; |
| 260 | 260 |
| 261 // The maximum number of popups that can be spawned from one page. | 261 // The maximum number of popups that can be spawned from one page. |
| 262 static const int kMaximumNumberOfUnacknowledgedPopups = 25; | 262 static const int kMaximumNumberOfUnacknowledgedPopups = 25; |
| 263 | 263 |
| 264 static const char kBackForwardNavigationScheme[] = "history"; | 264 static const char kBackForwardNavigationScheme[] = "history"; |
| 265 | 265 |
| 266 static const float kScalingIncrement = 0.1f; | |
| 267 | |
| 268 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 266 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 269 WebVector<WebURL> urls; | 267 WebVector<WebURL> urls; |
| 270 ds->redirectChain(urls); | 268 ds->redirectChain(urls); |
| 271 result->reserve(urls.size()); | 269 result->reserve(urls.size()); |
| 272 for (size_t i = 0; i < urls.size(); ++i) | 270 for (size_t i = 0; i < urls.size(); ++i) |
| 273 result->push_back(urls[i]); | 271 result->push_back(urls[i]); |
| 274 } | 272 } |
| 275 | 273 |
| 276 static bool WebAccessibilityNotificationToViewHostMsg( | 274 static bool WebAccessibilityNotificationToViewHostMsg( |
| 277 WebAccessibilityNotification notification, | 275 WebAccessibilityNotification notification, |
| (...skipping 3094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3372 const std::string& mime_type) { | 3370 const std::string& mime_type) { |
| 3373 return new webkit::npapi::WebPluginImpl( | 3371 return new webkit::npapi::WebPluginImpl( |
| 3374 frame, params, path, mime_type, AsWeakPtr()); | 3372 frame, params, path, mime_type, AsWeakPtr()); |
| 3375 } | 3373 } |
| 3376 | 3374 |
| 3377 void RenderView::OnZoom(PageZoom::Function function) { | 3375 void RenderView::OnZoom(PageZoom::Function function) { |
| 3378 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 3376 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 3379 return; | 3377 return; |
| 3380 | 3378 |
| 3381 webview()->hidePopups(); | 3379 webview()->hidePopups(); |
| 3382 #if !defined(TOUCH_UI) | 3380 |
| 3383 double old_zoom_level = webview()->zoomLevel(); | 3381 double old_zoom_level = webview()->zoomLevel(); |
| 3384 double zoom_level; | 3382 double zoom_level; |
| 3385 if (function == PageZoom::RESET) { | 3383 if (function == PageZoom::RESET) { |
| 3386 zoom_level = 0; | 3384 zoom_level = 0; |
| 3387 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { | 3385 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 3388 // Previous zoom level is a whole number, so just increment/decrement. | 3386 // Previous zoom level is a whole number, so just increment/decrement. |
| 3389 zoom_level = old_zoom_level + function; | 3387 zoom_level = old_zoom_level + function; |
| 3390 } else { | 3388 } else { |
| 3391 // Either the user hit the zoom factor limit and thus the zoom level is now | 3389 // Either the user hit the zoom factor limit and thus the zoom level is now |
| 3392 // not a whole number, or a plugin changed it to a custom value. We want | 3390 // not a whole number, or a plugin changed it to a custom value. We want |
| 3393 // to go to the next whole number so that the user can always get back to | 3391 // to go to the next whole number so that the user can always get back to |
| 3394 // 100% with the keyboard/menu. | 3392 // 100% with the keyboard/menu. |
| 3395 if ((old_zoom_level > 1 && function > 0) || | 3393 if ((old_zoom_level > 1 && function > 0) || |
| 3396 (old_zoom_level < 1 && function < 0)) { | 3394 (old_zoom_level < 1 && function < 0)) { |
| 3397 zoom_level = static_cast<int>(old_zoom_level + function); | 3395 zoom_level = static_cast<int>(old_zoom_level + function); |
| 3398 } else { | 3396 } else { |
| 3399 // We're going towards 100%, so first go to the next whole number. | 3397 // We're going towards 100%, so first go to the next whole number. |
| 3400 zoom_level = static_cast<int>(old_zoom_level); | 3398 zoom_level = static_cast<int>(old_zoom_level); |
| 3401 } | 3399 } |
| 3402 } | 3400 } |
| 3401 |
| 3403 webview()->setZoomLevel(false, zoom_level); | 3402 webview()->setZoomLevel(false, zoom_level); |
| 3404 #else | |
| 3405 double old_page_scale_factor = webview()->pageScaleFactor(); | |
| 3406 double page_scale_factor; | |
| 3407 if (function == PageZoom::RESET) { | |
| 3408 page_scale_factor = 1.0; | |
| 3409 } else { | |
| 3410 page_scale_factor = old_page_scale_factor + | |
| 3411 (function > 0 ? kScalingIncrement : -kScalingIncrement); | |
| 3412 } | |
| 3413 webview()->scalePage(page_scale_factor, WebPoint(0, 0)); | |
| 3414 #endif | |
| 3415 zoomLevelChanged(); | 3403 zoomLevelChanged(); |
| 3416 } | 3404 } |
| 3417 | 3405 |
| 3418 void RenderView::OnSetZoomLevel(double zoom_level) { | 3406 void RenderView::OnSetZoomLevel(double zoom_level) { |
| 3419 // Don't set zoom level for full-page plugin since they don't use the same | 3407 // Don't set zoom level for full-page plugin since they don't use the same |
| 3420 // zoom settings. | 3408 // zoom settings. |
| 3421 if (webview()->mainFrame()->document().isPluginDocument()) | 3409 if (webview()->mainFrame()->document().isPluginDocument()) |
| 3422 return; | 3410 return; |
| 3423 | 3411 |
| 3424 webview()->hidePopups(); | 3412 webview()->hidePopups(); |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4551 } | 4539 } |
| 4552 #endif | 4540 #endif |
| 4553 | 4541 |
| 4554 void RenderView::OnContextMenuClosed( | 4542 void RenderView::OnContextMenuClosed( |
| 4555 const webkit_glue::CustomContextMenuContext& custom_context) { | 4543 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 4556 if (custom_context.is_pepper_menu) | 4544 if (custom_context.is_pepper_menu) |
| 4557 pepper_delegate_.OnContextMenuClosed(custom_context); | 4545 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 4558 else | 4546 else |
| 4559 context_menu_node_.reset(); | 4547 context_menu_node_.reset(); |
| 4560 } | 4548 } |
| OLD | NEW |