Commit 077c539b authored by Oriol Brufau's avatar Oriol Brufau Committed by Commit Bot

[css-pseudo] Fix assert failure when combining ::first-line and ::marker

The interaction of a ::marker pseudo-element with a 'content' property
and the ::first-line of the list-item produced a DCHECK failure in debug
builds (it was fine with debug disabled). This patch fixes it.

Bug: 457718

TEST=external/wpt/css/css-pseudo/first-line-and-marker.html

Change-Id: I443934f3a5cbfd95913287ac2bfb0966fa707e3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937068Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Oriol Brufau <obrufau@igalia.com>
Cr-Commit-Position: refs/heads/master@{#719561}
parent 361d69df
......@@ -3382,6 +3382,11 @@ void LayoutObject::ForceLayout() {
const ComputedStyle* LayoutObject::FirstLineStyleWithoutFallback() const {
DCHECK(GetDocument().GetStyleEngine().UsesFirstLineRules());
// Normal markers don't use ::first-line styles in Chromium, so be consistent
// and return null for content markers. This may need to change depending on
// https://github.com/w3c/csswg-drafts/issues/4506
if (IsMarkerContent())
return nullptr;
if (IsBeforeOrAfterContent() || IsText()) {
if (!Parent())
return nullptr;
......
......@@ -755,6 +755,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
inline bool IsBeforeContent() const;
inline bool IsAfterContent() const;
inline bool IsMarkerContent() const;
inline bool IsBeforeOrAfterContent() const;
static inline bool IsAfterContent(const LayoutObject* obj) {
return obj && obj->IsAfterContent();
......@@ -3273,6 +3274,15 @@ inline bool LayoutObject::IsAfterContent() const {
return true;
}
inline bool LayoutObject::IsMarkerContent() const {
if (StyleRef().StyleType() != kPseudoIdMarker)
return false;
// Text nodes don't have their own styles, so ignore the style on a text node.
if (IsText() && !IsBR())
return false;
return true;
}
inline bool LayoutObject::IsBeforeOrAfterContent() const {
return IsBeforeContent() || IsAfterContent();
}
......
<!DOCTYPE html>
<meta charset="utf-8" />
<title>CSS Reftest Reference</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" />
<style>
span {
background: cyan;
}
.none {
list-style-type: none;
}
.string {
list-style-type: "2. ";
}
.content::marker {
content: "3. ";
}
</style>
<ol class="none">
<li><span>1. inside decimal</span></li>
<li><span>2. inside string</span></li>
<li><span>3. inside content</span></li>
</ol>
<ol class="outside">
<li class="decimal"><span>outside decimal</span></li>
<li class="string"><span>outside string</span></li>
<li class="content"><span>outside content</span></li>
</ol>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Interaction of ::first-line and ::marker</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" />
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#first-line-pseudo">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
<link rel="match" href="first-line-and-marker-ref.html">
<meta name="assert" content="Tests ::marker interaction with ::first-line pseudo element">
<style>
li::first-line {
background: cyan;
}
.inside {
list-style-position: inside;
}
.string {
list-style-type: "2. ";
}
.content::marker {
content: "3. ";
}
</style>
<ol class="inside">
<li class="decimal">inside decimal</li>
<li class="string">inside string</li>
<li class="content">inside content</li>
</ol>
<ol class="outside">
<li class="decimal">outside decimal</li>
<li class="string">outside string</li>
<li class="content">outside content</li>
</ol>
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