[Webkit-unassigned] [Bug 182181] Range getBoundingClientRect returning zero rect on simple text node with <br> before it

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Feb 1 23:06:27 PST 2018


https://bugs.webkit.org/show_bug.cgi?id=182181

--- Comment #2 from Benjamin San Souci <benjamin.sansouci at gmail.com> ---
Here is a more illustrative example that might help. I highlight 3 ranges
- one from the first text node's to the 2nd text node's 15th char
- one from the first text node's to the 3rd text node's 0th char
- one from the first text node's to the 3rd text node's 15th char

The first range goes to the 0th char of the 2nd text node instead of the 15th char.

The last two ranges return the same bounding rect.

```
<html>
<head>
</head>
<body>
  <script>
    function drawRect(rect) {
      let d = document.createElement("div");
      d.style.backgroundColor = "red";
      d.style.left = rect.left + "px";
      d.style.top = rect.top + "px";
      d.style.width = rect.width + "px";
      d.style.height = rect.height + "px";
      d.style.position = "absolute";
      d.style.opacity = 0.5;
      document.body.appendChild(d);
    }

    let d = document.createElement('div');
    d.appendChild(document.createTextNode("Testing something"));
    d.appendChild(document.createTextNode("Testing and things here"));
    d.appendChild(document.createTextNode("And another thing here"));
    document.body.appendChild(d);

    {
      let r = new Range();
      r.setStart(document.getElementsByTagName('div')[0].childNodes[0], 0);
      r.setEnd(document.getElementsByTagName('div')[0].childNodes[1], 15);
      drawRect(r.getBoundingClientRect());
    }

    {
      let r = new Range();
      r.setStart(document.getElementsByTagName('div')[0].childNodes[0], 0);
      r.setEnd(document.getElementsByTagName('div')[0].childNodes[2], 0);
      drawRect(r.getBoundingClientRect());
    }

    {
      let r = new Range();
      r.setStart(document.getElementsByTagName('div')[0].childNodes[0], 0);
      r.setEnd(document.getElementsByTagName('div')[0].childNodes[2], 15);
      drawRect(r.getBoundingClientRect());
    }
  </script>
  </body>
</html>
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180202/37e64751/attachment.html>


More information about the webkit-unassigned mailing list