::first-letter pseudo-element never applies to more than two characters

RESOLVED FIXED

Status

()

Core
CSS Parsing and Computation
RESOLVED FIXED
13 years ago
10 years ago

People

(Reporter: VG, Unassigned)

Tracking

1.8 Branch
x86
Windows XP
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

13 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; HCSC Custom IE 6 build HCSC20020522a)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

If the there is a first-letter style being applied to some text and the first character is an asterisk (instead of a "real letter") then that and the next character also has the style applied to it. Oddly enough, the logic does not continue beyond the second char whether it's a real "letter" or not. I *strongly" believe *only* the first ascii char should have the style applied unless it's a space. 

Reproducible: Always

Steps to Reproduce:

Type this in a txt file, save as .html file:
<html><head>
<style>
 p:first-letter{
  color:red;
 }
</style>
</head>

<body>
<p>test</p>
<p>*test</p>
<p>***test</p>
<p>&nbsp;test</p>
</body>
</html>
Actual Results:  
Style is applied inconsistanly. Red is on first to chars when it should only be applied to the first one.

Expected Results:  
Only the first chars should be red in all cases (unless there is a space).

Sample Code: 

<html>
<head>
<style>
 p:first-letter{
  color:red;
 }
</style>
</head>

<body>

<p>test</p>
<p>*test</p>
<p>***test</p>
<p>&nbsp;test</p>

</body>
</html>
Assignee: nobody → dbaron
Component: General → Style System (CSS)
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → 1.8 Branch
http://www.w3.org/TR/CSS21/selector.html#first-letter says:

# Punctuation (i.e, characters defined in Unicode [UNICODE] in the
# "open" (Ps), "close" (Pe), "initial" (Pi). "final" (Pf) and "other"
# (Po) punctuation classes), that precedes or follows the first letter
# should be included

The asterisk is in the Po character class, so it should be included.

I think much of the remaining issues may be in bug 23605 and bug 45091, but those bugs aren't very well defined...
Created attachment 212650 [details]
reporter's testcase
Created attachment 212652 [details] [diff] [review]
simple patch

So I came up with this simple patch to fix these testcases, but the work in bug 45091 probably supersedes this.
Summary: ::first-letter pseudo elements applies to two characters in some cases. → ::first-letter pseudo-element never applies to more than two characters
Assignee: dbaron → nobody
QA Contact: ian → style-system

Comment 4

11 years ago
This now seems to work for me on the trunk.

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a9pre) Gecko/2007093004 Minefield/3.0a9pre
It looks like new-textframe fixed this.

I checked in a reftest for this bug.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Depends on: 367177
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.