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

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

Issue 23436003: Clean up RenderViewImpl::didTapMultipleTargets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no default Created 7 years, 3 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) 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 6394 matching lines...) Expand 10 before | Expand all | Expand 10 after
6405 event.data.tap.width, event.data.tap.height); 6405 event.data.tap.width, event.data.tap.height);
6406 gfx::Rect zoom_rect; 6406 gfx::Rect zoom_rect;
6407 float new_total_scale = 6407 float new_total_scale =
6408 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 6408 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
6409 finger_rect, target_rects, GetSize(), 6409 finger_rect, target_rects, GetSize(),
6410 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), 6410 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(),
6411 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); 6411 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect);
6412 if (!new_total_scale) 6412 if (!new_total_scale)
6413 return false; 6413 return false;
6414 6414
6415 TapMultipleTargetsStrategy multitarget_strategy = 6415 bool handled = false;
6416 renderer_preferences_.tap_multiple_targets_strategy; 6416 switch (renderer_preferences_.tap_multiple_targets_strategy) {
6417 if (multitarget_strategy == TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM) { 6417 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM:
6418 return webview()->zoomToMultipleTargetsRect(zoom_rect); 6418 handled = webview()->zoomToMultipleTargetsRect(zoom_rect);
6419 } else if (multitarget_strategy == TAP_MULTIPLE_TARGETS_STRATEGY_POPUP) { 6419 break;
6420 case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: {
6420 gfx::Size canvas_size = 6421 gfx::Size canvas_size =
6421 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale)); 6422 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale));
6422 TransportDIB* transport_dib = NULL; 6423 TransportDIB* transport_dib = NULL;
6423 { 6424 {
6424 scoped_ptr<skia::PlatformCanvas> canvas( 6425 scoped_ptr<skia::PlatformCanvas> canvas(
6425 RenderProcess::current()->GetDrawingCanvas(&transport_dib, 6426 RenderProcess::current()->GetDrawingCanvas(&transport_dib,
6426 gfx::Rect(canvas_size))); 6427 gfx::Rect(canvas_size)));
6427 if (!canvas) 6428 if (!canvas) {
6428 return false; 6429 handled = false;
6430 break;
6431 }
6429 6432
6430 // TODO(trchen): Cleanup the device scale factor mess. 6433 // TODO(trchen): Cleanup the device scale factor mess.
6431 // device scale will be applied in WebKit 6434 // device scale will be applied in WebKit
6432 // --> zoom_rect doesn't include device scale, 6435 // --> zoom_rect doesn't include device scale,
6433 // but WebKit will still draw on zoom_rect * device_scale_factor_ 6436 // but WebKit will still draw on zoom_rect * device_scale_factor_
6434 canvas->scale(new_total_scale / device_scale_factor_, 6437 canvas->scale(new_total_scale / device_scale_factor_,
6435 new_total_scale / device_scale_factor_); 6438 new_total_scale / device_scale_factor_);
6436 canvas->translate(-zoom_rect.x() * device_scale_factor_, 6439 canvas->translate(-zoom_rect.x() * device_scale_factor_,
6437 -zoom_rect.y() * device_scale_factor_); 6440 -zoom_rect.y() * device_scale_factor_);
6438 6441
6439 webwidget_->paint( 6442 webwidget_->paint(
6440 canvas.get(), 6443 canvas.get(),
6441 zoom_rect, 6444 zoom_rect,
6442 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent); 6445 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent);
6443 } 6446 }
6444 6447
6445 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( 6448 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect(
6446 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect))); 6449 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect)));
6447 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, 6450 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_,
6448 physical_window_zoom_rect, 6451 physical_window_zoom_rect,
6449 canvas_size, 6452 canvas_size,
6450 transport_dib->id())); 6453 transport_dib->id()));
6451 } else { 6454 handled = true;
6452 return false; 6455 break;
6456 }
6457 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE:
6458 // No-op.
6459 break;
6453 } 6460 }
6454 6461
6455 return true; 6462 return handled;
6456 } 6463 }
6457 #endif 6464 #endif
6458 6465
6459 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { 6466 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const {
6460 return history_list_length_; 6467 return history_list_length_;
6461 } 6468 }
6462 6469
6463 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { 6470 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) {
6464 if (enable) { 6471 if (enable) {
6465 if (has_focus()) 6472 if (has_focus())
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6531 for (size_t i = 0; i < icon_urls.size(); i++) { 6538 for (size_t i = 0; i < icon_urls.size(); i++) {
6532 WebURL url = icon_urls[i].iconURL(); 6539 WebURL url = icon_urls[i].iconURL();
6533 if (!url.isEmpty()) 6540 if (!url.isEmpty())
6534 urls.push_back(FaviconURL(url, 6541 urls.push_back(FaviconURL(url,
6535 ToFaviconType(icon_urls[i].iconType()))); 6542 ToFaviconType(icon_urls[i].iconType())));
6536 } 6543 }
6537 SendUpdateFaviconURL(urls); 6544 SendUpdateFaviconURL(urls);
6538 } 6545 }
6539 6546
6540 } // namespace content 6547 } // namespace content
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