Bug 548792. Let the search for a scrollable parent cross document boundaries. r=mats

This commit is contained in:
Robert O'Callahan 2010-03-29 14:46:59 +13:00
Родитель ed39232acd
Коммит 59d891798f
2 изменённых файлов: 27 добавлений и 1 удалений

Просмотреть файл

@ -4129,7 +4129,9 @@ PresShell::ScrollFrameRectIntoView(nsIFrame* aFrame,
rect.IntersectRect(rect, sf->GetScrollPortRect());
}
rect += container->GetPosition();
container = container->GetParent();
nsPoint extraOffset(0,0);
container = nsLayoutUtils::GetCrossDocParentFrame(container, &extraOffset);
rect += extraOffset;
} while (container);
return didScroll;

Просмотреть файл

@ -30,6 +30,17 @@
</div>
<div style="height:400px;"></div>
</div>
<div id="c4" style="overflow-y:scroll; width:200px; height:200px; position:absolute; top:200px; left:600px;">
<iframe id="target4" style="border:none; width:100%; height:1100px; display:block;"
src="data:text/html,
<body style='margin:0; overflow:hidden;'>
<div style='height:400px;'></div>
<div><span id='target4'
style='display:inline-block; vertical-align:top; height:300px;'>target4</span>
</div>
<div style='height:400px;'></div>">
</iframe>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
@ -43,6 +54,9 @@ function testCollapsed(id, vPercent, startAt, expected) {
var c = document.getElementById("c" + id);
var target = document.getElementById("target" + id);
if (target.contentDocument) {
target = target.contentDocument.getElementById("target" + id);
}
selection.collapse(target.parentNode, 0);
c.scrollTop = startAt;
selection.scrollIntoView(FOCUS, true, vPercent, 0);
@ -78,6 +92,16 @@ function doTest() {
// visible.
testCollapsed("3", -1, 1000, 400);
// Test scrolling an element larger than the scrollport
testCollapsed("4", 0, 0, 400);
testCollapsed("4", 100, 0, 500);
testCollapsed("4", -1, 0, 400);
testCollapsed("4", 0, 1000, 400);
testCollapsed("4", 100, 1000, 500);
// If the element can't be completely visible, we make the top edge
// visible.
testCollapsed("4", -1, 1000, 400);
SimpleTest.finish();
}