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 3921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3932 return false; | 3932 return false; |
3933 | 3933 |
3934 // The touch_rect, target_rects and zoom_rect are in the outer viewport | 3934 // The touch_rect, target_rects and zoom_rect are in the outer viewport |
3935 // reference frame. | 3935 // reference frame. |
3936 gfx::Rect zoom_rect; | 3936 gfx::Rect zoom_rect; |
3937 float new_total_scale = | 3937 float new_total_scale = |
3938 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 3938 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
3939 touch_rect, target_rects, GetSize(), | 3939 touch_rect, target_rects, GetSize(), |
3940 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 3940 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
3941 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); | 3941 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); |
3942 if (!new_total_scale) | 3942 if (!new_total_scale || zoom_rect.IsEmpty()) |
3943 return false; | 3943 return false; |
3944 | 3944 |
3945 bool handled = false; | 3945 bool handled = false; |
3946 switch (renderer_preferences_.tap_multiple_targets_strategy) { | 3946 switch (renderer_preferences_.tap_multiple_targets_strategy) { |
3947 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: | 3947 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: |
3948 handled = webview()->zoomToMultipleTargetsRect(zoom_rect); | 3948 handled = webview()->zoomToMultipleTargetsRect(zoom_rect); |
3949 break; | 3949 break; |
3950 case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: { | 3950 case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: { |
3951 gfx::Size canvas_size = | 3951 gfx::Size canvas_size = |
3952 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale)); | 3952 gfx::ToCeiledSize(gfx::ScaleSize(zoom_rect.size(), new_total_scale)); |
3953 cc::SharedBitmapManager* manager = | 3953 cc::SharedBitmapManager* manager = |
3954 RenderThreadImpl::current()->shared_bitmap_manager(); | 3954 RenderThreadImpl::current()->shared_bitmap_manager(); |
3955 scoped_ptr<cc::SharedBitmap> shared_bitmap = | 3955 scoped_ptr<cc::SharedBitmap> shared_bitmap = |
3956 manager->AllocateSharedBitmap(canvas_size); | 3956 manager->AllocateSharedBitmap(canvas_size); |
| 3957 CHECK(!!shared_bitmap); |
3957 { | 3958 { |
3958 SkBitmap bitmap; | 3959 SkBitmap bitmap; |
3959 SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(), | 3960 SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(), |
3960 canvas_size.height()); | 3961 canvas_size.height()); |
3961 bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes()); | 3962 bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes()); |
3962 SkCanvas canvas(bitmap); | 3963 SkCanvas canvas(bitmap); |
3963 | 3964 |
3964 // TODO(trchen): Cleanup the device scale factor mess. | 3965 // TODO(trchen): Cleanup the device scale factor mess. |
3965 // device scale will be applied in WebKit | 3966 // device scale will be applied in WebKit |
3966 // --> zoom_rect doesn't include device scale, | 3967 // --> zoom_rect doesn't include device scale, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4099 std::vector<gfx::Size> sizes; | 4100 std::vector<gfx::Size> sizes; |
4100 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4101 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4101 if (!url.isEmpty()) | 4102 if (!url.isEmpty()) |
4102 urls.push_back( | 4103 urls.push_back( |
4103 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4104 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4104 } | 4105 } |
4105 SendUpdateFaviconURL(urls); | 4106 SendUpdateFaviconURL(urls); |
4106 } | 4107 } |
4107 | 4108 |
4108 } // namespace content | 4109 } // namespace content |
OLD | NEW |