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

Unified Diff: ios/chrome/browser/reading_list/reading_list_distiller_page.mm

Issue 2695313004: [iOS Reading List] Add distilling WKWebView to the view hierarchy. (Closed)
Patch Set: feedback Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/reading_list/reading_list_distiller_page.mm
diff --git a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
index b456e9023ace45fc1f2090de465c9857b6027584..e774a3c2f00b7d443290c235ab4c368fd492dfd5 100644
--- a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
+++ b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
@@ -72,6 +72,20 @@ void ReadingListDistillerPage::DistillPageImpl(const GURL& url,
FetchFavicon(url);
DistillerPageIOS::DistillPageImpl(url, script);
+
+ // WKWebView sets the document.hidden property to true and the
+ // document.visibilityState to prerender if the page is not added to a view
+ // hierarchy. Some pages may not render their content in these conditions.
+ // Add the view and move it out of the screen far in the top left corner of
+ // the coordinate space.
+ CGRect frame = [[[UIApplication sharedApplication] keyWindow] frame];
+ frame.origin.x = -5 * std::max(frame.size.width, frame.size.height);
+ frame.origin.y = frame.origin.x;
+ DCHECK(![CurrentWebState()->GetView() superview]);
+ [CurrentWebState()->GetView() setFrame:frame];
+ [[[UIApplication sharedApplication] keyWindow]
+ insertSubview:CurrentWebState()->GetView()
+ atIndex:0];
}
void ReadingListDistillerPage::FetchFavicon(const GURL& page_url) {
@@ -88,6 +102,7 @@ void ReadingListDistillerPage::OnDistillationDone(const GURL& page_url,
const base::Value* value) {
std::unique_ptr<web::WebState> old_web_state = DetachWebState();
if (old_web_state) {
+ [old_web_state->GetView() removeFromSuperview];
web_state_dispatcher_->ReturnWebState(std::move(old_web_state));
}
DistillerPageIOS::OnDistillationDone(page_url, value);
« 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