| 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@gmail.com> | 9 * Christian Biesinger <cbiesinger@gmail.com> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 namespace blink { | 80 namespace blink { |
| 81 | 81 |
| 82 PaintLayerScrollableAreaRareData::PaintLayerScrollableAreaRareData() | 82 PaintLayerScrollableAreaRareData::PaintLayerScrollableAreaRareData() |
| 83 { | 83 { |
| 84 } | 84 } |
| 85 | 85 |
| 86 const int ResizerControlExpandRatioForTouch = 2; | 86 const int ResizerControlExpandRatioForTouch = 2; |
| 87 | 87 |
| 88 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) | 88 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) |
| 89 : m_layer(layer) | 89 : m_layer(layer) |
| 90 , m_nextTopmostScrollChild(0) |
| 91 , m_topmostScrollChild(0) |
| 90 , m_inResizeMode(false) | 92 , m_inResizeMode(false) |
| 91 , m_scrollsOverflow(false) | 93 , m_scrollsOverflow(false) |
| 92 , m_inOverflowRelayout(false) | 94 , m_inOverflowRelayout(false) |
| 93 , m_nextTopmostScrollChild(0) | |
| 94 , m_topmostScrollChild(0) | |
| 95 , m_needsCompositedScrolling(false) | 95 , m_needsCompositedScrolling(false) |
| 96 , m_rebuildHorizontalScrollbarLayer(false) | 96 , m_rebuildHorizontalScrollbarLayer(false) |
| 97 , m_rebuildVerticalScrollbarLayer(false) | 97 , m_rebuildVerticalScrollbarLayer(false) |
| 98 , m_needsScrollPositionClamp(false) |
| 99 , m_needsRelayout(false) |
| 100 , m_hadHorizontalScrollbarBeforeRelayout(false) |
| 101 , m_hadVerticalScrollbarBeforeRelayout(false) |
| 98 , m_scrollbarManager(*this) | 102 , m_scrollbarManager(*this) |
| 99 , m_scrollCorner(nullptr) | 103 , m_scrollCorner(nullptr) |
| 100 , m_resizer(nullptr) | 104 , m_resizer(nullptr) |
| 101 , m_scrollAnchor(this) | 105 , m_scrollAnchor(this) |
| 102 #if ENABLE(ASSERT) | 106 #if ENABLE(ASSERT) |
| 103 , m_hasBeenDisposed(false) | 107 , m_hasBeenDisposed(false) |
| 104 #endif | 108 #endif |
| 105 { | 109 { |
| 106 Node* node = box().node(); | 110 Node* node = box().node(); |
| 107 if (node && node->isElementNode()) { | 111 if (node && node->isElementNode()) { |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 // We need to layout again if scrollbars are added or removed by overflow:au
to, | 652 // We need to layout again if scrollbars are added or removed by overflow:au
to, |
| 649 // or by changing between native and custom. | 653 // or by changing between native and custom. |
| 650 bool horizontalScrollbarShouldChange = (box().hasAutoHorizontalScrollbar() &
& (hasHorizontalScrollbar() != shouldHaveAutoHorizontalScrollbar)) | 654 bool horizontalScrollbarShouldChange = (box().hasAutoHorizontalScrollbar() &
& (hasHorizontalScrollbar() != shouldHaveAutoHorizontalScrollbar)) |
| 651 || (box().style()->overflowX() == OverflowScroll && !horizontalScrollbar
()); | 655 || (box().style()->overflowX() == OverflowScroll && !horizontalScrollbar
()); |
| 652 bool verticalScrollbarShouldChange = (box().hasAutoVerticalScrollbar() && (h
asVerticalScrollbar() != shouldHaveAutoVerticalScrollbar)) | 656 bool verticalScrollbarShouldChange = (box().hasAutoVerticalScrollbar() && (h
asVerticalScrollbar() != shouldHaveAutoVerticalScrollbar)) |
| 653 || (box().style()->overflowY() == OverflowScroll && !verticalScrollbar()
); | 657 || (box().style()->overflowY() == OverflowScroll && !verticalScrollbar()
); |
| 654 bool scrollbarsWillChange = !scrollbarsAreFrozen && !visualViewportSuppliesS
crollbars() | 658 bool scrollbarsWillChange = !scrollbarsAreFrozen && !visualViewportSuppliesS
crollbars() |
| 655 && (horizontalScrollbarShouldChange || verticalScrollbarShouldChange); | 659 && (horizontalScrollbarShouldChange || verticalScrollbarShouldChange); |
| 656 | 660 |
| 657 if (scrollbarsWillChange) { | 661 if (scrollbarsWillChange) { |
| 662 bool hadHorizontalScrollbar = hasHorizontalScrollbar(); |
| 663 bool hadVerticalScrollbar = hasVerticalScrollbar(); |
| 658 if (box().hasAutoHorizontalScrollbar()) | 664 if (box().hasAutoHorizontalScrollbar()) |
| 659 setHasHorizontalScrollbar(shouldHaveAutoHorizontalScrollbar); | 665 setHasHorizontalScrollbar(shouldHaveAutoHorizontalScrollbar); |
| 660 else if (box().style()->overflowX() == OverflowScroll) | 666 else if (box().style()->overflowX() == OverflowScroll) |
| 661 setHasHorizontalScrollbar(true); | 667 setHasHorizontalScrollbar(true); |
| 662 if (box().hasAutoVerticalScrollbar()) | 668 if (box().hasAutoVerticalScrollbar()) |
| 663 setHasVerticalScrollbar(shouldHaveAutoVerticalScrollbar); | 669 setHasVerticalScrollbar(shouldHaveAutoVerticalScrollbar); |
| 664 else if (box().style()->overflowY() == OverflowScroll) | 670 else if (box().style()->overflowY() == OverflowScroll) |
| 665 setHasVerticalScrollbar(true); | 671 setHasVerticalScrollbar(true); |
| 666 | 672 |
| 667 if (hasScrollbar()) | 673 if (hasScrollbar()) |
| 668 updateScrollCornerStyle(); | 674 updateScrollCornerStyle(); |
| 669 | 675 |
| 670 layer()->updateSelfPaintingLayer(); | 676 layer()->updateSelfPaintingLayer(); |
| 671 | 677 |
| 672 // Force an update since we know the scrollbars have changed things. | 678 // Force an update since we know the scrollbars have changed things. |
| 673 if (box().document().hasAnnotatedRegions()) | 679 if (box().document().hasAnnotatedRegions()) |
| 674 box().document().setAnnotatedRegionsDirty(true); | 680 box().document().setAnnotatedRegionsDirty(true); |
| 675 | 681 |
| 676 // Our proprietary overflow: overlay value doesn't trigger a layout. | 682 // Our proprietary overflow: overlay value doesn't trigger a layout. |
| 677 if ((horizontalScrollbarShouldChange && box().style()->overflowX() != Ov
erflowOverlay) | 683 if ((horizontalScrollbarShouldChange && box().style()->overflowX() != Ov
erflowOverlay) |
| 678 || (verticalScrollbarShouldChange && box().style()->overflowY() != O
verflowOverlay)) { | 684 || (verticalScrollbarShouldChange && box().style()->overflowY() != O
verflowOverlay)) { |
| 679 if ((verticalScrollbarShouldChange && box().isHorizontalWritingMode(
)) | 685 if ((verticalScrollbarShouldChange && box().isHorizontalWritingMode(
)) |
| 680 || (horizontalScrollbarShouldChange && !box().isHorizontalWritin
gMode())) { | 686 || (horizontalScrollbarShouldChange && !box().isHorizontalWritin
gMode())) { |
| 681 box().setPreferredLogicalWidthsDirty(); | 687 box().setPreferredLogicalWidthsDirty(); |
| 682 } | 688 } |
| 683 if (relayoutIsPrevented) { | 689 if (relayoutIsPrevented) { |
| 684 // We're not doing re-layout right now, but we still want to | 690 // We're not doing re-layout right now, but we still want to |
| 685 // add the scrollbar to the logical width now, to facilitate par
ent layout. | 691 // add the scrollbar to the logical width now, to facilitate par
ent layout. |
| 686 box().updateLogicalWidth(); | 692 box().updateLogicalWidth(); |
| 687 if (box().isLayoutBlock()) | 693 PreventRelayoutScope::setBoxNeedsLayout(*this, hadHorizontalScro
llbar, hadVerticalScrollbar); |
| 688 toLayoutBlock(box()).scrollbarsChanged(horizontalScrollbarSh
ouldChange, verticalScrollbarShouldChange); | |
| 689 PreventRelayoutScope::setNeedsLayout(box()); | |
| 690 } else { | 694 } else { |
| 691 m_inOverflowRelayout = true; | 695 m_inOverflowRelayout = true; |
| 692 SubtreeLayoutScope layoutScope(box()); | 696 SubtreeLayoutScope layoutScope(box()); |
| 693 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr
ollbarChanged); | 697 layoutScope.setNeedsLayout(&box(), LayoutInvalidationReason::Scr
ollbarChanged); |
| 694 if (box().isLayoutBlock()) { | 698 if (box().isLayoutBlock()) { |
| 695 LayoutBlock& block = toLayoutBlock(box()); | 699 LayoutBlock& block = toLayoutBlock(box()); |
| 696 block.scrollbarsChanged(horizontalScrollbarShouldChange, ver
ticalScrollbarShouldChange); | 700 block.scrollbarsChanged(horizontalScrollbarShouldChange, ver
ticalScrollbarShouldChange); |
| 697 block.layoutBlock(true); | 701 block.layoutBlock(true); |
| 698 } else { | 702 } else { |
| 699 box().layout(); | 703 box().layout(); |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) | 1643 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) |
| 1640 { | 1644 { |
| 1641 visitor->trace(m_scrollableArea); | 1645 visitor->trace(m_scrollableArea); |
| 1642 visitor->trace(m_hBar); | 1646 visitor->trace(m_hBar); |
| 1643 visitor->trace(m_vBar); | 1647 visitor->trace(m_vBar); |
| 1644 } | 1648 } |
| 1645 | 1649 |
| 1646 int PaintLayerScrollableArea::PreventRelayoutScope::s_count = 0; | 1650 int PaintLayerScrollableArea::PreventRelayoutScope::s_count = 0; |
| 1647 SubtreeLayoutScope* PaintLayerScrollableArea::PreventRelayoutScope::s_layoutScop
e = nullptr; | 1651 SubtreeLayoutScope* PaintLayerScrollableArea::PreventRelayoutScope::s_layoutScop
e = nullptr; |
| 1648 bool PaintLayerScrollableArea::PreventRelayoutScope::s_relayoutNeeded = false; | 1652 bool PaintLayerScrollableArea::PreventRelayoutScope::s_relayoutNeeded = false; |
| 1649 WTF::Vector<LayoutObject*>* PaintLayerScrollableArea::PreventRelayoutScope::s_ne
edsRelayout = nullptr; | 1653 PersistentHeapVector<Member<PaintLayerScrollableArea>>* PaintLayerScrollableArea
::PreventRelayoutScope::s_needsRelayout = nullptr; |
| 1650 | 1654 |
| 1651 PaintLayerScrollableArea::PreventRelayoutScope::PreventRelayoutScope(SubtreeLayo
utScope& layoutScope) | 1655 PaintLayerScrollableArea::PreventRelayoutScope::PreventRelayoutScope(SubtreeLayo
utScope& layoutScope) |
| 1652 { | 1656 { |
| 1653 if (!s_count) { | 1657 if (!s_count) { |
| 1654 DCHECK(!s_layoutScope); | 1658 DCHECK(!s_layoutScope); |
| 1655 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty()); | 1659 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty()); |
| 1656 s_layoutScope = &layoutScope; | 1660 s_layoutScope = &layoutScope; |
| 1657 } | 1661 } |
| 1658 s_count++; | 1662 s_count++; |
| 1659 } | 1663 } |
| 1660 | 1664 |
| 1661 PaintLayerScrollableArea::PreventRelayoutScope::~PreventRelayoutScope() | 1665 PaintLayerScrollableArea::PreventRelayoutScope::~PreventRelayoutScope() |
| 1662 { | 1666 { |
| 1663 if (--s_count == 0) { | 1667 if (--s_count == 0) { |
| 1664 if (s_relayoutNeeded) { | 1668 if (s_relayoutNeeded) { |
| 1665 for (auto layoutObject : *s_needsRelayout) | 1669 for (auto scrollableArea: *s_needsRelayout) { |
| 1666 s_layoutScope->setNeedsLayout(layoutObject, LayoutInvalidationRe
ason::ScrollbarChanged); | 1670 DCHECK(scrollableArea->needsRelayout()); |
| 1671 LayoutBox& box = scrollableArea->box(); |
| 1672 s_layoutScope->setNeedsLayout(&box, LayoutInvalidationReason::Sc
rollbarChanged); |
| 1673 if (box.isLayoutBlock()) { |
| 1674 bool horizontalScrollbarChanged = scrollableArea->hasHorizon
talScrollbar() != scrollableArea->hadHorizontalScrollbarBeforeRelayout(); |
| 1675 bool verticalScrollbarChanged = scrollableArea->hasVerticalS
crollbar() != scrollableArea->hadVerticalScrollbarBeforeRelayout(); |
| 1676 if (horizontalScrollbarChanged || verticalScrollbarChanged) |
| 1677 toLayoutBlock(box).scrollbarsChanged(horizontalScrollbar
Changed, verticalScrollbarChanged); |
| 1678 } |
| 1679 scrollableArea->setNeedsRelayout(false); |
| 1680 } |
| 1681 |
| 1667 s_needsRelayout->clear(); | 1682 s_needsRelayout->clear(); |
| 1668 } | 1683 } |
| 1669 s_layoutScope = nullptr; | 1684 s_layoutScope = nullptr; |
| 1670 } | 1685 } |
| 1671 } | 1686 } |
| 1672 | 1687 |
| 1673 void PaintLayerScrollableArea::PreventRelayoutScope::setNeedsLayout(LayoutObject
& layoutObject) | 1688 void PaintLayerScrollableArea::PreventRelayoutScope::setBoxNeedsLayout(PaintLaye
rScrollableArea& scrollableArea, bool hadHorizontalScrollbar, bool hadVerticalSc
rollbar) |
| 1674 { | 1689 { |
| 1675 DCHECK(s_count); | 1690 DCHECK(s_count); |
| 1676 DCHECK(s_layoutScope); | 1691 DCHECK(s_layoutScope); |
| 1692 if (scrollableArea.needsRelayout()) |
| 1693 return; |
| 1694 scrollableArea.setNeedsRelayout(true); |
| 1695 scrollableArea.setHadHorizontalScrollbarBeforeRelayout(hadHorizontalScrollba
r); |
| 1696 scrollableArea.setHadVerticalScrollbarBeforeRelayout(hadVerticalScrollbar); |
| 1697 |
| 1677 s_relayoutNeeded = true; | 1698 s_relayoutNeeded = true; |
| 1678 if (!s_needsRelayout) | 1699 if (!s_needsRelayout) |
| 1679 s_needsRelayout = new WTF::Vector<LayoutObject*>(); | 1700 s_needsRelayout = new PersistentHeapVector<Member<PaintLayerScrollableAr
ea>>(); |
| 1680 s_needsRelayout->append(&layoutObject); | 1701 s_needsRelayout->append(&scrollableArea); |
| 1681 } | 1702 } |
| 1682 | 1703 |
| 1683 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() | 1704 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() |
| 1684 { | 1705 { |
| 1685 DCHECK_EQ(s_count, 0); | 1706 DCHECK_EQ(s_count, 0); |
| 1686 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty()); | 1707 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty()); |
| 1687 s_relayoutNeeded = false; | 1708 s_relayoutNeeded = false; |
| 1688 } | 1709 } |
| 1689 | 1710 |
| 1690 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0; | 1711 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1716 | 1737 |
| 1717 void PaintLayerScrollableArea::DelayScrollPositionClampScope::clampScrollableAre
as() | 1738 void PaintLayerScrollableArea::DelayScrollPositionClampScope::clampScrollableAre
as() |
| 1718 { | 1739 { |
| 1719 for (auto& scrollableArea : *s_needsClamp) | 1740 for (auto& scrollableArea : *s_needsClamp) |
| 1720 scrollableArea->clampScrollPositionsAfterLayout(); | 1741 scrollableArea->clampScrollPositionsAfterLayout(); |
| 1721 delete s_needsClamp; | 1742 delete s_needsClamp; |
| 1722 s_needsClamp = nullptr; | 1743 s_needsClamp = nullptr; |
| 1723 } | 1744 } |
| 1724 | 1745 |
| 1725 } // namespace blink | 1746 } // namespace blink |
| OLD | NEW |