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()); |
|
skobes
2015/08/19 16:59:52
Wrap the line at the || for readability.
MuVen
2015/08/19 19:20:42
Done.
| |
| 685 | 692 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer ticalScrollbar() != hasVerticalOverflow)) || (box().style()->overflowY() == OSCR OLL && !verticalScrollbar()); |
|
skobes
2015/08/19 16:59:52
same here
MuVen
2015/08/19 19:20:42
Done.
| |
| 686 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged | | autoVerticalScrollBarChanged)) { | 693 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve rticalScrollBarChanged)) { |
| 687 if (box().hasAutoHorizontalScrollbar()) | 694 if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar())) |
|
skobes
2015/08/19 16:59:52
In the OSCROLL case we do not care about hasHorizo
MuVen
2015/08/19 19:20:42
Done.
| |
| 688 setHasHorizontalScrollbar(hasHorizontalOverflow); | 695 setHasHorizontalScrollbar(hasHorizontalOverflow); |
| 689 if (box().hasAutoVerticalScrollbar()) | 696 if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == O SCROLL && !verticalScrollbar())) |
| 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 ((horizontalScrollBarChanged && box().style()->overflowX() != OOVERLA Y) || (verticalScrollBarChanged && box().style()->overflowY() != OOVERLAY)) { |
| 702 if (!m_inOverflowRelayout) { | 709 if (!m_inOverflowRelayout) { |
| 703 // Our proprietary overflow: overlay value doesn't trigger a lay out. | 710 // Our proprietary overflow: overlay value doesn't trigger a lay out. |
|
skobes
2015/08/19 16:59:52
Can you move this comment to appear just above the
MuVen
2015/08/19 19:20:42
Done.
| |
| 704 m_inOverflowRelayout = true; | 711 m_inOverflowRelayout = true; |
| 705 SubtreeLayoutScope layoutScope(box()); | 712 SubtreeLayoutScope layoutScope(box()); |
| 706 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); | 713 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); |
| 707 if (box().isLayoutBlock()) { | 714 if (box().isLayoutBlock()) { |
| 708 LayoutBlock& block = toLayoutBlock(box()); | 715 LayoutBlock& block = toLayoutBlock(box()); |
| 709 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto VerticalScrollBarChanged); | 716 block.scrollbarsChanged(horizontalScrollBarChanged, vertical ScrollBarChanged); |
| 710 block.layoutBlock(true); | 717 block.layoutBlock(true); |
| 711 } else { | 718 } else { |
| 712 box().layout(); | 719 box().layout(); |
| 713 } | 720 } |
| 714 m_inOverflowRelayout = false; | 721 m_inOverflowRelayout = false; |
| 715 } | 722 } |
| 716 } | 723 } |
| 717 } | 724 } |
| 718 | 725 |
| 719 { | 726 { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 } | 958 } |
| 952 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { | 959 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
| 953 if (shadowRoot->type() == ShadowRootType::UserAgent) | 960 if (shadowRoot->type() == ShadowRootType::UserAgent) |
| 954 return shadowRoot->host()->layoutObject(); | 961 return shadowRoot->host()->layoutObject(); |
| 955 } | 962 } |
| 956 } | 963 } |
| 957 | 964 |
| 958 return &layoutObject; | 965 return &layoutObject; |
| 959 } | 966 } |
| 960 | 967 |
| 968 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const | |
| 969 { | |
| 970 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | |
| 971 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st yle()->hasPseudoStyle(SCROLLBAR); | |
| 972 bool hasAnyScrollbar = hasScrollbar(); | |
| 973 bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBa r->isCustomScrollbar()); | |
| 974 return hasAnyScrollbar && (shouldUseCustom != hasCustom); | |
| 975 } | |
| 976 | |
| 961 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) | 977 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) |
| 962 { | 978 { |
| 963 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | 979 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |
| 964 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | 980 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
| 965 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); | 981 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); |
| 966 if (hasCustomScrollbarStyle) { | 982 if (hasCustomScrollbarStyle) { |
| 967 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); | 983 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); |
| 968 } else { | 984 } else { |
| 969 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 985 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
| 970 if (actualLayoutObject->style()->hasAppearance()) | 986 if (actualLayoutObject->style()->hasAppearance()) |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1451 return false; | 1467 return false; |
| 1452 | 1468 |
| 1453 LocalFrame* frame = box().frame(); | 1469 LocalFrame* frame = box().frame(); |
| 1454 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1470 if (!frame || !frame->isMainFrame() || !frame->settings()) |
| 1455 return false; | 1471 return false; |
| 1456 | 1472 |
| 1457 return frame->settings()->viewportMetaEnabled(); | 1473 return frame->settings()->viewportMetaEnabled(); |
| 1458 } | 1474 } |
| 1459 | 1475 |
| 1460 } // namespace blink | 1476 } // namespace blink |
| OLD | NEW |