| 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 void DeprecatedPaintLayerScrollableArea::scrollToOffset(const DoubleSize& scroll
Offset, ScrollOffsetClamping clamp, ScrollBehavior scrollBehavior) | 643 void DeprecatedPaintLayerScrollableArea::scrollToOffset(const DoubleSize& scroll
Offset, ScrollOffsetClamping clamp, ScrollBehavior scrollBehavior) |
| 644 { | 644 { |
| 645 cancelProgrammaticScrollAnimation(); | 645 cancelProgrammaticScrollAnimation(); |
| 646 DoubleSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffse
t(scrollOffset) : scrollOffset; | 646 DoubleSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffse
t(scrollOffset) : scrollOffset; |
| 647 if (newScrollOffset != adjustedScrollOffset()) { | 647 if (newScrollOffset != adjustedScrollOffset()) { |
| 648 DoublePoint origin(scrollOrigin()); | 648 DoublePoint origin(scrollOrigin()); |
| 649 ScrollableArea::setScrollPosition(-origin + newScrollOffset, Programmati
cScroll, scrollBehavior); | 649 ScrollableArea::setScrollPosition(-origin + newScrollOffset, Programmati
cScroll, scrollBehavior); |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 void DeprecatedPaintLayerScrollableArea::updateAfterLayout() | 653 void DeprecatedPaintLayerScrollableArea::updateScrollDimensions(DoubleSize& scro
llOffset, bool& autoHorizontalScrollBarChanged, bool& autoVerticalScrollBarChang
ed) |
| 654 { | 654 { |
| 655 ASSERT(box().hasOverflowClip()); | 655 ASSERT(box().hasOverflowClip()); |
| 656 | 656 |
| 657 if (needsScrollbarReconstruction()) { | 657 if (needsScrollbarReconstruction()) { |
| 658 if (m_hBar) | 658 if (m_hBar) |
| 659 destroyScrollbar(HorizontalScrollbar); | 659 destroyScrollbar(HorizontalScrollbar); |
| 660 if (m_vBar) | 660 if (m_vBar) |
| 661 destroyScrollbar(VerticalScrollbar); | 661 destroyScrollbar(VerticalScrollbar); |
| 662 } | 662 } |
| 663 | 663 |
| 664 DoubleSize originalScrollOffset = adjustedScrollOffset(); | 664 scrollOffset = adjustedScrollOffset(); |
| 665 computeScrollDimensions(); | 665 computeScrollDimensions(); |
| 666 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 667 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 668 if (hasOverlayScrollbars()) { |
| 669 if (!scrollSize(HorizontalScrollbar)) |
| 670 setHasHorizontalScrollbar(false); |
| 671 if (!scrollSize(VerticalScrollbar)) |
| 672 setHasVerticalScrollbar(false); |
| 673 } |
| 674 |
| 675 // overflow:auto may need to lay out again if scrollbars got added/removed. |
| 676 autoHorizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (has
HorizontalScrollbar() != hasHorizontalOverflow)) || (box().style()->overflowX()
== OSCROLL && !horizontalScrollbar()); |
| 677 autoVerticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVert
icalScrollbar() != hasVerticalOverflow)) || (box().style()->overflowY() == OSCRO
LL && !verticalScrollbar()); |
| 678 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged |
| autoVerticalScrollBarChanged)) { |
| 679 if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() ==
OSCROLL && !horizontalScrollbar())) |
| 680 setHasHorizontalScrollbar(box().style()->overflowX() == OSCROLL ? tr
ue : hasHorizontalOverflow); |
| 681 if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == O
SCROLL && !verticalScrollbar())) |
| 682 setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true
: hasVerticalOverflow); |
| 683 } |
| 684 } |
| 685 |
| 686 void DeprecatedPaintLayerScrollableArea::finalizeScrollDimensions(const DoubleSi
ze& originalScrollOffset, bool autoHorizontalScrollBarChanged, bool autoVertical
ScrollBarChanged) |
| 687 { |
| 688 ASSERT(box().hasOverflowClip()); |
| 666 | 689 |
| 667 // Layout may cause us to be at an invalid scroll position. In this case we
need | 690 // Layout may cause us to be at an invalid scroll position. In this case we
need |
| 668 // to pull our scroll offsets back to the max (or push them up to the min). | 691 // to pull our scroll offsets back to the max (or push them up to the min). |
| 669 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); | 692 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); |
| 670 if (clampedScrollOffset != adjustedScrollOffset()) | 693 if (clampedScrollOffset != adjustedScrollOffset()) |
| 671 scrollToOffset(clampedScrollOffset); | 694 scrollToOffset(clampedScrollOffset); |
| 672 | 695 |
| 673 if (originalScrollOffset != adjustedScrollOffset()) { | 696 if (originalScrollOffset != adjustedScrollOffset()) { |
| 674 DoublePoint origin(scrollOrigin()); | 697 DoublePoint origin(scrollOrigin()); |
| 675 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro
ll); | 698 scrollPositionChanged(-origin + adjustedScrollOffset(), ProgrammaticScro
ll); |
| 676 } | 699 } |
| 677 | 700 |
| 678 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 701 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 679 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 702 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 680 | 703 |
| 681 { | 704 { |
| 682 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. | 705 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. |
| 683 DisableCompositingQueryAsserts disabler; | 706 DisableCompositingQueryAsserts disabler; |
| 684 | 707 |
| 685 // overflow:scroll should just enable/disable. | 708 // overflow:scroll should just enable/disable. |
| 686 if (box().style()->overflowX() == OSCROLL && horizontalScrollbar()) | 709 if (box().style()->overflowX() == OSCROLL && horizontalScrollbar()) |
| 687 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); | 710 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); |
| 688 if (box().style()->overflowY() == OSCROLL && verticalScrollbar()) | 711 if (box().style()->overflowY() == OSCROLL && verticalScrollbar()) |
| 689 verticalScrollbar()->setEnabled(hasVerticalOverflow); | 712 verticalScrollbar()->setEnabled(hasVerticalOverflow); |
| 690 } | 713 } |
| 691 | 714 |
| 692 // We need to layout again if scrollbars are added or removed by overflow:au
to, | 715 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged |
| autoVerticalScrollBarChanged)) { |
| 693 // or by changing between native and custom. | |
| 694 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha
sHorizontalScrollbar() != hasHorizontalOverflow)) | |
| 695 || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); | |
| 696 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer
ticalScrollbar() != hasVerticalOverflow)) | |
| 697 || (box().style()->overflowY() == OSCROLL && !verticalScrollbar()); | |
| 698 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve
rticalScrollBarChanged)) { | |
| 699 if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() ==
OSCROLL && !horizontalScrollbar())) | |
| 700 setHasHorizontalScrollbar(box().style()->overflowX() == OSCROLL ? tr
ue : hasHorizontalOverflow); | |
| 701 if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == O
SCROLL && !verticalScrollbar())) | |
| 702 setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true
: hasVerticalOverflow); | |
| 703 | |
| 704 if (hasVerticalOverflow || hasHorizontalOverflow) | 716 if (hasVerticalOverflow || hasHorizontalOverflow) |
| 705 updateScrollCornerStyle(); | 717 updateScrollCornerStyle(); |
| 706 | 718 |
| 707 layer()->updateSelfPaintingLayer(); | 719 layer()->updateSelfPaintingLayer(); |
| 708 | 720 |
| 709 // Force an update since we know the scrollbars have changed things. | 721 // Force an update since we know the scrollbars have changed things. |
| 710 if (box().document().hasAnnotatedRegions()) | 722 if (box().document().hasAnnotatedRegions()) |
| 711 box().document().setAnnotatedRegionsDirty(true); | 723 box().document().setAnnotatedRegionsDirty(true); |
| 712 | 724 |
| 713 // Our proprietary overflow: overlay value doesn't trigger a layout. | 725 // Our proprietary overflow: overlay value doesn't trigger a layout. |
| 714 if ((horizontalScrollBarChanged && box().style()->overflowX() != OOVERLA
Y) || (verticalScrollBarChanged && box().style()->overflowY() != OOVERLAY)) { | 726 if ((autoHorizontalScrollBarChanged && box().style()->overflowX() != OOV
ERLAY) || (autoVerticalScrollBarChanged && box().style()->overflowY() != OOVERLA
Y)) { |
| 715 if (!m_inOverflowRelayout) { | 727 if (!m_inOverflowRelayout) { |
| 716 m_inOverflowRelayout = true; | 728 m_inOverflowRelayout = true; |
| 717 SubtreeLayoutScope layoutScope(box()); | 729 SubtreeLayoutScope layoutScope(box()); |
| 718 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr
ollbarChanged); | 730 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr
ollbarChanged); |
| 719 if (box().isLayoutBlock()) { | 731 if (box().isLayoutBlock()) { |
| 720 LayoutBlock& block = toLayoutBlock(box()); | 732 LayoutBlock& block = toLayoutBlock(box()); |
| 721 block.scrollbarsChanged(horizontalScrollBarChanged, vertical
ScrollBarChanged); | 733 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto
VerticalScrollBarChanged); |
| 722 block.layoutBlock(true); | 734 block.layoutBlock(true); |
| 723 } else { | 735 } else { |
| 724 box().layout(); | 736 box().layout(); |
| 725 } | 737 } |
| 726 m_inOverflowRelayout = false; | 738 m_inOverflowRelayout = false; |
| 727 } | 739 } |
| 728 } | 740 } |
| 729 } | 741 } |
| 730 | 742 |
| 731 { | 743 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 750 setHasVerticalScrollbar(false); | 762 setHasVerticalScrollbar(false); |
| 751 } | 763 } |
| 752 | 764 |
| 753 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica
lOverflow(); | 765 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica
lOverflow(); |
| 754 updateScrollableAreaSet(hasOverflow); | 766 updateScrollableAreaSet(hasOverflow); |
| 755 | 767 |
| 756 DisableCompositingQueryAsserts disabler; | 768 DisableCompositingQueryAsserts disabler; |
| 757 positionOverflowControls(); | 769 positionOverflowControls(); |
| 758 } | 770 } |
| 759 | 771 |
| 772 void DeprecatedPaintLayerScrollableArea::updateAfterLayout() |
| 773 { |
| 774 DoubleSize originalScrollOffset; |
| 775 bool autoHorizontalScrollBarChanged; |
| 776 bool autoVerticalScrollBarChanged; |
| 777 updateScrollDimensions(originalScrollOffset, autoHorizontalScrollBarChanged,
autoVerticalScrollBarChanged); |
| 778 finalizeScrollDimensions(originalScrollOffset, autoHorizontalScrollBarChange
d, autoVerticalScrollBarChanged); |
| 779 } |
| 780 |
| 760 ScrollBehavior DeprecatedPaintLayerScrollableArea::scrollBehaviorStyle() const | 781 ScrollBehavior DeprecatedPaintLayerScrollableArea::scrollBehaviorStyle() const |
| 761 { | 782 { |
| 762 return box().style()->scrollBehavior(); | 783 return box().style()->scrollBehavior(); |
| 763 } | 784 } |
| 764 | 785 |
| 765 bool DeprecatedPaintLayerScrollableArea::hasHorizontalOverflow() const | 786 bool DeprecatedPaintLayerScrollableArea::hasHorizontalOverflow() const |
| 766 { | 787 { |
| 767 return pixelSnappedScrollWidth() > box().pixelSnappedClientWidth(); | 788 return pixelSnappedScrollWidth() > box().pixelSnappedClientWidth(); |
| 768 } | 789 } |
| 769 | 790 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 return false; | 1500 return false; |
| 1480 | 1501 |
| 1481 LocalFrame* frame = box().frame(); | 1502 LocalFrame* frame = box().frame(); |
| 1482 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1503 if (!frame || !frame->isMainFrame() || !frame->settings()) |
| 1483 return false; | 1504 return false; |
| 1484 | 1505 |
| 1485 return frame->settings()->viewportMetaEnabled(); | 1506 return frame->settings()->viewportMetaEnabled(); |
| 1486 } | 1507 } |
| 1487 | 1508 |
| 1488 } // namespace blink | 1509 } // namespace blink |
| OLD | NEW |