Android WebView 支持 getClientRects 吗?还是有bug?
我发现 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
元素是一个块元素,因此为该块返回一个
ClientRect
。未列出匿名内联框。因此,返回中的一个ClientRect
是正确的。但是,内联元素(例如
或
)将为该元素的每一行报告一个
ClientRect
被闯入。这是因为这些盒子不是匿名的。(从 中的
getClientRects()
规范的行间阅读W3C CSSOM 视图模块规范)The
<p>
element is a block element, so returns oneClientRect
for the block. Anonymous inline boxes are not listed. So, oneClientRect
in the return is correct.However, an inline element, like a
<span>
or<em>
for example, will report oneClientRect
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)