Chromium Code Reviews| Index: Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| diff --git a/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp b/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| index 75b2999646e092109c931114f7a27add34ba4c50..a18bf9080e377e08a1c3ec600d33c2c61b97b5f0 100644 |
| --- a/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| +++ b/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| @@ -646,6 +646,19 @@ void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
| { |
| ASSERT(box().hasOverflowClip()); |
| + bool needsHBarConstruction = false; |
| + bool needsVBarConstruction = false; |
| + if (needsScrollbarReconstruction()) { |
| + if (m_hBar) { |
| + destroyScrollbar(HorizontalScrollbar); |
| + needsHBarConstruction = true; |
|
skobes
2015/08/14 19:02:56
I don't understand the need to store this. Why do
|
| + } |
| + if (m_vBar) { |
| + destroyScrollbar(VerticalScrollbar); |
| + needsVBarConstruction = true; |
| + } |
| + } |
| + |
| DoubleSize originalScrollOffset = adjustedScrollOffset(); |
| computeScrollDimensions(); |
| @@ -679,14 +692,15 @@ void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
| if (!scrollSize(VerticalScrollbar)) |
| setHasVerticalScrollbar(false); |
| } |
| - // overflow:auto may need to lay out again if scrollbars got added/removed. |
| - bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); |
| - bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (hasVerticalScrollbar() != hasVerticalOverflow); |
| + // overflow:auto may need to lay out again if scrollbars got added/removed. And even on reconstruction of scrollbars |
| + // from native to custom or vice versa may also need to layout again. |
| + bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow)) || needsHBarConstruction; |
|
skobes
2015/08/14 19:23:37
Oh I see, the problem is with overflow:scroll and
MuVen
2015/08/17 09:21:03
Done.
|
| + bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVerticalScrollbar() != hasVerticalOverflow)) || needsVBarConstruction; |
| - if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged)) { |
| - if (box().hasAutoHorizontalScrollbar()) |
| + if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || verticalScrollBarChanged)) { |
| + if (box().hasAutoHorizontalScrollbar() || needsHBarConstruction) |
| setHasHorizontalScrollbar(hasHorizontalOverflow); |
| - if (box().hasAutoVerticalScrollbar()) |
| + if (box().hasAutoVerticalScrollbar() || needsVBarConstruction) |
| setHasVerticalScrollbar(hasVerticalOverflow); |
| if (hasVerticalOverflow || hasHorizontalOverflow) |
| @@ -698,7 +712,7 @@ void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
| if (box().document().hasAnnotatedRegions()) |
| box().document().setAnnotatedRegionsDirty(true); |
| - if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO) { |
| + if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO || needsHBarConstruction || needsVBarConstruction) { |
| if (!m_inOverflowRelayout) { |
| // Our proprietary overflow: overlay value doesn't trigger a layout. |
| m_inOverflowRelayout = true; |
| @@ -706,7 +720,7 @@ void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
| layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::ScrollbarChanged); |
| if (box().isLayoutBlock()) { |
| LayoutBlock& block = toLayoutBlock(box()); |
| - block.scrollbarsChanged(autoHorizontalScrollBarChanged, autoVerticalScrollBarChanged); |
| + block.scrollbarsChanged(horizontalScrollBarChanged, verticalScrollBarChanged); |
| block.layoutBlock(true); |
| } else { |
| box().layout(); |
| @@ -958,6 +972,15 @@ static inline LayoutObject* layoutObjectForScrollbar(LayoutObject& layoutObject) |
| return &layoutObject; |
| } |
| +bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const |
| +{ |
| + LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
| + bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->style()->hasPseudoStyle(SCROLLBAR); |
| + bool hasAnyScrollbar = hasScrollbar(); |
| + bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBar->isCustomScrollbar()); |
| + return hasAnyScrollbar && (shouldUseCustom != hasCustom); |
| +} |
| + |
| PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScrollbar(ScrollbarOrientation orientation) |
| { |
| RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |