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

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

Issue 2318243002: Promote opaque fixed position elements. (Closed)
Patch Set: Use ScopedRuntimeEnabledFeatureForTest. Created 4 years, 2 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/compositing/CompositingReasonFinder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "core/page/scrolling/TopDocumentRootScrollerController.h" 11 #include "core/page/scrolling/TopDocumentRootScrollerController.h"
12 #include "core/paint/PaintLayer.h" 12 #include "core/paint/PaintLayer.h"
13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class CompositedLayerMappingTest : public RenderingTest { 18 class CompositedLayerMappingTest : public RenderingTest {
18 public: 19 public:
19 CompositedLayerMappingTest() 20 CompositedLayerMappingTest()
20 : RenderingTest(SingleChildFrameLoaderClient::create()) 21 : RenderingTest(SingleChildFrameLoaderClient::create())
21 { } 22 { }
22 23
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 614
614 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the middle. 615 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the middle.
615 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 3000.0), Programmat icScroll); 616 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 3000.0), Programmat icScroll);
616 document().view()->updateAllLifecyclePhases(); 617 document().view()->updateAllLifecyclePhases();
617 618
618 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); 619 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer());
619 // The width is 485 pixels due to the size of the scrollbar. 620 // The width is 485 pixels due to the size of the scrollbar.
620 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500), recomputeInterestRect(frameDocument .view()->layoutViewItem().enclosingLayer()->graphicsLayerBacking())); 621 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500), recomputeInterestRect(frameDocument .view()->layoutViewItem().enclosingLayer()->graphicsLayerBacking()));
621 } 622 }
622 623
624 TEST_F(CompositedLayerMappingTest, PromoteOpaqueFixedPosition)
625 {
626 const bool preferCompositing = document().frame()->settings()->preferComposi tingToLCDTextEnabled();
627 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(false);
628 ScopedCompositeFixedPositionForTest compositeFixedPosition(true);
629
630 setBodyInnerHTML(
631 "<div id='translucent' style='width: 20px; height: 20px; position: fixed ; top: 100px; left: 100px;'></div>"
632 "<div id='opaque' style='width: 20px; height: 20px; position: fixed; top : 100px; left: 200px; background: white;'></div>"
633 "<div id='opaque-with-shadow' style='width: 20px; height: 20px; position : fixed; top: 100px; left: 300px; background: white; box-shadow: 10px 10px 5px # 888888;'></div>"
634 "<div id='spacer' style='height: 2000px'></div>");
635
636 document().view()->updateAllLifecyclePhases();
637
638 // The translucent fixed box should not be promoted.
639 Element* element = document().getElementById("translucent");
640 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la yer();
641 EXPECT_EQ(NotComposited, paintLayer->compositingState());
642
643 // The opaque fixed box should be promoted and be opaque so that text will b e drawn
644 // with subpixel anti-aliasing.
645 element = document().getElementById("opaque");
646 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
647 EXPECT_EQ(PaintsIntoOwnBacking, paintLayer->compositingState());
648 EXPECT_TRUE(paintLayer->graphicsLayerBacking()->contentsOpaque());
649
650 // The opaque fixed box with shadow should not be promoted because the layer will
651 // include the shadow which is not opaque.
652 element = document().getElementById("opaque-with-shadow");
653 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
654 EXPECT_EQ(NotComposited, paintLayer->compositingState());
655
656 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(preferC ompositing);
657 }
658
659
623 TEST_F(CompositedLayerMappingTest, ScrollingContentsAndForegroundLayerPaintingPh ase) 660 TEST_F(CompositedLayerMappingTest, ScrollingContentsAndForegroundLayerPaintingPh ase)
624 { 661 {
625 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 662 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
626 setBodyInnerHTML( 663 setBodyInnerHTML(
627 "<div id='container' style='position: relative; z-index: 1; overflow: sc roll; width: 300px; height: 300px'>" 664 "<div id='container' style='position: relative; z-index: 1; overflow: sc roll; width: 300px; height: 300px'>"
628 " <div id='negative-composited-child' style='background-color: red; w idth: 1px; height: 1px; position: absolute; backface-visibility: hidden; z-index : -1'></div>" 665 " <div id='negative-composited-child' style='background-color: red; w idth: 1px; height: 1px; position: absolute; backface-visibility: hidden; z-index : -1'></div>"
629 " <div style='background-color: blue; width: 2000px; height: 2000px; position: relative; top: 10px'></div>" 666 " <div style='background-color: blue; width: 2000px; height: 2000px; position: relative; top: 10px'></div>"
630 "</div>"); 667 "</div>");
631 668
632 CompositedLayerMapping* mapping = toLayoutBlock(getLayoutObjectByElementId(" container"))->layer()->compositedLayerMapping(); 669 CompositedLayerMapping* mapping = toLayoutBlock(getLayoutObjectByElementId(" container"))->layer()->compositedLayerMapping();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 document().setRootScroller(nullptr, nonThrow); 823 document().setRootScroller(nullptr, nonThrow);
787 document().view()->updateAllLifecyclePhases(); 824 document().view()->updateAllLifecyclePhases();
788 ASSERT_EQ(document().documentElement(), rootScrollerController.globalRoo tScroller()); 825 ASSERT_EQ(document().documentElement(), rootScrollerController.globalRoo tScroller());
789 826
790 EXPECT_TRUE(mapping3->clippingLayer()); 827 EXPECT_TRUE(mapping3->clippingLayer());
791 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()) ; 828 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()) ;
792 } 829 }
793 } 830 }
794 831
795 } // namespace blink 832 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/compositing/CompositingReasonFinder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698