| 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 |
| 266 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 268 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 267 WebVector<WebURL> urls; | 269 WebVector<WebURL> urls; |
| 268 ds->redirectChain(urls); | 270 ds->redirectChain(urls); |
| 269 result->reserve(urls.size()); | 271 result->reserve(urls.size()); |
| 270 for (size_t i = 0; i < urls.size(); ++i) | 272 for (size_t i = 0; i < urls.size(); ++i) |
| 271 result->push_back(urls[i]); | 273 result->push_back(urls[i]); |
| 272 } | 274 } |
| 273 | 275 |
| 274 static bool WebAccessibilityNotificationToViewHostMsg( | 276 static bool WebAccessibilityNotificationToViewHostMsg( |
| 275 WebAccessibilityNotification notification, | 277 WebAccessibilityNotification notification, |
| (...skipping 3045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3321 const std::string& mime_type) { | 3323 const std::string& mime_type) { |
| 3322 return new webkit::npapi::WebPluginImpl( | 3324 return new webkit::npapi::WebPluginImpl( |
| 3323 frame, params, path, mime_type, AsWeakPtr()); | 3325 frame, params, path, mime_type, AsWeakPtr()); |
| 3324 } | 3326 } |
| 3325 | 3327 |
| 3326 void RenderView::OnZoom(PageZoom::Function function) { | 3328 void RenderView::OnZoom(PageZoom::Function function) { |
| 3327 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 3329 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 3328 return; | 3330 return; |
| 3329 | 3331 |
| 3330 webview()->hidePopups(); | 3332 webview()->hidePopups(); |
| 3331 | 3333 #if !defined(TOUCH_UI) |
| 3332 double old_zoom_level = webview()->zoomLevel(); | 3334 double old_zoom_level = webview()->zoomLevel(); |
| 3333 double zoom_level; | 3335 double zoom_level; |
| 3334 if (function == PageZoom::RESET) { | 3336 if (function == PageZoom::RESET) { |
| 3335 zoom_level = 0; | 3337 zoom_level = 0; |
| 3336 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { | 3338 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 3337 // Previous zoom level is a whole number, so just increment/decrement. | 3339 // Previous zoom level is a whole number, so just increment/decrement. |
| 3338 zoom_level = old_zoom_level + function; | 3340 zoom_level = old_zoom_level + function; |
| 3339 } else { | 3341 } else { |
| 3340 // Either the user hit the zoom factor limit and thus the zoom level is now | 3342 // Either the user hit the zoom factor limit and thus the zoom level is now |
| 3341 // not a whole number, or a plugin changed it to a custom value. We want | 3343 // not a whole number, or a plugin changed it to a custom value. We want |
| 3342 // to go to the next whole number so that the user can always get back to | 3344 // to go to the next whole number so that the user can always get back to |
| 3343 // 100% with the keyboard/menu. | 3345 // 100% with the keyboard/menu. |
| 3344 if ((old_zoom_level > 1 && function > 0) || | 3346 if ((old_zoom_level > 1 && function > 0) || |
| 3345 (old_zoom_level < 1 && function < 0)) { | 3347 (old_zoom_level < 1 && function < 0)) { |
| 3346 zoom_level = static_cast<int>(old_zoom_level + function); | 3348 zoom_level = static_cast<int>(old_zoom_level + function); |
| 3347 } else { | 3349 } else { |
| 3348 // We're going towards 100%, so first go to the next whole number. | 3350 // We're going towards 100%, so first go to the next whole number. |
| 3349 zoom_level = static_cast<int>(old_zoom_level); | 3351 zoom_level = static_cast<int>(old_zoom_level); |
| 3350 } | 3352 } |
| 3351 } | 3353 } |
| 3352 | |
| 3353 webview()->setZoomLevel(false, zoom_level); | 3354 webview()->setZoomLevel(false, zoom_level); |
| 3355 #else |
| 3356 double old_page_scale_factor = webview()->pageScaleFactor(); |
| 3357 double page_scale_factor; |
| 3358 if (function == PageZoom::RESET) { |
| 3359 page_scale_factor = 1.0; |
| 3360 } else { |
| 3361 page_scale_factor = old_page_scale_factor + |
| 3362 (function > 0 ? kScalingIncrement : -kScalingIncrement); |
| 3363 } |
| 3364 webview()->scalePage(page_scale_factor, WebPoint(0, 0)); |
| 3365 #endif |
| 3354 zoomLevelChanged(); | 3366 zoomLevelChanged(); |
| 3355 } | 3367 } |
| 3356 | 3368 |
| 3357 void RenderView::OnSetZoomLevel(double zoom_level) { | 3369 void RenderView::OnSetZoomLevel(double zoom_level) { |
| 3358 // Don't set zoom level for full-page plugin since they don't use the same | 3370 // Don't set zoom level for full-page plugin since they don't use the same |
| 3359 // zoom settings. | 3371 // zoom settings. |
| 3360 if (webview()->mainFrame()->document().isPluginDocument()) | 3372 if (webview()->mainFrame()->document().isPluginDocument()) |
| 3361 return; | 3373 return; |
| 3362 | 3374 |
| 3363 webview()->hidePopups(); | 3375 webview()->hidePopups(); |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4489 } | 4501 } |
| 4490 #endif | 4502 #endif |
| 4491 | 4503 |
| 4492 void RenderView::OnContextMenuClosed( | 4504 void RenderView::OnContextMenuClosed( |
| 4493 const webkit_glue::CustomContextMenuContext& custom_context) { | 4505 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 4494 if (custom_context.is_pepper_menu) | 4506 if (custom_context.is_pepper_menu) |
| 4495 pepper_delegate_.OnContextMenuClosed(custom_context); | 4507 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 4496 else | 4508 else |
| 4497 context_menu_node_.reset(); | 4509 context_menu_node_.reset(); |
| 4498 } | 4510 } |
| OLD | NEW |