Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: content/renderer/render_view.cc

Issue 7619015: Enabled scaling zoom for TOUCH_UI. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3310 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 const std::string& mime_type) { 3321 const std::string& mime_type) {
3322 return new webkit::npapi::WebPluginImpl( 3322 return new webkit::npapi::WebPluginImpl(
3323 frame, params, path, mime_type, AsWeakPtr()); 3323 frame, params, path, mime_type, AsWeakPtr());
3324 } 3324 }
3325 3325
3326 void RenderView::OnZoom(PageZoom::Function function) { 3326 void RenderView::OnZoom(PageZoom::Function function) {
3327 if (!webview()) // Not sure if this can happen, but no harm in being safe. 3327 if (!webview()) // Not sure if this can happen, but no harm in being safe.
3328 return; 3328 return;
3329 3329
3330 webview()->hidePopups(); 3330 webview()->hidePopups();
3331 3331 #ifndef TOUCH_UI
jam 2011/08/11 20:44:56 nit: normal convention is "!defined(TOUCH_UI)"
Fady Samuel 2011/08/12 21:58:13 Done.
3332 double old_zoom_level = webview()->zoomLevel(); 3332 double old_zoom_level = webview()->zoomLevel();
3333 double zoom_level; 3333 double zoom_level;
3334 if (function == PageZoom::RESET) { 3334 if (function == PageZoom::RESET) {
3335 zoom_level = 0; 3335 zoom_level = 0;
3336 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { 3336 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) {
3337 // Previous zoom level is a whole number, so just increment/decrement. 3337 // Previous zoom level is a whole number, so just increment/decrement.
3338 zoom_level = old_zoom_level + function; 3338 zoom_level = old_zoom_level + function;
3339 } else { 3339 } else {
3340 // Either the user hit the zoom factor limit and thus the zoom level is now 3340 // 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 3341 // 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 3342 // to go to the next whole number so that the user can always get back to
3343 // 100% with the keyboard/menu. 3343 // 100% with the keyboard/menu.
3344 if ((old_zoom_level > 1 && function > 0) || 3344 if ((old_zoom_level > 1 && function > 0) ||
3345 (old_zoom_level < 1 && function < 0)) { 3345 (old_zoom_level < 1 && function < 0)) {
3346 zoom_level = static_cast<int>(old_zoom_level + function); 3346 zoom_level = static_cast<int>(old_zoom_level + function);
3347 } else { 3347 } else {
3348 // We're going towards 100%, so first go to the next whole number. 3348 // We're going towards 100%, so first go to the next whole number.
3349 zoom_level = static_cast<int>(old_zoom_level); 3349 zoom_level = static_cast<int>(old_zoom_level);
3350 } 3350 }
3351 } 3351 }
3352
3353 webview()->setZoomLevel(false, zoom_level); 3352 webview()->setZoomLevel(false, zoom_level);
3353 #else
3354 double old_page_scale_factor = webview()->pageScaleFactor();
3355 double page_scale_factor;
3356 if (function == PageZoom::RESET) {
3357 page_scale_factor = 1.0;
3358 } else {
3359 page_scale_factor = old_page_scale_factor + (function > 0 ? 0.1 : -0.1);
jam 2011/08/11 20:44:56 these all need to be constants
3360 }
3361 webview()->scalePage(page_scale_factor, WebPoint(0, 0));
3362 #endif
3354 zoomLevelChanged(); 3363 zoomLevelChanged();
3355 } 3364 }
3356 3365
3357 void RenderView::OnSetZoomLevel(double zoom_level) { 3366 void RenderView::OnSetZoomLevel(double zoom_level) {
3358 // Don't set zoom level for full-page plugin since they don't use the same 3367 // Don't set zoom level for full-page plugin since they don't use the same
3359 // zoom settings. 3368 // zoom settings.
3360 if (webview()->mainFrame()->document().isPluginDocument()) 3369 if (webview()->mainFrame()->document().isPluginDocument())
3361 return; 3370 return;
3362 3371
3363 webview()->hidePopups(); 3372 webview()->hidePopups();
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
4489 } 4498 }
4490 #endif 4499 #endif
4491 4500
4492 void RenderView::OnContextMenuClosed( 4501 void RenderView::OnContextMenuClosed(
4493 const webkit_glue::CustomContextMenuContext& custom_context) { 4502 const webkit_glue::CustomContextMenuContext& custom_context) {
4494 if (custom_context.is_pepper_menu) 4503 if (custom_context.is_pepper_menu)
4495 pepper_delegate_.OnContextMenuClosed(custom_context); 4504 pepper_delegate_.OnContextMenuClosed(custom_context);
4496 else 4505 else
4497 context_menu_node_.reset(); 4506 context_menu_node_.reset();
4498 } 4507 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698