Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
| index a6c4b4440b2bc3c701e2f9beaf71d61a293a8e20..5728f05cedda396ce9fe5a129d4beca88220707f 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
| @@ -115,7 +115,7 @@ PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) |
| m_scrollCorner(nullptr), |
| m_resizer(nullptr), |
| m_scrollAnchor(this), |
| - m_reasons(0) |
| + m_nonCompositedMainThreadScrollingReasons(0) |
| #if DCHECK_IS_ON() |
| , |
| m_hasBeenDisposed(false) |
| @@ -153,7 +153,7 @@ void PaintLayerScrollableArea::dispose() { |
| } |
| } |
| - removeStyleRelatedMainThreadScrollingReasons(); |
| + m_nonCompositedMainThreadScrollingReasons = 0; |
| if (ScrollingCoordinator* scrollingCoordinator = getScrollingCoordinator()) |
| scrollingCoordinator->willDestroyScrollableArea(this); |
| @@ -1774,6 +1774,9 @@ bool PaintLayerScrollableArea::shouldScrollOnMainThread() const { |
| bool PaintLayerScrollableArea::computeNeedsCompositedScrolling( |
| const LCDTextMode mode, |
| const PaintLayer* layer) { |
| + // Clear all non composited main thread scrolling reasons, if any, |
| + // before continuing computeNeedsCompositedScrolling |
|
bokan
2017/03/28 15:30:16
Comment unneeded.
|
| + m_nonCompositedMainThreadScrollingReasons = 0; |
| if (!layer->scrollsOverflow()) |
| return false; |
| @@ -1788,14 +1791,14 @@ bool PaintLayerScrollableArea::computeNeedsCompositedScrolling( |
| return false; |
| bool needsCompositedScrolling = true; |
| - uint32_t mainThreadScrollingReasons = 0; |
| // TODO(flackr): Allow integer transforms as long as all of the ancestor |
| // transforms are also integer. |
| bool backgroundSupportsLCDText = |
| RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && |
| layer->layoutObject().style()->isStackingContext() && |
| - layer->backgroundPaintLocation(&mainThreadScrollingReasons) & |
| + layer->backgroundPaintLocation( |
| + &m_nonCompositedMainThreadScrollingReasons) & |
| BackgroundPaintInScrollingContents && |
| layer->backgroundIsKnownToBeOpaqueInRect( |
| toLayoutBox(layer->layoutObject()).paddingBoxRect()) && |
| @@ -1805,16 +1808,16 @@ bool PaintLayerScrollableArea::computeNeedsCompositedScrolling( |
| !layer->compositor()->preferCompositingToLCDTextEnabled() && |
| !backgroundSupportsLCDText) { |
| if (layer->compositesWithOpacity()) { |
| - mainThreadScrollingReasons |= |
| + m_nonCompositedMainThreadScrollingReasons |= |
| MainThreadScrollingReason::kHasOpacityAndLCDText; |
| } |
| if (layer->compositesWithTransform()) { |
| - mainThreadScrollingReasons |= |
| + m_nonCompositedMainThreadScrollingReasons |= |
| MainThreadScrollingReason::kHasTransformAndLCDText; |
| } |
| if (!layer->backgroundIsKnownToBeOpaqueInRect( |
| toLayoutBox(layer->layoutObject()).paddingBoxRect())) { |
| - mainThreadScrollingReasons |= |
| + m_nonCompositedMainThreadScrollingReasons |= |
| MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; |
| } |
| @@ -1826,67 +1829,22 @@ bool PaintLayerScrollableArea::computeNeedsCompositedScrolling( |
| // behind dashed borders). Resolve this case, or not, and update this check |
| // with the results. |
| if (layer->layoutObject().style()->hasBorderRadius()) { |
| - mainThreadScrollingReasons |= MainThreadScrollingReason::kHasBorderRadius; |
| + m_nonCompositedMainThreadScrollingReasons |= |
| + MainThreadScrollingReason::kHasBorderRadius; |
| needsCompositedScrolling = false; |
| } |
| if (layer->layoutObject().hasClip() || layer->hasDescendantWithClipPath() || |
| layer->hasAncestorWithClipPath()) { |
| - mainThreadScrollingReasons |= |
| + m_nonCompositedMainThreadScrollingReasons |= |
| MainThreadScrollingReason::kHasClipRelatedProperty; |
| needsCompositedScrolling = false; |
| } |
| - if (mainThreadScrollingReasons) { |
| - addStyleRelatedMainThreadScrollingReasons(mainThreadScrollingReasons); |
| - } |
| - |
| return needsCompositedScrolling; |
| } |
| -void PaintLayerScrollableArea::addStyleRelatedMainThreadScrollingReasons( |
| - const uint32_t reasons) { |
| - LocalFrame* frame = box().frame(); |
| - if (!frame) |
| - return; |
| - FrameView* frameView = frame->view(); |
| - if (!frameView) |
| - return; |
| - |
| - for (uint32_t reason = 1; |
| - reason < 1 << MainThreadScrollingReason::kMainThreadScrollingReasonCount; |
| - reason <<= 1) { |
| - if (reasons & reason) { |
| - frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, true); |
| - m_reasons |= reason; |
| - } |
| - } |
| -} |
| - |
| -void PaintLayerScrollableArea::removeStyleRelatedMainThreadScrollingReasons() { |
| - LocalFrame* frame = box().frame(); |
| - if (!frame) |
| - return; |
| - FrameView* frameView = frame->view(); |
| - if (!frameView) |
| - return; |
| - |
| - // Decrease the number of layers that have any main thread |
| - // scrolling reasons stored in FrameView |
| - for (uint32_t i = 0; |
| - i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) { |
| - uint32_t reason = 1 << i; |
| - if (hasMainThreadScrollingReason(reason)) { |
| - m_reasons &= ~reason; |
| - frameView->adjustStyleRelatedMainThreadScrollingReasons(reason, false); |
| - } |
| - } |
| -} |
| - |
| void PaintLayerScrollableArea::updateNeedsCompositedScrolling( |
| LCDTextMode mode) { |
| - // Clear all style related main thread scrolling reasons, if any, |
| - // before calling computeNeedsCompositedScrolling |
| - removeStyleRelatedMainThreadScrollingReasons(); |
| const bool needsCompositedScrolling = |
| computeNeedsCompositedScrolling(mode, layer()); |