mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
Follow up update for PR #13724: improve GC and shorten comments
This commit is contained in:
@@ -24,26 +24,10 @@ 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 #7210: WebKitGTK crashes on vue-resize's hidden <object> probe used by
|
||||||
// Their bundled vue-resize component detects container resizes by inserting
|
// older Fluidd/Mainsail pages. Swap that <object> for a <div> shim at appendChild time
|
||||||
// <object aria-hidden="true" tabindex="-1" type="text/html" data="about:blank">
|
// and bridge resize events through a fake contentDocument.defaultView so vue-resize keeps
|
||||||
// inside a <div class="resize-observer">. The very insertion of that <object> into the DOM
|
// working. Workaround proposed by @VittC.
|
||||||
// corrupts the heap in WebKitGTK's AcceleratedBackingStore and segfaults.
|
|
||||||
//
|
|
||||||
// This hook patches Node.prototype.appendChild/insertBefore and *only* swaps the child
|
|
||||||
// when BOTH conditions hold:
|
|
||||||
// 1. The parent has class "resize-observer" (vue-resize's wrapper div), AND
|
|
||||||
// 2. The child is an <object> with vue-resize's exact attribute signature.
|
|
||||||
// Any other appendChild/insertBefore call passes through untouched, so PDF/plugin/embed
|
|
||||||
// <object> uses elsewhere on the page are not affected.
|
|
||||||
//
|
|
||||||
// The swap replaces the <object> with a hidden <div> shim that exposes a synthetic
|
|
||||||
// contentDocument.defaultView (an EventTarget), and bridges a ResizeObserver on the
|
|
||||||
// parent to fire 'resize' events on that fake view -- which is exactly what vue-resize's
|
|
||||||
// addResizeHandlers listens to. The synthetic 'load' event fires after insertion so
|
|
||||||
// vue-resize wires up its handlers normally.
|
|
||||||
//
|
|
||||||
// See: https://github.com/OrcaSlicer/OrcaSlicer/issues/7210
|
|
||||||
static void inject_vue_resize_workaround(wxWebView *webView)
|
static void inject_vue_resize_workaround(wxWebView *webView)
|
||||||
{
|
{
|
||||||
webView->AddUserScript(
|
webView->AddUserScript(
|
||||||
@@ -64,6 +48,12 @@ static void inject_vue_resize_workaround(wxWebView *webView)
|
|||||||
" shim.setAttribute('tabindex', '-1');"
|
" shim.setAttribute('tabindex', '-1');"
|
||||||
" shim.style.display = 'none';"
|
" shim.style.display = 'none';"
|
||||||
" var fakeWin = document.createElement('div');"
|
" var fakeWin = document.createElement('div');"
|
||||||
|
" var ro = null;"
|
||||||
|
" var origRemoveEL = fakeWin.removeEventListener.bind(fakeWin);"
|
||||||
|
" fakeWin.removeEventListener = function(type, fn, opts) {"
|
||||||
|
" origRemoveEL(type, fn, opts);"
|
||||||
|
" if (type === 'resize' && ro) { ro.disconnect(); ro = null; }"
|
||||||
|
" };"
|
||||||
" Object.defineProperty(shim, 'contentDocument', {"
|
" Object.defineProperty(shim, 'contentDocument', {"
|
||||||
" configurable: true,"
|
" configurable: true,"
|
||||||
" get: function() { return { defaultView: fakeWin }; }"
|
" get: function() { return { defaultView: fakeWin }; }"
|
||||||
@@ -75,7 +65,7 @@ static void inject_vue_resize_workaround(wxWebView *webView)
|
|||||||
" if (typeof orig.onload === 'function') { shim.onload = orig.onload; }"
|
" if (typeof orig.onload === 'function') { shim.onload = orig.onload; }"
|
||||||
" queueMicrotask(function() {"
|
" queueMicrotask(function() {"
|
||||||
" if (parentForRO && typeof ResizeObserver !== 'undefined') {"
|
" if (parentForRO && typeof ResizeObserver !== 'undefined') {"
|
||||||
" var ro = new ResizeObserver(function() {"
|
" ro = new ResizeObserver(function() {"
|
||||||
" fakeWin.dispatchEvent(new Event('resize'));"
|
" fakeWin.dispatchEvent(new Event('resize'));"
|
||||||
" });"
|
" });"
|
||||||
" ro.observe(parentForRO);"
|
" ro.observe(parentForRO);"
|
||||||
|
|||||||
Reference in New Issue
Block a user