OLD | NEW |
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 4031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4042 if (!webview()) | 4042 if (!webview()) |
4043 return; | 4043 return; |
4044 WebFrame* main_frame = webview()->mainFrame(); | 4044 WebFrame* main_frame = webview()->mainFrame(); |
4045 if (!main_frame) | 4045 if (!main_frame) |
4046 return; | 4046 return; |
4047 main_frame->enableViewSourceMode(true); | 4047 main_frame->enableViewSourceMode(true); |
4048 } | 4048 } |
4049 | 4049 |
4050 #if defined(OS_ANDROID) | 4050 #if defined(OS_ANDROID) |
4051 bool RenderViewImpl::didTapMultipleTargets( | 4051 bool RenderViewImpl::didTapMultipleTargets( |
4052 const blink::WebGestureEvent& event, | 4052 const WebSize& inner_viewport_offset, |
| 4053 const WebRect& touch_rect, |
4053 const WebVector<WebRect>& target_rects) { | 4054 const WebVector<WebRect>& target_rects) { |
4054 // Never show a disambiguation popup when accessibility is enabled, | 4055 // Never show a disambiguation popup when accessibility is enabled, |
4055 // as this interferes with "touch exploration". | 4056 // as this interferes with "touch exploration". |
4056 AccessibilityMode accessibility_mode = | 4057 AccessibilityMode accessibility_mode = |
4057 GetMainRenderFrame()->accessibility_mode(); | 4058 GetMainRenderFrame()->accessibility_mode(); |
4058 bool matches_accessibility_mode_complete = | 4059 bool matches_accessibility_mode_complete = |
4059 (accessibility_mode & AccessibilityModeComplete) == | 4060 (accessibility_mode & AccessibilityModeComplete) == |
4060 AccessibilityModeComplete; | 4061 AccessibilityModeComplete; |
4061 if (matches_accessibility_mode_complete) | 4062 if (matches_accessibility_mode_complete) |
4062 return false; | 4063 return false; |
4063 | 4064 |
4064 gfx::Rect finger_rect( | 4065 // The touch_rect, target_rects and zoom_rect are in the outer viewport |
4065 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, | 4066 // reference frame. |
4066 event.data.tap.width, event.data.tap.height); | |
4067 gfx::Rect zoom_rect; | 4067 gfx::Rect zoom_rect; |
4068 float new_total_scale = | 4068 float new_total_scale = |
4069 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 4069 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
4070 finger_rect, target_rects, GetSize(), | 4070 touch_rect, target_rects, GetSize(), |
4071 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 4071 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
4072 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); | 4072 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); |
4073 if (!new_total_scale) | 4073 if (!new_total_scale) |
4074 return false; | 4074 return false; |
4075 | 4075 |
4076 bool handled = false; | 4076 bool handled = false; |
4077 switch (renderer_preferences_.tap_multiple_targets_strategy) { | 4077 switch (renderer_preferences_.tap_multiple_targets_strategy) { |
4078 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: | 4078 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: |
4079 handled = webview()->zoomToMultipleTargetsRect(zoom_rect); | 4079 handled = webview()->zoomToMultipleTargetsRect(zoom_rect); |
4080 break; | 4080 break; |
(...skipping 19 matching lines...) Expand all Loading... |
4100 new_total_scale / device_scale_factor_); | 4100 new_total_scale / device_scale_factor_); |
4101 canvas.translate(-zoom_rect.x() * device_scale_factor_, | 4101 canvas.translate(-zoom_rect.x() * device_scale_factor_, |
4102 -zoom_rect.y() * device_scale_factor_); | 4102 -zoom_rect.y() * device_scale_factor_); |
4103 | 4103 |
4104 DCHECK(webwidget_->isAcceleratedCompositingActive()); | 4104 DCHECK(webwidget_->isAcceleratedCompositingActive()); |
4105 // TODO(aelias): The disambiguation popup should be composited so we | 4105 // TODO(aelias): The disambiguation popup should be composited so we |
4106 // don't have to call this method. | 4106 // don't have to call this method. |
4107 webwidget_->paintCompositedDeprecated(&canvas, zoom_rect); | 4107 webwidget_->paintCompositedDeprecated(&canvas, zoom_rect); |
4108 } | 4108 } |
4109 | 4109 |
| 4110 gfx::Rect zoom_rect_in_screen = |
| 4111 zoom_rect - gfx::Vector2d(inner_viewport_offset.width, |
| 4112 inner_viewport_offset.height); |
| 4113 |
4110 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( | 4114 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( |
4111 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect))); | 4115 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect_in_screen))); |
| 4116 |
4112 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, | 4117 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, |
4113 physical_window_zoom_rect, | 4118 physical_window_zoom_rect, |
4114 canvas_size, | 4119 canvas_size, |
4115 shared_bitmap->id())); | 4120 shared_bitmap->id())); |
4116 cc::SharedBitmapId id = shared_bitmap->id(); | 4121 cc::SharedBitmapId id = shared_bitmap->id(); |
4117 disambiguation_bitmaps_[id] = shared_bitmap.release(); | 4122 disambiguation_bitmaps_[id] = shared_bitmap.release(); |
4118 handled = true; | 4123 handled = true; |
4119 break; | 4124 break; |
4120 } | 4125 } |
4121 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: | 4126 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4216 std::vector<gfx::Size> sizes; | 4221 std::vector<gfx::Size> sizes; |
4217 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4222 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4218 if (!url.isEmpty()) | 4223 if (!url.isEmpty()) |
4219 urls.push_back( | 4224 urls.push_back( |
4220 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4225 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4221 } | 4226 } |
4222 SendUpdateFaviconURL(urls); | 4227 SendUpdateFaviconURL(urls); |
4223 } | 4228 } |
4224 | 4229 |
4225 } // namespace content | 4230 } // namespace content |
OLD | NEW |