Closed Bug 1363549 Opened 7 years ago Closed 7 years ago

stylo: setting element styles during onload is broken if the element is a block element with a :first-letter rule

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: manishearth, Unassigned)

References

(Blocks 1 open bug)

Details

Found whilst debugging layout/reftests/bidi/670226-1.html

<!DOCTYPE html>
<html>
 <head>
  <style type="text/css"> div:first-letter { color: red;} </style>
  <script type="text/javascript"> function boom() { document.getElementById("p").style.fontSize="100px"; } </script>
 </head>
 <body onload="boom()">
    <div id="p">abc<br>def</div>
 </body>
</html>


The above should show a large "abc" and a large "def" on the next line, with a red "a". Instead, in Stylo, it shows a small "abc" with a large "def" on the next line, with a red "a". The line spacing between the two is still large.

If you remove the first-letter rule it works again. If you use a span instead of a div, it works again. If you call boom() in a script loaded after the div it works too. Or if you don't do any dynamic CSSOM manip and directly create a document with a style="font-size: 16px" on it. It has to have a first-letter-set style on it, it has to have some style set during onload, and it has to be a block element.

You can change the `.fontSize` to .color and you see something similar, though interestingly the color of the first letter is also correctly affected (unlike the font-size case where the font size of the first letter is not affected, like the rest of the first line.

Using .setAttribute("style", "font-size: 16px") instead of .style continues to display broken behavior.

Perhaps we're incorrectly reusing styles here?
Yeah, this is because we only set the first style context unconditionally I think, shouldn't be hard to fix.

I can fix this generally, but I don't know if it's worth or we should just wait for proper first-letter support.
This is likely to do with things inside/outside first-letter not getting updated correctly on dynamic restyle.

I'm not sure it's worth worrying about until we fix first-letter in general.
Depends on: 1324618
Priority: -- → P3
Looks to me like this got fixed by bug 1369187.
Status: NEW → RESOLVED
Closed: 7 years ago
Depends on: 1369187
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.