提交 49129d12 编写于 作者: M Matt Bierner

Fix Webview scroll position preserve broken (#21531)

**Bug**
Some regression since 1.9 caused the scroll preserve behavior of webviews to stop working in certain cases. There appears to be a race condition where `newFrame.contentDocument.body` does not exist when the scroll update code is called

**Fix**
Instead of using a timeout, update the scroll position when `DOMContentLoaded` is fired from the webview window

Fixes #21491
上级 31c1c0f1
......@@ -135,13 +135,13 @@ document.addEventListener("DOMContentLoaded", function (event) {
// workaround for https://github.com/Microsoft/vscode/issues/12865
// check new scrollTop and reset if neccessary
setTimeout(function () {
newFrame.contentWindow.addEventListener('DOMContentLoaded', function () {
if (newFrame.contentDocument.body && scrollTop !== newFrame.contentDocument.body.scrollTop) {
newFrame.contentDocument.body.scrollTop = scrollTop;
}
document.body.removeChild(frame);
newFrame.style.display = 'block';
}, 0);
});
ipcRenderer.sendToHost('did-set-content', stats);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册