Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 const int ResizerControlExpandRatioForTouch = 2; | 81 const int ResizerControlExpandRatioForTouch = 2; |
| 82 | 82 |
| 83 DeprecatedPaintLayerScrollableArea::DeprecatedPaintLayerScrollableArea(Deprecate dPaintLayer& layer) | 83 DeprecatedPaintLayerScrollableArea::DeprecatedPaintLayerScrollableArea(Deprecate dPaintLayer& layer) |
| 84 : m_layer(layer) | 84 : m_layer(layer) |
| 85 , m_inResizeMode(false) | 85 , m_inResizeMode(false) |
| 86 , m_scrollsOverflow(false) | 86 , m_scrollsOverflow(false) |
| 87 , m_inOverflowRelayout(false) | 87 , m_inOverflowRelayout(false) |
| 88 , m_nextTopmostScrollChild(0) | 88 , m_nextTopmostScrollChild(0) |
| 89 , m_topmostScrollChild(0) | 89 , m_topmostScrollChild(0) |
| 90 , m_needsCompositedScrolling(false) | 90 , m_needsCompositedScrolling(false) |
| 91 , m_scrollbarManager(*this) | |
| 91 , m_scrollCorner(nullptr) | 92 , m_scrollCorner(nullptr) |
| 92 , m_resizer(nullptr) | 93 , m_resizer(nullptr) |
| 93 #if ENABLE(ASSERT) | 94 #if ENABLE(ASSERT) |
| 94 , m_hasBeenDisposed(false) | 95 , m_hasBeenDisposed(false) |
| 95 #endif | 96 #endif |
| 96 { | 97 { |
| 97 Node* node = box().node(); | 98 Node* node = box().node(); |
| 98 if (node && node->isElementNode()) { | 99 if (node && node->isElementNode()) { |
| 99 // We save and restore only the scrollOffset as the other scroll values are recalculated. | 100 // We save and restore only the scrollOffset as the other scroll values are recalculated. |
| 100 Element* element = toElement(node); | 101 Element* element = toElement(node); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/4142 83. | 136 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/4142 83. |
| 136 if (node && node->isElementNode()) | 137 if (node && node->isElementNode()) |
| 137 toElement(node)->setSavedLayerScrollOffset(flooredIntSize(m_scrollOf fset)); | 138 toElement(node)->setSavedLayerScrollOffset(flooredIntSize(m_scrollOf fset)); |
| 138 } | 139 } |
| 139 | 140 |
| 140 if (LocalFrame* frame = box().frame()) { | 141 if (LocalFrame* frame = box().frame()) { |
| 141 if (FrameView* frameView = frame->view()) | 142 if (FrameView* frameView = frame->view()) |
| 142 frameView->removeResizerArea(box()); | 143 frameView->removeResizerArea(box()); |
| 143 } | 144 } |
| 144 | 145 |
| 145 destroyScrollbar(HorizontalScrollbar); | 146 m_scrollbarManager.dispose(); |
| 146 destroyScrollbar(VerticalScrollbar); | |
| 147 | 147 |
| 148 if (m_scrollCorner) | 148 if (m_scrollCorner) |
| 149 m_scrollCorner->destroy(); | 149 m_scrollCorner->destroy(); |
| 150 if (m_resizer) | 150 if (m_resizer) |
| 151 m_resizer->destroy(); | 151 m_resizer->destroy(); |
| 152 | 152 |
| 153 clearScrollAnimators(); | 153 clearScrollAnimators(); |
| 154 | 154 |
| 155 #if ENABLE(ASSERT) | 155 #if ENABLE(ASSERT) |
| 156 m_hasBeenDisposed = true; | 156 m_hasBeenDisposed = true; |
| 157 #endif | 157 #endif |
| 158 } | 158 } |
| 159 | 159 |
| 160 DEFINE_TRACE(DeprecatedPaintLayerScrollableArea) | 160 DEFINE_TRACE(DeprecatedPaintLayerScrollableArea) |
| 161 { | 161 { |
| 162 visitor->trace(m_hBar); | 162 m_scrollbarManager.trace(visitor); |
| 163 visitor->trace(m_vBar); | |
| 164 ScrollableArea::trace(visitor); | 163 ScrollableArea::trace(visitor); |
| 165 } | 164 } |
| 166 | 165 |
| 167 HostWindow* DeprecatedPaintLayerScrollableArea::hostWindow() const | 166 HostWindow* DeprecatedPaintLayerScrollableArea::hostWindow() const |
| 168 { | 167 { |
| 169 if (Page* page = box().frame()->page()) | 168 if (Page* page = box().frame()->page()) |
| 170 return &page->chromeClient(); | 169 return &page->chromeClient(); |
| 171 return nullptr; | 170 return nullptr; |
| 172 } | 171 } |
| 173 | 172 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 198 DisableCompositingQueryAsserts disabler; | 197 DisableCompositingQueryAsserts disabler; |
| 199 | 198 |
| 200 return layer()->hasCompositedDeprecatedPaintLayerMapping() ? layer()->compos itedDeprecatedPaintLayerMapping()->layerForScrollCorner() : 0; | 199 return layer()->hasCompositedDeprecatedPaintLayerMapping() ? layer()->compos itedDeprecatedPaintLayerMapping()->layerForScrollCorner() : 0; |
| 201 } | 200 } |
| 202 | 201 |
| 203 void DeprecatedPaintLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scro llbar, const IntRect& rect) | 202 void DeprecatedPaintLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scro llbar, const IntRect& rect) |
| 204 { | 203 { |
| 205 // See crbug.com/343132. | 204 // See crbug.com/343132. |
| 206 DisableCompositingQueryAsserts disabler; | 205 DisableCompositingQueryAsserts disabler; |
| 207 | 206 |
| 208 ASSERT(scrollbar == m_hBar.get() || scrollbar == m_vBar.get()); | 207 ASSERT(scrollbar == horizontalScrollbar() || scrollbar == verticalScrollbar( )); |
| 209 ASSERT(scrollbar == m_hBar.get() ? !layerForHorizontalScrollbar() : !layerFo rVerticalScrollbar()); | 208 ASSERT(scrollbar == horizontalScrollbar() ? !layerForHorizontalScrollbar() : !layerForVerticalScrollbar()); |
| 210 | 209 |
| 211 IntRect scrollRect = rect; | 210 IntRect scrollRect = rect; |
| 212 // If we are not yet inserted into the tree, there is no need to issue paint invaldiations. | 211 // If we are not yet inserted into the tree, there is no need to issue paint invaldiations. |
| 213 if (!box().isLayoutView() && !box().parent()) | 212 if (!box().isLayoutView() && !box().parent()) |
| 214 return; | 213 return; |
| 215 | 214 |
| 216 if (scrollbar == m_vBar.get()) | 215 if (scrollbar == verticalScrollbar()) |
| 217 scrollRect.move(verticalScrollbarStart(0, box().size().width()), box().b orderTop()); | 216 scrollRect.move(verticalScrollbarStart(0, box().size().width()), box().b orderTop()); |
| 218 else | 217 else |
| 219 scrollRect.move(horizontalScrollbarStart(0), box().size().height() - box ().borderBottom() - scrollbar->height()); | 218 scrollRect.move(horizontalScrollbarStart(0), box().size().height() - box ().borderBottom() - scrollbar->height()); |
| 220 | 219 |
| 221 if (scrollRect.isEmpty()) | 220 if (scrollRect.isEmpty()) |
| 222 return; | 221 return; |
| 223 | 222 |
| 224 box().invalidateDisplayItemClient(*scrollbar); | 223 box().invalidateDisplayItemClient(*scrollbar); |
| 225 | 224 |
| 226 LayoutRect paintInvalidationRect = LayoutRect(scrollRect); | 225 LayoutRect paintInvalidationRect = LayoutRect(scrollRect); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 DoublePoint newScrollPosition = clamp == ScrollOffsetClamped ? clampScrollPo sition(scrollPosition) : scrollPosition; | 645 DoublePoint newScrollPosition = clamp == ScrollOffsetClamped ? clampScrollPo sition(scrollPosition) : scrollPosition; |
| 647 if (newScrollPosition != scrollPositionDouble()) | 646 if (newScrollPosition != scrollPositionDouble()) |
| 648 ScrollableArea::setScrollPosition(newScrollPosition, ProgrammaticScroll, scrollBehavior); | 647 ScrollableArea::setScrollPosition(newScrollPosition, ProgrammaticScroll, scrollBehavior); |
| 649 } | 648 } |
| 650 | 649 |
| 651 void DeprecatedPaintLayerScrollableArea::updateScrollDimensions(DoubleSize& scro llOffset, bool& autoHorizontalScrollBarChanged, bool& autoVerticalScrollBarChang ed) | 650 void DeprecatedPaintLayerScrollableArea::updateScrollDimensions(DoubleSize& scro llOffset, bool& autoHorizontalScrollBarChanged, bool& autoVerticalScrollBarChang ed) |
| 652 { | 651 { |
| 653 ASSERT(box().hasOverflowClip()); | 652 ASSERT(box().hasOverflowClip()); |
| 654 | 653 |
| 655 if (needsScrollbarReconstruction()) { | 654 if (needsScrollbarReconstruction()) { |
| 656 if (m_hBar) | 655 m_scrollbarManager.setCanDetachScrollbars(false); |
| 657 destroyScrollbar(HorizontalScrollbar); | 656 setHasHorizontalScrollbar(false); |
| 658 if (m_vBar) | 657 setHasVerticalScrollbar(false); |
| 659 destroyScrollbar(VerticalScrollbar); | |
| 660 } | 658 } |
| 661 | 659 |
| 660 m_scrollbarManager.setCanDetachScrollbars(true); | |
| 661 | |
| 662 scrollOffset = adjustedScrollOffset(); | 662 scrollOffset = adjustedScrollOffset(); |
| 663 computeScrollDimensions(); | 663 computeScrollDimensions(); |
| 664 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 664 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 665 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 665 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 666 if (hasOverlayScrollbars()) { | 666 if (hasOverlayScrollbars()) { |
| 667 if (!scrollSize(HorizontalScrollbar)) | 667 if (!scrollSize(HorizontalScrollbar)) |
| 668 setHasHorizontalScrollbar(false); | 668 setHasHorizontalScrollbar(false); |
| 669 if (!scrollSize(VerticalScrollbar)) | 669 if (!scrollSize(VerticalScrollbar)) |
| 670 setHasVerticalScrollbar(false); | 670 setHasVerticalScrollbar(false); |
| 671 } | 671 } |
| 672 | 672 |
| 673 // overflow:auto may need to lay out again if scrollbars got added/removed. | 673 // overflow:auto may need to lay out again if scrollbars got added/removed. |
| 674 autoHorizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (has HorizontalScrollbar() != hasHorizontalOverflow)) || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); | 674 autoHorizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (has HorizontalScrollbar() != hasHorizontalOverflow)) || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); |
| 675 autoVerticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVert icalScrollbar() != hasVerticalOverflow)) || (box().style()->overflowY() == OSCRO LL && !verticalScrollbar()); | 675 autoVerticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVert icalScrollbar() != hasVerticalOverflow)) || (box().style()->overflowY() == OSCRO LL && !verticalScrollbar()); |
| 676 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged | | autoVerticalScrollBarChanged)) { | 676 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged | | autoVerticalScrollBarChanged)) { |
| 677 if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar())) | 677 if (box().hasAutoHorizontalScrollbar()) |
| 678 setHasHorizontalScrollbar(box().style()->overflowX() == OSCROLL ? tr ue : hasHorizontalOverflow); | 678 setHasHorizontalScrollbar(hasHorizontalOverflow); |
| 679 if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == O SCROLL && !verticalScrollbar())) | 679 else if (box().style()->overflowX() == OSCROLL) |
| 680 setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true : hasVerticalOverflow); | 680 setHasHorizontalScrollbar(true); |
| 681 if (box().hasAutoVerticalScrollbar()) | |
| 682 setHasVerticalScrollbar(hasVerticalOverflow); | |
| 683 else if (box().style()->overflowX() == OSCROLL) | |
|
MuVen
2015/10/01 13:41:48
small typo error, corrected at
https://codereview
| |
| 684 setHasVerticalScrollbar(true); | |
| 681 } | 685 } |
| 682 } | 686 } |
| 683 | 687 |
| 684 void DeprecatedPaintLayerScrollableArea::finalizeScrollDimensions(const DoubleSi ze& originalScrollOffset, bool autoHorizontalScrollBarChanged, bool autoVertical ScrollBarChanged) | 688 void DeprecatedPaintLayerScrollableArea::finalizeScrollDimensions(const DoubleSi ze& originalScrollOffset, bool autoHorizontalScrollBarChanged, bool autoVertical ScrollBarChanged) |
| 685 { | 689 { |
| 686 ASSERT(box().hasOverflowClip()); | 690 ASSERT(box().hasOverflowClip()); |
| 687 | 691 |
| 688 // Layout may cause us to be at an invalid scroll position. In this case we need | 692 // Layout may cause us to be at an invalid scroll position. In this case we need |
| 689 // to pull our scroll offsets back to the max (or push them up to the min). | 693 // to pull our scroll offsets back to the max (or push them up to the min). |
| 690 DoublePoint clampedScrollPosition = clampScrollPosition(scrollPositionDouble ()); | 694 DoublePoint clampedScrollPosition = clampScrollPosition(scrollPositionDouble ()); |
| 691 if (clampedScrollPosition != scrollPositionDouble()) | 695 if (clampedScrollPosition != scrollPositionDouble()) |
| 692 scrollToPosition(clampedScrollPosition); | 696 scrollToPosition(clampedScrollPosition); |
| 693 | 697 |
| 694 if (originalScrollOffset != adjustedScrollOffset()) { | 698 if (originalScrollOffset != adjustedScrollOffset()) { |
| 695 DoublePoint origin(scrollOrigin()); | 699 DoublePoint origin(scrollOrigin()); |
| 696 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro ll); | 700 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro ll); |
| 697 } | 701 } |
| 698 | 702 |
| 703 m_scrollbarManager.setCanDetachScrollbars(false); | |
| 704 | |
| 699 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 705 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 700 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 706 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 701 | 707 |
| 702 { | 708 { |
| 703 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. | 709 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. |
| 704 DisableCompositingQueryAsserts disabler; | 710 DisableCompositingQueryAsserts disabler; |
| 705 | 711 |
| 706 // overflow:scroll should just enable/disable. | 712 // overflow:scroll should just enable/disable. |
| 707 if (box().style()->overflowX() == OSCROLL && horizontalScrollbar()) | 713 if (box().style()->overflowX() == OSCROLL && horizontalScrollbar()) |
| 708 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); | 714 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 } | 868 } |
| 863 } | 869 } |
| 864 | 870 |
| 865 setHasHorizontalScrollbar(needsHorizontalScrollbar); | 871 setHasHorizontalScrollbar(needsHorizontalScrollbar); |
| 866 setHasVerticalScrollbar(needsVerticalScrollbar); | 872 setHasVerticalScrollbar(needsVerticalScrollbar); |
| 867 | 873 |
| 868 // With overflow: scroll, scrollbars are always visible but may be disabled. | 874 // With overflow: scroll, scrollbars are always visible but may be disabled. |
| 869 // When switching to another value, we need to re-enable them (see bug 11985 ). | 875 // When switching to another value, we need to re-enable them (see bug 11985 ). |
| 870 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) { | 876 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) { |
| 871 ASSERT(hasHorizontalScrollbar()); | 877 ASSERT(hasHorizontalScrollbar()); |
| 872 m_hBar->setEnabled(true); | 878 horizontalScrollbar()->setEnabled(true); |
| 873 } | 879 } |
| 874 | 880 |
| 875 if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL & & overflowY != OSCROLL) { | 881 if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL & & overflowY != OSCROLL) { |
| 876 ASSERT(hasVerticalScrollbar()); | 882 ASSERT(hasVerticalScrollbar()); |
| 877 m_vBar->setEnabled(true); | 883 verticalScrollbar()->setEnabled(true); |
| 878 } | 884 } |
| 879 | 885 |
| 880 // FIXME: Need to detect a swap from custom to native scrollbars (and vice v ersa). | 886 // FIXME: Need to detect a swap from custom to native scrollbars (and vice v ersa). |
| 881 if (m_hBar) | 887 if (horizontalScrollbar()) |
| 882 m_hBar->styleChanged(); | 888 horizontalScrollbar()->styleChanged(); |
| 883 if (m_vBar) | 889 if (verticalScrollbar()) |
| 884 m_vBar->styleChanged(); | 890 verticalScrollbar()->styleChanged(); |
| 885 | 891 |
| 886 updateScrollCornerStyle(); | 892 updateScrollCornerStyle(); |
| 887 updateResizerAreaSet(); | 893 updateResizerAreaSet(); |
| 888 updateResizerStyle(); | 894 updateResizerStyle(); |
| 889 } | 895 } |
| 890 | 896 |
| 891 bool DeprecatedPaintLayerScrollableArea::updateAfterCompositingChange() | 897 bool DeprecatedPaintLayerScrollableArea::updateAfterCompositingChange() |
| 892 { | 898 { |
| 893 layer()->updateScrollingStateAfterCompositingChange(); | 899 layer()->updateScrollingStateAfterCompositingChange(); |
| 894 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; | 900 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 912 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 918 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 913 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 919 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 914 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); | 920 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); |
| 915 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow); | 921 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow); |
| 916 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) | 922 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) |
| 917 box().setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::U nknown); | 923 box().setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::U nknown); |
| 918 } | 924 } |
| 919 | 925 |
| 920 IntRect DeprecatedPaintLayerScrollableArea::rectForHorizontalScrollbar(const Int Rect& borderBoxRect) const | 926 IntRect DeprecatedPaintLayerScrollableArea::rectForHorizontalScrollbar(const Int Rect& borderBoxRect) const |
| 921 { | 927 { |
| 922 if (!m_hBar) | 928 if (!hasHorizontalScrollbar()) |
| 923 return IntRect(); | 929 return IntRect(); |
| 924 | 930 |
| 925 const IntRect& scrollCorner = scrollCornerRect(); | 931 const IntRect& scrollCorner = scrollCornerRect(); |
| 926 | 932 |
| 927 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), | 933 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), |
| 928 borderBoxRect.maxY() - box().borderBottom() - m_hBar->height(), | 934 borderBoxRect.maxY() - box().borderBottom() - horizontalScrollbar()->hei ght(), |
| 929 borderBoxRect.width() - (box().borderLeft() + box().borderRight()) - scr ollCorner.width(), | 935 borderBoxRect.width() - (box().borderLeft() + box().borderRight()) - scr ollCorner.width(), |
| 930 m_hBar->height()); | 936 horizontalScrollbar()->height()); |
| 931 } | 937 } |
| 932 | 938 |
| 933 IntRect DeprecatedPaintLayerScrollableArea::rectForVerticalScrollbar(const IntRe ct& borderBoxRect) const | 939 IntRect DeprecatedPaintLayerScrollableArea::rectForVerticalScrollbar(const IntRe ct& borderBoxRect) const |
| 934 { | 940 { |
| 935 if (!m_vBar) | 941 if (!hasVerticalScrollbar()) |
| 936 return IntRect(); | 942 return IntRect(); |
| 937 | 943 |
| 938 const IntRect& scrollCorner = scrollCornerRect(); | 944 const IntRect& scrollCorner = scrollCornerRect(); |
| 939 | 945 |
| 940 return IntRect(verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX( )), | 946 return IntRect(verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX( )), |
| 941 borderBoxRect.y() + box().borderTop(), | 947 borderBoxRect.y() + box().borderTop(), |
| 942 m_vBar->width(), | 948 verticalScrollbar()->width(), |
| 943 borderBoxRect.height() - (box().borderTop() + box().borderBottom()) - sc rollCorner.height()); | 949 borderBoxRect.height() - (box().borderTop() + box().borderBottom()) - sc rollCorner.height()); |
| 944 } | 950 } |
| 945 | 951 |
| 946 LayoutUnit DeprecatedPaintLayerScrollableArea::verticalScrollbarStart(int minX, int maxX) const | 952 LayoutUnit DeprecatedPaintLayerScrollableArea::verticalScrollbarStart(int minX, int maxX) const |
| 947 { | 953 { |
| 948 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 954 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 949 return minX + box().borderLeft(); | 955 return minX + box().borderLeft(); |
| 950 return maxX - box().borderRight() - m_vBar->width(); | 956 return maxX - box().borderRight() - verticalScrollbar()->width(); |
| 951 } | 957 } |
| 952 | 958 |
| 953 LayoutUnit DeprecatedPaintLayerScrollableArea::horizontalScrollbarStart(int minX ) const | 959 LayoutUnit DeprecatedPaintLayerScrollableArea::horizontalScrollbarStart(int minX ) const |
| 954 { | 960 { |
| 955 int x = minX + box().borderLeft(); | 961 int x = minX + box().borderLeft(); |
| 956 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 962 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 957 x += m_vBar ? m_vBar->width() : resizerCornerRect(box().pixelSnappedBord erBoxRect(), ResizerForPointer).width(); | 963 x += hasVerticalScrollbar() ? verticalScrollbar()->width() : resizerCorn erRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer).width(); |
| 958 return x; | 964 return x; |
| 959 } | 965 } |
| 960 | 966 |
| 961 IntSize DeprecatedPaintLayerScrollableArea::scrollbarOffset(const Scrollbar* scr ollbar) const | 967 IntSize DeprecatedPaintLayerScrollableArea::scrollbarOffset(const Scrollbar* scr ollbar) const |
| 962 { | 968 { |
| 963 if (scrollbar == m_vBar.get()) | 969 if (scrollbar == verticalScrollbar()) |
| 964 return IntSize(verticalScrollbarStart(0, box().size().width()), box().bo rderTop()); | 970 return IntSize(verticalScrollbarStart(0, box().size().width()), box().bo rderTop()); |
| 965 | 971 |
| 966 if (scrollbar == m_hBar.get()) | 972 if (scrollbar == horizontalScrollbar()) |
| 967 return IntSize(horizontalScrollbarStart(0), box().size().height() - box( ).borderBottom() - scrollbar->height()); | 973 return IntSize(horizontalScrollbarStart(0), box().size().height() - box( ).borderBottom() - scrollbar->height()); |
| 968 | 974 |
| 969 ASSERT_NOT_REACHED(); | 975 ASSERT_NOT_REACHED(); |
| 970 return IntSize(); | 976 return IntSize(); |
| 971 } | 977 } |
| 972 | 978 |
| 973 static inline LayoutObject* layoutObjectForScrollbar(LayoutObject& layoutObject) | 979 static inline LayoutObject* layoutObjectForScrollbar(LayoutObject& layoutObject) |
| 974 { | 980 { |
| 975 if (Node* node = layoutObject.node()) { | 981 if (Node* node = layoutObject.node()) { |
| 976 if (layoutObject.isLayoutView()) { | 982 if (layoutObject.isLayoutView()) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1002 } | 1008 } |
| 1003 | 1009 |
| 1004 return &layoutObject; | 1010 return &layoutObject; |
| 1005 } | 1011 } |
| 1006 | 1012 |
| 1007 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const | 1013 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const |
| 1008 { | 1014 { |
| 1009 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | 1015 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
| 1010 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st yle()->hasPseudoStyle(SCROLLBAR); | 1016 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st yle()->hasPseudoStyle(SCROLLBAR); |
| 1011 bool hasAnyScrollbar = hasScrollbar(); | 1017 bool hasAnyScrollbar = hasScrollbar(); |
| 1012 bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBa r->isCustomScrollbar()); | 1018 bool hasCustom = (hasHorizontalScrollbar() && horizontalScrollbar()->isCusto mScrollbar()) || (hasVerticalScrollbar() && verticalScrollbar()->isCustomScrollb ar()); |
| 1013 return hasAnyScrollbar && (shouldUseCustom != hasCustom); | 1019 return hasAnyScrollbar && (shouldUseCustom != hasCustom); |
| 1014 } | 1020 } |
| 1015 | 1021 |
| 1016 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) | |
| 1017 { | |
| 1018 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | |
| 1019 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | |
| 1020 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); | |
| 1021 if (hasCustomScrollbarStyle) { | |
| 1022 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); | |
| 1023 } else { | |
| 1024 ScrollbarControlSize scrollbarSize = RegularScrollbar; | |
| 1025 if (actualLayoutObject->style()->hasAppearance()) | |
| 1026 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act ualLayoutObject->style()->appearance()); | |
| 1027 widget = Scrollbar::create(this, orientation, scrollbarSize); | |
| 1028 if (orientation == HorizontalScrollbar) | |
| 1029 didAddScrollbar(widget.get(), HorizontalScrollbar); | |
| 1030 else | |
| 1031 didAddScrollbar(widget.get(), VerticalScrollbar); | |
| 1032 } | |
| 1033 box().document().view()->addChild(widget.get()); | |
| 1034 return widget.release(); | |
| 1035 } | |
| 1036 | |
| 1037 void DeprecatedPaintLayerScrollableArea::destroyScrollbar(ScrollbarOrientation o rientation) | |
| 1038 { | |
| 1039 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba r ? m_hBar : m_vBar; | |
| 1040 if (!scrollbar) | |
| 1041 return; | |
| 1042 | |
| 1043 if (!scrollbar->isCustomScrollbar()) | |
| 1044 willRemoveScrollbar(scrollbar.get(), orientation); | |
| 1045 | |
| 1046 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); | |
| 1047 scrollbar->disconnectFromScrollableArea(); | |
| 1048 scrollbar = nullptr; | |
| 1049 } | |
| 1050 | |
| 1051 void DeprecatedPaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrol lbar) | 1022 void DeprecatedPaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrol lbar) |
| 1052 { | 1023 { |
| 1053 if (hasScrollbar == hasHorizontalScrollbar()) | 1024 if (hasScrollbar == hasHorizontalScrollbar()) |
| 1054 return; | 1025 return; |
| 1055 | 1026 |
| 1056 if (hasScrollbar) { | 1027 if (!hasScrollbar && !layerForHorizontalScrollbar()) |
| 1057 // This doesn't hit in any tests, but since the equivalent code in setHa sVerticalScrollbar | 1028 horizontalScrollbar()->invalidate(); |
| 1058 // does, presumably this code does as well. | |
| 1059 DisableCompositingQueryAsserts disabler; | |
| 1060 m_hBar = createScrollbar(HorizontalScrollbar); | |
| 1061 } else { | |
| 1062 if (!layerForHorizontalScrollbar()) | |
| 1063 m_hBar->invalidate(); | |
| 1064 // Otherwise we will remove the layer and just need recompositing. | |
| 1065 | 1029 |
| 1066 destroyScrollbar(HorizontalScrollbar); | 1030 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); |
| 1067 } | |
| 1068 | 1031 |
| 1069 // Destroying or creating one bar can cause our scrollbar corner to come and go. We need to update the opposite scrollbar's style. | 1032 // Destroying or creating one bar can cause our scrollbar corner to come and go. We need to update the opposite scrollbar's style. |
| 1070 if (m_hBar) | 1033 if (hasHorizontalScrollbar()) |
| 1071 m_hBar->styleChanged(); | 1034 horizontalScrollbar()->styleChanged(); |
| 1072 if (m_vBar) | 1035 if (hasVerticalScrollbar()) |
| 1073 m_vBar->styleChanged(); | 1036 verticalScrollbar()->styleChanged(); |
| 1074 | 1037 |
| 1075 // These are valid because we want to invalidate display item clients on the current backing. | 1038 // These are valid because we want to invalidate display item clients on the current backing. |
| 1076 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; | 1039 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
| 1077 DisableCompositingQueryAsserts compositingAssertDisabler; | 1040 DisableCompositingQueryAsserts compositingAssertDisabler; |
| 1078 invalidateScrollCorner(scrollCornerRect()); | 1041 invalidateScrollCorner(scrollCornerRect()); |
| 1079 | 1042 |
| 1080 // Force an update since we know the scrollbars have changed things. | 1043 // Force an update since we know the scrollbars have changed things. |
| 1081 if (box().document().hasAnnotatedRegions()) | 1044 if (box().document().hasAnnotatedRegions()) |
| 1082 box().document().setAnnotatedRegionsDirty(true); | 1045 box().document().setAnnotatedRegionsDirty(true); |
| 1083 } | 1046 } |
| 1084 | 1047 |
| 1085 void DeprecatedPaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollb ar) | 1048 void DeprecatedPaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollb ar) |
| 1086 { | 1049 { |
| 1087 if (hasScrollbar == hasVerticalScrollbar()) | 1050 if (hasScrollbar == hasVerticalScrollbar()) |
| 1088 return; | 1051 return; |
| 1089 | 1052 |
| 1090 if (hasScrollbar) { | 1053 if (!hasScrollbar && !layerForVerticalScrollbar()) |
| 1091 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html | 1054 verticalScrollbar()->invalidate(); |
| 1092 DisableCompositingQueryAsserts disabler; | |
| 1093 m_vBar = createScrollbar(VerticalScrollbar); | |
| 1094 } else { | |
| 1095 if (!layerForVerticalScrollbar()) | |
| 1096 m_vBar->invalidate(); | |
| 1097 // Otherwise we will remove the layer and just need recompositing. | |
| 1098 | 1055 |
| 1099 destroyScrollbar(VerticalScrollbar); | 1056 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); |
| 1100 } | |
| 1101 | 1057 |
| 1102 // Destroying or creating one bar can cause our scrollbar corner to come and go. We need to update the opposite scrollbar's style. | 1058 // Destroying or creating one bar can cause our scrollbar corner to come and go. We need to update the opposite scrollbar's style. |
| 1103 if (m_hBar) | 1059 if (hasHorizontalScrollbar()) |
| 1104 m_hBar->styleChanged(); | 1060 horizontalScrollbar()->styleChanged(); |
| 1105 if (m_vBar) | 1061 if (hasVerticalScrollbar()) |
| 1106 m_vBar->styleChanged(); | 1062 verticalScrollbar()->styleChanged(); |
| 1107 | 1063 |
| 1108 // These are valid because we want to invalidate display item clients on the current backing. | 1064 // These are valid because we want to invalidate display item clients on the current backing. |
| 1109 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; | 1065 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
| 1110 DisableCompositingQueryAsserts compositingAssertDisabler; | 1066 DisableCompositingQueryAsserts compositingAssertDisabler; |
| 1111 invalidateScrollCorner(scrollCornerRect()); | 1067 invalidateScrollCorner(scrollCornerRect()); |
| 1112 | 1068 |
| 1113 // Force an update since we know the scrollbars have changed things. | 1069 // Force an update since we know the scrollbars have changed things. |
| 1114 if (box().document().hasAnnotatedRegions()) | 1070 if (box().document().hasAnnotatedRegions()) |
| 1115 box().document().setAnnotatedRegionsDirty(true); | 1071 box().document().setAnnotatedRegionsDirty(true); |
| 1116 } | 1072 } |
| 1117 | 1073 |
| 1118 int DeprecatedPaintLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarS izeRelevancy relevancy) const | 1074 int DeprecatedPaintLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarS izeRelevancy relevancy) const |
| 1119 { | 1075 { |
| 1120 if (!m_vBar || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayS crollbarSize || !m_vBar->shouldParticipateInHitTesting()))) | 1076 if (!hasVerticalScrollbar() || (verticalScrollbar()->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !verticalScrollbar()->shouldPartici pateInHitTesting()))) |
| 1121 return 0; | 1077 return 0; |
| 1122 return m_vBar->width(); | 1078 return verticalScrollbar()->width(); |
| 1123 } | 1079 } |
| 1124 | 1080 |
| 1125 int DeprecatedPaintLayerScrollableArea::horizontalScrollbarHeight(OverlayScrollb arSizeRelevancy relevancy) const | 1081 int DeprecatedPaintLayerScrollableArea::horizontalScrollbarHeight(OverlayScrollb arSizeRelevancy relevancy) const |
| 1126 { | 1082 { |
| 1127 if (!m_hBar || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayS crollbarSize || !m_hBar->shouldParticipateInHitTesting()))) | 1083 if (!hasHorizontalScrollbar() || (horizontalScrollbar()->isOverlayScrollbar( ) && (relevancy == IgnoreOverlayScrollbarSize || !horizontalScrollbar()->shouldP articipateInHitTesting()))) |
| 1128 return 0; | 1084 return 0; |
| 1129 return m_hBar->height(); | 1085 return horizontalScrollbar()->height(); |
| 1130 } | 1086 } |
| 1131 | 1087 |
| 1132 void DeprecatedPaintLayerScrollableArea::positionOverflowControls() | 1088 void DeprecatedPaintLayerScrollableArea::positionOverflowControls() |
| 1133 { | 1089 { |
| 1134 if (!hasScrollbar() && !box().canResize()) | 1090 if (!hasScrollbar() && !box().canResize()) |
| 1135 return; | 1091 return; |
| 1136 | 1092 |
| 1137 const IntRect borderBox = box().pixelSnappedBorderBoxRect(); | 1093 const IntRect borderBox = box().pixelSnappedBorderBoxRect(); |
| 1138 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) | 1094 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) |
| 1139 verticalScrollbar->setFrameRect(rectForVerticalScrollbar(borderBox)); | 1095 verticalScrollbar->setFrameRect(rectForVerticalScrollbar(borderBox)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 return false; | 1138 return false; |
| 1183 | 1139 |
| 1184 IntRect resizeControlRect; | 1140 IntRect resizeControlRect; |
| 1185 if (box().style()->resize() != RESIZE_NONE) { | 1141 if (box().style()->resize() != RESIZE_NONE) { |
| 1186 resizeControlRect = resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer); | 1142 resizeControlRect = resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer); |
| 1187 if (resizeControlRect.contains(localPoint)) | 1143 if (resizeControlRect.contains(localPoint)) |
| 1188 return true; | 1144 return true; |
| 1189 } | 1145 } |
| 1190 | 1146 |
| 1191 int resizeControlSize = max(resizeControlRect.height(), 0); | 1147 int resizeControlSize = max(resizeControlRect.height(), 0); |
| 1192 if (m_vBar && m_vBar->shouldParticipateInHitTesting()) { | 1148 if (hasVerticalScrollbar() && verticalScrollbar()->shouldParticipateInHitTes ting()) { |
| 1193 LayoutRect vBarRect(verticalScrollbarStart(0, box().size().width()), | 1149 LayoutRect vBarRect(verticalScrollbarStart(0, box().size().width()), |
| 1194 box().borderTop(), | 1150 box().borderTop(), |
| 1195 m_vBar->width(), | 1151 verticalScrollbar()->width(), |
| 1196 box().size().height() - (box().borderTop() + box().borderBottom()) - (m_hBar ? m_hBar->height() : resizeControlSize)); | 1152 box().size().height() - (box().borderTop() + box().borderBottom()) - (hasHorizontalScrollbar() ? horizontalScrollbar()->height() : resizeControlSize )); |
| 1197 if (vBarRect.contains(localPoint)) { | 1153 if (vBarRect.contains(localPoint)) { |
| 1198 result.setScrollbar(m_vBar.get()); | 1154 result.setScrollbar(verticalScrollbar()); |
| 1199 return true; | 1155 return true; |
| 1200 } | 1156 } |
| 1201 } | 1157 } |
| 1202 | 1158 |
| 1203 resizeControlSize = max(resizeControlRect.width(), 0); | 1159 resizeControlSize = max(resizeControlRect.width(), 0); |
| 1204 if (m_hBar && m_hBar->shouldParticipateInHitTesting()) { | 1160 if (hasHorizontalScrollbar() && horizontalScrollbar()->shouldParticipateInHi tTesting()) { |
| 1205 LayoutRect hBarRect(horizontalScrollbarStart(0), | 1161 LayoutRect hBarRect(horizontalScrollbarStart(0), |
| 1206 box().size().height() - box().borderBottom() - m_hBar->height(), | 1162 box().size().height() - box().borderBottom() - horizontalScrollbar() ->height(), |
| 1207 box().size().width() - (box().borderLeft() + box().borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize), | 1163 box().size().width() - (box().borderLeft() + box().borderRight()) - (hasVerticalScrollbar() ? verticalScrollbar()->width() : resizeControlSize), |
| 1208 m_hBar->height()); | 1164 horizontalScrollbar()->height()); |
| 1209 if (hBarRect.contains(localPoint)) { | 1165 if (hBarRect.contains(localPoint)) { |
| 1210 result.setScrollbar(m_hBar.get()); | 1166 result.setScrollbar(horizontalScrollbar()); |
| 1211 return true; | 1167 return true; |
| 1212 } | 1168 } |
| 1213 } | 1169 } |
| 1214 | 1170 |
| 1215 // FIXME: We should hit test the m_scrollCorner and pass it back through the result. | 1171 // FIXME: We should hit test the m_scrollCorner and pass it back through the result. |
| 1216 | 1172 |
| 1217 return false; | 1173 return false; |
| 1218 } | 1174 } |
| 1219 | 1175 |
| 1220 IntRect DeprecatedPaintLayerScrollableArea::resizerCornerRect(const IntRect& bou nds, ResizerHitTestType resizerHitTestType) const | 1176 IntRect DeprecatedPaintLayerScrollableArea::resizerCornerRect(const IntRect& bou nds, ResizerHitTestType resizerHitTestType) const |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1501 if (!layer()->isRootLayer()) | 1457 if (!layer()->isRootLayer()) |
| 1502 return false; | 1458 return false; |
| 1503 | 1459 |
| 1504 LocalFrame* frame = box().frame(); | 1460 LocalFrame* frame = box().frame(); |
| 1505 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1461 if (!frame || !frame->isMainFrame() || !frame->settings()) |
| 1506 return false; | 1462 return false; |
| 1507 | 1463 |
| 1508 return frame->settings()->viewportMetaEnabled(); | 1464 return frame->settings()->viewportMetaEnabled(); |
| 1509 } | 1465 } |
| 1510 | 1466 |
| 1467 DeprecatedPaintLayerScrollableArea::ScrollbarManager::ScrollbarManager(Deprecate dPaintLayerScrollableArea& scrollableArea) | |
| 1468 : m_scrollableArea(scrollableArea) | |
| 1469 , m_canDetachScrollbars(0) | |
| 1470 , m_hBarIsAttached(0) | |
| 1471 , m_vBarIsAttached(0) | |
| 1472 { | |
| 1473 } | |
| 1474 | |
| 1475 void DeprecatedPaintLayerScrollableArea::ScrollbarManager::dispose() | |
| 1476 { | |
| 1477 m_canDetachScrollbars = m_hBarIsAttached = m_vBarIsAttached = 0; | |
| 1478 destroyScrollbar(HorizontalScrollbar); | |
| 1479 destroyScrollbar(VerticalScrollbar); | |
| 1480 } | |
| 1481 | |
| 1482 void DeprecatedPaintLayerScrollableArea::ScrollbarManager::setCanDetachScrollbar s(bool detach) | |
| 1483 { | |
| 1484 ASSERT(!m_hBarIsAttached || m_hBar); | |
| 1485 ASSERT(!m_vBarIsAttached || m_vBar); | |
| 1486 m_canDetachScrollbars = detach ? 1 : 0; | |
| 1487 if (!detach) { | |
| 1488 if (m_hBar && !m_hBarIsAttached) | |
| 1489 destroyScrollbar(HorizontalScrollbar, true); | |
| 1490 if (m_vBar && !m_vBarIsAttached) | |
| 1491 destroyScrollbar(VerticalScrollbar, true); | |
| 1492 } | |
| 1493 } | |
| 1494 | |
| 1495 void DeprecatedPaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrol lbar(bool hasScrollbar) | |
| 1496 { | |
| 1497 if (hasScrollbar) { | |
| 1498 // This doesn't hit in any tests, but since the equivalent code in setHa sVerticalScrollbar | |
| 1499 // does, presumably this code does as well. | |
| 1500 DisableCompositingQueryAsserts disabler; | |
| 1501 if (!m_hBar) | |
| 1502 m_hBar = createScrollbar(HorizontalScrollbar); | |
| 1503 m_hBarIsAttached = 1; | |
| 1504 } else { | |
| 1505 m_hBarIsAttached = 0; | |
| 1506 if (!m_canDetachScrollbars) | |
| 1507 destroyScrollbar(HorizontalScrollbar); | |
| 1508 } | |
| 1509 } | |
| 1510 | |
| 1511 void DeprecatedPaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollb ar(bool hasScrollbar) | |
| 1512 { | |
| 1513 if (hasScrollbar) { | |
| 1514 DisableCompositingQueryAsserts disabler; | |
| 1515 if (!m_vBar) | |
| 1516 m_vBar = createScrollbar(VerticalScrollbar); | |
| 1517 m_vBarIsAttached = 1; | |
| 1518 } else { | |
| 1519 m_vBarIsAttached = 0; | |
| 1520 if (!m_canDetachScrollbars) | |
| 1521 destroyScrollbar(VerticalScrollbar); | |
| 1522 } | |
| 1523 } | |
| 1524 | |
| 1525 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::ScrollbarM anager::createScrollbar(ScrollbarOrientation orientation) | |
| 1526 { | |
| 1527 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached : !m_vBarIsAtt ached); | |
| 1528 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | |
| 1529 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(m_scrollableArea .box()); | |
| 1530 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); | |
| 1531 if (hasCustomScrollbarStyle) { | |
| 1532 widget = LayoutScrollbar::createCustomScrollbar(&m_scrollableArea, orien tation, actualLayoutObject->node()); | |
| 1533 } else { | |
| 1534 ScrollbarControlSize scrollbarSize = RegularScrollbar; | |
| 1535 if (actualLayoutObject->style()->hasAppearance()) | |
| 1536 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act ualLayoutObject->style()->appearance()); | |
| 1537 widget = Scrollbar::create(&m_scrollableArea, orientation, scrollbarSize ); | |
| 1538 if (orientation == HorizontalScrollbar) | |
| 1539 m_scrollableArea.didAddScrollbar(widget.get(), HorizontalScrollbar); | |
| 1540 else | |
| 1541 m_scrollableArea.didAddScrollbar(widget.get(), VerticalScrollbar); | |
| 1542 } | |
| 1543 m_scrollableArea.box().document().view()->addChild(widget.get()); | |
| 1544 return widget.release(); | |
| 1545 } | |
| 1546 | |
| 1547 void DeprecatedPaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(Scro llbarOrientation orientation, bool invalidate) | |
| 1548 { | |
| 1549 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba r ? m_hBar : m_vBar; | |
| 1550 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAtta ched); | |
| 1551 if (!scrollbar) | |
| 1552 return; | |
| 1553 | |
| 1554 if (invalidate) | |
| 1555 scrollbar->invalidate(); | |
| 1556 if (!scrollbar->isCustomScrollbar()) | |
| 1557 m_scrollableArea.willRemoveScrollbar(scrollbar.get(), orientation); | |
| 1558 | |
| 1559 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); | |
| 1560 scrollbar->disconnectFromScrollableArea(); | |
| 1561 scrollbar = nullptr; | |
| 1562 } | |
| 1563 | |
| 1564 DEFINE_TRACE(DeprecatedPaintLayerScrollableArea::ScrollbarManager) | |
| 1565 { | |
| 1566 visitor->trace(m_hBar); | |
| 1567 visitor->trace(m_vBar); | |
| 1568 } | |
| 1569 | |
| 1511 } // namespace blink | 1570 } // namespace blink |
| OLD | NEW |