Index: Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
diff --git a/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp b/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
index 75b2999646e092109c931114f7a27add34ba4c50..9b4ab61caa772760ca3277d8abef54dc49908682 100644 |
--- a/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
+++ b/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
@@ -646,6 +646,13 @@ void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
{ |
ASSERT(box().hasOverflowClip()); |
+ if (needsScrollbarReconstruction()) { |
+ if (m_hBar) |
+ destroyScrollbar(HorizontalScrollbar); |
+ if (m_vBar) |
+ destroyScrollbar(VerticalScrollbar); |
+ } |
+ |
DoubleSize originalScrollOffset = adjustedScrollOffset(); |
computeScrollDimensions(); |
@@ -679,14 +686,14 @@ 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); |
- |
- if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged)) { |
- if (box().hasAutoHorizontalScrollbar()) |
+ // 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 also needs to layout again. |
+ bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow)) || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); |
skobes
2015/08/19 16:59:52
Wrap the line at the || for readability.
MuVen
2015/08/19 19:20:42
Done.
|
+ bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVerticalScrollbar() != hasVerticalOverflow)) || (box().style()->overflowY() == OSCROLL && !verticalScrollbar()); |
skobes
2015/08/19 16:59:52
same here
MuVen
2015/08/19 19:20:42
Done.
|
+ if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || verticalScrollBarChanged)) { |
+ if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar())) |
skobes
2015/08/19 16:59:52
In the OSCROLL case we do not care about hasHorizo
MuVen
2015/08/19 19:20:42
Done.
|
setHasHorizontalScrollbar(hasHorizontalOverflow); |
- if (box().hasAutoVerticalScrollbar()) |
+ if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == OSCROLL && !verticalScrollbar())) |
setHasVerticalScrollbar(hasVerticalOverflow); |
if (hasVerticalOverflow || hasHorizontalOverflow) |
@@ -698,7 +705,7 @@ void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
if (box().document().hasAnnotatedRegions()) |
box().document().setAnnotatedRegionsDirty(true); |
- if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO) { |
+ if ((horizontalScrollBarChanged && box().style()->overflowX() != OOVERLAY) || (verticalScrollBarChanged && box().style()->overflowY() != OOVERLAY)) { |
if (!m_inOverflowRelayout) { |
// Our proprietary overflow: overlay value doesn't trigger a layout. |
skobes
2015/08/19 16:59:52
Can you move this comment to appear just above the
MuVen
2015/08/19 19:20:42
Done.
|
m_inOverflowRelayout = true; |
@@ -706,7 +713,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 +965,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; |