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

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, 5 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/renderer/render_view_impl.h ('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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } // namespace 771 } // namespace
772 772
773 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) 773 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
774 : RenderWidget(WebKit::WebPopupTypeNone, 774 : RenderWidget(WebKit::WebPopupTypeNone,
775 params->screen_info, 775 params->screen_info,
776 params->swapped_out), 776 params->swapped_out),
777 webkit_preferences_(params->webkit_prefs), 777 webkit_preferences_(params->webkit_prefs),
778 send_content_state_immediately_(false), 778 send_content_state_immediately_(false),
779 enabled_bindings_(0), 779 enabled_bindings_(0),
780 send_preferred_size_changes_(false), 780 send_preferred_size_changes_(false),
781 did_tap_multiple_targets_strategy_(MULTITARGET_POPUP),
781 is_loading_(false), 782 is_loading_(false),
782 navigation_gesture_(NavigationGestureUnknown), 783 navigation_gesture_(NavigationGestureUnknown),
783 opened_by_user_gesture_(true), 784 opened_by_user_gesture_(true),
784 opener_suppressed_(false), 785 opener_suppressed_(false),
785 page_id_(-1), 786 page_id_(-1),
786 last_page_id_sent_to_browser_(-1), 787 last_page_id_sent_to_browser_(-1),
787 next_page_id_(params->next_page_id), 788 next_page_id_(params->next_page_id),
788 history_list_offset_(-1), 789 history_list_offset_(-1),
789 history_list_length_(0), 790 history_list_length_(0),
790 target_url_status_(TARGET_NONE), 791 target_url_status_(TARGET_NONE),
(...skipping 5905 matching lines...) Expand 10 before | Expand all | Expand 10 after
6696 event.data.tap.width, event.data.tap.height); 6697 event.data.tap.width, event.data.tap.height);
6697 gfx::Rect zoom_rect; 6698 gfx::Rect zoom_rect;
6698 float new_total_scale = 6699 float new_total_scale =
6699 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 6700 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
6700 finger_rect, target_rects, GetSize(), 6701 finger_rect, target_rects, GetSize(),
6701 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), 6702 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(),
6702 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); 6703 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect);
6703 if (!new_total_scale) 6704 if (!new_total_scale)
6704 return false; 6705 return false;
6705 6706
6706 gfx::Size canvas_size = gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), 6707 if (did_tap_multiple_targets_strategy_ == MULTITARGET_ZOOM) {
6707 new_total_scale)); 6708 return webview()->zoomToMultipleTargetsRect(zoom_rect);
6708 TransportDIB* transport_dib = NULL; 6709 } else if (did_tap_multiple_targets_strategy_ == MULTITARGET_POPUP) {
6709 { 6710 gfx::Size canvas_size =
6710 scoped_ptr<skia::PlatformCanvas> canvas( 6711 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale));
6711 RenderProcess::current()->GetDrawingCanvas(&transport_dib, 6712 TransportDIB* transport_dib = NULL;
6712 gfx::Rect(canvas_size))); 6713 {
6713 if (!canvas) 6714 scoped_ptr<skia::PlatformCanvas> canvas(
6714 return false; 6715 RenderProcess::current()->GetDrawingCanvas(&transport_dib,
6716 gfx::Rect(canvas_size)));
6717 if (!canvas)
6718 return false;
6715 6719
6716 // TODO(trchen): Cleanup the device scale factor mess. 6720 // TODO(trchen): Cleanup the device scale factor mess.
6717 // device scale will be applied in WebKit 6721 // device scale will be applied in WebKit
6718 // --> zoom_rect doesn't include device scale, 6722 // --> zoom_rect doesn't include device scale,
6719 // but WebKit will still draw on zoom_rect * device_scale_factor_ 6723 // but WebKit will still draw on zoom_rect * device_scale_factor_
6720 canvas->scale(new_total_scale / device_scale_factor_, 6724 canvas->scale(new_total_scale / device_scale_factor_,
6721 new_total_scale / device_scale_factor_); 6725 new_total_scale / device_scale_factor_);
6722 canvas->translate(-zoom_rect.x() * device_scale_factor_, 6726 canvas->translate(-zoom_rect.x() * device_scale_factor_,
6723 -zoom_rect.y() * device_scale_factor_); 6727 -zoom_rect.y() * device_scale_factor_);
6724 6728
6725 webwidget_->paint(webkit_glue::ToWebCanvas(canvas.get()), zoom_rect, 6729 webwidget_->paint(webkit_glue::ToWebCanvas(canvas.get()), zoom_rect,
6726 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent); 6730 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent);
6727 } 6731 }
6728 6732
6729 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( 6733 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect(
6730 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect))); 6734 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect)));
6731 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, 6735 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_,
6732 physical_window_zoom_rect, 6736 physical_window_zoom_rect,
6733 canvas_size, 6737 canvas_size,
6734 transport_dib->id())); 6738 transport_dib->id()));
6739 } else
jochen (gone - plz use gerrit) 2013/07/16 10:05:54 nit. in chromium, if one if branch has curly brace
6740 return false;
6735 6741
6736 return true; 6742 return true;
6737 } 6743 }
6738 6744
6739 skia::RefPtr<SkPicture> RenderViewImpl::CapturePicture() { 6745 skia::RefPtr<SkPicture> RenderViewImpl::CapturePicture() {
6740 return compositor_ ? compositor_->CapturePicture() : 6746 return compositor_ ? compositor_->CapturePicture() :
6741 skia::RefPtr<SkPicture>(); 6747 skia::RefPtr<SkPicture>();
6742 } 6748 }
6743 #endif 6749 #endif
6744 6750
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
6818 WebURL url = icon_urls[i].iconURL(); 6824 WebURL url = icon_urls[i].iconURL();
6819 if (!url.isEmpty()) 6825 if (!url.isEmpty())
6820 urls.push_back(FaviconURL(url, 6826 urls.push_back(FaviconURL(url,
6821 ToFaviconType(icon_urls[i].iconType()))); 6827 ToFaviconType(icon_urls[i].iconType())));
6822 } 6828 }
6823 SendUpdateFaviconURL(urls); 6829 SendUpdateFaviconURL(urls);
6824 } 6830 }
6825 6831
6826 6832
6827 } // namespace content 6833 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698