mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
Compare commits
4 Commits
nightly-bu
...
fix/linux-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f67a53d97b | ||
|
|
6829e3cb14 | ||
|
|
4fd599ae20 | ||
|
|
d73bcc661b |
@@ -23,6 +23,81 @@
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
// Workaround for #7210: WebKitGTK crashes on vue-resize's hidden <object> probe used by
|
||||||
|
// older Fluidd/Mainsail pages. Swap that <object> for a <div> shim at appendChild time
|
||||||
|
// and bridge resize events through a fake contentDocument.defaultView so vue-resize keeps
|
||||||
|
// working. Workaround proposed by @VittC.
|
||||||
|
static void inject_vue_resize_workaround(wxWebView *webView)
|
||||||
|
{
|
||||||
|
webView->AddUserScript(
|
||||||
|
"(function() {"
|
||||||
|
" 'use strict';"
|
||||||
|
" function isVueResizeObject(el) {"
|
||||||
|
" return el && el.tagName === 'OBJECT'"
|
||||||
|
" && el.type === 'text/html'"
|
||||||
|
" && el.getAttribute('aria-hidden') === 'true'"
|
||||||
|
" && el.getAttribute('tabindex') === '-1';"
|
||||||
|
" }"
|
||||||
|
" function isResizeObserverParent(p) {"
|
||||||
|
" return p && p.classList && p.classList.contains('resize-observer');"
|
||||||
|
" }"
|
||||||
|
" function makeShim(orig, parentForRO) {"
|
||||||
|
" var shim = document.createElement('div');"
|
||||||
|
" shim.setAttribute('aria-hidden', 'true');"
|
||||||
|
" shim.setAttribute('tabindex', '-1');"
|
||||||
|
" shim.style.display = 'none';"
|
||||||
|
" 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', {"
|
||||||
|
" configurable: true,"
|
||||||
|
" get: function() { return { defaultView: fakeWin }; }"
|
||||||
|
" });"
|
||||||
|
" Object.defineProperty(shim, 'contentWindow', {"
|
||||||
|
" configurable: true,"
|
||||||
|
" get: function() { return fakeWin; }"
|
||||||
|
" });"
|
||||||
|
" if (typeof orig.onload === 'function') { shim.onload = orig.onload; }"
|
||||||
|
" queueMicrotask(function() {"
|
||||||
|
" if (parentForRO && typeof ResizeObserver !== 'undefined') {"
|
||||||
|
" ro = new ResizeObserver(function() {"
|
||||||
|
" fakeWin.dispatchEvent(new Event('resize'));"
|
||||||
|
" });"
|
||||||
|
" ro.observe(parentForRO);"
|
||||||
|
" }"
|
||||||
|
" if (typeof shim.onload === 'function') {"
|
||||||
|
" try { shim.onload(new Event('load')); } catch (e) {}"
|
||||||
|
" }"
|
||||||
|
" shim.dispatchEvent(new Event('load'));"
|
||||||
|
" });"
|
||||||
|
" return shim;"
|
||||||
|
" }"
|
||||||
|
" var origAppend = Node.prototype.appendChild;"
|
||||||
|
" Node.prototype.appendChild = function(child) {"
|
||||||
|
" if (isResizeObserverParent(this) && isVueResizeObject(child)) {"
|
||||||
|
" return origAppend.call(this, makeShim(child, this));"
|
||||||
|
" }"
|
||||||
|
" return origAppend.call(this, child);"
|
||||||
|
" };"
|
||||||
|
" var origInsertBefore = Node.prototype.insertBefore;"
|
||||||
|
" Node.prototype.insertBefore = function(child, ref) {"
|
||||||
|
" if (isResizeObserverParent(this) && isVueResizeObject(child)) {"
|
||||||
|
" return origInsertBefore.call(this, makeShim(child, this), ref);"
|
||||||
|
" }"
|
||||||
|
" return origInsertBefore.call(this, child, ref);"
|
||||||
|
" };"
|
||||||
|
" console.log('[vr-fix] vue-resize WebKitGTK patch active');"
|
||||||
|
"})();",
|
||||||
|
wxWEBVIEW_INJECT_AT_DOCUMENT_START
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
PrinterWebView::PrinterWebView(wxWindow *parent)
|
PrinterWebView::PrinterWebView(wxWindow *parent)
|
||||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||||
, m_browser(nullptr)
|
, m_browser(nullptr)
|
||||||
@@ -43,6 +118,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
inject_vue_resize_workaround(m_browser);
|
||||||
|
|
||||||
auto cookiesPath = boost::filesystem::path(data_dir() + "/cache/cookies.db");
|
auto cookiesPath = boost::filesystem::path(data_dir() + "/cache/cookies.db");
|
||||||
auto wv = static_cast<WebKitWebView*>(m_browser->GetNativeBackend());
|
auto wv = static_cast<WebKitWebView*>(m_browser->GetNativeBackend());
|
||||||
auto wv_ctx = webkit_web_view_get_context(wv);
|
auto wv_ctx = webkit_web_view_get_context(wv);
|
||||||
@@ -165,6 +242,10 @@ void PrinterWebView::SendAPIKey()
|
|||||||
)",
|
)",
|
||||||
m_apikey);
|
m_apikey);
|
||||||
m_browser->RemoveAllUserScripts();
|
m_browser->RemoveAllUserScripts();
|
||||||
|
#ifdef __linux__
|
||||||
|
// Re-inject the vue-resize/WebKitGTK workaround that RemoveAllUserScripts just cleared.
|
||||||
|
inject_vue_resize_workaround(m_browser);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_browser->AddUserScript(script);
|
m_browser->AddUserScript(script);
|
||||||
m_browser->Reload();
|
m_browser->Reload();
|
||||||
|
|||||||
Reference in New Issue
Block a user