Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 0f33d68c956ec9a92c43603f521795a29559022f https://github.com/WebKit/WebKit/commit/0f33d68c956ec9a92c43603f521795a29559022f Author: Abrar Rahman Protyasha <a_protya...@apple.com> Date: 2024-05-02 (Thu, 02 May 2024)
Changed paths: M Source/WTF/wtf/PlatformEnableCocoa.h M Source/WebCore/WebCore.xcodeproj/project.pbxproj M Source/WebCore/platform/graphics/ColorBlending.h M Source/WebCore/rendering/RenderObject.h M Source/WebCore/rendering/RenderTheme.h M Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm Log Message: ----------- [UnifiedPDF] Highlighted text in PDF disappears momentarily when Safari is resized and zoomed https://bugs.webkit.org/show_bug.cgi?id=273523 rdar://125426369 Reviewed by Simon Fraser. Our current selection drawing strategy is to hand off a graphics context to the `-[PDFSelection drawForPage:withBox:active:inContext:]` API, following which PDFKit duly manipulates the context with selection geometry. Unfortunately, PDFKit uses the "multiply" compositing mode when filling the selection paths in our supplied context. This can result in the white flashing described in the bug report in cases where WebKit has not painted anything into the associated layers. This patch addresses this issue by setting up our own graphics layer in which to paint PDF selections. To do so, we adopt the `-[PDFSelection enumerateRectsAndTransformsForPage:usingBlock:]` SPI, which gives us the selection geometry information necessary to fill the current path of our graphics context. * Source/WTF/wtf/PlatformEnableCocoa.h: Add a compile time flag to guard the new "paint selections into our own layer" behavior behind platform availability of requisite PDFSelection SPI. * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/graphics/ColorBlending.h: Export the blendSourceOver() method, which we use to blend the selection background color with opaque white, thus creating the final (opaque) selection appearance. We also annotate the blendSourceOver declaration with parameter names for clarity, and leave a cautionary note above the blendWithWhite() declaration. * Source/WebCore/rendering/RenderObject.h: * Source/WebCore/rendering/RenderTheme.h: * Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h: * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h: Introduce a new GraphicsLayer owned by the plugin, exclusively for painting PDF selections. Note that this is guarded behind enablement of the plugin painting its own selections, which itself depends on platform availability for the requisite PDFSelection SPI. * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm: (WebKit::UnifiedPDFPlugin::setNeedsRepaintInDocumentRect): Make sure to ask the selection layer to be repainted if a selection is the repaint reason. (WebKit::UnifiedPDFPlugin::ensureLayers): (WebKit::UnifiedPDFPlugin::updateLayerHierarchy): (WebKit::UnifiedPDFPlugin::updateLayerPositions): (WebKit::UnifiedPDFPlugin::didChangeSettings): (WebKit::UnifiedPDFPlugin::layerNeedsPlatformContext const): Make sure we return `false` under the new behavior where the plugin can paint selections into a layer it owns. This allows us to enable accelerated drawing for the selection layer, since it will not be backed by the WP. (WebKit::UnifiedPDFPlugin::didChangeIsInWindow): Propagate isInWindow update to the selection layer such that it paints correctly as a TiledBacking layer. (WebKit::UnifiedPDFPlugin::paintContents): (WebKit::UnifiedPDFPlugin::paintPDFContent): To not vend selection painting duty to PDFKit, while also maintaining correct selection painting behavior on platforms that do not have the new PDFSelection SPI, make sure that haveSelection is invariably false when we want to paint selections into our own layer. (WebKit::UnifiedPDFPlugin::paintPDFSelection): Avoid the problematic "multiply" compositing mode, instead painting opaquely into the context and compositing via the selection layer, which is configured with a "multiply" blend mode. (WebKit::UnifiedPDFPlugin::canPaintSelectionIntoOwnedLayer const): Returns true iff the requisite PDFSelection interface is available at runtime. (WebKit::UnifiedPDFPlugin::determineCurrentlySnappedPage): Canonical link: https://commits.webkit.org/278263@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes