Bug 1630385 - Don't descend into scroll frames with a pre-existing anchor. r=dholbert

We can modify the scroll position without invalidating the anchor (that's kind
of the point, actually).

So it's possible (and ok) to end up with a frame which is already maintaining
an anchor but for which CanMaintainAnchor now returns false.

So if you have a scrollframe with a non-zero scroll position and select an
anchor for that scrollframe, and then try to select an anchor for an ancestor,
you don't want to dig into there.

Differential Revision: https://phabricator.services.mozilla.com/D71103

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-04-15 23:13:00 +00:00
parent 9f11c31d1a
commit 072ca409e3
3 changed files with 36 additions and 4 deletions

View File

@ -539,10 +539,15 @@ ScrollAnchorContainer::ExamineAnchorCandidate(nsIFrame* aFrame) const {
const bool isAnonBox = aFrame->Style()->IsAnonBox();
// See if this frame could have its own anchor node.
nsIScrollableFrame* scrollable = do_QueryFrame(aFrame);
const bool isScrollableWithAnchor =
scrollable && scrollable->Anchor()->CanMaintainAnchor();
// See if this frame has or could maintain its own anchor node.
const bool isScrollableWithAnchor = [&] {
nsIScrollableFrame* scrollable = do_QueryFrame(aFrame);
if (!scrollable) {
return false;
}
auto* anchor = scrollable->Anchor();
return anchor->AnchorNode() || anchor->CanMaintainAnchor();
}();
// We don't allow scroll anchors to be selected inside of nested scrollable
// frames which maintain an anchor node as it's not clear how an anchor

View File

@ -0,0 +1,26 @@
<html class="reftest-wait">
<script>
window.requestIdleCallback(() => {
try{ c.style.cssText="margin-top:78%" }catch(e){}
try{ b.style.cssText="padding-right:100em" }catch(e){}
try{ b.scrollIntoView() }catch(e){}
try{ b.setAttribute('style', "filter:opacity()drop-shadow(2px 8vmax hsl(2,9%,6%))opacity(") }catch(e){}
try{ b.scrollIntoView() }catch(e){}
try{ a.setAttribute('style', "") }catch(e){}
try{ a.offsetHeight }catch(e){}
try{ a.textContent="" }catch(e){}
requestIdleCallback(() => {
document.documentElement.className = "";
})
})
</script>
<style>
:last-of-type {
overflow-y:-moz-hidden-unscrollable;
}
</style>
<body id='a'>
e
<samp id='b'>
</samp>
<canvas id='c'/>

View File

@ -761,3 +761,4 @@ load 1625051-1.html
load 1625051-2.html
load 1626970.html
load 1628804.html
load 1630385.html