| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/compositing/CompositedLayerMapping.h" | 5 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
| 9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "core/layout/api/LayoutViewItem.h" | 10 #include "core/layout/api/LayoutViewItem.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect,
const IntRect& newInterestRect, const IntSize& layerSize) | 38 bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect,
const IntRect& newInterestRect, const IntSize& layerSize) |
| 39 { | 39 { |
| 40 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previo
usInterestRect, newInterestRect, layerSize); | 40 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previo
usInterestRect, newInterestRect, layerSize); |
| 41 } | 41 } |
| 42 | 42 |
| 43 IntRect previousInterestRect(const GraphicsLayer* graphicsLayer) | 43 IntRect previousInterestRect(const GraphicsLayer* graphicsLayer) |
| 44 { | 44 { |
| 45 return graphicsLayer->m_previousInterestRect; | 45 return graphicsLayer->m_previousInterestRect; |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool shouldPaintBackgroundOntoScrollingContentsLayer(const char* elementId) | 48 bool canPaintBackgroundOntoScrollingContentsLayer(const char* elementId) |
| 49 { | 49 { |
| 50 CompositedLayerMapping* mapping = toLayoutBlock(getLayoutObjectByElement
Id(elementId))->layer()->compositedLayerMapping(); | 50 CompositedLayerMapping* mapping = toLayoutBlock(getLayoutObjectByElement
Id(elementId))->layer()->compositedLayerMapping(); |
| 51 return mapping->shouldPaintBackgroundOntoScrollingContentsLayer(); | 51 return mapping->canPaintBackgroundOntoScrollingContentsLayer(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 void SetUp() override | 55 void SetUp() override |
| 56 { | 56 { |
| 57 RenderingTest::SetUp(); | 57 RenderingTest::SetUp(); |
| 58 enableCompositing(); | 58 enableCompositing(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void TearDown() override | 61 void TearDown() override |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 "</div>" | 643 "</div>" |
| 644 "<div id='scroller2' class='scroller' style='background: white content-b
ox; padding: 10px;'>" | 644 "<div id='scroller2' class='scroller' style='background: white content-b
ox; padding: 10px;'>" |
| 645 " <div class='spacer'></div>" | 645 " <div class='spacer'></div>" |
| 646 "</div>" | 646 "</div>" |
| 647 "<div id='scroller3' class='scroller' style='background: white local con
tent-box; padding: 10px;'>" | 647 "<div id='scroller3' class='scroller' style='background: white local con
tent-box; padding: 10px;'>" |
| 648 " <div class='spacer'></div>" | 648 " <div class='spacer'></div>" |
| 649 "</div>" | 649 "</div>" |
| 650 ); | 650 ); |
| 651 | 651 |
| 652 // First scroller cannot paint background into scrolling contents layer beca
use it has a negative z-index child. | 652 // First scroller cannot paint background into scrolling contents layer beca
use it has a negative z-index child. |
| 653 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller1")); | 653 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller1")); |
| 654 | 654 |
| 655 // Second scroller cannot paint background into scrolling contents layer bec
ause it has a content-box clip without local attachment. | 655 // Second scroller cannot paint background into scrolling contents layer bec
ause it has a content-box clip without local attachment. |
| 656 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller2")); | 656 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller2")); |
| 657 | 657 |
| 658 // Third scroller can paint background into scrolling contents layer. | 658 // Third scroller can paint background into scrolling contents layer. |
| 659 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller3")); | 659 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller3")); |
| 660 } |
| 661 |
| 662 TEST_F(CompositedLayerMappingTest, BackgroundPaintedIntoGraphicsLayerIfNotCompos
itedScrolling) |
| 663 { |
| 664 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| 665 setBodyInnerHTML( |
| 666 "<div id='container' style='overflow: scroll; width: 300px; height: 300p
x; border-radius: 5px; background: white local; will-change: transform;'>" |
| 667 " <div style='background-color: blue; width: 2000px; height: 2000px;'
></div>" |
| 668 "</div>"); |
| 669 |
| 670 PaintLayer* layer = toLayoutBlock(getLayoutObjectByElementId("container"))->
layer(); |
| 671 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("container")); |
| 672 |
| 673 // We currently don't use composited scrolling when the container has a bord
er-radius |
| 674 // so even though we can paint the background onto the scrolling contents la
yer we |
| 675 // don't have a scrolling contents layer to paint into in this case. |
| 676 CompositedLayerMapping* mapping = layer->compositedLayerMapping(); |
| 677 EXPECT_FALSE(mapping->hasScrollingLayer()); |
| 678 EXPECT_FALSE(mapping->backgroundPaintsOntoScrollingContentsLayer()); |
| 660 } | 679 } |
| 661 | 680 |
| 662 } // namespace blink | 681 } // namespace blink |
| OLD | NEW |