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. | |
| 683 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); | |
| 684 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow); | |
| 685 | 689 |
| 686 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged | | autoVerticalScrollBarChanged)) { | 690 // We need to layout again if scrollbars are added or removed by overflow:au to, |
| 687 if (box().hasAutoHorizontalScrollbar()) | 691 // or by changing between native and custom. |
| 688 setHasHorizontalScrollbar(hasHorizontalOverflow); | 692 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha sHorizontalScrollbar() != hasHorizontalOverflow)) |
| 689 if (box().hasAutoVerticalScrollbar()) | 693 || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar() && ! ScrollbarTheme::theme()->usesOverlayScrollbars()); |
|
skobes
2015/08/20 19:44:02
Won't this fail to reconstruct in the case where w
MuVen
2015/08/21 14:27:38
True, this logic goes for toss when switching from
| |
| 690 setHasVerticalScrollbar(hasVerticalOverflow); | 694 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer ticalScrollbar() != hasVerticalOverflow)) |
| 695 || (box().style()->overflowY() == OSCROLL && !verticalScrollbar() && !Sc rollbarTheme::theme()->usesOverlayScrollbars()); | |
| 696 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve rticalScrollBarChanged)) { | |
| 697 if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar())) | |
| 698 setHasHorizontalScrollbar(box().style()->overflowX() == OSCROLL ? tr ue : hasHorizontalOverflow); | |
| 699 if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == O SCROLL && !verticalScrollbar())) | |
| 700 setHasVerticalScrollbar(box().style()->overflowY() == OSCROLL ? true : hasVerticalOverflow); | |
| 691 | 701 |
| 692 if (hasVerticalOverflow || hasHorizontalOverflow) | 702 if (hasVerticalOverflow || hasHorizontalOverflow) |
| 693 updateScrollCornerStyle(); | 703 updateScrollCornerStyle(); |
| 694 | 704 |
| 695 layer()->updateSelfPaintingLayer(); | 705 layer()->updateSelfPaintingLayer(); |
| 696 | 706 |
| 697 // Force an update since we know the scrollbars have changed things. | 707 // Force an update since we know the scrollbars have changed things. |
| 698 if (box().document().hasAnnotatedRegions()) | 708 if (box().document().hasAnnotatedRegions()) |
| 699 box().document().setAnnotatedRegionsDirty(true); | 709 box().document().setAnnotatedRegionsDirty(true); |
| 700 | 710 |
| 701 if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO) { | 711 // Our proprietary overflow: overlay value doesn't trigger a layout. |
| 712 if ((horizontalScrollBarChanged && box().style()->overflowX() != OOVERLA Y) || (verticalScrollBarChanged && box().style()->overflowY() != OOVERLAY)) { | |
| 702 if (!m_inOverflowRelayout) { | 713 if (!m_inOverflowRelayout) { |
| 703 // Our proprietary overflow: overlay value doesn't trigger a lay out. | |
| 704 m_inOverflowRelayout = true; | 714 m_inOverflowRelayout = true; |
| 705 SubtreeLayoutScope layoutScope(box()); | 715 SubtreeLayoutScope layoutScope(box()); |
| 706 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); | 716 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); |
| 707 if (box().isLayoutBlock()) { | 717 if (box().isLayoutBlock()) { |
| 708 LayoutBlock& block = toLayoutBlock(box()); | 718 LayoutBlock& block = toLayoutBlock(box()); |
| 709 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto VerticalScrollBarChanged); | 719 block.scrollbarsChanged(horizontalScrollBarChanged, vertical ScrollBarChanged); |
| 710 block.layoutBlock(true); | 720 block.layoutBlock(true); |
| 711 } else { | 721 } else { |
| 712 box().layout(); | 722 box().layout(); |
| 713 } | 723 } |
| 714 m_inOverflowRelayout = false; | 724 m_inOverflowRelayout = false; |
| 715 } | 725 } |
| 716 } | 726 } |
| 717 } | 727 } |
| 718 | 728 |
| 719 { | 729 { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 } | 961 } |
| 952 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { | 962 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
| 953 if (shadowRoot->type() == ShadowRootType::UserAgent) | 963 if (shadowRoot->type() == ShadowRootType::UserAgent) |
| 954 return shadowRoot->host()->layoutObject(); | 964 return shadowRoot->host()->layoutObject(); |
| 955 } | 965 } |
| 956 } | 966 } |
| 957 | 967 |
| 958 return &layoutObject; | 968 return &layoutObject; |
| 959 } | 969 } |
| 960 | 970 |
| 971 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const | |
| 972 { | |
| 973 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | |
| 974 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st yle()->hasPseudoStyle(SCROLLBAR); | |
| 975 bool hasAnyScrollbar = hasScrollbar(); | |
| 976 bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBa r->isCustomScrollbar()); | |
| 977 return hasAnyScrollbar && (shouldUseCustom != hasCustom); | |
| 978 } | |
| 979 | |
| 961 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) | 980 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) |
| 962 { | 981 { |
| 963 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | 982 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |
| 964 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | 983 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
| 965 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); | 984 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); |
| 966 if (hasCustomScrollbarStyle) { | 985 if (hasCustomScrollbarStyle) { |
| 967 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); | 986 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); |
| 968 } else { | 987 } else { |
| 969 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 988 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
| 970 if (actualLayoutObject->style()->hasAppearance()) | 989 if (actualLayoutObject->style()->hasAppearance()) |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1451 return false; | 1470 return false; |
| 1452 | 1471 |
| 1453 LocalFrame* frame = box().frame(); | 1472 LocalFrame* frame = box().frame(); |
| 1454 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1473 if (!frame || !frame->isMainFrame() || !frame->settings()) |
| 1455 return false; | 1474 return false; |
| 1456 | 1475 |
| 1457 return frame->settings()->viewportMetaEnabled(); | 1476 return frame->settings()->viewportMetaEnabled(); |
| 1458 } | 1477 } |
| 1459 | 1478 |
| 1460 } // namespace blink | 1479 } // namespace blink |
| OLD | NEW |