Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp

Issue 2259493004: Fix Compositing of Opaque Scrolling Layers and Add Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
54 private: 48 private:
55 void SetUp() override 49 void SetUp() override
56 { 50 {
57 RenderingTest::SetUp(); 51 RenderingTest::SetUp();
58 enableCompositing(); 52 enableCompositing();
59 } 53 }
60 54
61 void TearDown() override 55 void TearDown() override
62 { 56 {
63 RenderingTest::TearDown(); 57 RenderingTest::TearDown();
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 Element* negativeCompositedChild = document().getElementById("negative-compo sited-child"); 619 Element* negativeCompositedChild = document().getElementById("negative-compo sited-child");
626 negativeCompositedChild->parentNode()->removeChild(negativeCompositedChild); 620 negativeCompositedChild->parentNode()->removeChild(negativeCompositedChild);
627 document().view()->updateAllLifecyclePhases(); 621 document().view()->updateAllLifecyclePhases();
628 622
629 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c ompositedLayerMapping(); 623 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c ompositedLayerMapping();
630 ASSERT_TRUE(mapping->scrollingContentsLayer()); 624 ASSERT_TRUE(mapping->scrollingContentsLayer());
631 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m apping->scrollingContentsLayer()->paintingPhase()); 625 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m apping->scrollingContentsLayer()->paintingPhase());
632 EXPECT_FALSE(mapping->foregroundLayer()); 626 EXPECT_FALSE(mapping->foregroundLayer());
633 } 627 }
634 628
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;'><div class='spacer'></div></div>"
645 "<div id='scroller3' class='scroller' style='background: white local con tent-box; padding: 10px;'><div class='spacer'></div></div>"
646 "<div id='scroller4' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg), white local;'><div class='spacer'></div></di v>"
647 "<div id='scroller5' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white local;'><div class='spacer'></di v></div>"
648 "<div id='scroller6' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white padding-box; padding: 10px;'><di v class='spacer'></div></div>"
649 "<div id='scroller7' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white content-box; padding: 10px;'><di v class='spacer'></div></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 // Fourth scroller cannot paint background into scrolling contents layer bec ause the background image is not locally attached.
662 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller4"));
663
664 // Fifth scroller can paint background into scrolling contents layer because both the image and color are locally attached.
665 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller5"));
666
667 // Sixth scroller can paint background into scrolling contents layer because the image is locally attached and even though
668 // the color is not, it is filled to the padding box so it will be drawn the same as a locally attached background.
669 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller6"));
670
671 // Seventh scroller cannot paint background into scrolling contents layer be cause the color is filled to the content
672 // box and we have padding so it is not equivalent to a locally attached bac kground.
673 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller7"));
674 }
675
676 } // namespace blink 629 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698