Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 879143002: Avoid crashing if multiple target popup is empty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698