blob: f191ecd0ba2cb8108ffb3cfa9225ae440f15ff6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/graphics/graphics_layer.h"
namespace blink {
class CompositedLayerAssignerTest : public RenderingTest {
private:
void SetUp() override {
EnableCompositing();
RenderingTest::SetUp();
}
};
TEST_F(CompositedLayerAssignerTest, SquashingSimple) {
SetBodyInnerHTML(R"HTML(
<div>
<div style="width: 20px; height: 20px; will-change: transform"></div>
</div>
<div id="squashed" style="position: absolute; top: 0; width: 100px;
height: 100px; background: green"></div>
)HTML");
PaintLayer* squashed =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("squashed"))->Layer();
EXPECT_EQ(kPaintsIntoGroupedBacking, squashed->GetCompositingState());
}
TEST_F(CompositedLayerAssignerTest, SquashingAcrossClipPathDisallowed) {
SetBodyInnerHTML(R"HTML(
<div style="clip-path: circle(100%)">
<div style="width: 20px; height: 20px; will-change: transform"></div>
</div>
<div id="squashed" style="position: absolute; top: 0; width: 100px;
height: 100px; background: green"></div>
)HTML");
// #squashed should not be squashed after all, because of the clip path above
// #squashing.
PaintLayer* squashed =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("squashed"))->Layer();
EXPECT_EQ(kPaintsIntoOwnBacking, squashed->GetCompositingState());
}
TEST_F(CompositedLayerAssignerTest, SquashingAcrossMaskDisallowed) {
SetBodyInnerHTML(R"HTML(
<div style="-webkit-mask-image: linear-gradient(black, white);">
<div style="width: 20px; height: 20px; will-change: transform"></div>
</div>
<div id="squashed" style="position: absolute; top: 0; width: 100px;
height: 100px; background: green"></div>
)HTML");
// #squashed should not be squashed after all, because of the mask above
// #squashing.
PaintLayer* squashed =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("squashed"))->Layer();
EXPECT_EQ(kPaintsIntoOwnBacking, squashed->GetCompositingState());
}
} // namespace blink
|