Bug 1364360 part 3. Don't flush layout when setting scrollTop to 0. r=ehsan

This commit is contained in:
Boris Zbarsky 2017-05-25 13:39:44 -04:00
Родитель 42c1cf9ea3
Коммит d50c80150f
1 изменённых файлов: 12 добавлений и 1 удалений

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

@ -855,7 +855,15 @@ Element::ScrollTop()
void void
Element::SetScrollTop(int32_t aScrollTop) Element::SetScrollTop(int32_t aScrollTop)
{ {
nsIScrollableFrame* sf = GetScrollFrame(); // When aScrollTop is 0, we don't need to flush layout to scroll to that
// point; we know 0 is always in range. At least we think so... But we do
// need to flush frames so we ensure we find the right scrollable frame if
// there is one.
//
// If aScrollTop is nonzero, we need to flush layout because we need to figure
// out what our real scrollTopMax is.
FlushType flushType = aScrollTop == 0 ? FlushType::Frames : FlushType::Layout;
nsIScrollableFrame* sf = GetScrollFrame(nullptr, flushType);
if (sf) { if (sf) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT; nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) { if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
@ -877,6 +885,9 @@ Element::ScrollLeft()
void void
Element::SetScrollLeft(int32_t aScrollLeft) Element::SetScrollLeft(int32_t aScrollLeft)
{ {
// We can't assume things here based on the value of aScrollLeft, because
// depending on our direction and layout 0 may or may not be in our scroll
// range. So we need to flush layout no matter what.
nsIScrollableFrame* sf = GetScrollFrame(); nsIScrollableFrame* sf = GetScrollFrame();
if (sf) { if (sf) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT; nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;