| 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@gmail.com> | 9 * Christian Biesinger <cbiesinger@gmail.com> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 | 535 |
| 536 bool PaintLayerScrollableArea::userInputScrollable(ScrollbarOrientation orientat
ion) const | 536 bool PaintLayerScrollableArea::userInputScrollable(ScrollbarOrientation orientat
ion) const |
| 537 { | 537 { |
| 538 if (box().isIntrinsicallyScrollable(orientation)) | 538 if (box().isIntrinsicallyScrollable(orientation)) |
| 539 return true; | 539 return true; |
| 540 | 540 |
| 541 EOverflow overflowStyle = (orientation == HorizontalScrollbar) ? | 541 EOverflow overflowStyle = (orientation == HorizontalScrollbar) ? |
| 542 box().style()->overflowX() : box().style()->overflowY(); | 542 box().style()->overflowX() : box().style()->overflowY(); |
| 543 return (overflowStyle == OSCROLL || overflowStyle == OAUTO || overflowStyle
== OOVERLAY); | 543 return (overflowStyle == OverflowScroll || overflowStyle == OverflowAuto ||
overflowStyle == OverflowOverlay); |
| 544 } | 544 } |
| 545 | 545 |
| 546 bool PaintLayerScrollableArea::shouldPlaceVerticalScrollbarOnLeft() const | 546 bool PaintLayerScrollableArea::shouldPlaceVerticalScrollbarOnLeft() const |
| 547 { | 547 { |
| 548 return box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft(); | 548 return box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft(); |
| 549 } | 549 } |
| 550 | 550 |
| 551 int PaintLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const | 551 int PaintLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const |
| 552 { | 552 { |
| 553 int length = (orientation == HorizontalScrollbar) ? | 553 int length = (orientation == HorizontalScrollbar) ? |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 m_scrollbarManager.setCanDetachScrollbars(false); | 638 m_scrollbarManager.setCanDetachScrollbars(false); |
| 639 | 639 |
| 640 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 640 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 641 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 641 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 642 | 642 |
| 643 { | 643 { |
| 644 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. | 644 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. |
| 645 DisableCompositingQueryAsserts disabler; | 645 DisableCompositingQueryAsserts disabler; |
| 646 | 646 |
| 647 // overflow:scroll should just enable/disable. | 647 // overflow:scroll should just enable/disable. |
| 648 if (box().style()->overflowX() == OSCROLL && horizontalScrollbar()) | 648 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar(
)) |
| 649 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); | 649 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); |
| 650 if (box().style()->overflowY() == OSCROLL && verticalScrollbar()) | 650 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) |
| 651 verticalScrollbar()->setEnabled(hasVerticalOverflow); | 651 verticalScrollbar()->setEnabled(hasVerticalOverflow); |
| 652 } | 652 } |
| 653 | 653 |
| 654 // We need to layout again if scrollbars are added or removed by overflow:au
to, | 654 // We need to layout again if scrollbars are added or removed by overflow:au
to, |
| 655 // or by changing between native and custom. | 655 // or by changing between native and custom. |
| 656 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha
sHorizontalScrollbar() != hasHorizontalOverflow)) | 656 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha
sHorizontalScrollbar() != hasHorizontalOverflow)) |
| 657 || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); | 657 || (box().style()->overflowX() == OverflowScroll && !horizontalScrollbar
()); |
| 658 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer
ticalScrollbar() != hasVerticalOverflow)) | 658 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer
ticalScrollbar() != hasVerticalOverflow)) |
| 659 || (box().style()->overflowY() == OSCROLL && !verticalScrollbar()); | 659 || (box().style()->overflowY() == OverflowScroll && !verticalScrollbar()
); |
| 660 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve
rticalScrollBarChanged)) { | 660 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve
rticalScrollBarChanged)) { |
| 661 if (box().hasAutoHorizontalScrollbar()) | 661 if (box().hasAutoHorizontalScrollbar()) |
| 662 setHasHorizontalScrollbar(hasHorizontalOverflow); | 662 setHasHorizontalScrollbar(hasHorizontalOverflow); |
| 663 else if (box().style()->overflowX() == OSCROLL) | 663 else if (box().style()->overflowX() == OverflowScroll) |
| 664 setHasHorizontalScrollbar(true); | 664 setHasHorizontalScrollbar(true); |
| 665 if (box().hasAutoVerticalScrollbar()) | 665 if (box().hasAutoVerticalScrollbar()) |
| 666 setHasVerticalScrollbar(hasVerticalOverflow); | 666 setHasVerticalScrollbar(hasVerticalOverflow); |
| 667 else if (box().style()->overflowY() == OSCROLL) | 667 else if (box().style()->overflowY() == OverflowScroll) |
| 668 setHasVerticalScrollbar(true); | 668 setHasVerticalScrollbar(true); |
| 669 | 669 |
| 670 if (hasVerticalOverflow || hasHorizontalOverflow) | 670 if (hasVerticalOverflow || hasHorizontalOverflow) |
| 671 updateScrollCornerStyle(); | 671 updateScrollCornerStyle(); |
| 672 | 672 |
| 673 layer()->updateSelfPaintingLayer(); | 673 layer()->updateSelfPaintingLayer(); |
| 674 | 674 |
| 675 // Force an update since we know the scrollbars have changed things. | 675 // Force an update since we know the scrollbars have changed things. |
| 676 if (box().document().hasAnnotatedRegions()) | 676 if (box().document().hasAnnotatedRegions()) |
| 677 box().document().setAnnotatedRegionsDirty(true); | 677 box().document().setAnnotatedRegionsDirty(true); |
| 678 | 678 |
| 679 // Our proprietary overflow: overlay value doesn't trigger a layout. | 679 // Our proprietary overflow: overlay value doesn't trigger a layout. |
| 680 if ((horizontalScrollBarChanged && box().style()->overflowX() != OOVERLA
Y) || (verticalScrollBarChanged && box().style()->overflowY() != OOVERLAY)) { | 680 if ((horizontalScrollBarChanged && box().style()->overflowX() != Overflo
wOverlay) || (verticalScrollBarChanged && box().style()->overflowY() != Overflow
Overlay)) { |
| 681 if (!m_inOverflowRelayout) { | 681 if (!m_inOverflowRelayout) { |
| 682 m_inOverflowRelayout = true; | 682 m_inOverflowRelayout = true; |
| 683 if (delayedLayoutScope) { | 683 if (delayedLayoutScope) { |
| 684 delayedLayoutScope->setNeedsLayout(&box(), LayoutInvalidatio
nReason::ScrollbarChanged); | 684 delayedLayoutScope->setNeedsLayout(&box(), LayoutInvalidatio
nReason::ScrollbarChanged); |
| 685 didMarkForDelayedLayout = true; | 685 didMarkForDelayedLayout = true; |
| 686 } else { | 686 } else { |
| 687 SubtreeLayoutScope layoutScope(box()); | 687 SubtreeLayoutScope layoutScope(box()); |
| 688 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason:
:ScrollbarChanged); | 688 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason:
:ScrollbarChanged); |
| 689 if (box().isLayoutBlock()) { | 689 if (box().isLayoutBlock()) { |
| 690 LayoutBlock& block = toLayoutBlock(box()); | 690 LayoutBlock& block = toLayoutBlock(box()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 return hasHorizontalOverflow() && box().scrollsOverflowX(); | 753 return hasHorizontalOverflow() && box().scrollsOverflowX(); |
| 754 } | 754 } |
| 755 | 755 |
| 756 bool PaintLayerScrollableArea::hasScrollableVerticalOverflow() const | 756 bool PaintLayerScrollableArea::hasScrollableVerticalOverflow() const |
| 757 { | 757 { |
| 758 return hasVerticalOverflow() && box().scrollsOverflowY(); | 758 return hasVerticalOverflow() && box().scrollsOverflowY(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 static bool overflowRequiresScrollbar(EOverflow overflow) | 761 static bool overflowRequiresScrollbar(EOverflow overflow) |
| 762 { | 762 { |
| 763 return overflow == OSCROLL; | 763 return overflow == OverflowScroll; |
| 764 } | 764 } |
| 765 | 765 |
| 766 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) | 766 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) |
| 767 { | 767 { |
| 768 return overflow == OAUTO || overflow == OOVERLAY; | 768 return overflow == OverflowAuto || overflow == OverflowOverlay; |
| 769 } | 769 } |
| 770 | 770 |
| 771 // This function returns true if the given box requires overflow scrollbars (as | 771 // This function returns true if the given box requires overflow scrollbars (as |
| 772 // opposed to the 'viewport' scrollbars managed by the PaintLayerCompositor). | 772 // opposed to the 'viewport' scrollbars managed by the PaintLayerCompositor). |
| 773 // FIXME: we should use the same scrolling machinery for both the viewport and | 773 // FIXME: we should use the same scrolling machinery for both the viewport and |
| 774 // overflow. Currently, we need to avoid producing scrollbars here if they'll be | 774 // overflow. Currently, we need to avoid producing scrollbars here if they'll be |
| 775 // handled externally in the RLC. | 775 // handled externally in the RLC. |
| 776 static bool canHaveOverflowScrollbars(const LayoutBox& box) | 776 static bool canHaveOverflowScrollbars(const LayoutBox& box) |
| 777 { | 777 { |
| 778 bool rootLayerScrolls = box.document().settings() && box.document().settings
()->rootLayerScrolls(); | 778 bool rootLayerScrolls = box.document().settings() && box.document().settings
()->rootLayerScrolls(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 needsVerticalScrollbar = true; | 817 needsVerticalScrollbar = true; |
| 818 } | 818 } |
| 819 } | 819 } |
| 820 } | 820 } |
| 821 | 821 |
| 822 setHasHorizontalScrollbar(needsHorizontalScrollbar); | 822 setHasHorizontalScrollbar(needsHorizontalScrollbar); |
| 823 setHasVerticalScrollbar(needsVerticalScrollbar); | 823 setHasVerticalScrollbar(needsVerticalScrollbar); |
| 824 | 824 |
| 825 // With overflow: scroll, scrollbars are always visible but may be disabled. | 825 // With overflow: scroll, scrollbars are always visible but may be disabled. |
| 826 // When switching to another value, we need to re-enable them (see bug 11985
). | 826 // When switching to another value, we need to re-enable them (see bug 11985
). |
| 827 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL
&& overflowX != OSCROLL) { | 827 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == Overflo
wScroll && overflowX != OverflowScroll) { |
| 828 ASSERT(hasHorizontalScrollbar()); | 828 ASSERT(hasHorizontalScrollbar()); |
| 829 horizontalScrollbar()->setEnabled(true); | 829 horizontalScrollbar()->setEnabled(true); |
| 830 } | 830 } |
| 831 | 831 |
| 832 if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL &
& overflowY != OSCROLL) { | 832 if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OverflowS
croll && overflowY != OverflowScroll) { |
| 833 ASSERT(hasVerticalScrollbar()); | 833 ASSERT(hasVerticalScrollbar()); |
| 834 verticalScrollbar()->setEnabled(true); | 834 verticalScrollbar()->setEnabled(true); |
| 835 } | 835 } |
| 836 | 836 |
| 837 // FIXME: Need to detect a swap from custom to native scrollbars (and vice v
ersa). | 837 // FIXME: Need to detect a swap from custom to native scrollbars (and vice v
ersa). |
| 838 if (horizontalScrollbar()) | 838 if (horizontalScrollbar()) |
| 839 horizontalScrollbar()->styleChanged(); | 839 horizontalScrollbar()->styleChanged(); |
| 840 if (verticalScrollbar()) | 840 if (verticalScrollbar()) |
| 841 verticalScrollbar()->styleChanged(); | 841 verticalScrollbar()->styleChanged(); |
| 842 | 842 |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 } | 1574 } |
| 1575 | 1575 |
| 1576 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) | 1576 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) |
| 1577 { | 1577 { |
| 1578 visitor->trace(m_scrollableArea); | 1578 visitor->trace(m_scrollableArea); |
| 1579 visitor->trace(m_hBar); | 1579 visitor->trace(m_hBar); |
| 1580 visitor->trace(m_vBar); | 1580 visitor->trace(m_vBar); |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 } // namespace blink | 1583 } // namespace blink |
| OLD | NEW |