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

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

Issue 2318243002: Promote opaque fixed position elements. (Closed)
Patch Set: Merge with master 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"
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 613
614 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the middle. 614 // 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); 615 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 3000.0), Programmat icScroll);
616 document().view()->updateAllLifecyclePhases(); 616 document().view()->updateAllLifecyclePhases();
617 617
618 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); 618 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer());
619 // The width is 485 pixels due to the size of the scrollbar. 619 // 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())); 620 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500), recomputeInterestRect(frameDocument .view()->layoutViewItem().enclosingLayer()->graphicsLayerBacking()));
621 } 621 }
622 622
623 TEST_F(CompositedLayerMappingTest, PromoteOpaqueFixedPosition)
624 {
625 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(false);
626 RuntimeEnabledFeatures::setCompositeOpaqueFixedPositionEnabled(true);
chrishtr 2016/09/29 17:25:25 Restore these flags at the end of the test. I thin
flackr 2016/09/29 18:01:28 Done. I couldn't find any helper classes or existi
627
628 setBodyInnerHTML(
629 "<div id='translucent' style='width: 20px; height: 20px; position: fixed ; top: 100px; left: 100px;'></div>"
630 "<div id='opaque' style='width: 20px; height: 20px; position: fixed; top : 100px; left: 200px; background: white;'></div>"
631 "<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>"
632 "<div id='spacer' style='height: 2000px'></div>");
633
634 document().view()->updateAllLifecyclePhases();
635
636 // The translucent fixed box should not be promoted.
637 Element* element = document().getElementById("translucent");
638 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la yer();
639 EXPECT_EQ(NotComposited, paintLayer->compositingState());
640
641 // The opaque fixed box should be promoted and be opaque so that text will b e drawn
642 // with subpixel anti-aliasing.
643 element = document().getElementById("opaque");
644 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
645 EXPECT_EQ(PaintsIntoOwnBacking, paintLayer->compositingState());
646 EXPECT_TRUE(paintLayer->graphicsLayerBacking()->contentsOpaque());
647
648 // The opaque fixed box with shadow should not be promoted because the layer will
649 // include the shadow which is not opaque.
650 element = document().getElementById("opaque-with-shadow");
651 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
652 EXPECT_EQ(NotComposited, paintLayer->compositingState());
653 }
654
655
623 TEST_F(CompositedLayerMappingTest, ScrollingContentsAndForegroundLayerPaintingPh ase) 656 TEST_F(CompositedLayerMappingTest, ScrollingContentsAndForegroundLayerPaintingPh ase)
624 { 657 {
625 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 658 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
626 setBodyInnerHTML( 659 setBodyInnerHTML(
627 "<div id='container' style='position: relative; z-index: 1; overflow: sc roll; width: 300px; height: 300px'>" 660 "<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>" 661 " <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>" 662 " <div style='background-color: blue; width: 2000px; height: 2000px; position: relative; top: 10px'></div>"
630 "</div>"); 663 "</div>");
631 664
632 CompositedLayerMapping* mapping = toLayoutBlock(getLayoutObjectByElementId(" container"))->layer()->compositedLayerMapping(); 665 CompositedLayerMapping* mapping = toLayoutBlock(getLayoutObjectByElementId(" container"))->layer()->compositedLayerMapping();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 document().setRootScroller(nullptr, nonThrow); 819 document().setRootScroller(nullptr, nonThrow);
787 document().view()->updateAllLifecyclePhases(); 820 document().view()->updateAllLifecyclePhases();
788 ASSERT_EQ(document().documentElement(), rootScrollerController.globalRoo tScroller()); 821 ASSERT_EQ(document().documentElement(), rootScrollerController.globalRoo tScroller());
789 822
790 EXPECT_TRUE(mapping3->clippingLayer()); 823 EXPECT_TRUE(mapping3->clippingLayer());
791 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()) ; 824 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()) ;
792 } 825 }
793 } 826 }
794 827
795 } // namespace blink 828 } // 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