Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Range/get-bounding-client-rect-empty-and-non-empty.html

Issue 1949373003: Change Range.getBoundingClientRect() when the first rect is empty (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Range.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTPYE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <style>
5 html, body {
6 margin: 0;
7 }
8
9 #container > div {
10 font-size: 10px;
11 width: 5ch;
12 border: thin solid black;
13 }
14 </style>
15 <div id="log"></div>
16 <div id="container">
17 <div title="normal wrap">0123 456</div>
18 <div title="normal wrap, space overflows">01234 567</div>
19 <div title="pre-wrap" style="white-space: pre-wrap">0123 45678</div>
20 <div title="pre-wrap, space overflows" style="white-space: pre-wrap">01234 567 8</div>
21 <div title="break-word" style="word-wrap: break-word">0123456789</div>
22 <div title="pre" style="white-space:pre">a
23 b<span></span>b</div>
24 </div>
25 <script>
26 var range = document.createRange();
27
28 Array.prototype.forEach.call(container.children, function (element) {
eae 2016/05/05 13:28:29 Please don't do this. Data driven tests like this
kojii 2016/05/06 06:11:02 Done, I'm not certain if I understand this correct
29 var name = element.title;
30 var node = element.firstChild;
31 for (var i = 0; i < node.textContent.length; i++) {
32 range.setStart(node, i);
33 range.setEnd(node, i + 1);
34 var rects = range.getClientRects();
35 var bounds = range.getBoundingClientRect();
36 if (rects.length <= 1)
37 continue;
38 // If all rects are empty, bounds should be rects[0].
39 if (bounds.width == 0 || bounds.height == 0) {
40 test(function () {
41 assert_equals_rect(bounds, rects[0]);
42 }, name + "[" + i + "]isEmpty: " + rectToString(bounds) + " from " + rects ToString(rects));
43 }
44 test(function () {
45 assert_equals(bounds.height, rects[0].height);
46 }, name + "[" + i + "].height: " + rectToString(bounds) + " from " + rectsTo String(rects));
47 }
48 });
49
50 function assert_equals_rect(actual, expected, description) {
51 for (var prop in expected)
52 assert_equals(actual[prop], expected[prop], description + "." + prop);
53 }
54 function rectsToString(rects) {
55 return "[" + Array.prototype.map.call(rects, rectToString).join() + "]";
56 }
57
58 function rectToString(r) {
59 return "(" + r.left + "," + r.top + "-" + r.width + "," + r.height + ")";
60 }
61 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Range.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698