| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
| 10 * Christian Biesinger <cbiesinger@gmail.com> | 10 * Christian Biesinger <cbiesinger@gmail.com> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 m_needsCompositedScrolling(false), | 99 m_needsCompositedScrolling(false), |
| 100 m_rebuildHorizontalScrollbarLayer(false), | 100 m_rebuildHorizontalScrollbarLayer(false), |
| 101 m_rebuildVerticalScrollbarLayer(false), | 101 m_rebuildVerticalScrollbarLayer(false), |
| 102 m_needsScrollOffsetClamp(false), | 102 m_needsScrollOffsetClamp(false), |
| 103 m_needsRelayout(false), | 103 m_needsRelayout(false), |
| 104 m_hadHorizontalScrollbarBeforeRelayout(false), | 104 m_hadHorizontalScrollbarBeforeRelayout(false), |
| 105 m_hadVerticalScrollbarBeforeRelayout(false), | 105 m_hadVerticalScrollbarBeforeRelayout(false), |
| 106 m_scrollbarManager(*this), | 106 m_scrollbarManager(*this), |
| 107 m_scrollCorner(nullptr), | 107 m_scrollCorner(nullptr), |
| 108 m_resizer(nullptr), | 108 m_resizer(nullptr), |
| 109 m_scrollAnchor(this) | 109 m_scrollAnchor(this), |
| 110 m_reasons(0) |
| 110 #if DCHECK_IS_ON() | 111 #if DCHECK_IS_ON() |
| 111 , | 112 , |
| 112 m_hasBeenDisposed(false) | 113 m_hasBeenDisposed(false) |
| 113 #endif | 114 #endif |
| 114 { | 115 { |
| 115 Node* node = box().node(); | 116 Node* node = box().node(); |
| 116 if (node && node->isElementNode()) { | 117 if (node && node->isElementNode()) { |
| 117 // We save and restore only the scrollOffset as the other scroll values are | 118 // We save and restore only the scrollOffset as the other scroll values are |
| 118 // recalculated. | 119 // recalculated. |
| 119 Element* element = toElement(node); | 120 Element* element = toElement(node); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 137 frame->eventHandler().resizeScrollableAreaDestroyed(); | 138 frame->eventHandler().resizeScrollableAreaDestroyed(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 if (LocalFrame* frame = box().frame()) { | 141 if (LocalFrame* frame = box().frame()) { |
| 141 if (FrameView* frameView = frame->view()) { | 142 if (FrameView* frameView = frame->view()) { |
| 142 frameView->removeScrollableArea(this); | 143 frameView->removeScrollableArea(this); |
| 143 frameView->removeAnimatingScrollableArea(this); | 144 frameView->removeAnimatingScrollableArea(this); |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 | 147 |
| 148 removeStyleRelatedMainThreadScrollingReasons(); |
| 149 |
| 147 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) | 150 if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) |
| 148 scrollingCoordinator->willDestroyScrollableArea(this); | 151 scrollingCoordinator->willDestroyScrollableArea(this); |
| 149 | 152 |
| 150 if (!box().documentBeingDestroyed()) { | 153 if (!box().documentBeingDestroyed()) { |
| 151 Node* node = box().node(); | 154 Node* node = box().node(); |
| 152 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. | 155 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. |
| 153 if (node && node->isElementNode()) | 156 if (node && node->isElementNode()) |
| 154 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset); | 157 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset); |
| 155 } | 158 } |
| 156 | 159 |
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 } | 1717 } |
| 1715 | 1718 |
| 1716 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const { | 1719 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const { |
| 1717 if (LocalFrame* frame = box().frame()) { | 1720 if (LocalFrame* frame = box().frame()) { |
| 1718 if (frame->view()->mainThreadScrollingReasons()) | 1721 if (frame->view()->mainThreadScrollingReasons()) |
| 1719 return true; | 1722 return true; |
| 1720 } | 1723 } |
| 1721 return ScrollableArea::shouldScrollOnMainThread(); | 1724 return ScrollableArea::shouldScrollOnMainThread(); |
| 1722 } | 1725 } |
| 1723 | 1726 |
| 1724 static bool layerNeedsCompositedScrolling( | 1727 bool PaintLayerScrollableArea::computeNeedsCompositedScrolling( |
| 1725 PaintLayerScrollableArea::LCDTextMode mode, | 1728 const LCDTextMode mode, |
| 1726 const PaintLayer* layer) { | 1729 const PaintLayer* layer) { |
| 1727 if (!layer->scrollsOverflow()) | 1730 if (!layer->scrollsOverflow()) |
| 1728 return false; | 1731 return false; |
| 1729 | 1732 |
| 1730 Node* node = layer->enclosingNode(); | 1733 Node* node = layer->enclosingNode(); |
| 1731 if (node && node->isElementNode() && | 1734 if (node && node->isElementNode() && |
| 1732 (toElement(node)->compositorMutableProperties() & | 1735 (toElement(node)->compositorMutableProperties() & |
| 1733 (CompositorMutableProperty::kScrollTop | | 1736 (CompositorMutableProperty::kScrollTop | |
| 1734 CompositorMutableProperty::kScrollLeft))) | 1737 CompositorMutableProperty::kScrollLeft))) |
| 1735 return true; | 1738 return true; |
| 1736 | 1739 |
| 1737 // TODO(flackr): Allow integer transforms as long as all of the ancestor | 1740 // TODO(flackr): Allow integer transforms as long as all of the ancestor |
| 1738 // transforms are also integer. | 1741 // transforms are also integer. |
| 1739 bool backgroundSupportsLCDText = | 1742 bool backgroundSupportsLCDText = |
| 1740 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && | 1743 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && |
| 1741 layer->layoutObject()->style()->isStackingContext() && | 1744 layer->layoutObject()->style()->isStackingContext() && |
| 1742 layer->backgroundPaintLocation() & BackgroundPaintInScrollingContents && | 1745 layer->backgroundPaintLocation() & BackgroundPaintInScrollingContents && |
| 1743 layer->backgroundIsKnownToBeOpaqueInRect( | 1746 layer->backgroundIsKnownToBeOpaqueInRect( |
| 1744 toLayoutBox(layer->layoutObject())->paddingBoxRect()) && | 1747 toLayoutBox(layer->layoutObject())->paddingBoxRect()) && |
| 1745 !layer->compositesWithTransform() && !layer->compositesWithOpacity(); | 1748 !layer->compositesWithTransform() && !layer->compositesWithOpacity(); |
| 1749 |
| 1746 if (mode == PaintLayerScrollableArea::ConsiderLCDText && | 1750 if (mode == PaintLayerScrollableArea::ConsiderLCDText && |
| 1747 !layer->compositor()->preferCompositingToLCDTextEnabled() && | 1751 !layer->compositor()->preferCompositingToLCDTextEnabled() && |
| 1748 !backgroundSupportsLCDText) | 1752 !backgroundSupportsLCDText) { |
| 1753 if (layer->compositesWithOpacity()) { |
| 1754 addStyleRelatedMainThreadScrollingReasons( |
| 1755 MainThreadScrollingReason::kHasOpacity); |
| 1756 } |
| 1749 return false; | 1757 return false; |
| 1758 } |
| 1750 | 1759 |
| 1751 // TODO(schenney) Tests fail if we do not also exclude | 1760 // TODO(schenney) Tests fail if we do not also exclude |
| 1752 // layer->layoutObject()->style()->hasBorderDecoration() (missing background | 1761 // layer->layoutObject()->style()->hasBorderDecoration() (missing background |
| 1753 // behind dashed borders). Resolve this case, or not, and update this check | 1762 // behind dashed borders). Resolve this case, or not, and update this check |
| 1754 // with the results. | 1763 // with the results. |
| 1755 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() || | 1764 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() || |
| 1756 layer->hasAncestorWithClipPath() || | 1765 layer->hasAncestorWithClipPath() || |
| 1757 layer->layoutObject()->style()->hasBorderRadius()); | 1766 layer->layoutObject()->style()->hasBorderRadius()); |
| 1758 } | 1767 } |
| 1759 | 1768 |
| 1769 void PaintLayerScrollableArea::addStyleRelatedMainThreadScrollingReasons( |
| 1770 const uint32_t reason) { |
| 1771 LocalFrame* frame = box().frame(); |
| 1772 if (!frame) |
| 1773 return; |
| 1774 FrameView* frameView = frame->view(); |
| 1775 if (!frameView) |
| 1776 return; |
| 1777 |
| 1778 frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, true); |
| 1779 m_reasons |= reason; |
| 1780 } |
| 1781 |
| 1782 void PaintLayerScrollableArea::removeStyleRelatedMainThreadScrollingReasons() { |
| 1783 LocalFrame* frame = box().frame(); |
| 1784 if (!frame) |
| 1785 return; |
| 1786 FrameView* frameView = frame->view(); |
| 1787 if (!frameView) |
| 1788 return; |
| 1789 |
| 1790 // Decrese the number of layers that have any main thread |
| 1791 // scrolling reasons stored in FrameView |
| 1792 for (uint32_t i = 0; |
| 1793 i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) { |
| 1794 uint32_t reason = 1 << i; |
| 1795 if (hasMainThreadScrollingReason(reason)) { |
| 1796 m_reasons &= ~reason; |
| 1797 frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, false); |
| 1798 } |
| 1799 } |
| 1800 } |
| 1801 |
| 1760 void PaintLayerScrollableArea::updateNeedsCompositedScrolling( | 1802 void PaintLayerScrollableArea::updateNeedsCompositedScrolling( |
| 1761 LCDTextMode mode) { | 1803 LCDTextMode mode) { |
| 1804 // Clear all style related main thread scrolling reasons, if any, |
| 1805 // before calling computeNeedsCompositedScrolling |
| 1806 removeStyleRelatedMainThreadScrollingReasons(); |
| 1762 const bool needsCompositedScrolling = | 1807 const bool needsCompositedScrolling = |
| 1763 layerNeedsCompositedScrolling(mode, layer()); | 1808 computeNeedsCompositedScrolling(mode, layer()); |
| 1809 |
| 1764 if (static_cast<bool>(m_needsCompositedScrolling) != | 1810 if (static_cast<bool>(m_needsCompositedScrolling) != |
| 1765 needsCompositedScrolling) { | 1811 needsCompositedScrolling) { |
| 1766 m_needsCompositedScrolling = needsCompositedScrolling; | 1812 m_needsCompositedScrolling = needsCompositedScrolling; |
| 1767 layer()->didUpdateNeedsCompositedScrolling(); | 1813 layer()->didUpdateNeedsCompositedScrolling(); |
| 1768 } | 1814 } |
| 1769 } | 1815 } |
| 1770 | 1816 |
| 1771 void PaintLayerScrollableArea::setTopmostScrollChild(PaintLayer* scrollChild) { | 1817 void PaintLayerScrollableArea::setTopmostScrollChild(PaintLayer* scrollChild) { |
| 1772 // We only want to track the topmost scroll child for scrollable areas with | 1818 // We only want to track the topmost scroll child for scrollable areas with |
| 1773 // overlay scrollbars. | 1819 // overlay scrollbars. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 | 2072 |
| 2027 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 2073 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
| 2028 clampScrollableAreas() { | 2074 clampScrollableAreas() { |
| 2029 for (auto& scrollableArea : *s_needsClamp) | 2075 for (auto& scrollableArea : *s_needsClamp) |
| 2030 scrollableArea->clampScrollOffsetAfterOverflowChange(); | 2076 scrollableArea->clampScrollOffsetAfterOverflowChange(); |
| 2031 delete s_needsClamp; | 2077 delete s_needsClamp; |
| 2032 s_needsClamp = nullptr; | 2078 s_needsClamp = nullptr; |
| 2033 } | 2079 } |
| 2034 | 2080 |
| 2035 } // namespace blink | 2081 } // namespace blink |
| OLD | NEW |