Bug 36793 - CSS outline property on a narrow element has rabbit ear artifacts
Summary: CSS outline property on a narrow element has rabbit ear artifacts
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Robert Hogan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-29 16:59 PDT by James Robinson
Modified: 2011-09-22 09:13 PDT (History)
3 users (show)

See Also:


Attachments
Test cases (459 bytes, text/html)
2010-03-29 17:03 PDT, James Robinson
no flags Details
Patch (5.51 KB, patch)
2011-06-15 20:05 PDT, Jason Liu
no flags Details | Formatted Diff | Diff
patch (3.86 KB, patch)
2011-06-17 03:24 PDT, Jason Liu
no flags Details | Formatted Diff | Diff
Patch (5.10 KB, patch)
2011-06-19 18:46 PDT, Jason Liu
no flags Details | Formatted Diff | Diff
Patch (7.43 KB, patch)
2011-09-21 14:55 PDT, Robert Hogan
simon.fraser: review+
simon.fraser: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Robinson 2010-03-29 16:59:18 PDT
With the following HTML:

<!DOCTYPE html>
<span style="outline: solid red 5px"><br><span>

the outline around the span has a non-rectangular top and bottom.  It sort of looks like we're not generating enough strokes for very narrow outlines.
Comment 1 James Robinson 2010-03-29 17:03:31 PDT
Created attachment 51984 [details]
Test cases

We do not match Firefox 3.6's rendering exactly on any of these four cases.
Comment 2 Jason Liu 2011-06-15 20:05:27 PDT
Created attachment 97392 [details]
Patch

Patch
Comment 3 Simon Fraser (smfr) 2011-06-15 20:09:58 PDT
Comment on attachment 97392 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=97392&action=review

r- for the test

> LayoutTests/ChangeLog:9
> +        * fonts/outline-expected.txt: Added.
> +        * fonts/outline.html: Added.

Why is the test in fonts? I'd suggest fast/css

I think the test can also be dumpAsText(true) since you only care about the pixel result. The test should contain no text, and use large outlines to make the fix very obvious. You also need to include a pixel result in your patch.
Comment 4 Jason Liu 2011-06-17 03:24:30 PDT
Created attachment 97571 [details]
patch

I've changed the test case.
Comment 5 Simon Fraser (smfr) 2011-06-17 07:40:00 PDT
Comment on attachment 97571 [details]
patch

Can you include binary fixes in your patch (or use webkit-patch upload)?
Comment 6 Jason Liu 2011-06-19 18:46:33 PDT
Created attachment 97730 [details]
Patch

This is webkit-patch.
Comment 7 Robert Hogan 2011-08-10 13:26:37 PDT
Comment on attachment 97730 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=97730&action=review

> LayoutTests/fast/css/outline-narrowLine.html:1
> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

Is this important to the test? The DOCTYPE used elsewhere, when specified, seems to be: 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

But if it doesn't affect the behaviour of the test I would suggest leave it out.

> Source/WebCore/rendering/RenderInline.cpp:1527
> +
> +    if (thisline.x() == thisline.maxX())
> +        drawLineForBoxSide(graphicsContext,
> +                   l - ow,
> +                   b,
> +                   r + ow,
> +                   b + ow,
> +                   BSBottom, outlineColor, os,
> +                   ow,
> +                   ow,
> +                   antialias
> +                   );
> +

This needs rebasing - the function's variable names have changed.
Comment 8 Robert Hogan 2011-09-21 14:55:45 PDT
Created attachment 108241 [details]
Patch
Comment 9 Robert Hogan 2011-09-21 14:59:08 PDT
Note that for:

<span style="outline: solid red 5px"></span>

WebKit, unlike firefox, does nothing. This is because empty inlines do not get a renderer in WebKit.
Comment 10 Simon Fraser (smfr) 2011-09-21 16:06:29 PDT
Comment on attachment 108241 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=108241&action=review

> LayoutTests/fast/css/outline-narrowLine.html:22
> +<html>
> +<body>
> +<!--Outline around an empty span: WebKit does nothing here, as empty inlines are ignored.-->
> +<p>
> +<span style="outline: solid red 5px"></span>
> +<p>
> +
> +<!--Outline around a span with a line break:-->
> +<p>
> +<span style="outline: solid green 5px"><br></span>
> +<p>
> +
> +<!--Outline around a span with a line break and an 'x':-->
> +<p>
> +<span style="outline: solid blue 5px"><br>x</span>
> +<p>
> +
> +<!--Outline around a span with an 'x' and two line breaks:-->
> +<p>
> +<span style="outline: solid purple 5px">x<br><br></span>
> +</body>
> +</html>

Can you make this test accentuate the outline? Try 50px-wide outlines.
Comment 11 Robert Hogan 2011-09-22 09:13:59 PDT
Committed r95721: <http://trac.webkit.org/changeset/95721>