mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-18 05:02:15 +01:00
docs(chromium): tighten paint-polyfill godoc per CONTRIBUTING style [skip ci]
This commit is contained in:
@@ -10,17 +10,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// paintCallbacksPolyfill is a JavaScript shim installed before any user
|
// paintCallbacksPolyfill is a JavaScript shim installed before any user
|
||||||
// script runs. It replaces [requestAnimationFrame], [cancelAnimationFrame],
|
// script runs. Replaces requestAnimationFrame, cancelAnimationFrame,
|
||||||
// [ResizeObserver], and [IntersectionObserver] with timer-backed
|
// ResizeObserver, and IntersectionObserver with timer-backed
|
||||||
// implementations. Headless Chromium's print-emulation pipeline does not
|
// implementations. Headless Chromium's print-emulation pipeline does
|
||||||
// tick the compositor refresh driver reliably between
|
// not tick the compositor refresh driver between the load event and
|
||||||
// "load" and [Page.printToPDF], which leaves the native rAF /
|
// the Page.printToPDF call, which leaves the native callback queues
|
||||||
// ResizeObserver / IntersectionObserver queues permanently stalled and
|
// stalled and breaks charting libraries (visx, ApexCharts) that rely
|
||||||
// breaks charting libraries (visx, ApexCharts, and similar) that rely on
|
// on rAF-gated measurement. The polyfill exposes the same APIs with
|
||||||
// rAF-gated measurement. The polyfill exposes the same APIs with timer
|
// timer semantics so user-scheduled callbacks fire in print mode and
|
||||||
// semantics, so user scripts that schedule work on those callbacks
|
// the rendered output matches a live browser. See
|
||||||
// receive their measurements and Gotenberg's rendered output reflects
|
|
||||||
// the page the author intended. See
|
|
||||||
// https://github.com/gotenberg/gotenberg/issues/1535.
|
// https://github.com/gotenberg/gotenberg/issues/1535.
|
||||||
const paintCallbacksPolyfill = `
|
const paintCallbacksPolyfill = `
|
||||||
(function () {
|
(function () {
|
||||||
@@ -126,10 +124,9 @@ const paintCallbacksPolyfill = `
|
|||||||
|
|
||||||
// injectPaintCallbacksPolyfillActionFunc installs the
|
// injectPaintCallbacksPolyfillActionFunc installs the
|
||||||
// [paintCallbacksPolyfill] via [page.AddScriptToEvaluateOnNewDocument]
|
// [paintCallbacksPolyfill] via [page.AddScriptToEvaluateOnNewDocument]
|
||||||
// so that it runs before any user script on the navigated page. Callers
|
// so that it runs before any user script on the navigated page. When
|
||||||
// set install=false to skip the shim when no readiness signal gates the
|
// install is false the action is a no-op and the page keeps the native
|
||||||
// conversion, which preserves the native implementations for pages that
|
// rAF, ResizeObserver, and IntersectionObserver implementations.
|
||||||
// do not require it.
|
|
||||||
func injectPaintCallbacksPolyfillActionFunc(logger *slog.Logger, install bool) chromedp.ActionFunc {
|
func injectPaintCallbacksPolyfillActionFunc(logger *slog.Logger, install bool) chromedp.ActionFunc {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
if !install {
|
if !install {
|
||||||
|
|||||||
Reference in New Issue
Block a user