fix: stop horizontal candidate wrap flash on long lists

Keep horizontal candidates on one line with max-content/nowrap, and resize the host/WebView before painting so content is never laid out in a still-narrow viewport.
This commit is contained in:
fanlusky committed 2026-07-24 02:07:27 +08:00
1 parent 35f7dbd96e
commit b01a73e336
4 files changed
+129 -45

No files matched your search

+11 -2
View File
@@ -61,8 +61,17 @@ void GetContainerSizeCand(ComPtr<ICoreWebView2> webview, std::function<void(std:
}
std::wstring script = LR"(
(function() {
var rect = document.getElementById("measureContainerParent").getBoundingClientRect();
return JSON.stringify({width: rect.width, height: rect.height});
var el = document.getElementById("measureContainerParent");
var box = document.getElementById("measureContainer");
if (!el) {
return JSON.stringify({width: 0, height: 0});
}
var rect = el.getBoundingClientRect();
// Prefer intrinsic content width so horizontal nowrap layouts are not
// under-reported when the WebView viewport is still narrow.
var width = Math.max(rect.width, box ? box.scrollWidth : 0, el.scrollWidth || 0);
var height = Math.max(rect.height, box ? box.scrollHeight : 0, el.scrollHeight || 0);
return JSON.stringify({width: width, height: height});
})();
)";
const HRESULT submitHr = webview->ExecuteScript( //