| 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 6246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6257 event.data.tap.width, event.data.tap.height); | 6257 event.data.tap.width, event.data.tap.height); |
| 6258 gfx::Rect zoom_rect; | 6258 gfx::Rect zoom_rect; |
| 6259 float new_total_scale = | 6259 float new_total_scale = |
| 6260 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 6260 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
| 6261 finger_rect, target_rects, GetSize(), | 6261 finger_rect, target_rects, GetSize(), |
| 6262 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 6262 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
| 6263 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); | 6263 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); |
| 6264 if (!new_total_scale) | 6264 if (!new_total_scale) |
| 6265 return false; | 6265 return false; |
| 6266 | 6266 |
| 6267 gfx::Size canvas_size = gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), | 6267 DidTapMultipleTargetsStrategy multitarget_strategy = |
| 6268 new_total_scale)); | 6268 renderer_preferences_.did_tap_multiple_targets_strategy; |
| 6269 TransportDIB* transport_dib = NULL; | 6269 if (multitarget_strategy == MULTITARGET_ZOOM) { |
| 6270 { | 6270 return webview()->zoomToMultipleTargetsRect(zoom_rect); |
| 6271 scoped_ptr<skia::PlatformCanvas> canvas( | 6271 } else if (multitarget_strategy == MULTITARGET_POPUP) { |
| 6272 RenderProcess::current()->GetDrawingCanvas(&transport_dib, | 6272 gfx::Size canvas_size = |
| 6273 gfx::Rect(canvas_size))); | 6273 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale)); |
| 6274 if (!canvas) | 6274 TransportDIB* transport_dib = NULL; |
| 6275 return false; | 6275 { |
| 6276 scoped_ptr<skia::PlatformCanvas> canvas( |
| 6277 RenderProcess::current()->GetDrawingCanvas(&transport_dib, |
| 6278 gfx::Rect(canvas_size))); |
| 6279 if (!canvas) |
| 6280 return false; |
| 6276 | 6281 |
| 6277 // TODO(trchen): Cleanup the device scale factor mess. | 6282 // TODO(trchen): Cleanup the device scale factor mess. |
| 6278 // device scale will be applied in WebKit | 6283 // device scale will be applied in WebKit |
| 6279 // --> zoom_rect doesn't include device scale, | 6284 // --> zoom_rect doesn't include device scale, |
| 6280 // but WebKit will still draw on zoom_rect * device_scale_factor_ | 6285 // but WebKit will still draw on zoom_rect * device_scale_factor_ |
| 6281 canvas->scale(new_total_scale / device_scale_factor_, | 6286 canvas->scale(new_total_scale / device_scale_factor_, |
| 6282 new_total_scale / device_scale_factor_); | 6287 new_total_scale / device_scale_factor_); |
| 6283 canvas->translate(-zoom_rect.x() * device_scale_factor_, | 6288 canvas->translate(-zoom_rect.x() * device_scale_factor_, |
| 6284 -zoom_rect.y() * device_scale_factor_); | 6289 -zoom_rect.y() * device_scale_factor_); |
| 6285 | 6290 |
| 6286 webwidget_->paint( | 6291 webwidget_->paint( |
| 6287 canvas.get(), | 6292 canvas.get(), |
| 6288 zoom_rect, | 6293 zoom_rect, |
| 6289 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent); | 6294 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent); |
| 6295 } |
| 6296 |
| 6297 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( |
| 6298 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect))); |
| 6299 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, |
| 6300 physical_window_zoom_rect, |
| 6301 canvas_size, |
| 6302 transport_dib->id())); |
| 6303 } else { |
| 6304 return false; |
| 6290 } | 6305 } |
| 6291 | 6306 |
| 6292 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( | |
| 6293 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect))); | |
| 6294 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, | |
| 6295 physical_window_zoom_rect, | |
| 6296 canvas_size, | |
| 6297 transport_dib->id())); | |
| 6298 | |
| 6299 return true; | 6307 return true; |
| 6300 } | 6308 } |
| 6301 #endif | 6309 #endif |
| 6302 | 6310 |
| 6303 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { | 6311 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 6304 return history_list_length_; | 6312 return history_list_length_; |
| 6305 } | 6313 } |
| 6306 | 6314 |
| 6307 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { | 6315 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
| 6308 if (enable) { | 6316 if (enable) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6376 WebURL url = icon_urls[i].iconURL(); | 6384 WebURL url = icon_urls[i].iconURL(); |
| 6377 if (!url.isEmpty()) | 6385 if (!url.isEmpty()) |
| 6378 urls.push_back(FaviconURL(url, | 6386 urls.push_back(FaviconURL(url, |
| 6379 ToFaviconType(icon_urls[i].iconType()))); | 6387 ToFaviconType(icon_urls[i].iconType()))); |
| 6380 } | 6388 } |
| 6381 SendUpdateFaviconURL(urls); | 6389 SendUpdateFaviconURL(urls); |
| 6382 } | 6390 } |
| 6383 | 6391 |
| 6384 | 6392 |
| 6385 } // namespace content | 6393 } // namespace content |
| OLD | NEW |