2009-09-06 17:35:13 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<style>
|
2009-11-30 15:14:04 -08:00
|
|
|
.testcase {
|
2009-09-06 17:35:13 -07:00
|
|
|
height:200px;
|
|
|
|
width:200px;
|
|
|
|
position:absolute;
|
2009-11-30 15:14:04 -08:00
|
|
|
overflow:hidden;
|
2009-09-06 17:35:13 -07:00
|
|
|
left:0;
|
|
|
|
top:0;
|
|
|
|
}
|
2009-11-30 15:14:04 -08:00
|
|
|
iframe {
|
|
|
|
border:none;
|
|
|
|
}
|
2009-09-06 17:35:13 -07:00
|
|
|
</style>
|
|
|
|
<script src="region_lib.js"></script>
|
|
|
|
</head>
|
|
|
|
<body style="margin:0">
|
|
|
|
<!-- We use gradients here to fill elements with an unpredictable image. Since
|
|
|
|
our scrolling optimizations take account of areas of an element which
|
|
|
|
are blank or filled with a solid color, it's fragile to use those in
|
|
|
|
tests which expect to observe scrolling happening. -->
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<!-- Each of the "testcase" elements is one test. We scroll that element's
|
|
|
|
scrollTop (or scrollLeft, if the element's class is 'horizontal')
|
|
|
|
from 0 to 20 and then call the function given by the element's id,
|
2009-09-06 17:35:13 -07:00
|
|
|
passing the blit region and the paint region as a parameters. -->
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testSimpleScroll" class="testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, red, black);"></div>
|
2009-09-06 17:35:13 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testFixedBackground" class="testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="height:300px; margin-bottom:-300px; background:-moz-linear-gradient(left, red, black) fixed;"></div>
|
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, rgba(0,0,0,0.7), rgba(255,0,0,0.7));"></div>
|
2009-09-06 17:35:13 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testFixedPosOverlay" class="testcase">
|
2009-09-06 17:35:13 -07:00
|
|
|
<div style="position:fixed; left:0; top:50px; width:100px; height:45px; background:yellow;"></div>
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
<p>Hello
|
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div style="border:1px solid black;" id="testBorder" class="testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, red, black);"></div>
|
2009-09-06 17:35:13 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testScrollOutOfView" class="testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="height:10px; margin-bottom:210px; background:-moz-linear-gradient(top, rgba(0,0,0,0.7), rgba(255,0,0,0.7));"></div>
|
2009-09-06 17:35:13 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testScrollIntoView" class="testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="height:10px; margin-top:210px; background:-moz-linear-gradient(top, rgba(0,0,0,0.7), rgba(255,0,0,0.7));"></div>
|
2009-09-06 17:35:13 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testSimpleScrollWithSubpixelOffset1" style="top:0.2px" class="testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, red, black);"></div>
|
2009-09-06 17:35:14 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testSimpleScrollWithSubpixelOffset2" style="top:0.8px" class="testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, red, black);"></div>
|
2009-09-06 17:35:14 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testSimpleScrollWithSubpixelOffset3" style="left:0.2px" class="horizontal testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="width:300px; height:200px; background:-moz-linear-gradient(left, red, black);"></div>
|
2009-09-06 17:35:14 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testSimpleScrollWithSubpixelOffset4" style="left:0.8px" class="horizontal testcase">
|
2009-11-02 11:36:43 -08:00
|
|
|
<div style="width:300px; height:200px; background:-moz-linear-gradient(left, red, black);"></div>
|
2009-09-06 17:35:14 -07:00
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testMovingClipArea" class="testcase">
|
2009-10-06 21:28:41 -07:00
|
|
|
<div style="margin-top:20px; height:20px; margin-bottom:300px; background-color:blue; overflow:hidden;"></div>
|
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testNonmovingClipArea" class="testcase">
|
2009-11-17 16:38:17 -08:00
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, red, black);"></div>
|
|
|
|
<div style="position:fixed; left:0; top:150px; width:200px; height:50px; background:yellow; overflow:hidden; opacity:0.5;">
|
|
|
|
<div style="height:50px; background:-moz-linear-gradient(top, green, yellow); opacity:0.3;"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<div id="testFixedOverUniform" class="testcase">
|
2009-11-03 10:39:42 -08:00
|
|
|
<div style="height:300px; background:blue;"></div>
|
|
|
|
<div style="position:fixed; left:0; top:50px; width:100px; height:45px; background:yellow; opacity:0.5;"></div>
|
|
|
|
</div>
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
<iframe class="testcase" id="testClipIFRAME"
|
|
|
|
src="data:text/html,<body class='testcase' style='margin:0; height:300px; background:-moz-linear-gradient(top, red, black);'>">
|
|
|
|
</iframe>
|
|
|
|
|
|
|
|
<iframe class="testcase" id="testClipIFRAME2" style="top:-50px"
|
|
|
|
src="data:text/html,<body class='testcase' style='margin:0; height:300px; background:-moz-linear-gradient(top, red, black);'>">
|
|
|
|
</iframe>
|
|
|
|
|
2009-12-12 10:50:25 -08:00
|
|
|
<div id="testHiddenTable" class="testcase">
|
|
|
|
<table style="position:fixed; visibility:hidden; width:200px; height:200px; background:blue;">
|
|
|
|
<tr><td>Hidden stuff</td></tr>
|
|
|
|
</table>
|
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, red, black);"></div>
|
|
|
|
</div>
|
|
|
|
|
2009-12-12 10:50:30 -08:00
|
|
|
<div id="testTableNoBackground" class="testcase">
|
|
|
|
<table style="position:fixed; width:200px; height:200px;">
|
|
|
|
<tr><td></td></tr>
|
|
|
|
</table>
|
|
|
|
<div style="height:300px; background:-moz-linear-gradient(top, red, black);"></div>
|
|
|
|
</div>
|
|
|
|
|
2010-01-26 12:39:02 -08:00
|
|
|
<iframe class="testcase" id="testNoBlitInSVG" height="200" width="200"
|
|
|
|
src="data:text/html,<body class='testcase' style='margin:0; height:300px; background:-moz-linear-gradient(top, red, black);'>">
|
|
|
|
</iframe>
|
|
|
|
<script>
|
|
|
|
// We're not in XHTML, so we have to make our SVG elements with script.
|
|
|
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
|
|
var svg = document.createElementNS(SVG_NS, "svg");
|
|
|
|
svg.setAttribute("style", "width: 300px; height: 300px");
|
|
|
|
var g = document.createElementNS(SVG_NS, "g");
|
|
|
|
g.setAttribute("transform", "translate(100,0) rotate(30)");
|
|
|
|
var fo = document.createElementNS(SVG_NS, "foreignObject");
|
|
|
|
fo.setAttribute("x", "0");
|
|
|
|
fo.setAttribute("y", "0");
|
|
|
|
fo.setAttribute("width", "200");
|
|
|
|
fo.setAttribute("height", "200");
|
|
|
|
var iframe = document.getElementById("testNoBlitInSVG");
|
|
|
|
iframe.parentNode.replaceChild(svg, iframe);
|
|
|
|
fo.appendChild(iframe);
|
|
|
|
g.appendChild(fo);
|
|
|
|
svg.appendChild(g);
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<iframe class="testcase" id="testNoBlitInTransform" height="200" width="200" style="-moz-transform-origin: 0 0; -moz-transform: translateX(100px) rotate(30deg)"
|
|
|
|
src="data:text/html,<body class='testcase' style='margin:0; height:300px; background:-moz-linear-gradient(top, red, black);'>">
|
|
|
|
</iframe>
|
|
|
|
|
2009-09-06 17:35:13 -07:00
|
|
|
<script>
|
2009-11-30 15:14:04 -08:00
|
|
|
var testcases = document.querySelectorAll("div.testcase");
|
|
|
|
var tests = [];
|
|
|
|
var iframes = document.querySelectorAll("iframe.testcase");
|
|
|
|
|
2009-09-06 17:35:13 -07:00
|
|
|
var currentTest = -1;
|
|
|
|
|
|
|
|
function ok(a, msg) {
|
2009-11-30 15:14:04 -08:00
|
|
|
window.opener.ok(a, tests[currentTest].container.id + ": " + msg);
|
2009-09-06 17:35:13 -07:00
|
|
|
};
|
|
|
|
function todo(a, msg) {
|
2009-11-30 15:14:04 -08:00
|
|
|
window.opener.todo(a, tests[currentTest].container.id + ": " + msg);
|
2009-09-06 17:35:13 -07:00
|
|
|
};
|
|
|
|
function finish() {
|
|
|
|
window.opener.SimpleTest.finish();
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
window.onerror = function (event) { window.opener.onerror(event); window.close(); };
|
|
|
|
|
|
|
|
// Simple sanity check that scrolling a window with moving content in it does
|
|
|
|
// the obvious thing: blit the content that was already visible, and repaint
|
|
|
|
// the content that has scrolled into view.
|
|
|
|
function testSimpleScroll(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,200,180]])),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,180,200,200]])),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that scrolling visible content over background-attachment:fixed
|
|
|
|
// content repaints everything
|
|
|
|
function testFixedBackground(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.isEmpty(),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Shouldn't blit anything: " + blitRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,0,200,200]])),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Should repaint everything: " + paintRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that we optimize scrolling in a reasonable way in the presence of a
|
|
|
|
// non-moving opaque overlay
|
|
|
|
function testFixedPosOverlay(blitRegion, paintRegion) {
|
|
|
|
// The area of the fixed element should not be repainted or blitted at all
|
|
|
|
var fixedElemRect = [0,50,100,95]
|
|
|
|
ok(!blitRegion.intersectsRect(fixedElemRect),
|
2009-09-06 17:35:14 -07:00
|
|
|
"blit region should not intersect fixed-pos element area: " + blitRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
ok(!paintRegion.intersectsRect(fixedElemRect),
|
2009-09-06 17:35:14 -07:00
|
|
|
"paint region should not intersect fixed-pos element area: " + paintRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
|
|
|
|
// The area to the right of the fixed element that we can fill with blitting
|
|
|
|
// existing content should not be repainted (but may be blitted, although
|
|
|
|
// it doesn't all need to be blitted either, since most of it is blank)
|
|
|
|
var noPaintRect = [100,0,200,180];
|
|
|
|
ok(!paintRegion.intersectsRect(noPaintRect),
|
2009-09-06 17:35:14 -07:00
|
|
|
"paint region should not intersect blittable area: " + paintRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 17:35:13 -07:00
|
|
|
// Check that scrolling an element with moving content in it does
|
|
|
|
// the obvious thing, even if the element has a border.
|
|
|
|
function testBorder(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[1,1,201,181]])),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
ok(paintRegion.equalsRegion(new Region([[1,181,201,201]])),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 17:35:13 -07:00
|
|
|
// Check that scrolling some content out of view updates the area that
|
|
|
|
// was displaying the content
|
|
|
|
function testScrollOutOfView(blitRegion, paintRegion) {
|
|
|
|
var all = blitRegion.unionRegion(paintRegion);
|
|
|
|
ok(all.containsRect([0,0,200,10]),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Should update everything that was previously visible but scrolled out of view: " + all.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that scrolling some content into view updates the area that
|
|
|
|
// is displaying the content
|
|
|
|
function testScrollIntoView(blitRegion, paintRegion) {
|
|
|
|
var all = blitRegion.unionRegion(paintRegion);
|
|
|
|
ok(all.containsRect([0,190,200,200]),
|
2009-09-06 17:35:14 -07:00
|
|
|
"Should update everything that was previously visible: " + all.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
// When we scroll an area which has a very small subpixel offset, we should
|
|
|
|
// still be doing the obvious thing --- we shouldn't end up painting an extra
|
|
|
|
// row of pixels anywhere
|
|
|
|
function testSimpleScrollWithSubpixelOffset1(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,200,180]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
// The next test is contains, not equals, since we repaint down to 200.2
|
|
|
|
// which is OK
|
|
|
|
ok(paintRegion.containsRegion(new Region([[0,180,200,200]])),
|
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
// Check that we're not repainting anything in the area that's blitted
|
|
|
|
ok(!paintRegion.intersectsRect([0,0,200,180]),
|
|
|
|
"Should not repaint area that was blitted: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSimpleScrollWithSubpixelOffset2(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,1,200,181]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
// The next test is contains, not equals, since we repaint down to 200.8
|
|
|
|
// which is OK
|
|
|
|
ok(paintRegion.containsRegion(new Region([[0,181,200,200]])),
|
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
// Check that we're not repainting anything in the area that's blitted
|
2009-11-03 10:39:42 -08:00
|
|
|
ok(!paintRegion.intersectsRect([0,0,200,180]),
|
|
|
|
"Should not repaint area that was blitted: " + paintRegion.toString());
|
2009-09-06 17:35:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testSimpleScrollWithSubpixelOffset3(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,180,200]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
// The next test is contains, not equals, since we repaint across to 200.2
|
|
|
|
// which is OK
|
|
|
|
ok(paintRegion.containsRegion(new Region([[180,0,200,200]])),
|
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
// Check that we're not repainting anything in the area that's blitted
|
|
|
|
ok(!paintRegion.intersectsRect([0,0,180,200]),
|
|
|
|
"Should not repaint area that was blitted: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSimpleScrollWithSubpixelOffset4(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[1,0,181,200]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
// The next test is contains, not equals, since we repaint down to 200.8
|
|
|
|
// which is OK
|
|
|
|
ok(paintRegion.containsRegion(new Region([[181,0,200,200]])),
|
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
// Check that we're not repainting anything in the area that's blitted
|
2009-11-03 10:39:42 -08:00
|
|
|
ok(!paintRegion.intersectsRect([0,0,180,200]),
|
|
|
|
"Should not repaint area that was blitted: " + paintRegion.toString());
|
2009-09-06 17:35:13 -07:00
|
|
|
}
|
|
|
|
|
2009-10-06 21:28:41 -07:00
|
|
|
function testMovingClipArea(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,200,40]])),
|
|
|
|
"Should blit everything that's affected: " + blitRegion.toString());
|
|
|
|
ok(paintRegion.isEmpty(),
|
|
|
|
"Shouldn't repaint anything: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
2009-11-17 16:38:17 -08:00
|
|
|
function testNonmovingClipArea(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,200,130]])),
|
|
|
|
"Should only blit necessary strip: " + blitRegion.toString());
|
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,130,200,200]])),
|
|
|
|
"Should only repaint necessary strip: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
2009-11-03 10:39:42 -08:00
|
|
|
function testFixedOverUniform(blitRegion, paintRegion) {
|
|
|
|
ok(!blitRegion.intersectsRect([0,20,200,200]),
|
|
|
|
"Shouldn't blit anything except possibly to cover the area that has moved offscreen: " + blitRegion.toString());
|
|
|
|
ok(paintRegion.isEmpty(),
|
|
|
|
"Shouldn't repaint anything: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
function testClipIFRAME(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,200,180]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,180,200,200]])),
|
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testClipIFRAME2(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,50,200,180]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
// ok(paintRegion.equalsRegion(new Region([[0,180,200,200]])),
|
|
|
|
// "Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
2009-12-12 10:50:25 -08:00
|
|
|
function testHiddenTable(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,200,180]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,180,200,200]])),
|
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
2009-12-12 10:50:30 -08:00
|
|
|
function testTableNoBackground(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.equalsRegion(new Region([[0,0,200,180]])),
|
|
|
|
"Should blit everything that was already visible: " + blitRegion.toString());
|
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,180,200,200]])),
|
|
|
|
"Should repaint area that was scrolled into view: " + paintRegion.toString());
|
|
|
|
}
|
|
|
|
|
2010-01-26 12:39:02 -08:00
|
|
|
function testNoBlitInSVG(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.isEmpty(), "should not blit when in transformed SVG");
|
|
|
|
// We're looking at regions in the coordinates of the inner iframe.
|
|
|
|
// (Not the most useful test, but it does test the particular bug that we
|
|
|
|
// should be repainting rather than blitting.)
|
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,0,200,200]])),
|
|
|
|
"repaint rect must contain area completely inside scrolled region");
|
|
|
|
}
|
|
|
|
|
|
|
|
function testNoBlitInTransform(blitRegion, paintRegion) {
|
|
|
|
ok(blitRegion.isEmpty(), "should not blit when in CSS Transform");
|
|
|
|
// We're looking at regions in the coordinates of the inner iframe.
|
|
|
|
// (Not the most useful test, but it does test the particular bug that we
|
|
|
|
// should be repainting rather than blitting.)
|
|
|
|
ok(paintRegion.equalsRegion(new Region([[0,0,200,200]])),
|
|
|
|
"repaint rect must contain area completely inside scrolled region");
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:35:13 -07:00
|
|
|
function clientRectToRect(cr)
|
|
|
|
{
|
|
|
|
return [cr.left, cr.top, cr.right, cr.bottom];
|
|
|
|
}
|
|
|
|
|
2010-01-26 12:39:02 -08:00
|
|
|
// Return the ancestor-or-self of |container| that is a child of body.
|
|
|
|
function bodyChild(container)
|
|
|
|
{
|
|
|
|
var prev;
|
|
|
|
var next = container;
|
|
|
|
do {
|
|
|
|
prev = next;
|
|
|
|
next = prev.parentNode;
|
|
|
|
} while (next != document.body);
|
|
|
|
return prev;
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:35:13 -07:00
|
|
|
function regionForReason(requests, reason)
|
|
|
|
{
|
|
|
|
var rects = [];
|
|
|
|
for (var i = 0; i < requests.length; ++i) {
|
|
|
|
var r = requests[i];
|
|
|
|
if (r.reason == reason) {
|
|
|
|
rects.push(clientRectToRect(r.clientRect));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new Region(rects);
|
|
|
|
}
|
|
|
|
|
|
|
|
function afterPaint(event) {
|
|
|
|
var requests = event.paintRequests;
|
|
|
|
|
|
|
|
if (!requests) {
|
|
|
|
todo(false, "cannot run tests since paintRequests not supported");
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var blitRegion = regionForReason(requests, "scroll copy");
|
|
|
|
var paintRegion = regionForReason(requests, "scroll repaint");
|
|
|
|
|
|
|
|
if (blitRegion.isEmpty() && paintRegion.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
var testFunc = window[tests[currentTest].container.id];
|
2009-09-06 17:35:13 -07:00
|
|
|
if (!testFunc) {
|
2009-11-30 15:14:04 -08:00
|
|
|
ok(false, "Cannot find test function for " + tests[currentTest].container.id);
|
2009-09-06 17:35:13 -07:00
|
|
|
} else {
|
|
|
|
testFunc(blitRegion, paintRegion);
|
|
|
|
}
|
2010-01-26 12:39:02 -08:00
|
|
|
bodyChild(tests[currentTest].container).style.display = 'none';
|
2009-09-06 17:35:13 -07:00
|
|
|
|
|
|
|
nextTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
function nextTest() {
|
|
|
|
++currentTest;
|
|
|
|
if (currentTest >= tests.length) {
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
var t = tests[currentTest];
|
2010-01-26 12:39:02 -08:00
|
|
|
bodyChild(t.container).style.display = "";
|
2009-09-06 17:35:14 -07:00
|
|
|
setTimeout(function() {
|
2009-11-30 15:14:04 -08:00
|
|
|
if (t.scrollable.getAttribute("class").match(/horizontal/)) {
|
|
|
|
t.scrollable.scrollLeft = 20;
|
2009-09-06 17:35:14 -07:00
|
|
|
} else {
|
2009-11-30 15:14:04 -08:00
|
|
|
t.scrollable.scrollTop = 20;
|
2009-09-06 17:35:14 -07:00
|
|
|
}
|
|
|
|
}, 0);
|
2009-09-06 17:35:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function runTests() {
|
2009-11-30 15:14:04 -08:00
|
|
|
for (var i = 0; i < testcases.length; ++i) {
|
|
|
|
tests.push({ scrollable:testcases[i], container:testcases[i] });
|
|
|
|
}
|
|
|
|
for (var i = 0; i < iframes.length; ++i) {
|
|
|
|
tests.push({ scrollable:iframes[i].contentDocument.body, container:iframes[i] });
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < tests.length; ++i) {
|
|
|
|
var t = tests[i];
|
2010-01-26 12:39:02 -08:00
|
|
|
bodyChild(t.container).style.display = "none";
|
2009-11-30 15:14:04 -08:00
|
|
|
// Make sure we don't remember a scroll position from history
|
|
|
|
t.scrollable.scrollTop = 0;
|
|
|
|
t.scrollable.scrollLeft = 0;
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:35:13 -07:00
|
|
|
window.addEventListener("MozAfterPaint", afterPaint, false);
|
2009-11-30 15:14:04 -08:00
|
|
|
for (var i = 0; i < iframes.length; ++i) {
|
|
|
|
iframes[i].contentWindow.addEventListener("MozAfterPaint", afterPaint, false);
|
|
|
|
}
|
2009-09-06 17:35:13 -07:00
|
|
|
nextTest();
|
|
|
|
}
|
|
|
|
window.onload = function() { setTimeout(runTests, 0); };
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|