Bug 132770 - [Mac] [iOS] Underlines are too low
Summary: [Mac] [iOS] Underlines are too low
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
: 132722 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-09 22:47 PDT by Myles C. Maxfield
Modified: 2014-05-19 17:26 PDT (History)
13 users (show)

See Also:


Attachments
Patch (7.33 KB, patch)
2014-05-09 22:50 PDT, Myles C. Maxfield
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2014-05-09 22:47:32 PDT
[Mac] [iOS] Underlines are too low
Comment 1 Myles C. Maxfield 2014-05-09 22:50:10 PDT
Created attachment 231215 [details]
Patch
Comment 2 Myles C. Maxfield 2014-05-09 22:54:55 PDT
<rdar://problem/16364632>
Comment 3 Darin Adler 2014-05-10 11:37:09 PDT
Comment on attachment 231215 [details]
Patch

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

> Source/WebCore/rendering/InlineTextBox.cpp:1015
> +    float textDecorationThickness = roundf(fontSizeScaling);

Seems really strange to “round a scaling”; why do strokes need to be integers? Wouldn’t the pixel ratio have something to do with the rounding we want to do, rather than just integer boundaries. Rationale might be helpful.

Is it really OK to round the thickness down to 0 if the font size is <1/2 the size of the text decoration base font size?

I think getting rid of the fontSizeScaling local would be helpful, since it would be incorrect to use that value in the code below.
Comment 4 zalan 2014-05-10 11:46:52 PDT
(In reply to comment #3)
> (From update of attachment 231215 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=231215&action=review
> 
> > Source/WebCore/rendering/InlineTextBox.cpp:1015
> > +    float textDecorationThickness = roundf(fontSizeScaling);
> 
> Seems really strange to “round a scaling”; why do strokes need to be integers? Wouldn’t the pixel ratio have something to do with the rounding we want to do, rather than just integer boundaries. Rationale might be helpful.
Agree, integral rounding at painting time needs strong justification.
Comment 5 Myles C. Maxfield 2014-05-11 10:17:31 PDT
*** Bug 132722 has been marked as a duplicate of this bug. ***
Comment 6 Myles C. Maxfield 2014-05-11 10:22:52 PDT
Comment on attachment 231215 [details]
Patch

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

>>> Source/WebCore/rendering/InlineTextBox.cpp:1015
>>> +    float textDecorationThickness = roundf(fontSizeScaling);
>> 
>> Seems really strange to “round a scaling”; why do strokes need to be integers? Wouldn’t the pixel ratio have something to do with the rounding we want to do, rather than just integer boundaries. Rationale might be helpful.
>> 
>> Is it really OK to round the thickness down to 0 if the font size is <1/2 the size of the text decoration base font size?
>> 
>> I think getting rid of the fontSizeScaling local would be helpful, since it would be incorrect to use that value in the code below.
> 
> Agree, integral rounding at painting time needs strong justification.

Done. I was keeping the roundf() from above, but I think the two of you are right.
Comment 7 Myles C. Maxfield 2014-05-11 10:36:54 PDT
https://trac.webkit.org/changeset/168599
Comment 8 Darin Adler 2014-05-11 10:42:12 PDT
While the roundf is probably not right, removing it could have big effects; we might start drawing anti-aliased grey underlines that don’t look good where before we would be rounding up or down and drawing much-different-looking black underlines. We need to follow up with plenty of testing.
Comment 9 zalan 2014-05-11 11:56:42 PDT
(In reply to comment #7)
> https://trac.webkit.org/changeset/168599
+float textDecorationThickness = renderer().style().fontSize() / textDecorationBaseFontSize; 
This should be pixel snapped to avoid lines like 1.6px -to not to produce anti-aliased lines.

+FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()));
This is integral rounding, so it will most likely end up snapping to wrong coordinates in certain edge cases. I think we should not round in this function at all and the caller (or where we have the context of the rounding strategy) should do the snapping instead.
Comment 10 Myles C. Maxfield 2014-05-13 14:33:47 PDT
(In reply to comment #9)
> (In reply to comment #7)
> > https://trac.webkit.org/changeset/168599
> +float textDecorationThickness = renderer().style().fontSize() / textDecorationBaseFontSize; 
> This should be pixel snapped to avoid lines like 1.6px -to not to produce anti-aliased lines.
> 
> +FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()));
> This is integral rounding, so it will most likely end up snapping to wrong coordinates in certain edge cases. I think we should not round in this function at all and the caller (or where we have the context of the rounding strategy) should do the snapping instead.

<rdar://problem/16903502>
Comment 11 Myles C. Maxfield 2014-05-14 12:10:16 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #7)
> > > https://trac.webkit.org/changeset/168599
> > +float textDecorationThickness = renderer().style().fontSize() / textDecorationBaseFontSize; 
> > This should be pixel snapped to avoid lines like 1.6px -to not to produce anti-aliased lines.
> > 
> > +FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()));
> > This is integral rounding, so it will most likely end up snapping to wrong coordinates in certain edge cases. I think we should not round in this function at all and the caller (or where we have the context of the rounding strategy) should do the snapping instead.
> 
> <rdar://problem/16903502>

I confused the Radar Bug Importer with my last comment.

The new radar I filed for moving the pixel-snapping code is at <rdar://problem/16903502>

<rdar://problem/16364632>
Comment 12 Myles C. Maxfield 2014-05-19 17:26:41 PDT
http://trac.webkit.org/changeset/168599