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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c
ompositedLayerMapping(); | 629 mapping = toLayoutBlock(getLayoutObjectByElementId("container"))->layer()->c
ompositedLayerMapping(); |
630 ASSERT_TRUE(mapping->scrollingContentsLayer()); | 630 ASSERT_TRUE(mapping->scrollingContentsLayer()); |
631 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()); |
632 EXPECT_FALSE(mapping->foregroundLayer()); | 632 EXPECT_FALSE(mapping->foregroundLayer()); |
633 } | 633 } |
634 | 634 |
635 TEST_F(CompositedLayerMappingTest, ShouldPaintBackgroundOntoScrollingContentsLay
er) | 635 TEST_F(CompositedLayerMappingTest, ShouldPaintBackgroundOntoScrollingContentsLay
er) |
636 { | 636 { |
637 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 637 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
638 setBodyInnerHTML( | 638 setBodyInnerHTML( |
639 "<style>.scroller { overflow: scroll; will-change: transform; width: 300
px; height: 300px;} .spacer { height: 1000px; }</style>" | 639 "<style>" |
| 640 ".scroller { overflow: scroll; will-change: transform; width: 300px; hei
ght: 300px;} .spacer { height: 1000px; }" |
| 641 "#scroller13::-webkit-scrollbar { width: 13px; height: 13px;}" |
| 642 "</style>" |
640 "<div id='scroller1' class='scroller' style='background: white local;'>" | 643 "<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>" | 644 " <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>" | 645 " <div class='spacer'></div>" |
643 "</div>" | 646 "</div>" |
644 "<div id='scroller2' class='scroller' style='background: white content-b
ox; padding: 10px;'><div class='spacer'></div></div>" | 647 "<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>" | 648 "<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>" | 649 "<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>" | 650 "<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>" | 651 "<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>" | 652 "<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>" |
| 653 "<div id='scroller8' class='scroller' style='background: white border-bo
x;'><div class='spacer'></div></div>" |
| 654 "<div id='scroller9' class='scroller' style='background: white border-bo
x; border: 10px solid black;'><div class='spacer'></div></div>" |
| 655 "<div id='scroller10' class='scroller' style='background: white border-b
ox; border: 10px solid rgba(0, 0, 0, 0.5);'><div class='spacer'></div></div>" |
| 656 "<div id='scroller11' class='scroller' style='background: white content-
box;'><div class='spacer'></div></div>" |
| 657 "<div id='scroller12' class='scroller' style='background: white content-
box; padding: 10px;'><div class='spacer'></div></div>" |
| 658 "<div id='scroller13' class='scroller' style='background: white border-b
ox;'><div class='spacer'></div></div>" |
| 659 "<div id='scroller14' class='scroller' style='background: white; border:
1px solid black; outline: 1px solid blue; outline-offset: -1px;'><div class='sp
acer'></div></div>" |
| 660 "<div id='scroller15' class='scroller' style='background: white; border:
1px solid black; outline: 1px solid blue; outline-offset: -2px;'><div class='sp
acer'></div></div>" |
650 ); | 661 ); |
651 | 662 |
652 // First scroller cannot paint background into scrolling contents layer beca
use it has a negative z-index child. | 663 // #scroller1 cannot paint background into scrolling contents layer because
it has a negative z-index child. |
653 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller1")); | 664 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller1")); |
654 | 665 |
655 // Second scroller cannot paint background into scrolling contents layer bec
ause it has a content-box clip without local attachment. | 666 // #scroller2 cannot paint background into scrolling contents layer because
it has a content-box clip without local attachment. |
656 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller2")); | 667 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller2")); |
657 | 668 |
658 // Third scroller can paint background into scrolling contents layer. | 669 // #scroller3 can paint background into scrolling contents layer. |
659 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller3")); | 670 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller3")); |
660 | 671 |
661 // Fourth scroller cannot paint background into scrolling contents layer bec
ause the background image is not locally attached. | 672 // #scroller4 cannot paint background into scrolling contents layer because
the background image is not locally attached. |
662 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller4")); | 673 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller4")); |
663 | 674 |
664 // Fifth scroller can paint background into scrolling contents layer because
both the image and color are locally attached. | 675 // #scroller5 can paint background into scrolling contents layer because bot
h the image and color are locally attached. |
665 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller5")); | 676 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller5")); |
666 | 677 |
667 // Sixth scroller can paint background into scrolling contents layer because
the image is locally attached and even though | 678 // #scroller6 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. | 679 // 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")); | 680 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller6")); |
670 | 681 |
671 // Seventh scroller cannot paint background into scrolling contents layer be
cause the color is filled to the content | 682 // #scroller7 cannot paint background into scrolling contents layer because
the color is filled to the content |
672 // box and we have padding so it is not equivalent to a locally attached bac
kground. | 683 // box and we have padding so it is not equivalent to a locally attached bac
kground. |
673 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller7")); | 684 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller7")); |
| 685 |
| 686 // #scroller8 can paint background into scrolling contents layer because its
border-box is equivalent to its |
| 687 // padding box since it has no border. |
| 688 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller8")); |
| 689 |
| 690 // #scroller9 can paint background into scrolling contents layer because its
border is opaque so it completely |
| 691 // covers the background outside of the padding-box. |
| 692 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller9")); |
| 693 |
| 694 // #scroller10 cannot paint background into scrolling contents layer because
its border is partially transparent |
| 695 // so the background must be drawn to the border-box edges. |
| 696 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller10")); |
| 697 |
| 698 // #scroller11 can paint background into scrolling contents layer because it
s content-box is equivalent to its |
| 699 // padding box since it has no padding. |
| 700 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller11")); |
| 701 |
| 702 // #scroller12 cannot paint background into scrolling contents layer because
it has padding so its content-box |
| 703 // is not equivalent to its padding-box. |
| 704 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller12")); |
| 705 |
| 706 // #scroller13 cannot paint background into scrolling contents layer because
it has a custom |
| 707 // scrollbar which the background may need to draw under. |
| 708 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller13")); |
| 709 |
| 710 // #scroller14 can paint background into scrolling contents layer because th
e outline is drawn outside the |
| 711 // padding box. |
| 712 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller14")); |
| 713 |
| 714 // #scroller15 cannot paint background into scrolling contents layer because
the outline is drawn inside |
| 715 // the padding box. |
| 716 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller15")); |
674 } | 717 } |
675 | 718 |
676 } // namespace blink | 719 } // namespace blink |
OLD | NEW |