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

Unified Diff: third_party/WebKit/LayoutTests/accessibility/inline-text-bounds-for-range-br.html

Issue 2372823002: Fix a case where the accessible bounding box of an inline text box was wrong. (Closed)
Patch Set: Fix bug in bounds calc uncovered by windows test Created 4 years, 3 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
Index: third_party/WebKit/LayoutTests/accessibility/inline-text-bounds-for-range-br.html
diff --git a/third_party/WebKit/LayoutTests/accessibility/inline-text-bounds-for-range-br.html b/third_party/WebKit/LayoutTests/accessibility/inline-text-bounds-for-range-br.html
new file mode 100644
index 0000000000000000000000000000000000000000..843b49e62918493da15637a27323cce6f5489b07
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/accessibility/inline-text-bounds-for-range-br.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<p id="paragraph">Line 1<br>Line 2</p>
+
+<script>
+test(function(t) {
+ // Due to rounding we won't get identical bounds as getBoundingClientRect(),
+ // so allow the test to pass if we're within 1 pixel.
+ var epsilon = 1;
+
+ var axParagraph = accessibilityController.accessibleElementById("paragraph");
+ var axStaticText1 = axParagraph.childAtIndex(0);
+ eval("var axTextBounds1 = " + axStaticText1.boundsForRange(0, 6));
+
+ var paragraph = document.getElementById("paragraph");
+ var range = new Range();
+ range.setStart(paragraph.firstChild, 0);
+ range.setEnd(paragraph.firstChild, 6);
+ var rangeBounds = range.getBoundingClientRect();
+
+ assert_approx_equals(axTextBounds1.x, rangeBounds.left, epsilon, "Line 1 left");
+ assert_approx_equals(axTextBounds1.y, rangeBounds.top, epsilon, "Line 1 top");
+ assert_approx_equals(axTextBounds1.width, rangeBounds.width, epsilon, "Line 1 width");
+ assert_approx_equals(axTextBounds1.height, rangeBounds.height, epsilon, "Line 1 height");
+
+ var axStaticText2 = axParagraph.childAtIndex(2);
+ eval("var axTextBounds2 = " + axStaticText2.boundsForRange(0, 6));
+ range.setStart(paragraph.lastChild, 0);
+ range.setEnd(paragraph.lastChild, 6);
+ rangeBounds = range.getBoundingClientRect();
+
+ assert_approx_equals(axTextBounds2.x, rangeBounds.left, epsilon, "Line 2 left");
+ assert_approx_equals(axTextBounds2.y, rangeBounds.top, epsilon, "Line 2 top");
+ assert_approx_equals(axTextBounds2.width, rangeBounds.width, epsilon, "Line 2 width");
+ assert_approx_equals(axTextBounds2.height, rangeBounds.height, epsilon, "Line 2 height");
+}, "Check bounds of inline text boxes after line breaks");
+</script>

Powered by Google App Engine
This is Rietveld 408576698