Skip to content

[UnifiedPDF] Adjust automatically resize logic.#26142

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
sammygill:rework-automatically-resize-logic
Mar 19, 2024
Merged

[UnifiedPDF] Adjust automatically resize logic.#26142
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
sammygill:rework-automatically-resize-logic

Conversation

@sammygill
Copy link
Contributor

@sammygill sammygill commented Mar 19, 2024

088d359

[UnifiedPDF] Adjust automatically resize logic.
https://bugs.webkit.org/show_bug.cgi?id=271264
rdar://123417338

Reviewed by Simon Fraser and Abrar Rahman Protyasha.

This patch aims to make the "Automatically Resize," context menu item
logic a little more intuitive. The way that this setting works now
with this patch is as follows:

1. Defaults to off
- PDFDocumentLayout has m_autoSizeState initialized to
ShouldUpdateAutoSizeScale::Yes, but the plugin will set it to No after
the first layout. This is so that the document gets fitted according to
our existing logic on initial load. Any sort of window resizing at this
point will not resize the document.

2. Turning it on rescales the PDF to the window width
- This is done by adjusting the logic that we have when we handle the
associated context menu event. Instead of setting the plugin's scale
factor to its initial scale that was computed on load, we will set it
to 1.0.

3. Any type of zooming turns it off
- This is already handled already in UnifiedPDFPlugin::setPageScaleFactor.
This includes HUD, pinch, and keyboard zooming.

4. The setting can also be toggleable
- Expanded the associated context menu action handling to include this.
When the setting is toggled off the scales will remain the same even
during window resizing. Toggling it back on will reset the plugin's
scale factor and adjust the document fitting scale so that the document
once again fits the available width.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updateLayout):
(WebKit::UnifiedPDFPlugin::performContextMenuAction):

Canonical link: https://commits.webkit.org/276371@main

339ad03

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 🧪 api-mac ✅ 🧪 api-wpe
🧪 ios-wk2-wpt ✅ 🛠 wpe-skia
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 tv loading 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
🛠 tv-sim ❌ 🧪 api-gtk
✅ 🛠 🧪 merge 🛠 watch
✅ 🛠 watch-sim

@sammygill sammygill requested a review from cdumez as a code owner March 19, 2024 20:40
@sammygill sammygill self-assigned this Mar 19, 2024
@sammygill sammygill added the PDF For bugs in WebKit's built-in PDF support. label Mar 19, 2024
@sammygill sammygill added the merge-queue Applied to send a pull request to merge-queue label Mar 19, 2024
https://bugs.webkit.org/show_bug.cgi?id=271264
rdar://123417338

Reviewed by Simon Fraser and Abrar Rahman Protyasha.

This patch aims to make the "Automatically Resize," context menu item
logic a little more intuitive. The way that this setting works now
with this patch is as follows:

1. Defaults to off
- PDFDocumentLayout has m_autoSizeState initialized to
ShouldUpdateAutoSizeScale::Yes, but the plugin will set it to No after
the first layout. This is so that the document gets fitted according to
our existing logic on initial load. Any sort of window resizing at this
point will not resize the document.

2. Turning it on rescales the PDF to the window width
- This is done by adjusting the logic that we have when we handle the
associated context menu event. Instead of setting the plugin's scale
factor to its initial scale that was computed on load, we will set it
to 1.0.

3. Any type of zooming turns it off
- This is already handled already in UnifiedPDFPlugin::setPageScaleFactor.
This includes HUD, pinch, and keyboard zooming.

4. The setting can also be toggleable
- Expanded the associated context menu action handling to include this.
When the setting is toggled off the scales will remain the same even
during window resizing. Toggling it back on will reset the plugin's
scale factor and adjust the document fitting scale so that the document
once again fits the available width.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updateLayout):
(WebKit::UnifiedPDFPlugin::performContextMenuAction):

Canonical link: https://commits.webkit.org/276371@main
@webkit-commit-queue webkit-commit-queue force-pushed the rework-automatically-resize-logic branch from 339ad03 to 088d359 Compare March 19, 2024 22:39
@webkit-commit-queue
Copy link
Collaborator

Committed 276371@main (088d359): https://commits.webkit.org/276371@main

Reviewed commits have been landed. Closing PR #26142 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 088d359 into WebKit:main Mar 19, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PDF For bugs in WebKit's built-in PDF support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments