Commit 5c301712 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Fix CompositingContainer for replaced normal-flow stacking contexts.

For such PaintLayers, the CompositingContainer is the parent, not the
containing stacking context. This is because such stacking contexts
paint during the normal-flow of the ancestor layout object.

This also allows us to enable subsequence caching; the previous attempt
last week was still suffering from the under-invalidation reported
in issue 859520.

The testcases that crash on ASAN from the referenced bugs are fixed;
one such example is included in this CL.

Bug:859294,719835,723076,859520

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I6ab5271d70bd834482c22b89f09b93907788ed0c
Reviewed-on: https://chromium-review.googlesource.com/1125269
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572428}
parent e1dd1a78
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<style>
svg { position: relative }
</style>
This test passes if it does not crash.
<svg style="position:relative">
<foreignObject>
<div id="target" style="">test</div>
</foreignObject>
</svg>
<script>
onload = () => {
async_test(t => {
runAfterLayoutAndPaint(t.step_func_done(() => {
target.style.position='relative';
}));
});
};
</script>
......@@ -57,7 +57,8 @@ class GraphicsLayerUpdater::UpdateContext {
const PaintLayer* CompositingContainer(const PaintLayer& layer) const {
const PaintLayer* compositing_container;
if (layer.GetLayoutObject().StyleRef().IsStacked()) {
if (layer.GetLayoutObject().StyleRef().IsStacked() &&
!layer.IsReplacedNormalFlowStacking()) {
compositing_container = compositing_stacking_context_;
} else if ((layer.Parent() &&
!layer.Parent()->GetLayoutObject().IsLayoutBlock()) ||
......
......@@ -276,6 +276,9 @@ void PaintInvalidator::UpdatePaintInvalidationContainer(
// This is to exclude some objects (e.g. LayoutText) inheriting
// stacked style from parent but aren't actually stacked.
object.HasLayer() &&
!ToLayoutBoxModelObject(object)
.Layer()
->IsReplacedNormalFlowStacking() &&
context.paint_invalidation_container !=
context.paint_invalidation_container_for_stacked_contents) {
// The current object is stacked, so we should use
......
......@@ -1068,6 +1068,8 @@ LayoutPoint PaintLayer::ComputeOffsetFromAncestor(
}
PaintLayer* PaintLayer::CompositingContainer() const {
if (IsReplacedNormalFlowStacking())
return Parent();
if (!GetLayoutObject().StyleRef().IsStacked())
return IsSelfPaintingLayer() ? Parent() : ContainingLayer();
if (PaintLayerStackingNode* ancestor_stacking_node =
......@@ -2354,7 +2356,7 @@ bool PaintLayer::HitTestContents(HitTestResult& result,
return true;
}
bool PaintLayer::IsReplacedNormalFlowStacking() {
bool PaintLayer::IsReplacedNormalFlowStacking() const {
if (!GetLayoutObject().IsSVGForeignObject())
return false;
if (!GetLayoutObject().StyleRef().HasAutoZIndex())
......@@ -2851,9 +2853,8 @@ bool PaintLayer::SupportsSubsequenceCaching() const {
if (EnclosingPaginationLayer())
return false;
// SVG documents paint atomically.
if (GetLayoutObject().IsSVGRoot() &&
GetLayoutObject().GetDocument().IsSVGDocument())
// SVG paints atomically.
if (GetLayoutObject().IsSVGRoot())
return true;
// Create subsequence for only stacking contexts whose painting are atomic.
......
......@@ -1066,7 +1066,7 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
// See
// https://chromium.googlesource.com/chromium/src.git/+/master/third_party/blink/renderer/core/paint/README.md
// for the definition of a replaced normal-flow stacking element.
bool IsReplacedNormalFlowStacking();
bool IsReplacedNormalFlowStacking() const;
void SetNeeedsCompositingReasonsUpdate() {
needs_compositing_reasons_update_ = true;
......
......@@ -453,7 +453,7 @@ TEST_P(PaintLayerTest, SubsequenceCachingSVGRoot) {
)HTML");
PaintLayer* svgroot = GetPaintLayerByElementId("svgroot");
EXPECT_FALSE(svgroot->SupportsSubsequenceCaching());
EXPECT_TRUE(svgroot->SupportsSubsequenceCaching());
}
TEST_P(PaintLayerTest, SubsequenceCachingMuticol) {
......
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