Commit d6021f65 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[SPv175] Mask layers should have clip state equal to MaskClip

Otherwise there may be a clip inversion when drawing mask layers
for objects which include CSS clip.

Bug:822906

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I037304f4b6d777bf14aa1204631dac7cf24da139
Reviewed-on: https://chromium-review.googlesource.com/986718Reviewed-by: default avatarTien-Ren Chen <trchen@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547084}
parent 2b603cc6
......@@ -2055,6 +2055,7 @@ jumbo_source_set("unit_tests") {
"paint/compositing/CompositedLayerMappingTest.cpp",
"paint/compositing/CompositingInputsUpdaterTest.cpp",
"paint/compositing/CompositingLayerAssignerTest.cpp",
"paint/compositing/CompositingLayerPropertyUpdaterTest.cpp",
"paint/compositing/CompositingReasonFinderTest.cpp",
"paint/compositing/PaintLayerCompositorTest.cpp",
"paint/ng/ng_paint_fragment_test.cc",
......
......@@ -98,6 +98,8 @@ class CORE_EXPORT ObjectPaintProperties {
// | Clips to a fragment's bounds.
// | This is only present for content under a fragmentation
// | container.
// | NOTE: for composited SPv1/SPv175 clip path clips, we move clip path clip
// | below mask.
// +-[ clip path clip ]
// | Clip created by path-based CSS clip-path. Only exists if the
// / clip-path is "simple" that can be applied geometrically. This and
......
......@@ -104,6 +104,8 @@ void CompositingLayerPropertyUpdater::Update(const LayoutObject& object) {
const auto* properties = fragment_data.PaintProperties();
DCHECK(properties && properties->Mask());
state.SetEffect(properties->Mask());
state.SetClip(properties->MaskClip());
mask_layer->SetLayerState(
state, snapped_paint_offset + mask_layer->OffsetFromLayoutObject());
}
......
// 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 "core/paint/PaintLayer.h"
#include "core/paint/compositing/CompositedLayerMapping.h"
#include "core/paint/compositing/CompositingLayerPropertyUpdater.h"
#include "core/testing/CoreUnitTestHelper.h"
#include "platform/graphics/GraphicsLayer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
class CompositingLayerPropertyUpdaterTest : public RenderingTest {
private:
void SetUp() override {
RenderingTest::SetUp();
EnableCompositing();
}
};
TEST_F(CompositingLayerPropertyUpdaterTest, MaskLayerState) {
SetBodyInnerHTML(R"HTML(
<div id=target style="position: absolute;
clip-path: polygon(-1px -1px, 86px 400px);
clip: rect(9px, -1px, -1px, 96px); will-change: transform">
</div>
)HTML");
PaintLayer* target =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
EXPECT_EQ(kPaintsIntoOwnBacking, target->GetCompositingState());
auto* mapping = target->GetCompositedLayerMapping();
auto* mask_layer = mapping->MaskLayer();
auto* paint_properties =
target->GetLayoutObject().FirstFragment().PaintProperties();
EXPECT_TRUE(paint_properties->CssClip());
EXPECT_TRUE(paint_properties->MaskClip());
EXPECT_EQ(paint_properties->MaskClip(),
mask_layer->layer_state_->state.Clip());
}
} // namespace blink
......@@ -433,6 +433,8 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
std::unique_ptr<CompositedLayerRasterInvalidator> raster_invalidator_;
base::WeakPtrFactory<GraphicsLayer> weak_ptr_factory_;
FRIEND_TEST_ALL_PREFIXES(CompositingLayerPropertyUpdaterTest, MaskLayerState);
};
// ObjectPaintInvalidatorWithContext::InvalidatePaintRectangleWithContext uses
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment