Skip to content

Commit

Permalink
Merge pull request #1149 from mozilla/jhugman/Bug1184344-ScreenshotTa…
Browse files Browse the repository at this point in the history
…bsLoadedInBackground

Bug 1184344 – Screenshot page as it is loaded in the background.
  • Loading branch information
thebnich committed Oct 16, 2015
2 parents ab9970a + 7afa119 commit 13d48fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,15 @@ extension BrowserViewController: WKNavigationDelegate {
// VoiceOver will sometimes be stuck on the element, not allowing user to move
// forward/backward. Strange, but LayoutChanged fixes that.
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil)
} else {
// Tab is in the backgroud, but we want to be able to see it in the TabTray.
// Delay 100ms to let the tab render (it doesn't work without the delay)
// before screenshotting.
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(100 * NSEC_PER_MSEC))
dispatch_after(time, dispatch_get_main_queue()) {
let screenshot = self.screenshotHelper.takeScreenshot(tab, aspectRatio: 0, quality: 1)
tab.setScreenshot(screenshot)
}
}

addOpenInViewIfNeccessary(webView.URL)
Expand Down

0 comments on commit 13d48fe

Please sign in to comment.