Commit 57da1c75 authored by sunyunjia's avatar sunyunjia Committed by Commit bot

ScrollRectToVisible should bubble up through its layout container.

Previously, ScrollRectToVisible bubbles up through its dom parent. It works
fine when its layout container is its dom parent, but this is not the case for
absolute-positioned elements. Simply scrolling the dom parent of an
absolute-positioned element wouldn't put the desired rect into view. This patch
changes the behavior by bubbling up through its layout parent.

BUG=645841
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2336013002
Cr-Commit-Position: refs/heads/master@{#419197}
parent 66090fb3
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body id="body">
<div style="height: 500px;overflow-x: hidden;">
<div style="height: 2000px; background-color: blue;"></div>
<div style="position: absolute;">
<div style="height: 1000px; background-color: yellow;"></div>
<a href="somelink" id="focusable" style="font-size:60px">anchor</a>
</div>
<div style="height: 2000px; background-color: red;"></div>
</div>
</body>
<script type="text/javascript">
window.onload = function() {
test(function(t) {
var focusable = document.getElementById("focusable");
focusable.focus();
assert_not_equals(window.scrollY, 0);
}, "Tests that for an element with absolute position and whose parent has overflowclip, it can still scroll automatically.");
}
</script>
...@@ -575,9 +575,9 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen ...@@ -575,9 +575,9 @@ void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen
LayoutRect newRect = rectToScroll; LayoutRect newRect = rectToScroll;
bool restrictedByLineClamp = false; bool restrictedByLineClamp = false;
if (parent()) { if (containingBlock()) {
parentBox = parent()->enclosingBox(); parentBox = containingBlock();
restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); restrictedByLineClamp = !containingBlock()->style()->lineClamp().isNone();
} }
if (hasOverflowClip() && !restrictedByLineClamp) { if (hasOverflowClip() && !restrictedByLineClamp) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment