Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp

Issue 1292513002: Create custom scrollbars when html element has overflow:scroll (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerScrollableArea.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bool needsHBarConstruction = false;
650 bool needsVBarConstruction = false;
651 if (needsScrollbarReconstruction()) {
652 if (m_hBar) {
653 destroyScrollbar(HorizontalScrollbar);
654 needsHBarConstruction = true;
skobes 2015/08/14 19:02:56 I don't understand the need to store this. Why do
655 }
656 if (m_vBar) {
657 destroyScrollbar(VerticalScrollbar);
658 needsVBarConstruction = true;
659 }
660 }
661
649 DoubleSize originalScrollOffset = adjustedScrollOffset(); 662 DoubleSize originalScrollOffset = adjustedScrollOffset();
650 computeScrollDimensions(); 663 computeScrollDimensions();
651 664
652 // Layout may cause us to be at an invalid scroll position. In this case we need 665 // 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). 666 // to pull our scroll offsets back to the max (or push them up to the min).
654 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); 667 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset());
655 if (clampedScrollOffset != adjustedScrollOffset()) 668 if (clampedScrollOffset != adjustedScrollOffset())
656 scrollToOffset(clampedScrollOffset); 669 scrollToOffset(clampedScrollOffset);
657 670
658 if (originalScrollOffset != adjustedScrollOffset()) { 671 if (originalScrollOffset != adjustedScrollOffset()) {
(...skipping 13 matching lines...) Expand all
672 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); 685 horizontalScrollbar()->setEnabled(hasHorizontalOverflow);
673 if (box().style()->overflowY() == OSCROLL && verticalScrollbar()) 686 if (box().style()->overflowY() == OSCROLL && verticalScrollbar())
674 verticalScrollbar()->setEnabled(hasVerticalOverflow); 687 verticalScrollbar()->setEnabled(hasVerticalOverflow);
675 } 688 }
676 if (hasOverlayScrollbars()) { 689 if (hasOverlayScrollbars()) {
677 if (!scrollSize(HorizontalScrollbar)) 690 if (!scrollSize(HorizontalScrollbar))
678 setHasHorizontalScrollbar(false); 691 setHasHorizontalScrollbar(false);
679 if (!scrollSize(VerticalScrollbar)) 692 if (!scrollSize(VerticalScrollbar))
680 setHasVerticalScrollbar(false); 693 setHasVerticalScrollbar(false);
681 } 694 }
682 // overflow:auto may need to lay out again if scrollbars got added/removed. 695 // overflow:auto may need to lay out again if scrollbars got added/removed. And even on reconstruction of scrollbars
683 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); 696 // from native to custom or vice versa may also need to layout again.
684 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow); 697 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha sHorizontalScrollbar() != hasHorizontalOverflow)) || needsHBarConstruction;
skobes 2015/08/14 19:23:37 Oh I see, the problem is with overflow:scroll and
MuVen 2015/08/17 09:21:03 Done.
698 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer ticalScrollbar() != hasVerticalOverflow)) || needsVBarConstruction;
685 699
686 if (!visualViewportSuppliesScrollbars() && (autoHorizontalScrollBarChanged | | autoVerticalScrollBarChanged)) { 700 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve rticalScrollBarChanged)) {
687 if (box().hasAutoHorizontalScrollbar()) 701 if (box().hasAutoHorizontalScrollbar() || needsHBarConstruction)
688 setHasHorizontalScrollbar(hasHorizontalOverflow); 702 setHasHorizontalScrollbar(hasHorizontalOverflow);
689 if (box().hasAutoVerticalScrollbar()) 703 if (box().hasAutoVerticalScrollbar() || needsVBarConstruction)
690 setHasVerticalScrollbar(hasVerticalOverflow); 704 setHasVerticalScrollbar(hasVerticalOverflow);
691 705
692 if (hasVerticalOverflow || hasHorizontalOverflow) 706 if (hasVerticalOverflow || hasHorizontalOverflow)
693 updateScrollCornerStyle(); 707 updateScrollCornerStyle();
694 708
695 layer()->updateSelfPaintingLayer(); 709 layer()->updateSelfPaintingLayer();
696 710
697 // Force an update since we know the scrollbars have changed things. 711 // Force an update since we know the scrollbars have changed things.
698 if (box().document().hasAnnotatedRegions()) 712 if (box().document().hasAnnotatedRegions())
699 box().document().setAnnotatedRegionsDirty(true); 713 box().document().setAnnotatedRegionsDirty(true);
700 714
701 if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO) { 715 if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO || needsHBarConstruction || needsVBarConstruction) {
702 if (!m_inOverflowRelayout) { 716 if (!m_inOverflowRelayout) {
703 // Our proprietary overflow: overlay value doesn't trigger a lay out. 717 // Our proprietary overflow: overlay value doesn't trigger a lay out.
704 m_inOverflowRelayout = true; 718 m_inOverflowRelayout = true;
705 SubtreeLayoutScope layoutScope(box()); 719 SubtreeLayoutScope layoutScope(box());
706 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged); 720 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged);
707 if (box().isLayoutBlock()) { 721 if (box().isLayoutBlock()) {
708 LayoutBlock& block = toLayoutBlock(box()); 722 LayoutBlock& block = toLayoutBlock(box());
709 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto VerticalScrollBarChanged); 723 block.scrollbarsChanged(horizontalScrollBarChanged, vertical ScrollBarChanged);
710 block.layoutBlock(true); 724 block.layoutBlock(true);
711 } else { 725 } else {
712 box().layout(); 726 box().layout();
713 } 727 }
714 m_inOverflowRelayout = false; 728 m_inOverflowRelayout = false;
715 } 729 }
716 } 730 }
717 } 731 }
718 732
719 { 733 {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 965 }
952 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { 966 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) {
953 if (shadowRoot->type() == ShadowRootType::UserAgent) 967 if (shadowRoot->type() == ShadowRootType::UserAgent)
954 return shadowRoot->host()->layoutObject(); 968 return shadowRoot->host()->layoutObject();
955 } 969 }
956 } 970 }
957 971
958 return &layoutObject; 972 return &layoutObject;
959 } 973 }
960 974
975 bool DeprecatedPaintLayerScrollableArea::needsScrollbarReconstruction() const
976 {
977 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box());
978 bool shouldUseCustom = actualLayoutObject->isBox() && actualLayoutObject->st yle()->hasPseudoStyle(SCROLLBAR);
979 bool hasAnyScrollbar = hasScrollbar();
980 bool hasCustom = (m_hBar && m_hBar->isCustomScrollbar()) || (m_vBar && m_vBa r->isCustomScrollbar());
981 return hasAnyScrollbar && (shouldUseCustom != hasCustom);
982 }
983
961 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation) 984 PassRefPtrWillBeRawPtr<Scrollbar> DeprecatedPaintLayerScrollableArea::createScro llbar(ScrollbarOrientation orientation)
962 { 985 {
963 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; 986 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr;
964 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box()); 987 LayoutObject* actualLayoutObject = layoutObjectForScrollbar(box());
965 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR); 988 bool hasCustomScrollbarStyle = actualLayoutObject->isBox() && actualLayoutOb ject->style()->hasPseudoStyle(SCROLLBAR);
966 if (hasCustomScrollbarStyle) { 989 if (hasCustomScrollbarStyle) {
967 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node()); 990 widget = LayoutScrollbar::createCustomScrollbar(this, orientation, actua lLayoutObject->node());
968 } else { 991 } else {
969 ScrollbarControlSize scrollbarSize = RegularScrollbar; 992 ScrollbarControlSize scrollbarSize = RegularScrollbar;
970 if (actualLayoutObject->style()->hasAppearance()) 993 if (actualLayoutObject->style()->hasAppearance())
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 return false; 1474 return false;
1452 1475
1453 LocalFrame* frame = box().frame(); 1476 LocalFrame* frame = box().frame();
1454 if (!frame || !frame->isMainFrame() || !frame->settings()) 1477 if (!frame || !frame->isMainFrame() || !frame->settings())
1455 return false; 1478 return false;
1456 1479
1457 return frame->settings()->viewportMetaEnabled(); 1480 return frame->settings()->viewportMetaEnabled();
1458 } 1481 }
1459 1482
1460 } // namespace blink 1483 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerScrollableArea.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698