update comments

This commit is contained in:
SoftFever
2026-05-19 12:51:41 +08:00
parent 4fd599ae20
commit 6829e3cb14

View File

@@ -24,26 +24,31 @@ namespace Slic3r {
namespace GUI { namespace GUI {
#ifdef __linux__ #ifdef __linux__
// Workaround for crash in WebKitGTK when loading Fluidd < v1.37.0 or Mainsail < v2.16.1. // Workaround for a WebKitGTK crash that happens when PrinterWebView loads pages built on
// Their bundled vue-resize component detects container resizes by inserting // older Fluidd or Mainsail (Fluidd < 1.37.0, Mainsail < 2.16.1, and forks/firmware UIs
// derived from them). Those bundles ship vue-resize, whose <resize-observer> component
// implements container-resize detection by inserting
// <object aria-hidden="true" tabindex="-1" type="text/html" data="about:blank"> // <object aria-hidden="true" tabindex="-1" type="text/html" data="about:blank">
// inside a <div class="resize-observer">. The very insertion of that <object> into the DOM // inside its <div class="resize-observer"> wrapper, then listens for 'resize' on the
// corrupts the heap in WebKitGTK's AcceleratedBackingStore and segfaults. // object's contentDocument.defaultView. WebKitGTK segfaults somewhere in its handling
// of that <object>; the simplest reliable fix is to never let it enter the DOM.
// //
// This hook patches Node.prototype.appendChild/insertBefore and *only* swaps the child // We hook Node.prototype.appendChild and insertBefore, and swap the inserted child only
// when BOTH conditions hold: // when BOTH conditions hold:
// 1. The parent has class "resize-observer" (vue-resize's wrapper div), AND // 1. The parent has class "resize-observer" (vue-resize's wrapper), AND
// 2. The child is an <object> with vue-resize's exact attribute signature. // 2. The child is an <object> matching vue-resize's exact attribute signature.
// Any other appendChild/insertBefore call passes through untouched, so PDF/plugin/embed // Any other appendChild / insertBefore call passes through unchanged, so unrelated
// <object> uses elsewhere on the page are not affected. // <object> use on the page (PDF embeds, plugins, etc.) is unaffected.
// //
// The swap replaces the <object> with a hidden <div> shim that exposes a synthetic // The swap inserts a hidden <div> in place of the <object>. The shim exposes a synthetic
// contentDocument.defaultView (an EventTarget), and bridges a ResizeObserver on the // contentDocument.defaultView (another <div>, which inherits EventTarget); a
// parent to fire 'resize' events on that fake view -- which is exactly what vue-resize's // ResizeObserver on the parent forwards resize notifications to that fake defaultView,
// addResizeHandlers listens to. The synthetic 'load' event fires after insertion so // so vue-resize's addResizeHandlers keeps receiving 'resize' events as expected. A
// vue-resize wires up its handlers normally. // synthetic 'load' event is dispatched on the shim after insertion so vue-resize wires
// up its handlers exactly as it would have on a real <object>.
// //
// See: https://github.com/OrcaSlicer/OrcaSlicer/issues/7210 // Credit: workaround approach by @VittC -- see
// https://github.com/OrcaSlicer/OrcaSlicer/issues/7210#issuecomment-4479760201
static void inject_vue_resize_workaround(wxWebView *webView) static void inject_vue_resize_workaround(wxWebView *webView)
{ {
webView->AddUserScript( webView->AddUserScript(