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

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

Issue 19256012: Allow zoom-in as alternative to popup when tapping multiple targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
« no previous file with comments | « content/public/common/renderer_preferences.cc ('k') | 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) 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 6202 matching lines...) Expand 10 before | Expand all | Expand 10 after
6213 event.data.tap.width, event.data.tap.height); 6213 event.data.tap.width, event.data.tap.height);
6214 gfx::Rect zoom_rect; 6214 gfx::Rect zoom_rect;
6215 float new_total_scale = 6215 float new_total_scale =
6216 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 6216 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
6217 finger_rect, target_rects, GetSize(), 6217 finger_rect, target_rects, GetSize(),
6218 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), 6218 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(),
6219 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); 6219 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect);
6220 if (!new_total_scale) 6220 if (!new_total_scale)
6221 return false; 6221 return false;
6222 6222
6223 gfx::Size canvas_size = gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), 6223 TapMultipleTargetsStrategy multitarget_strategy =
6224 new_total_scale)); 6224 renderer_preferences_.tap_multiple_targets_strategy;
6225 TransportDIB* transport_dib = NULL; 6225 if (multitarget_strategy == TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM) {
6226 { 6226 return webview()->zoomToMultipleTargetsRect(zoom_rect);
6227 scoped_ptr<skia::PlatformCanvas> canvas( 6227 } else if (multitarget_strategy == TAP_MULTIPLE_TARGETS_STRATEGY_POPUP) {
6228 RenderProcess::current()->GetDrawingCanvas(&transport_dib, 6228 gfx::Size canvas_size =
6229 gfx::Rect(canvas_size))); 6229 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale));
6230 if (!canvas) 6230 TransportDIB* transport_dib = NULL;
6231 return false; 6231 {
6232 scoped_ptr<skia::PlatformCanvas> canvas(
6233 RenderProcess::current()->GetDrawingCanvas(&transport_dib,
6234 gfx::Rect(canvas_size)));
6235 if (!canvas)
6236 return false;
6232 6237
6233 // TODO(trchen): Cleanup the device scale factor mess. 6238 // TODO(trchen): Cleanup the device scale factor mess.
6234 // device scale will be applied in WebKit 6239 // device scale will be applied in WebKit
6235 // --> zoom_rect doesn't include device scale, 6240 // --> zoom_rect doesn't include device scale,
6236 // but WebKit will still draw on zoom_rect * device_scale_factor_ 6241 // but WebKit will still draw on zoom_rect * device_scale_factor_
6237 canvas->scale(new_total_scale / device_scale_factor_, 6242 canvas->scale(new_total_scale / device_scale_factor_,
6238 new_total_scale / device_scale_factor_); 6243 new_total_scale / device_scale_factor_);
6239 canvas->translate(-zoom_rect.x() * device_scale_factor_, 6244 canvas->translate(-zoom_rect.x() * device_scale_factor_,
6240 -zoom_rect.y() * device_scale_factor_); 6245 -zoom_rect.y() * device_scale_factor_);
6241 6246
6242 webwidget_->paint( 6247 webwidget_->paint(
6243 canvas.get(), 6248 canvas.get(),
6244 zoom_rect, 6249 zoom_rect,
6245 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent); 6250 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent);
6251 }
6252
6253 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect(
6254 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect)));
6255 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_,
6256 physical_window_zoom_rect,
6257 canvas_size,
6258 transport_dib->id()));
6259 } else {
6260 return false;
6246 } 6261 }
6247 6262
6248 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect(
6249 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect)));
6250 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_,
6251 physical_window_zoom_rect,
6252 canvas_size,
6253 transport_dib->id()));
6254
6255 return true; 6263 return true;
6256 } 6264 }
6257 #endif 6265 #endif
6258 6266
6259 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { 6267 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const {
6260 return history_list_length_; 6268 return history_list_length_;
6261 } 6269 }
6262 6270
6263 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { 6271 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) {
6264 if (enable) { 6272 if (enable) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
6332 WebURL url = icon_urls[i].iconURL(); 6340 WebURL url = icon_urls[i].iconURL();
6333 if (!url.isEmpty()) 6341 if (!url.isEmpty())
6334 urls.push_back(FaviconURL(url, 6342 urls.push_back(FaviconURL(url,
6335 ToFaviconType(icon_urls[i].iconType()))); 6343 ToFaviconType(icon_urls[i].iconType())));
6336 } 6344 }
6337 SendUpdateFaviconURL(urls); 6345 SendUpdateFaviconURL(urls);
6338 } 6346 }
6339 6347
6340 6348
6341 } // namespace content 6349 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/renderer_preferences.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698