Repository navigation
Conversation
Metrics.Tablet sat in TabletLayoutPreferences.swift, beside the layout choices. Every other size is in Design/Metrics.swift, and the fixes that follow add the iPad's downloads sizes there. Nothing changes on screen.
The iPad's workspace never mounts ChromeLayer, where the phone keeps the download question, the Now line and the Downloads page. A site's first download asked a question nothing showed, so it never started. - A downloads button in the sidebar's foot, and in the toolbar while the sidebar is away and there is a file: its popover asks a site's first file, then lists every file. - Site Controls gains Downloaded Here and shows the Downloads page; its Downloads permission had the microphone's mark. - Share sheets point under the toolbar on iPad, and topController skips a popover on its way out, so Share from Site Controls presents.
…on iPad DownloadsUITests failed on iPad for four reasons, one in the app: - The popover's panel named itself tablet.downloads around the question too, and the card and panel made one element: the card lost its name, download.ask, so VoiceOver and the tests could not find it, though it was on screen. The panel's name now goes on its list only. - The test then looked for the phone's Now line and plate menu. On iPad it opens the downloads button's list and Site Controls instead; the button's VoiceOver value now says how many files its list holds, so a file's arrival can be waited on without opening the popover over the page, which would refuse the file (WebPool.canInteract). - Download Linked File was counted among every button whose label begins with Download, the iPad's Downloads button too. - Save to Photos waited up to nine seconds on a question iOS asks once per install, so on a simulator that had answered it the toast came and went unseen. It now waits for whichever comes first. A tap on the page as a popover finishes going can be UIKit's: the allowed site's second file is tapped once more if it isn't in after five seconds, as hold() does for a lost press.
A site's first file opens the downloads popover with its question. Once answered, the popover stayed up with the list, and the next tap on the page only closed it: tap a link again after Cancel and nothing came, and DownloadsUITests' second Report found no question. The phone's card goes as it is answered. A popover the question opened now closes with the answer; one the person opened, or that was open already, stays. The test waits for the popover's ground to go before it taps the page.
Site Controls › More gains the Mac's Print… and Save as PDF: the system's print panel with WebKit's print formatter, and the page as one PDF to the share sheet (Save to Files and the rest), named for the page.
A PDF or another document a tab opens (Word, Excel, PowerPoint, iWork, rich text) becomes a file: kept in Downloads without asking and shown in QuickLook, which saves and shares it; WebKit's inline view had no way to keep it. A tab out of sight still shows it inline. A tab whose first load became a file (a new window's PDF or attachment) was cancelled because there was no page to restore; it now keeps the file, and a page-opened window that was only that file closes back to its opener.
WKWebView.url can still name the file for a moment after the file is whole, then reads the source again with no navigation and no change to history (measured: /file at completion, /second 800 ms later, about one run in eighteen). The tests read it at that moment and failed now and then; they now wait for it to come back.
WebPool.swift had grown past 2,400 lines with download work mixed into navigation. The download path (origins, conversions, the response's file branch, the source put back or released, adopt, Download Linked File, Retry) now lives in WebPool+Downloads.swift, as the site work lives in WebPool+Site.swift. The delegate callbacks stay in the conformance and call into it. The stored state stays in the class, so the members the extension uses lose their file-private access. Nothing changes for the person using Yab.
The store kept the last file in as flash for the iPhone's Now line, cleared by a timer, with a held copy while Yab was away, and each clear had to remember both. Now there is one Arrival: the id, done or failed, seen or not, and when it could be heard (nil while Yab is away). The Now line shows it for its two seconds from then. Opening the file, or the iPad's downloads list, marks it seen, which also ends the line, so flashTaken is gone.
The app opened QuickLook when the source tab was in front or no longer existed. A closed tab's id matched nothing, so a document from a closed private tab opened over an ordinary page, and one from any closed tab opened over an unrelated page. The pool reported the gone tab rather than the tab the document was for. The pool now names the tab the viewer belongs to: the tab itself, or the opener when a window the page opened was only the file and closes back. The app opens the viewer only when that tab is in front, the app is active, and the file's privacy matches the page in front (AppModel.showsDocument). Otherwise the file lands in Downloads with the normal arrival. A new window's PDF never reached Downloads at all: WebKit names the opener's web view on a new window's first-load download, so the download.webView check cancelled it. That check now also accepts the opener's view for a fresh window the pool opened.
WebKit shows a bare picture, video, sound or text file as the page, and until now the iPad and iPhone had no way to keep that file. The web pool now remembers each tab's main-document type from the response it let load, set when that load commits, and a page of one of those types (not HTML, not the viewer's documents, not blob: or data:) offers Download in iPad Site Controls > More and the iPhone page menu. It asks for the committed address again through Download Linked File, so the file comes through the tab's own store and cookies and history stays put. A sound or video page also failed outright: WebKit ends its load with "Plug-in handled load" (WebKitErrorDomain 204) when its player takes over, and the pool took that for a failed navigation. It is now treated as the page finishing, as it is.
PageDownloadTests gains a video page in the Download test (/clip.mp4), and real-download tests for the viewer through the app over the pool: the page in front opens its PDF, while a private tab's PDF behind a public page and the PDF of a tab closed before it was whole only land in Downloads. AppModel takes an optional download store so those tests keep their files out of the app's own Downloads folder.
Site Controls offered Save as PDF and Print for any tab in front, but both draw WebKit's view of the page and returned quietly when the tab had none (a restored tab, a Mac's tab not loaded yet), so the row did nothing. Both rows now ask pageCanBeDrawn, which is what the actions need, and are dimmed without a page.
Phone/AGENTS.md asks every UI change to show its states before and after. Print and a PDF in the system's viewer had none. print.panel and print.viewer (in States+Print, joined to the page group) wait for the page to draw before printing and open a real one-page PDF.
A PDF or other viewer document skipped the download question, so a site the person had turned downloads off for still wrote files into Downloads. Such a document now stays WebKit's own view of it, as it did before the viewer. Private tabs remember no answer and are unchanged.
With no controller to present the share sheet on, the PDF written to a temporary folder was never removed.
A document a private tab opened, and Save as PDF of a private page, are shown once their work ends, which can be after the person left. The viewer checked the tab and its privacy but not Private's lock: with Open with Face ID, Yab left and come back while a PDF came opened it over the lock. Save as PDF checked nothing: Private left or locked while the page was drawn, its share sheet still came up over whatever was in front, with the private page's PDF written to a temporary folder. Both now ask one rule, presents(for:isPrivate:appActive:): the tab it was made for is in front of an active Yab, of the same privacy, and a private one only while privateLock.mayReveal. Save as PDF made when that fails is dropped before anything is written.
…ps its extension PageDownload.filename cuts a name to 120 characters and 255 bytes, the file system's limit, from the end: through its extension. Save as PDF put .pdf after the cut name, so a title of 85 Chinese characters made a name of 259 bytes, the write failed and Save as PDF said it couldn't save. A download with a long name lost its .pdf or .zip the same way. The cut now comes before a short extension, which stays whole, and Save as PDF passes its whole name, .pdf and all, through it.
A page's type came only from the response that loaded it. Going Back or Forward to a picture or text page WebKit kept in its back-forward cache brings no response, so the commit cleared the type and Download went from the menus until the page was loaded again. Each tab keeps the types of the file pages in its history by address, only for addresses its history still holds, and a commit with no response takes the one its address had.
[Medium impact] The PR changes how documents and downloadable pages behave across the iPhone and iPad browser. Save as PDF needs privacy fixes before merging. FindingsSummaryThis PR keeps opened documents in Downloads and opens them in the system viewer. It also adds:
Save as PDF needs two privacy fixes: its share sheet can outlive the Private lock, and its temporary private files can survive a restart. Validation was limited to source review. The iOS suites and visible states were not run in this Linux environment. Acknowledged deferral:
|
| let sheet = UIActivityViewController(activityItems: [file], applicationActivities: nil) | ||
| sheet.popoverPresentationController?.sourceView = root.view | ||
| sheet.popoverPresentationController?.sourceRect = Self.shareAnchor(in: root.view) | ||
| sheet.completionWithItemsHandler = { _, _, _, _ in try? FileManager.default.removeItem(at: folder) } | ||
| root.present(sheet, animated: !Motion.disabled) |
There was a problem hiding this comment.
Save as PDF checks presents() before showing the share sheet, but never dismisses it when Private locks. Open it from Private, background Yab, and return with Face ID required: PrivateLockView replaces only the content underneath the still-visible sheet. Dismiss or cover the private sheet when Yab becomes inactive, and keep it hidden until Private unlocks.
How this was verified: The private PDF is passed to a presented UIActivityViewController, while the lock and inactive cover change only the root view beneath presented controllers.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| let folder = FileManager.default.temporaryDirectory.appendingPathComponent("yab-pdf-\(UUID())", isDirectory: true) | ||
| let file = folder.appendingPathComponent(Self.pdfName(tab.title)) | ||
| do { | ||
| try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) | ||
| try data.write(to: file) |
There was a problem hiding this comment.
Save as PDF writes private pages into yab-pdf-* folders and deletes them only when the share sheet finishes. If Yab is killed while that sheet is open, the callback cannot run. The next launch clears privateFolder, not these folders, so a full copy of the private page remains until iOS removes it. Put private exports under a folder that is also cleared on launch.
How this was verified: Private pages reach this write, and the only removal registered for the created folder is the share sheet's completion callback; startup cleanup removes a different folder.
What changes
On iPhone and iPad, a PDF or another document a tab opens (Word, Excel, PowerPoint, iWork, rich text) is kept in Downloads and opens in the system viewer, which can save and share it. Before, WebKit's inline view had no way to keep it. A picture, sound, text or video page also offers Download. On iPad, Site Controls gains Print… and Save as PDF.
Built on #1132 (the downloads button). Review only the commits after it. On iPad, a site's first download asks, and only that button can show the question.
Why it happened
presents(). They show a file only over the tab that asked for it, only while the app is active, and only whileprivateLock.mayReveal. This fixes Greptile's two Private findings on The Mac's page keys, Print, Save as PDF, Duplicate Tab, documents to the viewer #1108: a PDF finishing after you left Private, and a document opening over a locked Private. Onmainno path opens a private file outside Private (checked with tests). The risk came only with this viewer, so the fix ships with it..pdfwas added. Names are now cut before the extension. This also stops long download names losing their extension.WebPool+Downloads.swift, as the site code lives inWebPool+Site.swift, with no behavior change.DownloadStorekeeps one arrival state ("the last file in, done or failed, seen or not"), replacing two copies.Proof
mainand pass here:PageDownloadTests: PDF, private, closed tab, opener, Download of a picture, sound, text and video page, and Back from the cache.DocumentViewerTests: the source tab, Private's lock, and the app in the background.DownloadStoreTests: the arrival state.PagePrint: a long title, and no file is left behind when the share sheet can't present.print.panelandprint.viewer.main)main)Checked on
Checklist
DownloadsUITests. Known failures that also fail onmain: one Duo layout test../design-check --base origin/mainandscripts/swift-parse-check --base origin/mainare clean.