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) |
| 49 { |
| 50 CompositedLayerMapping* mapping = toLayoutBlock(getLayoutObjectByElement
Id(elementId))->layer()->compositedLayerMapping(); |
| 51 return mapping->shouldPaintBackgroundOntoScrollingContentsLayer(); |
| 52 } |
| 53 |
48 private: | 54 private: |
49 void SetUp() override | 55 void SetUp() override |
50 { | 56 { |
51 RenderingTest::SetUp(); | 57 RenderingTest::SetUp(); |
52 enableCompositing(); | 58 enableCompositing(); |
53 } | 59 } |
54 | 60 |
55 void TearDown() override | 61 void TearDown() override |
56 { | 62 { |
57 RenderingTest::TearDown(); | 63 RenderingTest::TearDown(); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 Element* negativeCompositedChild = document().getElementById("negative-compo
sited-child"); | 625 Element* negativeCompositedChild = document().getElementById("negative-compo
sited-child"); |
620 negativeCompositedChild->parentNode()->removeChild(negativeCompositedChild); | 626 negativeCompositedChild->parentNode()->removeChild(negativeCompositedChild); |
621 document().view()->updateAllLifecyclePhases(); | 627 document().view()->updateAllLifecyclePhases(); |
622 | 628 |
623 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c
ompositedLayerMapping(); | 629 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c
ompositedLayerMapping(); |
624 ASSERT_TRUE(mapping->scrollingContentsLayer()); | 630 ASSERT_TRUE(mapping->scrollingContentsLayer()); |
625 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow
Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m
apping->scrollingContentsLayer()->paintingPhase()); | 631 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow
Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m
apping->scrollingContentsLayer()->paintingPhase()); |
626 EXPECT_FALSE(mapping->foregroundLayer()); | 632 EXPECT_FALSE(mapping->foregroundLayer()); |
627 } | 633 } |
628 | 634 |
| 635 TEST_F(CompositedLayerMappingTest, ShouldPaintBackgroundOntoScrollingContentsLay
er) |
| 636 { |
| 637 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| 638 setBodyInnerHTML( |
| 639 "<style>.scroller { overflow: scroll; will-change: transform; width: 300
px; height: 300px;} .spacer { height: 1000px; }</style>" |
| 640 "<div id='scroller1' class='scroller' style='background: white local;'>" |
| 641 " <div id='negative-composited-child' style='background-color: red; w
idth: 1px; height: 1px; position: absolute; backface-visibility: hidden; z-index
: -1'></div>" |
| 642 " <div class='spacer'></div>" |
| 643 "</div>" |
| 644 "<div id='scroller2' class='scroller' style='background: white content-b
ox; padding: 10px;'>" |
| 645 " <div class='spacer'></div>" |
| 646 "</div>" |
| 647 "<div id='scroller3' class='scroller' style='background: white local con
tent-box; padding: 10px;'>" |
| 648 " <div class='spacer'></div>" |
| 649 "</div>" |
| 650 ); |
| 651 |
| 652 // First scroller cannot paint background into scrolling contents layer beca
use it has a negative z-index child. |
| 653 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller1")); |
| 654 |
| 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")); |
| 657 |
| 658 // Third scroller can paint background into scrolling contents layer. |
| 659 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller3")); |
| 660 } |
| 661 |
629 } // namespace blink | 662 } // namespace blink |
OLD | NEW |