Index: third_party/WebKit/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
diff --git a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
index 616ad1964fcf455198d94ba86c31977e90b7b0cf..7f23aa54fe791c3f63dc5aa6d0b9e115c2104ec2 100644 |
--- a/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
+++ b/third_party/WebKit/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
@@ -88,7 +88,6 @@ |
, m_nextTopmostScrollChild(0) |
, m_topmostScrollChild(0) |
, m_needsCompositedScrolling(false) |
- , m_scrollbarManager(*this) |
, m_scrollCorner(nullptr) |
, m_resizer(nullptr) |
#if ENABLE(ASSERT) |
@@ -143,7 +142,8 @@ |
frameView->removeResizerArea(box()); |
} |
- m_scrollbarManager.dispose(); |
+ destroyScrollbar(HorizontalScrollbar); |
+ destroyScrollbar(VerticalScrollbar); |
if (m_scrollCorner) |
m_scrollCorner->destroy(); |
@@ -159,7 +159,8 @@ |
DEFINE_TRACE(DeprecatedPaintLayerScrollableArea) |
{ |
- m_scrollbarManager.trace(visitor); |
+ visitor->trace(m_hBar); |
+ visitor->trace(m_vBar); |
ScrollableArea::trace(visitor); |
} |
@@ -204,15 +205,15 @@ |
// See crbug.com/343132. |
DisableCompositingQueryAsserts disabler; |
- ASSERT(scrollbar == horizontalScrollbar() || scrollbar == verticalScrollbar()); |
- ASSERT(scrollbar == horizontalScrollbar() ? !layerForHorizontalScrollbar() : !layerForVerticalScrollbar()); |
+ ASSERT(scrollbar == m_hBar.get() || scrollbar == m_vBar.get()); |
+ ASSERT(scrollbar == m_hBar.get() ? !layerForHorizontalScrollbar() : !layerForVerticalScrollbar()); |
IntRect scrollRect = rect; |
// If we are not yet inserted into the tree, there is no need to issue paint invaldiations. |
if (!box().isLayoutView() && !box().parent()) |
return; |
- if (scrollbar == verticalScrollbar()) |
+ if (scrollbar == m_vBar.get()) |
scrollRect.move(verticalScrollbarStart(0, box().size().width()), box().borderTop()); |
else |
scrollRect.move(horizontalScrollbarStart(0), box().size().height() - box().borderBottom() - scrollbar->height()); |
@@ -652,12 +653,11 @@ |
ASSERT(box().hasOverflowClip()); |
if (needsScrollbarReconstruction()) { |
- m_scrollbarManager.setCanDetachScrollbars(false); |
- setHasHorizontalScrollbar(false); |
- setHasVerticalScrollbar(false); |
- } |
- |
- m_scrollbarManager.setCanDetachScrollbars(true); |
+ if (m_hBar) |
+ destroyScrollbar(HorizontalScrollbar); |
+ if (m_vBar) |
+ destroyScrollbar(VerticalScrollbar); |
+ } |
scrollOffset = adjustedScrollOffset(); |
computeScrollDimensions(); |
@@ -674,14 +674,10 @@ |
autoHorizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow)) || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); |
autoVerticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVerticalScrollbar() != hasVerticalOverflow)) || (box().style()->overflowY() == OSCROLL && !verticalScrollbar()); |
if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged)) { |
- if (box().hasAutoHorizontalScrollbar()) |
- setHasHorizontalScrollbar(hasHorizontalOverflow); |
- else if (box().style()->overflowX() == OSCROLL) |
- setHasHorizontalScrollbar(true); |
- if (box().hasAutoVerticalScrollbar()) |
- setHasVerticalScrollbar(hasVerticalOverflow); |
- else if (box().style()->overflowX() == OSCROLL) |
- setHasVerticalScrollbar(true); |
+ if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar())) |
+ setHasHorizontalScrollbar(box().style()->overflowX() == OSCROLL ? true : hasHorizontalOverflow); |
+ if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == OSCROLL && !verticalScrollbar())) |
+ setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true : hasVerticalOverflow); |
} |
} |
@@ -699,8 +695,6 @@ |
DoublePoint origin(scrollOrigin()); |
scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScroll); |
} |
- |
- m_scrollbarManager.setCanDetachScrollbars(false); |
bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
bool hasVerticalOverflow = this->hasVerticalOverflow(); |
@@ -857,19 +851,19 @@ |
// When switching to another value, we need to re-enable them (see bug 11985). |
if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) { |
ASSERT(hasHorizontalScrollbar()); |
- horizontalScrollbar()->setEnabled(true); |
+ m_hBar->setEnabled(true); |
} |
if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL && overflowY != OSCROLL) { |
ASSERT(hasVerticalScrollbar()); |
- verticalScrollbar()->setEnabled(true); |
+ m_vBar->setEnabled(true); |
} |
// FIXME: Need to detect a swap from custom to native scrollbars (and vice versa). |
- if (horizontalScrollbar()) |
- horizontalScrollbar()->styleChanged(); |
- if (verticalScrollbar()) |
- verticalScrollbar()->styleChanged(); |
+ if (m_hBar) |
+ m_hBar->styleChanged(); |
+ if (m_vBar) |
+ m_vBar->styleChanged(); |
updateScrollCornerStyle(); |
updateResizerAreaSet(); |
@@ -907,27 +901,27 @@ |
IntRect DeprecatedPaintLayerScrollableArea::rectForHorizontalScrollbar(const IntRect& borderBoxRect) const |
{ |
- if (!hasHorizontalScrollbar()) |
+ if (!m_hBar) |
return IntRect(); |
const IntRect& scrollCorner = scrollCornerRect(); |
return IntRect(horizontalScrollbarStart(borderBoxRect.x()), |
- borderBoxRect.maxY() - box().borderBottom() - horizontalScrollbar()->height(), |
+ borderBoxRect.maxY() - box().borderBottom() - m_hBar->height(), |
borderBoxRect.width() - (box().borderLeft() + box().borderRight()) - scrollCorner.width(), |
- horizontalScrollbar()->height()); |
+ m_hBar->height()); |
} |
IntRect DeprecatedPaintLayerScrollableArea::rectForVerticalScrollbar(const IntRect& borderBoxRect) const |
{ |
- if (!hasVerticalScrollbar()) |
+ if (!m_vBar) |
return IntRect(); |
const IntRect& scrollCorner = scrollCornerRect(); |
return IntRect(verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX()), |
borderBoxRect.y() + box().borderTop(), |
- verticalScrollbar()->width(), |
+ m_vBar->width(), |
borderBoxRect.height() - (box().borderTop() + box().borderBottom()) - scrollCorner.height()); |
} |
@@ -935,23 +929,23 @@ |
{ |
if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
return minX + box().borderLeft(); |
- return maxX - box().borderRight() - verticalScrollbar()->width(); |
+ return maxX - box().borderRight() - m_vBar->width(); |
} |
LayoutUnit DeprecatedPaintLayerScrollableArea::horizontalScrollbarStart(int minX) const |
{ |
int x = minX + box().borderLeft(); |
if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
- x += hasVerticalScrollbar() ? verticalScrollbar()->width() : resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer).width(); |
+ x += m_vBar ? m_vBar->width() : resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer).width(); |
return x; |
} |
IntSize DeprecatedPaintLayerScrollableArea::scrollbarOffset(const Scrollbar* scrollbar) const |
{ |
- if (scrollbar == verticalScrollbar()) |
+ if (scrollbar == m_vBar.get()) |
return IntSize(verticalScrollbarStart(0, box().size().width()), box().borderTop()); |
- if (scrollbar == horizontalScrollbar()) |
+ if (scrollbar == m_hBar.get()) |
return IntSize(horizontalScrollbarStart(0), box().size().height() - box().borderBottom() - scrollbar->height()); |
ASSERT_NOT_REACHED(); |
@@ -997,25 +991,68 @@ |
LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->style()->hasPseudoStyle(SCROLLBAR); |
bool hasAnyScrollbar = hasScrollbar(); |
- bool hasCustom = (hasHorizontalScrollbar() && horizontalScrollbar()->isCustomScrollbar()) || (hasVerticalScrollbar() && verticalScrollbar()->isCustomScrollbar()); |
+ 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; |
+ LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
+ bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutObject->style()->hasPseudoStyle(SCROLLBAR); |
+ if (hasCustomScrollbarStyle) { |
+ widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actualLayoutObject->node()); |
+ } else { |
+ ScrollbarControlSize scrollbarSize = RegularScrollbar; |
+ if (actualLayoutObject->style()->hasAppearance()) |
+ scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(actualLayoutObject->style()->appearance()); |
+ widget = Scrollbar::create(this, orientation, scrollbarSize); |
+ if (orientation == HorizontalScrollbar) |
+ didAddScrollbar(widget.get(), HorizontalScrollbar); |
+ else |
+ didAddScrollbar(widget.get(), VerticalScrollbar); |
+ } |
+ box().document().view()->addChild(widget.get()); |
+ return widget.release(); |
+} |
+ |
+void DeprecatedPaintLayerScrollableArea::destroyScrollbar(ScrollbarOrientation orientation) |
+{ |
+ RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollbar ? m_hBar : m_vBar; |
+ if (!scrollbar) |
+ return; |
+ |
+ if (!scrollbar->isCustomScrollbar()) |
+ willRemoveScrollbar(scrollbar.get(), orientation); |
+ |
+ toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); |
+ scrollbar->disconnectFromScrollableArea(); |
+ scrollbar = nullptr; |
+} |
+ |
void DeprecatedPaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) |
{ |
if (hasScrollbar == hasHorizontalScrollbar()) |
return; |
- if (!hasScrollbar && !layerForHorizontalScrollbar()) |
- horizontalScrollbar()->invalidate(); |
- |
- m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); |
+ if (hasScrollbar) { |
+ // This doesn't hit in any tests, but since the equivalent code in setHasVerticalScrollbar |
+ // does, presumably this code does as well. |
+ DisableCompositingQueryAsserts disabler; |
+ m_hBar = createScrollbar(HorizontalScrollbar); |
+ } else { |
+ if (!layerForHorizontalScrollbar()) |
+ m_hBar->invalidate(); |
+ // Otherwise we will remove the layer and just need recompositing. |
+ |
+ destroyScrollbar(HorizontalScrollbar); |
+ } |
// Destroying or creating one bar can cause our scrollbar corner to come and go. We need to update the opposite scrollbar's style. |
- if (hasHorizontalScrollbar()) |
- horizontalScrollbar()->styleChanged(); |
- if (hasVerticalScrollbar()) |
- verticalScrollbar()->styleChanged(); |
+ if (m_hBar) |
+ m_hBar->styleChanged(); |
+ if (m_vBar) |
+ m_vBar->styleChanged(); |
// These are valid because we want to invalidate display item clients on the current backing. |
DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
@@ -1032,16 +1069,23 @@ |
if (hasScrollbar == hasVerticalScrollbar()) |
return; |
- if (!hasScrollbar && !layerForVerticalScrollbar()) |
- verticalScrollbar()->invalidate(); |
- |
- m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); |
+ if (hasScrollbar) { |
+ // Hits in compositing/overflow/automatically-opt-into-composited-scrolling-after-style-change.html |
+ DisableCompositingQueryAsserts disabler; |
+ m_vBar = createScrollbar(VerticalScrollbar); |
+ } else { |
+ if (!layerForVerticalScrollbar()) |
+ m_vBar->invalidate(); |
+ // Otherwise we will remove the layer and just need recompositing. |
+ |
+ destroyScrollbar(VerticalScrollbar); |
+ } |
// Destroying or creating one bar can cause our scrollbar corner to come and go. We need to update the opposite scrollbar's style. |
- if (hasHorizontalScrollbar()) |
- horizontalScrollbar()->styleChanged(); |
- if (hasVerticalScrollbar()) |
- verticalScrollbar()->styleChanged(); |
+ if (m_hBar) |
+ m_hBar->styleChanged(); |
+ if (m_vBar) |
+ m_vBar->styleChanged(); |
// These are valid because we want to invalidate display item clients on the current backing. |
DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
@@ -1055,16 +1099,16 @@ |
int DeprecatedPaintLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarSizeRelevancy relevancy) const |
{ |
- if (!hasVerticalScrollbar() || (verticalScrollbar()->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !verticalScrollbar()->shouldParticipateInHitTesting()))) |
+ if (!m_vBar || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_vBar->shouldParticipateInHitTesting()))) |
return 0; |
- return verticalScrollbar()->width(); |
+ return m_vBar->width(); |
} |
int DeprecatedPaintLayerScrollableArea::horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy relevancy) const |
{ |
- if (!hasHorizontalScrollbar() || (horizontalScrollbar()->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !horizontalScrollbar()->shouldParticipateInHitTesting()))) |
+ if (!m_hBar || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_hBar->shouldParticipateInHitTesting()))) |
return 0; |
- return horizontalScrollbar()->height(); |
+ return m_hBar->height(); |
} |
void DeprecatedPaintLayerScrollableArea::positionOverflowControls() |
@@ -1127,25 +1171,25 @@ |
} |
int resizeControlSize = max(resizeControlRect.height(), 0); |
- if (hasVerticalScrollbar() && verticalScrollbar()->shouldParticipateInHitTesting()) { |
+ if (m_vBar && m_vBar->shouldParticipateInHitTesting()) { |
LayoutRect vBarRect(verticalScrollbarStart(0, box().size().width()), |
box().borderTop(), |
- verticalScrollbar()->width(), |
- box().size().height() - (box().borderTop() + box().borderBottom()) - (hasHorizontalScrollbar() ? horizontalScrollbar()->height() : resizeControlSize)); |
+ m_vBar->width(), |
+ box().size().height() - (box().borderTop() + box().borderBottom()) - (m_hBar ? m_hBar->height() : resizeControlSize)); |
if (vBarRect.contains(localPoint)) { |
- result.setScrollbar(verticalScrollbar()); |
+ result.setScrollbar(m_vBar.get()); |
return true; |
} |
} |
resizeControlSize = max(resizeControlRect.width(), 0); |
- if (hasHorizontalScrollbar() && horizontalScrollbar()->shouldParticipateInHitTesting()) { |
+ if (m_hBar && m_hBar->shouldParticipateInHitTesting()) { |
LayoutRect hBarRect(horizontalScrollbarStart(0), |
- box().size().height() - box().borderBottom() - horizontalScrollbar()->height(), |
- box().size().width() - (box().borderLeft() + box().borderRight()) - (hasVerticalScrollbar() ? verticalScrollbar()->width() : resizeControlSize), |
- horizontalScrollbar()->height()); |
+ box().size().height() - box().borderBottom() - m_hBar->height(), |
+ box().size().width() - (box().borderLeft() + box().borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize), |
+ m_hBar->height()); |
if (hBarRect.contains(localPoint)) { |
- result.setScrollbar(horizontalScrollbar()); |
+ result.setScrollbar(m_hBar.get()); |
return true; |
} |
} |
@@ -1446,107 +1490,4 @@ |
return frame->settings()->viewportMetaEnabled(); |
} |
-DeprecatedPaintLayerScrollableArea::ScrollbarManager::ScrollbarManager(DeprecatedPaintLayerScrollableArea& scrollableArea) |
- : m_scrollableArea(scrollableArea) |
- , m_canDetachScrollbars(0) |
- , m_hBarIsAttached(0) |
- , m_vBarIsAttached(0) |
-{ |
-} |
- |
-void DeprecatedPaintLayerScrollableArea::ScrollbarManager::dispose() |
-{ |
- m_canDetachScrollbars = m_hBarIsAttached = m_vBarIsAttached = 0; |
- destroyScrollbar(HorizontalScrollbar); |
- destroyScrollbar(VerticalScrollbar); |
-} |
- |
-void DeprecatedPaintLayerScrollableArea::ScrollbarManager::setCanDetachScrollbars(bool detach) |
-{ |
- ASSERT(!m_hBarIsAttached || m_hBar); |
- ASSERT(!m_vBarIsAttached || m_vBar); |
- m_canDetachScrollbars = detach ? 1 : 0; |
- if (!detach) { |
- if (m_hBar && !m_hBarIsAttached) |
- destroyScrollbar(HorizontalScrollbar, true); |
- if (m_vBar && !m_vBarIsAttached) |
- destroyScrollbar(VerticalScrollbar, true); |
- } |
-} |
- |
-void DeprecatedPaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(bool hasScrollbar) |
-{ |
- if (hasScrollbar) { |
- // This doesn't hit in any tests, but since the equivalent code in setHasVerticalScrollbar |
- // does, presumably this code does as well. |
- DisableCompositingQueryAsserts disabler; |
- if (!m_hBar) |
- m_hBar = createScrollbar(HorizontalScrollbar); |
- m_hBarIsAttached = 1; |
- } else { |
- m_hBarIsAttached = 0; |
- if (!m_canDetachScrollbars) |
- destroyScrollbar(HorizontalScrollbar); |
- } |
-} |
- |
-void DeprecatedPaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar(bool hasScrollbar) |
-{ |
- if (hasScrollbar) { |
- DisableCompositingQueryAsserts disabler; |
- if (!m_vBar) |
- m_vBar = createScrollbar(VerticalScrollbar); |
- m_vBarIsAttached = 1; |
- } else { |
- m_vBarIsAttached = 0; |
- if (!m_canDetachScrollbars) |
- destroyScrollbar(VerticalScrollbar); |
- } |
-} |
- |
-PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::ScrollbarManager::createScrollbar(ScrollbarOrientation orientation) |
-{ |
- ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached : !m_vBarIsAttached); |
- RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |
- LayoutObject* actualLayoutObject = layoutObjectForScrollbar(m_scrollableArea.box()); |
- bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutObject->style()->hasPseudoStyle(SCROLLBAR); |
- if (hasCustomScrollbarStyle) { |
- widget = LayoutScrollbar::createCustomScrollbar(&m_scrollableArea, orientation, actualLayoutObject->node()); |
- } else { |
- ScrollbarControlSize scrollbarSize = RegularScrollbar; |
- if (actualLayoutObject->style()->hasAppearance()) |
- scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(actualLayoutObject->style()->appearance()); |
- widget = Scrollbar::create(&m_scrollableArea, orientation, scrollbarSize); |
- if (orientation == HorizontalScrollbar) |
- m_scrollableArea.didAddScrollbar(widget.get(), HorizontalScrollbar); |
- else |
- m_scrollableArea.didAddScrollbar(widget.get(), VerticalScrollbar); |
- } |
- m_scrollableArea.box().document().view()->addChild(widget.get()); |
- return widget.release(); |
-} |
- |
-void DeprecatedPaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrientation orientation, bool invalidate) |
-{ |
- RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollbar ? m_hBar : m_vBar; |
- ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAttached); |
- if (!scrollbar) |
- return; |
- |
- if (invalidate) |
- scrollbar->invalidate(); |
- if (!scrollbar->isCustomScrollbar()) |
- m_scrollableArea.willRemoveScrollbar(scrollbar.get(), orientation); |
- |
- toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); |
- scrollbar->disconnectFromScrollableArea(); |
- scrollbar = nullptr; |
-} |
- |
-DEFINE_TRACE(DeprecatedPaintLayerScrollableArea::ScrollbarManager) |
-{ |
- visitor->trace(m_hBar); |
- visitor->trace(m_vBar); |
-} |
- |
} // namespace blink |