[CSSRegions] Need test case for 66198 (sliced line box rendering)
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2011 21:59:44 +0000 (21:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2011 21:59:44 +0000 (21:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68257

Patch by Alan Stearns <stearns@adobe.com> on 2011-09-20
Reviewed by David Hyatt.

* fast/regions/resources/helper.js:
(assertTopLeftMatch):
(sameTopLeft):
* fast/regions/no-split-line-box-expected.txt: Added.
* fast/regions/no-split-line-box.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95571 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/regions/no-split-line-box-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/no-split-line-box.html [new file with mode: 0644]
LayoutTests/fast/regions/resources/helper.js

index b38400d..7ea4dd7 100644 (file)
@@ -1,3 +1,16 @@
+2011-09-20  Alan Stearns  <stearns@adobe.com>
+
+        [CSSRegions] Need test case for 66198 (sliced line box rendering)
+        https://bugs.webkit.org/show_bug.cgi?id=68257
+
+        Reviewed by David Hyatt.
+
+        * fast/regions/resources/helper.js:
+        (assertTopLeftMatch):
+        (sameTopLeft):
+        * fast/regions/no-split-line-box-expected.txt: Added.
+        * fast/regions/no-split-line-box.html: Added.
+
 2011-09-20  David Hyatt  <hyatt@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=68314
diff --git a/LayoutTests/fast/regions/no-split-line-box-expected.txt b/LayoutTests/fast/regions/no-split-line-box-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/fast/regions/no-split-line-box.html b/LayoutTests/fast/regions/no-split-line-box.html
new file mode 100644 (file)
index 0000000..29f1939
--- /dev/null
@@ -0,0 +1,54 @@
+<!--
+  Each of the two regions should only display two line boxes in this test. 
+  The buggy behavior splits the third line box between the first and second region.
+  --> 
+<script type="text/javascript" charset="utf-8" src="resources/helper.js"></script>
+
+<style type="text/css"> 
+  .article{
+    -webkit-flow: "thread";
+    line-height:14px;
+  }
+  .region{
+    content:-webkit-from-flow("thread");
+    width:4em;
+    height:35px;  /*2.5x line height*/
+    background-color:lightgray;
+  }
+  .divider{
+    width:4em;
+    height:10px;
+  }
+  .description{
+    color:blue;
+  }
+</style> 
+<div id="test">
+  <div class="region"></div> 
+  <div class="divider"></div> 
+  <div id="secondRegion" class="region"></div> 
+  <div class="article"> 
+    mnopqr mnopqr <span id="testSpan">m</span>nopqr mnopqr mnopqr mnopqr
+  </div>
+  <p class="description">The two regions on either side of the divider should each have two text lines.</p>
+  <p class="description">There should be no text line split between the regions.</p>
+  <p class="description">The top left corner of the third text line should be in the top left corner of the second region.</p>
+</div>
+<div id="result"></div>
+
+<script>
+  if (window.layoutTestController)
+    layoutTestController.dumpAsText(true);
+    
+  var testElement = document.getElementById("testSpan")
+  var testRect = testElement.getBoundingClientRect();
+  var regionElement = document.getElementById("secondRegion")
+  var regionRect = regionElement.getBoundingClientRect();
+  var resultString = assertTopLeftMatch (regionRect, testRect);
+
+  if (window.layoutTestController)
+       document.getElementById("test").innerText="";
+  var resultDiv = document.getElementById("result");
+  resultDiv.innerText = resultString;
+</script>
index 0f174ee..0340809 100644 (file)
@@ -4,16 +4,19 @@ function isDebugEnabled()
     return window.location.hash == "#debug";
 }
 
-function rectToArray(rect) {
+function rectToArray(rect)
+{
     return [rect.top, rect.left, rect.bottom, rect.right, rect.width, rect.height];
 }
 
-function areEqualNumbers(actual, expected, tolerance) {
+function areEqualNumbers(actual, expected, tolerance)
+{
     var diff = Math.abs(actual - expected);
     return diff <= tolerance;
 }
 
-function areEqualRects(r1, r2, tolerance) {
+function areEqualRects(r1, r2, tolerance)
+{
     if (r1.length != r2.length)
         return false;
     
@@ -24,7 +27,24 @@ function areEqualRects(r1, r2, tolerance) {
     return true;
 }
 
-function assertEqualRects(results, name, actualRect, expectedRect, tolerance) {
+function assertTopLeftMatch (r1, r2, tolerance)
+{
+    if (sameTopLeft(r1, r2, tolerance))
+        return "PASS";
+    return "FAIL. Expected top left points to match, but got ("+ r1.top + "," + r1.left + ") and ("+ r2.top + "," + r2.left + ")";
+}
+
+function sameTopLeft(r1, r2, tolerance)
+{
+    if (tolerance === undefined)
+        tolerance = 0;
+    if ( areEqualNumbers(r1.top, r2.top, tolerance) && areEqualNumbers(r1.left, r2.left, tolerance) )
+        return true;
+    return false;
+}
+
+function assertEqualRects(results, name, actualRect, expectedRect, tolerance)
+{
     if (areEqualRects(actualRect, expectedRect, tolerance))
         return;
 
@@ -50,7 +70,8 @@ function testBoundingRects(expectedBoundingRects, tolerance)
     return !results.length;
 }
 
-function assertRectContains(results, name, containerRect, insideRect, tolerance) {
+function assertRectContains(results, name, containerRect, insideRect, tolerance)
+{
     // make the container rect bigger with tolerance
     var left = containerRect.left - tolerance;
     var right = containerRect.right + tolerance;
@@ -63,7 +84,8 @@ function assertRectContains(results, name, containerRect, insideRect, tolerance)
     return pass;
 }
 
-function addPageLevelDebugBox(rect, color) {
+function addPageLevelDebugBox(rect, color)
+{
     var el = document.createElement("div");
     el.style.position = "absolute";
     el.style.left = rect.left + "px";