Skip to content

Commit

Permalink
[UnifiedPDF] Checked form controls flicker off while resizing the window
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270040
rdar://123566546

Reviewed by Abrar Rahman Protyasha and Sammy Gill.

When PDF annotations change that affect painted annotations, we need to update
the page previews so that while tiles are missing during zooming/resize, the low
res snapshot has the correct state.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm:
(WebKit::AsyncPDFRenderer::pdfContentChangedInRect):
(WebKit::AsyncPDFRenderer::updateTilesForPaintingRect): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::setNeedsRepaintInDocumentRect):

Canonical link: https://commits.webkit.org/276781@main
  • Loading branch information
smfr committed Mar 28, 2024
1 parent 664d22e commit 4c27f79
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class AsyncPDFRenderer : public WebCore::TiledBackingClient,
void invalidateTilesForPaintingRect(float pageScaleFactor, const WebCore::FloatRect& paintingRect);

// Updates existing tiles. Can result in temporarily stale content.
void updateTilesForPaintingRect(float pageScaleFactor, const WebCore::FloatRect& paintingRect);
void pdfContentChangedInRect(float pageScaleFactor, const WebCore::FloatRect& paintingRect);

void generatePreviewImageForPage(PDFDocumentLayout::PageIndex, float scale);
RefPtr<WebCore::ImageBuffer> previewImageForPage(PDFDocumentLayout::PageIndex) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@
});
}

void AsyncPDFRenderer::updateTilesForPaintingRect(float pageScaleFactor, const FloatRect& paintingRect)
void AsyncPDFRenderer::pdfContentChangedInRect(float pageScaleFactor, const FloatRect& paintingRect)
{
// FIXME: If our platform does not support partial updates (supportsPartialRepaint() is false) then this should behave
// identically to invalidateTilesForPaintingRect().
Expand Down Expand Up @@ -583,9 +583,11 @@
m_paintingWorkQueue->dispatch([protectedThis = Ref { *this }, pdfDocument, tileInfo, tileRenderInfo]() mutable {
protectedThis->paintTileOnWorkQueue(WTFMove(pdfDocument), tileInfo, tileRenderInfo, TileRenderRequestType::TileUpdate);
});

// FIXME: We also need to update the page previews, but probably after a slight delay so they don't compete with tile rendering. webkit.org/b/270040
}

auto pagePreviewScale = plugin->scaleForPagePreviews();
for (auto& pageInfo : pageCoverage.pages)
generatePreviewImageForPage(pageInfo.pageIndex, pagePreviewScale);
}

TextStream& operator<<(TextStream& ts, const TileForGrid& tileInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static String mutationObserverNotificationString()
auto contentsRect = convertUp(CoordinateSpace::PDFDocumentLayout, CoordinateSpace::Contents, rectInDocumentCoordinates);
if (repaintRequirements.contains(RepaintRequirement::PDFContent)) {
if (RefPtr asyncRenderer = asyncRendererIfExists())
asyncRenderer->updateTilesForPaintingRect(m_scaleFactor, contentsRect);
asyncRenderer->pdfContentChangedInRect(m_scaleFactor, contentsRect);
}

RefPtr { m_contentsLayer }->setNeedsDisplayInRect(contentsRect);
Expand Down

0 comments on commit 4c27f79

Please sign in to comment.