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 |
skobes
2015/08/19 19:40:18
Rephrase this comment:
// We need to layout a
MuVen
2015/08/19 20:37:33
Done.
| |
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)) |
685 | 692 || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar()); |
skobes
2015/08/19 19:40:17
fix indentation
MuVen
2015/08/19 20:37:33
Done.
| |
686 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged | | autoVerticalScrollBarChanged)) { | 693 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer ticalScrollbar() != hasVerticalOverflow)) |
687 if (box().hasAutoHorizontalScrollbar()) | 694 || (box().style()->overflowY() == OSCROLL && !verticalScrollbar()); |
688 setHasHorizontalScrollbar(hasHorizontalOverflow); | 695 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve rticalScrollBarChanged)) { |
689 if (box().hasAutoVerticalScrollbar()) | 696 if (box().hasAutoHorizontalScrollbar() || (box().style()->overflowX() == OSCROLL && !horizontalScrollbar())) |
690 setHasVerticalScrollbar(hasVerticalOverflow); | 697 setHasHorizontalScrollbar(true); |
skobes
2015/08/19 19:40:18
This still looks wrong. Auto and OSCROLL are sepa
MuVen
2015/08/19 20:37:33
True, Miss-read your previous comment, Even i was
| |
698 if (box().hasAutoVerticalScrollbar() || (box().style()->overflowY() == O SCROLL && !verticalScrollbar())) | |
699 setHasVerticalScrollbar(true); | |
691 | 700 |
692 if (hasVerticalOverflow || hasHorizontalOverflow) | 701 if (hasVerticalOverflow || hasHorizontalOverflow) |
693 updateScrollCornerStyle(); | 702 updateScrollCornerStyle(); |
694 | 703 |
695 layer()->updateSelfPaintingLayer(); | 704 layer()->updateSelfPaintingLayer(); |
696 | 705 |
697 // Force an update since we know the scrollbars have changed things. | 706 // Force an update since we know the scrollbars have changed things. |
698 if (box().document().hasAnnotatedRegions()) | 707 if (box().document().hasAnnotatedRegions()) |
699 box().document().setAnnotatedRegionsDirty(true); | 708 box().document().setAnnotatedRegionsDirty(true); |
700 | 709 |
701 if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO) { | 710 // Our proprietary overflow: overlay value doesn't trigger a layout. |
711 if ((horizontalScrollBarChanged && box().style()->overflowX() != OOVERLA Y) || (verticalScrollBarChanged && box().style()->overflowY() != OOVERLAY)) { | |
702 if (!m_inOverflowRelayout) { | 712 if (!m_inOverflowRelayout) { |
703 // Our proprietary overflow: overlay value doesn't trigger a lay out. | |
704 m_inOverflowRelayout = true; | 713 m_inOverflowRelayout = true; |
705 SubtreeLayoutScope layoutScope(box()); | 714 SubtreeLayoutScope layoutScope(box()); |
706 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); | 715 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); |
707 if (box().isLayoutBlock()) { | 716 if (box().isLayoutBlock()) { |
708 LayoutBlock& block = toLayoutBlock(box()); | 717 LayoutBlock& block = toLayoutBlock(box()); |
709 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto VerticalScrollBarChanged); | 718 block.scrollbarsChanged(horizontalScrollBarChanged, vertical ScrollBarChanged); |
710 block.layoutBlock(true); | 719 block.layoutBlock(true); |
711 } else { | 720 } else { |
712 box().layout(); | 721 box().layout(); |
713 } | 722 } |
714 m_inOverflowRelayout = false; | 723 m_inOverflowRelayout = false; |
715 } | 724 } |
716 } | 725 } |
717 } | 726 } |
718 | 727 |
719 { | 728 { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 } | 960 } |
952 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { | 961 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
953 if (shadowRoot->type() == ShadowRootType::UserAgent) | 962 if (shadowRoot->type() == ShadowRootType::UserAgent) |
954 return shadowRoot->host()->layoutObject(); | 963 return shadowRoot->host()->layoutObject(); |
955 } | 964 } |
956 } | 965 } |
957 | 966 |
958 return &layoutObject; | 967 return &layoutObject; |
959 } | 968 } |
960 | 969 |
970 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const | |
971 { | |
972 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | |
973 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st yle()->hasPseudoStyle(SCROLLBAR); | |
974 bool hasAnyScrollbar = hasScrollbar(); | |
975 bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBa r->isCustomScrollbar()); | |
976 return hasAnyScrollbar && (shouldUseCustom != hasCustom); | |
977 } | |
978 | |
961 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) | 979 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) |
962 { | 980 { |
963 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | 981 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |
964 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); | 982 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); |
965 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); | 983 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); |
966 if (hasCustomScrollbarStyle) { | 984 if (hasCustomScrollbarStyle) { |
967 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); | 985 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); |
968 } else { | 986 } else { |
969 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 987 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
970 if (actualLayoutObject->style()->hasAppearance()) | 988 if (actualLayoutObject->style()->hasAppearance()) |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 return false; | 1469 return false; |
1452 | 1470 |
1453 LocalFrame* frame = box().frame(); | 1471 LocalFrame* frame = box().frame(); |
1454 if (!frame || !frame->isMainFrame() || !frame->settings()) | 1472 if (!frame || !frame->isMainFrame() || !frame->settings()) |
1455 return false; | 1473 return false; |
1456 | 1474 |
1457 return frame->settings()->viewportMetaEnabled(); | 1475 return frame->settings()->viewportMetaEnabled(); |
1458 } | 1476 } |
1459 | 1477 |
1460 } // namespace blink | 1478 } // namespace blink |
OLD | NEW |