Commit 36cb2980 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Fix placeholder view positioning in PagePlaceholderTabHelper.

This fixes the bug where grey placeholder image looks scrolled. This
CL accounts for contentInset set on web view proxy.

Bug: None
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ic6346a1cf5b0a637016be53bfde6e6a9df4ddca8
Reviewed-on: https://chromium-review.googlesource.com/979607Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546127}
parent 264544cf
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#import "ios/chrome/browser/snapshots/snapshot_tab_helper.h" #import "ios/chrome/browser/snapshots/snapshot_tab_helper.h"
#import "ios/web/public/web_state/ui/crw_web_view_proxy.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -82,11 +83,17 @@ void PagePlaceholderTabHelper::AddPlaceholder() { ...@@ -82,11 +83,17 @@ void PagePlaceholderTabHelper::AddPlaceholder() {
// Update placeholder view's image and display it on top of WebState's view. // Update placeholder view's image and display it on top of WebState's view.
__weak UIImageView* weak_placeholder_view = placeholder_view_; __weak UIImageView* weak_placeholder_view = placeholder_view_;
__weak UIView* weak_web_state_view = web_state_->GetView(); __weak UIView* weak_web_state_view = web_state_->GetView();
// placeholder_view_.image = SnapshotTabHelper::DefautSnapshotImage(); __weak id<CRWWebViewProxy> web_view_proxy = web_state_->GetWebViewProxy();
SnapshotTabHelper::FromWebState(web_state_) SnapshotTabHelper::FromWebState(web_state_)
->RetrieveGreySnapshot(^(UIImage* snapshot) { ->RetrieveGreySnapshot(^(UIImage* snapshot) {
CGRect frame = weak_web_state_view.frame;
UIEdgeInsets inset = web_view_proxy.contentInset;
frame.origin.x += inset.left;
frame.origin.y += inset.top;
frame.size.width -= (inset.right + inset.left);
frame.size.height -= (inset.bottom + inset.top);
weak_placeholder_view.frame = frame;
weak_placeholder_view.image = snapshot; weak_placeholder_view.image = snapshot;
weak_placeholder_view.frame = weak_web_state_view.frame;
[weak_web_state_view addSubview:weak_placeholder_view]; [weak_web_state_view addSubview:weak_placeholder_view];
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment