From 5be18eeec67c248e59525469ea97a7d4b99e5355 Mon Sep 17 00:00:00 2001 From: Sergei Ilinykh Date: Mon, 8 Jul 2024 01:00:51 +0300 Subject: [PATCH] Adium: scrolling hack for compatibility with webengine --- themes/chatview/adium/Template.html | 5 ++--- themes/chatview/adium/adapter.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/themes/chatview/adium/Template.html b/themes/chatview/adium/Template.html index e096d2e5d..dfb08ecb9 100644 --- a/themes/chatview/adium/Template.html +++ b/themes/chatview/adium/Template.html @@ -214,11 +214,10 @@ //Auto-scroll to bottom. Use nearBottom to determine if a scrollToBottom is desired. function nearBottom() { - return ( (document.documentElement.scrollTop + document.body.scrollTop) >= ( document.body.offsetHeight - ( window.innerHeight * 1.2 ) ) ); + return ( document.body.scrollTop >= ( document.body.offsetHeight - ( window.innerHeight * 1.2 ) ) ); } function scrollToBottom() { document.body.scrollTop = document.body.offsetHeight; - document.documentElement.scrollTop = document.body.offsetHeight; } //Dynamically exchange the active stylesheet @@ -321,7 +320,7 @@ .actionMessageBody:before { content:"*"; } .actionMessageBody:after { content:"*"; } * { word-wrap:break-word; text-rendering: optimizelegibility; } - img.scaledToFitImage { height: auto; max-width: 100%%; } + img.scaledToFitImage { height: auto; max-width: 100%; } diff --git a/themes/chatview/adium/adapter.js b/themes/chatview/adium/adapter.js index 73a756642..ca4015244 100644 --- a/themes/chatview/adium/adapter.js +++ b/themes/chatview/adium/adapter.js @@ -567,6 +567,18 @@ chat.util.updateObject(adapter, function(chat){ session.newMessage.connect(chat.receiveObject); session.scrollRequested.connect((value) => { window.scrollBy(0, value); }); + if (QWebChannel) { + // define compatibility hack for webengine + Object.defineProperty(document.body, "scrollTop", { + set: function(x) { document.documentElement.scrollTop = x; }, + get: function() { return document.documentElement.scrollTop; } + }); + Object.defineProperty(document.body, "scrollHeight", { + set: function(x) { document.documentElement.scrollHeight = x; }, + get: function() { return document.documentElement.scrollHeight; } + }); + } + chat.util.rereadOptions(); session.signalInited(); }