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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Range.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/dom/Range/get-bounding-client-rect-empty-and-non-empty.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Range/get-bounding-client-rect-empty-and-non-empty.html b/third_party/WebKit/LayoutTests/fast/dom/Range/get-bounding-client-rect-empty-and-non-empty.html
new file mode 100644
index 0000000000000000000000000000000000000000..ce1b00cd4ac7249cf33fa14da25621da00bb927a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/Range/get-bounding-client-rect-empty-and-non-empty.html
@@ -0,0 +1,61 @@
+<!DOCTPYE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<style>
+html, body {
+ margin: 0;
+}
+
+#container > div {
+ font-size: 10px;
+ width: 5ch;
+ border: thin solid black;
+}
+</style>
+<div id="log"></div>
+<div id="container">
+ <div title="normal wrap">0123 456</div>
+ <div title="normal wrap, space overflows">01234 567</div>
+ <div title="pre-wrap" style="white-space: pre-wrap">0123 45678</div>
+ <div title="pre-wrap, space overflows" style="white-space: pre-wrap">01234 5678</div>
+ <div title="break-word" style="word-wrap: break-word">0123456789</div>
+ <div title="pre" style="white-space:pre">a
+b<span></span>b</div>
+</div>
+<script>
+var range = document.createRange();
+
+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
+ var name = element.title;
+ var node = element.firstChild;
+ for (var i = 0; i < node.textContent.length; i++) {
+ range.setStart(node, i);
+ range.setEnd(node, i + 1);
+ var rects = range.getClientRects();
+ var bounds = range.getBoundingClientRect();
+ if (rects.length <= 1)
+ continue;
+ // If all rects are empty, bounds should be rects[0].
+ if (bounds.width == 0 || bounds.height == 0) {
+ test(function () {
+ assert_equals_rect(bounds, rects[0]);
+ }, name + "[" + i + "]isEmpty: " + rectToString(bounds) + " from " + rectsToString(rects));
+ }
+ test(function () {
+ assert_equals(bounds.height, rects[0].height);
+ }, name + "[" + i + "].height: " + rectToString(bounds) + " from " + rectsToString(rects));
+ }
+});
+
+function assert_equals_rect(actual, expected, description) {
+ for (var prop in expected)
+ assert_equals(actual[prop], expected[prop], description + "." + prop);
+}
+function rectsToString(rects) {
+ return "[" + Array.prototype.map.call(rects, rectToString).join() + "]";
+}
+
+function rectToString(r) {
+ return "(" + r.left + "," + r.top + "-" + r.width + "," + r.height + ")";
+}
+</script>
« 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