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 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()) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 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()) { | 683 if (hasOverlayScrollbars()) { |
| 677 if (!scrollSize(HorizontalScrollbar)) | 684 if (!scrollSize(HorizontalScrollbar)) |
| 678 setHasHorizontalScrollbar(false); | 685 setHasHorizontalScrollbar(false); |
| 679 if (!scrollSize(VerticalScrollbar)) | 686 if (!scrollSize(VerticalScrollbar)) |
| 680 setHasVerticalScrollbar(false); | 687 setHasVerticalScrollbar(false); |
| 681 } | 688 } |
| 682 // overflow:auto may need to lay out again if scrollbars got added/removed. | 689 // overflow:auto may need to lay out again if scrollbars got added/removed a nd even on reconstruction of scrollbars |
| 683 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); | 690 // from native to custom or vice versa also needs to layout again. |
| 684 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow); | 691 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha sHorizontalScrollbar() != hasHorizontalOverflow)) || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); |
| 685 | 692 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer ticalScrollbar() != hasVerticalOverflow)) || (box().style()->overflowY() == OSCR OLL && !verticalScrollbar()); |
| 686 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged | | autoVerticalScrollBarChanged)) { | 693 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve rticalScrollBarChanged)) { |
| 687 if (box().hasAutoHorizontalScrollbar()) | 694 if (box().hasAutoHorizontalScrollbar() || box().style()->overflowX() == OSCROLL) |
|
MuVen
2015/08/18 13:20:01
in case of overflow-x:scroll and overflow-y:auto,
| |
| 688 setHasHorizontalScrollbar(hasHorizontalOverflow); | 695 setHasHorizontalScrollbar(hasHorizontalOverflow); |
| 689 if (box().hasAutoVerticalScrollbar()) | 696 if (box().hasAutoVerticalScrollbar() || box().style()->overflowY() == OS CROLL) |
| 690 setHasVerticalScrollbar(hasVerticalOverflow); | 697 setHasVerticalScrollbar(hasVerticalOverflow); |
| 691 | 698 |
| 692 if (hasVerticalOverflow || hasHorizontalOverflow) | 699 if (hasVerticalOverflow || hasHorizontalOverflow) |
| 693 updateScrollCornerStyle(); | 700 updateScrollCornerStyle(); |
| 694 | 701 |
| 695 layer()->updateSelfPaintingLayer(); | 702 layer()->updateSelfPaintingLayer(); |
| 696 | 703 |
| 697 // Force an update since we know the scrollbars have changed things. | 704 // Force an update since we know the scrollbars have changed things. |
| 698 if (box().document().hasAnnotatedRegions()) | 705 if (box().document().hasAnnotatedRegions()) |
| 699 box().document().setAnnotatedRegionsDirty(true); | 706 box().document().setAnnotatedRegionsDirty(true); |
| 700 | 707 |
| 701 if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO) { | 708 if (!m_inOverflowRelayout) { |
| 702 if (!m_inOverflowRelayout) { | 709 // Our proprietary overflow: overlay value doesn't trigger a layout. |
| 703 // Our proprietary overflow: overlay value doesn't trigger a lay out. | 710 m_inOverflowRelayout = true; |
| 704 m_inOverflowRelayout = true; | 711 SubtreeLayoutScope layoutScope(box()); |
| 705 SubtreeLayoutScope layoutScope(box()); | 712 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scrollb arChanged); |
| 706 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); | 713 if (box().isLayoutBlock()) { |
| 707 if (box().isLayoutBlock()) { | 714 LayoutBlock& block = toLayoutBlock(box()); |
| 708 LayoutBlock& block = toLayoutBlock(box()); | 715 block.scrollbarsChanged(horizontalScrollBarChanged, verticalScro llBarChanged); |
| 709 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto VerticalScrollBarChanged); | 716 block.layoutBlock(true); |
| 710 block.layoutBlock(true); | 717 } else { |
| 711 } else { | 718 box().layout(); |
| 712 box().layout(); | |
| 713 } | |
| 714 m_inOverflowRelayout = false; | |
| 715 } | 719 } |
| 720 m_inOverflowRelayout = false; | |
| 716 } | 721 } |
| 717 } | 722 } |
| 718 | 723 |
| 719 { | 724 { |
| 720 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. | 725 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. |
| 721 DisableCompositingQueryAsserts disabler; | 726 DisableCompositingQueryAsserts disabler; |
| 722 | 727 |
| 723 // Set up the range (and page step/line step). | 728 // Set up the range (and page step/line step). |
| 724 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 729 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
| 725 int clientWidth = box().pixelSnappedClientWidth(); | 730 int clientWidth = box().pixelSnappedClientWidth(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 } | 956 } |
| 952 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { | 957 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
| 953 if (shadowRoot->type() == ShadowRootType::UserAgent) | 958 if (shadowRoot->type() == ShadowRootType::UserAgent) |
| 954 return shadowRoot->host()->layoutObject(); | 959 return shadowRoot->host()->layoutObject(); |
| 955 } | 960 } |
| 956 } | 961 } |
| 957 | 962 |
| 958 return &layoutObject; | 963 return &layoutObject; |
| 959 } | 964 } |
| 960 | 965 |
| 966 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const | |
| 967 { | |
| 968 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | |
| 969 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st yle()->hasPseudoStyle(SCROLLBAR); | |
| 970 bool hasAnyScrollbar = hasScrollbar(); | |
| 971 bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBa r->isCustomScrollbar()); | |
| 972 return hasAnyScrollbar && (shouldUseCustom != hasCustom); | |
| 973 } | |
| 974 | |
| 961 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) | 975 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) |
| 962 { | 976 { |
| 963 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | 977 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |
| 964 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | 978 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
| 965 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); | 979 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); |
| 966 if (hasCustomScrollbarStyle) { | 980 if (hasCustomScrollbarStyle) { |
| 967 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); | 981 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); |
| 968 } else { | 982 } else { |
| 969 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 983 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
| 970 if (actualLayoutObject->style()->hasAppearance()) | 984 if (actualLayoutObject->style()->hasAppearance()) |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1451 return false; | 1465 return false; |
| 1452 | 1466 |
| 1453 LocalFrame* frame = box().frame(); | 1467 LocalFrame* frame = box().frame(); |
| 1454 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1468 if (!frame || !frame->isMainFrame() || !frame->settings()) |
| 1455 return false; | 1469 return false; |
| 1456 | 1470 |
| 1457 return frame->settings()->viewportMetaEnabled(); | 1471 return frame->settings()->viewportMetaEnabled(); |
| 1458 } | 1472 } |
| 1459 | 1473 |
| 1460 } // namespace blink | 1474 } // namespace blink |
| OLD | NEW |