Android WebView 支持 getClientRects 吗?还是有bug?

发布于 2025-01-07 19:59:56 字数 132 浏览 2 评论 0原文

我发现 Javascript 方法 getClientRects 总是生成仅包含 1 个元素的数组,即使是为多行 p 调用它时也是如此。我期望 p 显示的矩形数量与行数一样多,因为它比单行长。 Android WebView 支持此方法还是存在错误?

I found that Javascript method getClientRects always yields an array of 1 element only, even when it is called for multiple lines p, for example. I expect as many rects as many lines the p was displayed over because it is longer than a single line. Is this method supported on Android WebView or there is a bug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜柠檬 2025-01-14 19:59:56

元素是一个块元素,因此为该块返回一个 ClientRect。未列出匿名内联框。因此,返回中的一个 ClientRect 是正确的。

但是,内联元素(例如 )将为该元素的每一行报告一个 ClientRect被闯入。这是因为这些盒子不是匿名的。

(从 中的 getClientRects() 规范的行间阅读W3C CSSOM 视图模块规范

The <p> element is a block element, so returns one ClientRect for the block. Anonymous inline boxes are not listed. So, one ClientRect in the return is correct.

However, an inline element, like a <span> or <em> for example, will report one ClientRect for each line the element is broken into. That's because the boxes are not anonymous.

(Read from between the lines in the specification of getClientRects() in the W3C CSSOM View Module spec)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文