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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 1980103002: Include auto vertical scrollbar in intrinsicScrollbarLogicalWidth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Restore list box height calculation, fix scrollbar width factor Created 4 years, 6 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
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@gmail.com> 9 * Christian Biesinger <cbiesinger@gmail.com>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 // PaintLayerScrollableArea does not maintain that flag: it gets set, bu t it never 635 // PaintLayerScrollableArea does not maintain that flag: it gets set, bu t it never
636 // gets unset. We should unset the flag after layout. 636 // gets unset. We should unset the flag after layout.
637 scrollPositionChanged(scrollPositionDouble(), ProgrammaticScroll); 637 scrollPositionChanged(scrollPositionDouble(), ProgrammaticScroll);
638 } 638 }
639 639
640 m_scrollbarManager.setCanDetachScrollbars(false); 640 m_scrollbarManager.setCanDetachScrollbars(false);
641 641
642 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); 642 bool hasHorizontalOverflow = this->hasHorizontalOverflow();
643 bool hasVerticalOverflow = this->hasVerticalOverflow(); 643 bool hasVerticalOverflow = this->hasVerticalOverflow();
644 644
645 // Don't add auto scrollbars if the box contents aren't visible.
646 bool shouldHaveAutoHorizontalScrollbar = hasHorizontalOverflow && box().pixe lSnappedClientHeight();
647 bool shouldHaveAutoVerticalScrollbar = hasVerticalOverflow && box().pixelSna ppedClientWidth();
648
645 { 649 {
646 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. 650 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html.
647 DisableCompositingQueryAsserts disabler; 651 DisableCompositingQueryAsserts disabler;
648 652
649 // overflow:scroll should just enable/disable. 653 // overflow:scroll should just enable/disable.
650 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar( )) 654 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar( ))
651 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); 655 horizontalScrollbar()->setEnabled(hasHorizontalOverflow);
652 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) 656 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar())
653 verticalScrollbar()->setEnabled(hasVerticalOverflow); 657 verticalScrollbar()->setEnabled(hasVerticalOverflow);
654 } 658 }
655 659
656 // We need to layout again if scrollbars are added or removed by overflow:au to, 660 // We need to layout again if scrollbars are added or removed by overflow:au to,
657 // or by changing between native and custom. 661 // or by changing between native and custom.
658 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha sHorizontalScrollbar() != hasHorizontalOverflow)) 662 bool horizontalScrollBarChanged = (box().hasAutoHorizontalScrollbar() && (ha sHorizontalScrollbar() != shouldHaveAutoHorizontalScrollbar))
659 || (box().style()->overflowX() == OverflowScroll && !horizontalScrollbar ()); 663 || (box().style()->overflowX() == OverflowScroll && !horizontalScrollbar ());
660 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer ticalScrollbar() != hasVerticalOverflow)) 664 bool verticalScrollBarChanged = (box().hasAutoVerticalScrollbar() && (hasVer ticalScrollbar() != shouldHaveAutoVerticalScrollbar))
661 || (box().style()->overflowY() == OverflowScroll && !verticalScrollbar() ); 665 || (box().style()->overflowY() == OverflowScroll && !verticalScrollbar() );
662 if (!visualViewportSuppliesScrollbars() && (horizontalScrollBarChanged || ve rticalScrollBarChanged)) { 666 if (!m_inOverflowRelayout
667 && !visualViewportSuppliesScrollbars()
668 && (horizontalScrollBarChanged || verticalScrollBarChanged)) {
663 if (box().hasAutoHorizontalScrollbar()) 669 if (box().hasAutoHorizontalScrollbar())
664 setHasHorizontalScrollbar(hasHorizontalOverflow); 670 setHasHorizontalScrollbar(shouldHaveAutoHorizontalScrollbar);
665 else if (box().style()->overflowX() == OverflowScroll) 671 else if (box().style()->overflowX() == OverflowScroll)
666 setHasHorizontalScrollbar(true); 672 setHasHorizontalScrollbar(true);
667 if (box().hasAutoVerticalScrollbar()) 673 if (box().hasAutoVerticalScrollbar())
668 setHasVerticalScrollbar(hasVerticalOverflow); 674 setHasVerticalScrollbar(shouldHaveAutoVerticalScrollbar);
669 else if (box().style()->overflowY() == OverflowScroll) 675 else if (box().style()->overflowY() == OverflowScroll)
670 setHasVerticalScrollbar(true); 676 setHasVerticalScrollbar(true);
671 677
672 if (hasVerticalOverflow || hasHorizontalOverflow) 678 if (hasScrollbar())
673 updateScrollCornerStyle(); 679 updateScrollCornerStyle();
674 680
675 layer()->updateSelfPaintingLayer(); 681 layer()->updateSelfPaintingLayer();
676 682
677 // Force an update since we know the scrollbars have changed things. 683 // Force an update since we know the scrollbars have changed things.
678 if (box().document().hasAnnotatedRegions()) 684 if (box().document().hasAnnotatedRegions())
679 box().document().setAnnotatedRegionsDirty(true); 685 box().document().setAnnotatedRegionsDirty(true);
680 686
681 // Our proprietary overflow: overlay value doesn't trigger a layout. 687 // Our proprietary overflow: overlay value doesn't trigger a layout.
682 if ((horizontalScrollBarChanged && box().style()->overflowX() != Overflo wOverlay) || (verticalScrollBarChanged && box().style()->overflowY() != Overflow Overlay)) { 688 if ((horizontalScrollBarChanged && box().style()->overflowX() != Overflo wOverlay) || (verticalScrollBarChanged && box().style()->overflowY() != Overflow Overlay)) {
683 if (!m_inOverflowRelayout) { 689 if ((verticalScrollBarChanged && box().isHorizontalWritingMode())
690 || (horizontalScrollBarChanged && !box().isHorizontalWritingMode ())) {
691 box().setPreferredLogicalWidthsDirty();
692 }
693 if (delayedLayoutScope) {
694 box().updateLogicalWidth();
695 if (box().isLayoutBlock())
696 toLayoutBlock(box()).scrollbarsChanged(horizontalScrollBarCh anged, verticalScrollBarChanged);
697 delayedLayoutScope->setNeedsLayout(&box(), LayoutInvalidationRea son::ScrollbarChanged);
698 didMarkForDelayedLayout = true;
699 } else {
684 m_inOverflowRelayout = true; 700 m_inOverflowRelayout = true;
685 if (delayedLayoutScope) { 701 SubtreeLayoutScope layoutScope(box());
686 if (box().isLayoutBlock()) 702 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr ollbarChanged);
687 toLayoutBlock(box()).scrollbarsChanged(horizontalScrollB arChanged, verticalScrollBarChanged); 703 if (box().isLayoutBlock()) {
688 delayedLayoutScope->setNeedsLayout(&box(), LayoutInvalidatio nReason::ScrollbarChanged); 704 LayoutBlock& block = toLayoutBlock(box());
689 didMarkForDelayedLayout = true; 705 block.scrollbarsChanged(horizontalScrollBarChanged, vertical ScrollBarChanged);
706 block.layoutBlock(true);
690 } else { 707 } else {
691 SubtreeLayoutScope layoutScope(box()); 708 box().layout();
692 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason: :ScrollbarChanged);
693 if (box().isLayoutBlock()) {
694 LayoutBlock& block = toLayoutBlock(box());
695 block.scrollbarsChanged(horizontalScrollBarChanged, vert icalScrollBarChanged);
696 block.layoutBlock(true);
697 } else {
698 box().layout();
699 }
700 } 709 }
701 LayoutObject* parent = box().parent();
702 if (parent && parent->isFlexibleBox())
703 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box ());
704 m_inOverflowRelayout = false; 710 m_inOverflowRelayout = false;
705 } 711 }
712 LayoutObject* parent = box().parent();
713 if (parent && parent->isFlexibleBox())
714 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box());
706 } 715 }
707 } 716 }
708 717
709 { 718 {
710 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. 719 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html.
711 DisableCompositingQueryAsserts disabler; 720 DisableCompositingQueryAsserts disabler;
712 721
713 // Set up the range (and page step/line step). 722 // Set up the range (and page step/line step).
714 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { 723 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
715 int clientWidth = box().pixelSnappedClientWidth(); 724 int clientWidth = box().pixelSnappedClientWidth();
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 if (!layer->scrollsOverflow()) 1448 if (!layer->scrollsOverflow())
1440 return false; 1449 return false;
1441 1450
1442 Node* node = layer->enclosingNode(); 1451 Node* node = layer->enclosingNode();
1443 if (node && node->isElementNode() && (toElement(node)->compositorMutableProp erties() & (CompositorMutableProperty::kScrollTop | CompositorMutableProperty::k ScrollLeft))) 1452 if (node && node->isElementNode() && (toElement(node)->compositorMutableProp erties() & (CompositorMutableProperty::kScrollTop | CompositorMutableProperty::k ScrollLeft)))
1444 return true; 1453 return true;
1445 1454
1446 if (mode == PaintLayerScrollableArea::ConsiderLCDText && !layer->compositor( )->preferCompositingToLCDTextEnabled()) 1455 if (mode == PaintLayerScrollableArea::ConsiderLCDText && !layer->compositor( )->preferCompositingToLCDTextEnabled())
1447 return false; 1456 return false;
1448 1457
1449 return !layer->hasDescendantWithClipPath() 1458 return !layer->size().isEmpty()
1459 && !layer->hasDescendantWithClipPath()
1450 && !layer->hasAncestorWithClipPath() 1460 && !layer->hasAncestorWithClipPath()
1451 && !layer->layoutObject()->style()->hasBorderRadius(); 1461 && !layer->layoutObject()->style()->hasBorderRadius();
1452 } 1462 }
1453 1463
1454 void PaintLayerScrollableArea::updateNeedsCompositedScrolling(LCDTextMode mode) 1464 void PaintLayerScrollableArea::updateNeedsCompositedScrolling(LCDTextMode mode)
1455 { 1465 {
1456 const bool needsCompositedScrolling = layerNeedsCompositedScrolling(mode, la yer()); 1466 const bool needsCompositedScrolling = layerNeedsCompositedScrolling(mode, la yer());
1457 if (static_cast<bool>(m_needsCompositedScrolling) != needsCompositedScrollin g) { 1467 if (static_cast<bool>(m_needsCompositedScrolling) != needsCompositedScrollin g) {
1458 m_needsCompositedScrolling = needsCompositedScrolling; 1468 m_needsCompositedScrolling = needsCompositedScrolling;
1459 layer()->didUpdateNeedsCompositedScrolling(); 1469 layer()->didUpdateNeedsCompositedScrolling();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 } 1621 }
1612 1622
1613 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) 1623 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager)
1614 { 1624 {
1615 visitor->trace(m_scrollableArea); 1625 visitor->trace(m_scrollableArea);
1616 visitor->trace(m_hBar); 1626 visitor->trace(m_hBar);
1617 visitor->trace(m_vBar); 1627 visitor->trace(m_vBar);
1618 } 1628 }
1619 1629
1620 } // namespace blink 1630 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.cpp ('k') | third_party/WebKit/Source/web/resources/listPicker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698