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 9d2e3244d4bbc060bbbc4de05139fca73412ee74..b54debdf94fa585ad6f7cdec05cdeb0556f4b3b5 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
@@ -114,7 +114,7 @@ PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) |
scroll_corner_(nullptr), |
resizer_(nullptr), |
scroll_anchor_(this), |
- reasons_(0) |
+ non_composited_main_thread_scrolling_reasons_(0) |
#if DCHECK_IS_ON() |
, |
has_been_disposed_(false) |
@@ -152,7 +152,7 @@ void PaintLayerScrollableArea::Dispose() { |
} |
} |
- RemoveStyleRelatedMainThreadScrollingReasons(); |
+ non_composited_main_thread_scrolling_reasons_ = 0; |
if (ScrollingCoordinator* scrolling_coordinator = GetScrollingCoordinator()) |
scrolling_coordinator->WillDestroyScrollableArea(this); |
@@ -1796,6 +1796,7 @@ bool PaintLayerScrollableArea::ShouldScrollOnMainThread() const { |
bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling( |
const LCDTextMode mode, |
const PaintLayer* layer) { |
+ non_composited_main_thread_scrolling_reasons_ = 0; |
if (!layer->ScrollsOverflow()) |
return false; |
@@ -1810,14 +1811,14 @@ bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling( |
return false; |
bool needs_composited_scrolling = true; |
- uint32_t main_thread_scrolling_reasons = 0; |
// TODO(flackr): Allow integer transforms as long as all of the ancestor |
// transforms are also integer. |
bool background_supports_lcd_text = |
RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && |
layer->GetLayoutObject().Style()->IsStackingContext() && |
- layer->GetBackgroundPaintLocation(&main_thread_scrolling_reasons) & |
+ layer->GetBackgroundPaintLocation( |
+ &non_composited_main_thread_scrolling_reasons_) & |
kBackgroundPaintInScrollingContents && |
layer->BackgroundIsKnownToBeOpaqueInRect( |
ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect()) && |
@@ -1827,16 +1828,16 @@ bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling( |
!layer->Compositor()->PreferCompositingToLCDTextEnabled() && |
!background_supports_lcd_text) { |
if (layer->CompositesWithOpacity()) { |
- main_thread_scrolling_reasons |= |
+ non_composited_main_thread_scrolling_reasons_ |= |
MainThreadScrollingReason::kHasOpacityAndLCDText; |
} |
if (layer->CompositesWithTransform()) { |
- main_thread_scrolling_reasons |= |
+ non_composited_main_thread_scrolling_reasons_ |= |
MainThreadScrollingReason::kHasTransformAndLCDText; |
} |
if (!layer->BackgroundIsKnownToBeOpaqueInRect( |
ToLayoutBox(layer->GetLayoutObject()).PaddingBoxRect())) { |
- main_thread_scrolling_reasons |= |
+ non_composited_main_thread_scrolling_reasons_ |= |
MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; |
} |
@@ -1848,68 +1849,22 @@ bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling( |
// behind dashed borders). Resolve this case, or not, and update this check |
// with the results. |
if (layer->GetLayoutObject().Style()->HasBorderRadius()) { |
- main_thread_scrolling_reasons |= |
+ non_composited_main_thread_scrolling_reasons_ |= |
MainThreadScrollingReason::kHasBorderRadius; |
needs_composited_scrolling = false; |
} |
if (layer->GetLayoutObject().HasClip() || |
layer->HasDescendantWithClipPath() || layer->HasAncestorWithClipPath()) { |
- main_thread_scrolling_reasons |= |
+ non_composited_main_thread_scrolling_reasons_ |= |
MainThreadScrollingReason::kHasClipRelatedProperty; |
needs_composited_scrolling = false; |
} |
flackr
2017/04/11 19:35:36
Can you add a check that the reasons are one of th
yigu
2017/04/11 21:28:11
Done.
|
- if (main_thread_scrolling_reasons) { |
- AddStyleRelatedMainThreadScrollingReasons(main_thread_scrolling_reasons); |
- } |
- |
return needs_composited_scrolling; |
} |
-void PaintLayerScrollableArea::AddStyleRelatedMainThreadScrollingReasons( |
- const uint32_t reasons) { |
- LocalFrame* frame = Box().GetFrame(); |
- if (!frame) |
- return; |
- FrameView* frame_view = frame->View(); |
- if (!frame_view) |
- return; |
- |
- for (uint32_t reason = 1; |
- reason < 1 << MainThreadScrollingReason::kMainThreadScrollingReasonCount; |
- reason <<= 1) { |
- if (reasons & reason) { |
- frame_view->AdjustStyleRelatedMainThreadScrollingReasons(reason, true); |
- reasons_ |= reason; |
- } |
- } |
-} |
- |
-void PaintLayerScrollableArea::RemoveStyleRelatedMainThreadScrollingReasons() { |
- LocalFrame* frame = Box().GetFrame(); |
- if (!frame) |
- return; |
- FrameView* frame_view = frame->View(); |
- if (!frame_view) |
- 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)) { |
- reasons_ &= ~reason; |
- frame_view->AdjustStyleRelatedMainThreadScrollingReasons(reason, false); |
- } |
- } |
-} |
- |
void PaintLayerScrollableArea::UpdateNeedsCompositedScrolling( |
LCDTextMode mode) { |
- // Clear all style related main thread scrolling reasons, if any, |
- // before calling computeNeedsCompositedScrolling |
- RemoveStyleRelatedMainThreadScrollingReasons(); |
const bool needs_composited_scrolling = |
ComputeNeedsCompositedScrolling(mode, Layer()); |