Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 9585844

Browse files
Merge 182954 "Don't bubble scrolls across boundary when scrollin..."
> Don't bubble scrolls across boundary when scrolling to anchor > > Takes the same approach as FrameLoader to ensure that we don't > bubble scrolls incorrectly. > > BUG=415141 > > Review URL: https://codereview.chromium.org/606023003 [email protected] Review URL: https://codereview.chromium.org/627663003 git-svn-id: svn://svn.chromium.org/blink/branches/chromium/2171@183208 bbb929c8-8fbe-4397-9dbb-9b2b20218538
1 parent 43d6830 commit 9585844

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<style>
3+
iframe {
4+
position: absolute;
5+
top: 50px;
6+
width: 100px;
7+
height: 100px;
8+
border: 1px solid black;
9+
}
10+
::-webkit-scrollbar {
11+
width: 0px;
12+
}
13+
</style>
14+
<iframe src='http://127.0.0.1:8000/navigation/resources/focus-shifting-frame-with-anchor.html'></iframe>
15+
<script>
16+
if (window.testRunner) {
17+
testRunner.waitUntilDone();
18+
}
19+
onload = function() {
20+
requestAnimationFrame(function() {
21+
if (window.testRunner) {
22+
testRunner.notifyDone();
23+
}
24+
});
25+
};
26+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<style>
3+
iframe {
4+
position: absolute;
5+
top: 50px;
6+
width: 100px;
7+
height: 100px;
8+
border: 1px solid black;
9+
}
10+
::-webkit-scrollbar {
11+
width: 0px;
12+
}
13+
</style>
14+
<div style='width:10px;height:2000px;background:white;position:absolute'></div>
15+
<iframe src='http://127.0.0.1:8000/navigation/resources/focus-shifting-frame-with-anchor.html' sandbox='allow-scripts'></iframe>
16+
<script>
17+
if (window.testRunner) {
18+
testRunner.waitUntilDone();
19+
}
20+
onload = function() {
21+
requestAnimationFrame(function() {
22+
if (window.testRunner) {
23+
testRunner.notifyDone();
24+
}
25+
});
26+
};
27+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<a href='#'>anchor</a>
3+
<a id='dummy' href='dummy'>dummy</a>
4+
<div style='width:10px;height:2000px;background:white'></div>
5+
<script>
6+
onload = function() {
7+
location.href = '#';
8+
requestAnimationFrame(function() {
9+
document.getElementById('dummy').focus();
10+
});
11+
}
12+
</script>

Source/core/frame/FrameView.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1815,10 +1815,18 @@ void FrameView::scrollToAnchor()
18151815
if (anchorNode != m_frame->document())
18161816
rect = anchorNode->boundingBox();
18171817

1818+
RefPtrWillBeRawPtr<LocalFrame> boundaryFrame = m_frame->document()->findUnsafeParentScrollPropagationBoundary();
1819+
1820+
if (boundaryFrame)
1821+
boundaryFrame->view()->setSafeToPropagateScrollToParent(false);
1822+
18181823
// Scroll nested layers and frames to reveal the anchor.
18191824
// Align to the top and to the closest side (this matches other browsers).
18201825
anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
18211826

1827+
if (boundaryFrame)
1828+
boundaryFrame->view()->setSafeToPropagateScrollToParent(true);
1829+
18221830
if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache())
18231831
cache->handleScrolledToAnchor(anchorNode.get());
18241832

0 commit comments

Comments
 (0)