Commit b30e86f0 authored by Jaeyong Bae's avatar Jaeyong Bae Committed by Commit Bot

[CSS] Skip empty span when finding the first-letter text

This patch does skip empty span when finding the first-letter text.
Also, this adds the following tests.

external/wpt/css/css-pseudo/first-letter-skip-empty-span.html
external/wpt/css/css-pseudo/first-letter-skip-empty-span-nested.html

Bug: 911093
Change-Id: Iee9c6f531771826ea8f8446cd73e2015dfc2fb23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560522Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Jaeyong Bae <jdragon.bae@gmail.com>
Cr-Commit-Position: refs/heads/master@{#831851}
parent 8ae5d4b4
......@@ -180,6 +180,14 @@ LayoutText* FirstLetterPseudoElement::FirstLetterTextLayoutObject(
// PseudoIdFirstLetter set. When that node is attached we will handle
// setting up the first letter then.
return nullptr;
} else if (first_letter_text_layout_object->IsInline() &&
!first_letter_text_layout_object->SlowFirstChild()) {
LayoutObject* next_sibling =
first_letter_text_layout_object->NextSibling();
first_letter_text_layout_object =
next_sibling
? next_sibling
: first_letter_text_layout_object->Parent()->NextSibling();
} else {
first_letter_text_layout_object =
first_letter_text_layout_object->SlowFirstChild();
......
<!DOCTYPE HTML>
<title>Reference: The nested empty span should be skipped when finding the ::first-letter content</title>
<link rel="author" title="Jaeyong Bae" href="jdragon.bae@gmail.com">
<style>
first-letter { color: green }
</style>
<div>
<span><first-letter>F</first-letter>irst letter should be green</span>
</div>
<!DOCTYPE HTML>
<title>CSS Test: The nested empty span should be skipped when finding the ::first-letter content</title>
<link rel="author" title="Jaeyong Bae" href="jdragon.bae@gmail.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#application-in-css">
<link rel="match" href="first-letter-skip-empty-span-nested-ref.html">
<style>
div::first-letter { color: green }
</style>
<div>
<span></span>
<span><span></span>First letter should be green</span>
</div>
<!DOCTYPE HTML>
<title>Reference: The empty span should be skipped when finding the ::first-letter content</title>
<link rel="author" title="Jaeyong Bae" href="jdragon.bae@gmail.com">
<style>
first-letter { color: green }
</style>
<div>
<span><first-letter>F</first-letter>irst letter should be green</span>
</div>
<!DOCTYPE HTML>
<title>CSS Test: The empty span should be skipped when finding the ::first-letter content</title>
<link rel="author" title="Jaeyong Bae" href="jdragon.bae@gmail.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#application-in-css">
<link rel="match" href="first-letter-skip-empty-span-ref.html">
<style>
div::first-letter { color: green }
</style>
<div>
<span></span>
<span>First letter should be green</span>
</div>
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