Commit 6ddbf962 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Style containment applies to display:content elements.

The CSS Containment spec explicitly states that containment has no
effect on elements with display:contents element for paint, layout and
others. Not stated for contain:style.

Check for style containment for counters even when LayoutObject is null.

Note that due to the bug reported in 766650, the added test passes even
without this code change.

Bug: 766650
Change-Id: I64082f52255d5d810ba803148a418edff5da66c8
Reviewed-on: https://chromium-review.googlesource.com/771830Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517140}
parent 491b1a06
<!DOCTYPE html>
<title>CSS Containment Reference File</title>
<div>You should see the number 1 here: 1</div>
<div>You should see the number 4 here: 4</div>
<!DOCTYPE html>
<title>CSS Containment Test: contain:style for counters</title>
<link rel="help" href="https://drafts.csswg.org/css-contain/#containment-style">
<link rel="match" href="contain-style-counters-ref.html">
<style>
#t1 { contain: style }
#t1 span::after { content: counter(t1) }
.t1-reset { counter-reset: t1 5 }
#t1 span { counter-increment: t1 1 }
#t2 {
contain: style;
display: contents;
}
#t2 span::after { content: counter(t2) }
.t2-reset { counter-reset: t2 7; }
#t2 span { counter-increment: t2 4; }
</style>
<div class="t1-reset"></div>
<div id="t1"><span>You should see the number 1 here: </span></div>
<div class="t2-reset"></div>
<div id="t2"><span>You should see the number 4 here: </span></div>
......@@ -24,6 +24,7 @@
#include <memory>
#include "core/dom/Element.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/NodeComputedStyle.h"
#include "core/dom/PseudoElement.h"
#include "core/html/HTMLOListElement.h"
#include "core/html/ListItemOrdinal.h"
......@@ -60,9 +61,10 @@ static CounterMaps& GetCounterMaps() {
Element* AncestorStyleContainmentObject(const Element& element) {
for (Element* ancestor = FlatTreeTraversal::ParentElement(element); ancestor;
ancestor = FlatTreeTraversal::ParentElement(*ancestor)) {
if (ancestor->GetLayoutObject() &&
ancestor->GetLayoutObject()->Style()->ContainsStyle())
return ancestor;
if (const ComputedStyle* style = ancestor->GetComputedStyle()) {
if (style->ContainsStyle())
return ancestor;
}
}
return nullptr;
}
......
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