| 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 6685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6696 event.data.tap.width, event.data.tap.height); | 6696 event.data.tap.width, event.data.tap.height); |
| 6697 gfx::Rect zoom_rect; | 6697 gfx::Rect zoom_rect; |
| 6698 float new_total_scale = | 6698 float new_total_scale = |
| 6699 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 6699 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
| 6700 finger_rect, target_rects, GetSize(), | 6700 finger_rect, target_rects, GetSize(), |
| 6701 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 6701 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
| 6702 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); | 6702 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); |
| 6703 if (!new_total_scale) | 6703 if (!new_total_scale) |
| 6704 return false; | 6704 return false; |
| 6705 | 6705 |
| 6706 gfx::Size canvas_size = gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), | 6706 DidTapMultipleTargetsStrategy multitarget_strategy = |
| 6707 new_total_scale)); | 6707 renderer_preferences_.did_tap_multiple_targets_strategy; |
| 6708 TransportDIB* transport_dib = NULL; | 6708 if (multitarget_strategy == MULTITARGET_ZOOM) { |
| 6709 { | 6709 return webview()->zoomToMultipleTargetsRect(zoom_rect); |
| 6710 scoped_ptr<skia::PlatformCanvas> canvas( | 6710 } else if (multitarget_strategy == MULTITARGET_POPUP) { |
| 6711 RenderProcess::current()->GetDrawingCanvas(&transport_dib, | 6711 gfx::Size canvas_size = |
| 6712 gfx::Rect(canvas_size))); | 6712 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale)); |
| 6713 if (!canvas) | 6713 TransportDIB* transport_dib = NULL; |
| 6714 return false; | 6714 { |
| 6715 scoped_ptr<skia::PlatformCanvas> canvas( |
| 6716 RenderProcess::current()->GetDrawingCanvas(&transport_dib, |
| 6717 gfx::Rect(canvas_size))); |
| 6718 if (!canvas) |
| 6719 return false; |
| 6715 | 6720 |
| 6716 // TODO(trchen): Cleanup the device scale factor mess. | 6721 // TODO(trchen): Cleanup the device scale factor mess. |
| 6717 // device scale will be applied in WebKit | 6722 // device scale will be applied in WebKit |
| 6718 // --> zoom_rect doesn't include device scale, | 6723 // --> zoom_rect doesn't include device scale, |
| 6719 // but WebKit will still draw on zoom_rect * device_scale_factor_ | 6724 // but WebKit will still draw on zoom_rect * device_scale_factor_ |
| 6720 canvas->scale(new_total_scale / device_scale_factor_, | 6725 canvas->scale(new_total_scale / device_scale_factor_, |
| 6721 new_total_scale / device_scale_factor_); | 6726 new_total_scale / device_scale_factor_); |
| 6722 canvas->translate(-zoom_rect.x() * device_scale_factor_, | 6727 canvas->translate(-zoom_rect.x() * device_scale_factor_, |
| 6723 -zoom_rect.y() * device_scale_factor_); | 6728 -zoom_rect.y() * device_scale_factor_); |
| 6724 | 6729 |
| 6725 webwidget_->paint(webkit_glue::ToWebCanvas(canvas.get()), zoom_rect, | 6730 webwidget_->paint(webkit_glue::ToWebCanvas(canvas.get()), zoom_rect, |
| 6726 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent); | 6731 WebWidget::ForceSoftwareRenderingAndIgnoreGPUResidentContent); |
| 6732 } |
| 6733 |
| 6734 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( |
| 6735 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect))); |
| 6736 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, |
| 6737 physical_window_zoom_rect, |
| 6738 canvas_size, |
| 6739 transport_dib->id())); |
| 6740 } else { |
| 6741 return false; |
| 6727 } | 6742 } |
| 6728 | 6743 |
| 6729 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( | |
| 6730 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect))); | |
| 6731 Send(new ViewHostMsg_ShowDisambiguationPopup(routing_id_, | |
| 6732 physical_window_zoom_rect, | |
| 6733 canvas_size, | |
| 6734 transport_dib->id())); | |
| 6735 | |
| 6736 return true; | 6744 return true; |
| 6737 } | 6745 } |
| 6738 | 6746 |
| 6739 skia::RefPtr<SkPicture> RenderViewImpl::CapturePicture() { | 6747 skia::RefPtr<SkPicture> RenderViewImpl::CapturePicture() { |
| 6740 return compositor_ ? compositor_->CapturePicture() : | 6748 return compositor_ ? compositor_->CapturePicture() : |
| 6741 skia::RefPtr<SkPicture>(); | 6749 skia::RefPtr<SkPicture>(); |
| 6742 } | 6750 } |
| 6743 #endif | 6751 #endif |
| 6744 | 6752 |
| 6745 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { | 6753 unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6818 WebURL url = icon_urls[i].iconURL(); | 6826 WebURL url = icon_urls[i].iconURL(); |
| 6819 if (!url.isEmpty()) | 6827 if (!url.isEmpty()) |
| 6820 urls.push_back(FaviconURL(url, | 6828 urls.push_back(FaviconURL(url, |
| 6821 ToFaviconType(icon_urls[i].iconType()))); | 6829 ToFaviconType(icon_urls[i].iconType()))); |
| 6822 } | 6830 } |
| 6823 SendUpdateFaviconURL(urls); | 6831 SendUpdateFaviconURL(urls); |
| 6824 } | 6832 } |
| 6825 | 6833 |
| 6826 | 6834 |
| 6827 } // namespace content | 6835 } // namespace content |
| OLD | NEW |