Chromium Code Reviews| 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 6394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // multitarget_strategy == TAP_MULTIPLE_TARGETS_STRATEGY_NONE. | 6455 break; |
| 6453 return false; | 6456 } |
| 6457 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: | |
| 6458 // No-op. | |
| 6459 break; | |
| 6460 default: | |
| 6461 NOTREACHED(); | |
|
piman
2013/08/28 03:01:00
nit: no default, so that the compiler warns if a n
boliu
2013/08/28 03:09:46
Hmm, how would it handle TAP_MULTIPLE_TARGETS_STRA
piman
2013/08/28 03:18:22
Since it's actually one of the other values, it sh
| |
| 6454 } | 6462 } |
| 6455 | 6463 |
| 6456 return true; | 6464 return handled; |
| 6457 } | 6465 } |
| 6458 #endif | 6466 #endif |
| 6459 | 6467 |
| 6460 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { | 6468 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 6461 return history_list_length_; | 6469 return history_list_length_; |
| 6462 } | 6470 } |
| 6463 | 6471 |
| 6464 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { | 6472 void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
| 6465 if (enable) { | 6473 if (enable) { |
| 6466 if (has_focus()) | 6474 if (has_focus()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6532 for (size_t i = 0; i < icon_urls.size(); i++) { | 6540 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6533 WebURL url = icon_urls[i].iconURL(); | 6541 WebURL url = icon_urls[i].iconURL(); |
| 6534 if (!url.isEmpty()) | 6542 if (!url.isEmpty()) |
| 6535 urls.push_back(FaviconURL(url, | 6543 urls.push_back(FaviconURL(url, |
| 6536 ToFaviconType(icon_urls[i].iconType()))); | 6544 ToFaviconType(icon_urls[i].iconType()))); |
| 6537 } | 6545 } |
| 6538 SendUpdateFaviconURL(urls); | 6546 SendUpdateFaviconURL(urls); |
| 6539 } | 6547 } |
| 6540 | 6548 |
| 6541 } // namespace content | 6549 } // namespace content |
| OLD | NEW |