| 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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 if (newScrollOffset != adjustedScrollOffset()) { | 639 if (newScrollOffset != adjustedScrollOffset()) { |
| 640 DoublePoint origin(scrollOrigin()); | 640 DoublePoint origin(scrollOrigin()); |
| 641 ScrollableArea::setScrollPosition(-origin + newScrollOffset, Programmati
cScroll, scrollBehavior); | 641 ScrollableArea::setScrollPosition(-origin + newScrollOffset, Programmati
cScroll, scrollBehavior); |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 | 644 |
| 645 void DeprecatedPaintLayerScrollableArea::updateAfterLayout() | 645 void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
| 646 { | 646 { |
| 647 ASSERT(box().hasOverflowClip()); | 647 ASSERT(box().hasOverflowClip()); |
| 648 | 648 |
| 649 if (needsScrollbarReconstruction()) { |
| 650 if (m_hBar) |
| 651 destroyScrollbar(HorizontalScrollbar); |
| 652 if (m_vBar) |
| 653 destroyScrollbar(VerticalScrollbar); |
| 654 } |
| 655 |
| 649 DoubleSize originalScrollOffset = adjustedScrollOffset(); | 656 DoubleSize originalScrollOffset = adjustedScrollOffset(); |
| 650 computeScrollDimensions(); | 657 computeScrollDimensions(); |
| 651 | 658 |
| 652 // Layout may cause us to be at an invalid scroll position. In this case we
need | 659 // Layout may cause us to be at an invalid scroll position. In this case we
need |
| 653 // to pull our scroll offsets back to the max (or push them up to the min). | 660 // to pull our scroll offsets back to the max (or push them up to the min). |
| 654 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); | 661 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); |
| 655 if (clampedScrollOffset != adjustedScrollOffset()) | 662 if (clampedScrollOffset != adjustedScrollOffset()) |
| 656 scrollToOffset(clampedScrollOffset); | 663 scrollToOffset(clampedScrollOffset); |
| 657 | 664 |
| 658 if (originalScrollOffset != adjustedScrollOffset()) { | 665 if (originalScrollOffset != adjustedScrollOffset()) { |
| 659 DoublePoint origin(scrollOrigin()); | 666 DoublePoint origin(scrollOrigin()); |
| 660 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro
ll); | 667 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro
ll); |
| 661 } | 668 } |
| 662 | 669 |
| 663 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 670 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 664 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 671 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 665 | 672 |
| 666 { | 673 { |
| 667 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. | 674 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. |
| 668 DisableCompositingQueryAsserts disabler; | 675 DisableCompositingQueryAsserts disabler; |
| 669 | 676 |
| 670 // overflow:scroll should just enable/disable. | 677 // overflow:scroll should just enable/disable. |
| 671 if (box().style()->overflowX() == OSCROLL && horizontalScrollbar()) | 678 if (box().style()->overflowX() == OSCROLL && horizontalScrollbar()) |
| 672 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); | 679 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); |
| 673 if (box().style()->overflowY() == OSCROLL && verticalScrollbar()) | 680 if (box().style()->overflowY() == OSCROLL && verticalScrollbar()) |
| 674 verticalScrollbar()->setEnabled(hasVerticalOverflow); | 681 verticalScrollbar()->setEnabled(hasVerticalOverflow); |
| 675 } | 682 } |
| 676 if (hasOverlayScrollbars()) { | |
| 677 if (!scrollSize(HorizontalScrollbar)) | |
| 678 setHasHorizontalScrollbar(false); | |
| 679 if (!scrollSize(VerticalScrollbar)) | |
| 680 setHasVerticalScrollbar(false); | |
| 681 } | |
| 682 // overflow:auto may need to lay out again if scrollbars got added/removed. | |
| 683 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() &&
(hasHorizontalScrollbar() != hasHorizontalOverflow); | |
| 684 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has
VerticalScrollbar() != hasVerticalOverflow); | |
| 685 | 683 |
| 686 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged |
| autoVerticalScrollBarChanged)) { | 684 // We need to layout again if scrollbars are added or removed by overflow:au
to, |
| 687 if (box().hasAutoHorizontalScrollbar()) | 685 // or by changing between native and custom. |
| 688 setHasHorizontalScrollbar(hasHorizontalOverflow); | 686 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha
sHorizontalScrollbar() != hasHorizontalOverflow)) |
| 689 if (box().hasAutoVerticalScrollbar()) | 687 || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); |
| 690 setHasVerticalScrollbar(hasVerticalOverflow); | 688 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer
ticalScrollbar() != hasVerticalOverflow)) |
| 689 || (box().style()->overflowY() == OSCROLL && !verticalScrollbar()); |
| 690 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve
rticalScrollBarChanged)) { |
| 691 if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() ==
OSCROLL && !horizontalScrollbar())) |
| 692 setHasHorizontalScrollbar(box().style()->overflowX() == OSCROLL ? tr
ue : hasHorizontalOverflow); |
| 693 if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == O
SCROLL && !verticalScrollbar())) |
| 694 setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true
: hasVerticalOverflow); |
| 691 | 695 |
| 692 if (hasVerticalOverflow || hasHorizontalOverflow) | 696 if (hasVerticalOverflow || hasHorizontalOverflow) |
| 693 updateScrollCornerStyle(); | 697 updateScrollCornerStyle(); |
| 694 | 698 |
| 695 layer()->updateSelfPaintingLayer(); | 699 layer()->updateSelfPaintingLayer(); |
| 696 | 700 |
| 697 // Force an update since we know the scrollbars have changed things. | 701 // Force an update since we know the scrollbars have changed things. |
| 698 if (box().document().hasAnnotatedRegions()) | 702 if (box().document().hasAnnotatedRegions()) |
| 699 box().document().setAnnotatedRegionsDirty(true); | 703 box().document().setAnnotatedRegionsDirty(true); |
| 700 | 704 |
| 701 if (box().style()->overflowX() == OAUTO || box().style()->overflowY() ==
OAUTO) { | 705 // Our proprietary overflow: overlay value doesn't trigger a layout. |
| 706 if ((horizontalScrollBarChanged && box().style()->overflowX() != OOVERLA
Y) || (verticalScrollBarChanged && box().style()->overflowY() != OOVERLAY)) { |
| 702 if (!m_inOverflowRelayout) { | 707 if (!m_inOverflowRelayout) { |
| 703 // Our proprietary overflow: overlay value doesn't trigger a lay
out. | |
| 704 m_inOverflowRelayout = true; | 708 m_inOverflowRelayout = true; |
| 705 SubtreeLayoutScope layoutScope(box()); | 709 SubtreeLayoutScope layoutScope(box()); |
| 706 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr
ollbarChanged); | 710 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr
ollbarChanged); |
| 707 if (box().isLayoutBlock()) { | 711 if (box().isLayoutBlock()) { |
| 708 LayoutBlock& block = toLayoutBlock(box()); | 712 LayoutBlock& block = toLayoutBlock(box()); |
| 709 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto
VerticalScrollBarChanged); | 713 block.scrollbarsChanged(horizontalScrollBarChanged, vertical
ScrollBarChanged); |
| 710 block.layoutBlock(true); | 714 block.layoutBlock(true); |
| 711 } else { | 715 } else { |
| 712 box().layout(); | 716 box().layout(); |
| 713 } | 717 } |
| 714 m_inOverflowRelayout = false; | 718 m_inOverflowRelayout = false; |
| 715 } | 719 } |
| 716 } | 720 } |
| 717 } | 721 } |
| 718 | 722 |
| 719 { | 723 { |
| 720 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. | 724 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. |
| 721 DisableCompositingQueryAsserts disabler; | 725 DisableCompositingQueryAsserts disabler; |
| 722 | 726 |
| 723 // Set up the range (and page step/line step). | 727 // Set up the range (and page step/line step). |
| 724 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 728 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
| 725 int clientWidth = box().pixelSnappedClientWidth(); | 729 int clientWidth = box().pixelSnappedClientWidth(); |
| 726 horizontalScrollbar->setProportion(clientWidth, overflowRect().width
()); | 730 horizontalScrollbar->setProportion(clientWidth, overflowRect().width
()); |
| 727 } | 731 } |
| 728 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { | 732 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { |
| 729 int clientHeight = box().pixelSnappedClientHeight(); | 733 int clientHeight = box().pixelSnappedClientHeight(); |
| 730 verticalScrollbar->setProportion(clientHeight, overflowRect().height
()); | 734 verticalScrollbar->setProportion(clientHeight, overflowRect().height
()); |
| 731 } | 735 } |
| 732 } | 736 } |
| 733 | 737 |
| 738 if (hasOverlayScrollbars()) { |
| 739 if (!scrollSize(HorizontalScrollbar)) |
| 740 setHasHorizontalScrollbar(false); |
| 741 if (!scrollSize(VerticalScrollbar)) |
| 742 setHasVerticalScrollbar(false); |
| 743 } |
| 744 |
| 734 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica
lOverflow(); | 745 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica
lOverflow(); |
| 735 updateScrollableAreaSet(hasOverflow); | 746 updateScrollableAreaSet(hasOverflow); |
| 736 | 747 |
| 737 DisableCompositingQueryAsserts disabler; | 748 DisableCompositingQueryAsserts disabler; |
| 738 positionOverflowControls(); | 749 positionOverflowControls(); |
| 739 } | 750 } |
| 740 | 751 |
| 741 ScrollBehavior DeprecatedPaintLayerScrollableArea::scrollBehaviorStyle() const | 752 ScrollBehavior DeprecatedPaintLayerScrollableArea::scrollBehaviorStyle() const |
| 742 { | 753 { |
| 743 return box().style()->scrollBehavior(); | 754 return box().style()->scrollBehavior(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 } | 962 } |
| 952 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { | 963 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
| 953 if (shadowRoot->type() == ShadowRootType::UserAgent) | 964 if (shadowRoot->type() == ShadowRootType::UserAgent) |
| 954 return shadowRoot->host()->layoutObject(); | 965 return shadowRoot->host()->layoutObject(); |
| 955 } | 966 } |
| 956 } | 967 } |
| 957 | 968 |
| 958 return &layoutObject; | 969 return &layoutObject; |
| 959 } | 970 } |
| 960 | 971 |
| 972 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const |
| 973 { |
| 974 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
| 975 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st
yle()->hasPseudoStyle(SCROLLBAR); |
| 976 bool hasAnyScrollbar = hasScrollbar(); |
| 977 bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBa
r->isCustomScrollbar()); |
| 978 return hasAnyScrollbar && (shouldUseCustom != hasCustom); |
| 979 } |
| 980 |
| 961 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro
llbar(ScrollbarOrientation orientation) | 981 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro
llbar(ScrollbarOrientation orientation) |
| 962 { | 982 { |
| 963 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | 983 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |
| 964 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | 984 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
| 965 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb
ject->style()->hasPseudoStyle(SCROLLBAR); | 985 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb
ject->style()->hasPseudoStyle(SCROLLBAR); |
| 966 if (hasCustomScrollbarStyle) { | 986 if (hasCustomScrollbarStyle) { |
| 967 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua
lLayoutObject->node()); | 987 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua
lLayoutObject->node()); |
| 968 } else { | 988 } else { |
| 969 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 989 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
| 970 if (actualLayoutObject->style()->hasAppearance()) | 990 if (actualLayoutObject->style()->hasAppearance()) |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 return false; | 1471 return false; |
| 1452 | 1472 |
| 1453 LocalFrame* frame = box().frame(); | 1473 LocalFrame* frame = box().frame(); |
| 1454 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1474 if (!frame || !frame->isMainFrame() || !frame->settings()) |
| 1455 return false; | 1475 return false; |
| 1456 | 1476 |
| 1457 return frame->settings()->viewportMetaEnabled(); | 1477 return frame->settings()->viewportMetaEnabled(); |
| 1458 } | 1478 } |
| 1459 | 1479 |
| 1460 } // namespace blink | 1480 } // namespace blink |
| OLD | NEW |