Bug 123310 - Underline bounds cannot be queried before underline itself is drawn
Summary: Underline bounds cannot be queried before underline itself is drawn
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
Depends on: 123520
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-24 18:37 PDT by Myles C. Maxfield
Modified: 2013-10-31 14:12 PDT (History)
11 users (show)

See Also:


Attachments
Patch (15.91 KB, patch)
2013-10-24 18:49 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (15.70 KB, patch)
2013-10-25 10:44 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (15.54 KB, patch)
2013-10-25 13:18 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (15.51 KB, patch)
2013-10-25 13:31 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (15.57 KB, patch)
2013-10-25 15:46 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (15.58 KB, patch)
2013-10-29 15:01 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (16.26 KB, patch)
2013-10-29 17:56 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (10.88 KB, patch)
2013-10-30 13:58 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (10.84 KB, patch)
2013-10-31 13:15 PDT, Myles C. Maxfield
no flags 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 2013-10-24 18:37:22 PDT
Underline bounds cannot be queried before underline itself is drawn
Comment 1 Myles C. Maxfield 2013-10-24 18:49:19 PDT
Created attachment 215134 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2013-10-24 18:50:13 PDT
<rdar://problem/15316301>
Comment 3 EFL EWS Bot 2013-10-24 18:56:21 PDT
Comment on attachment 215134 [details]
Patch

Attachment 215134 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/10348238
Comment 4 kov's GTK+ EWS bot 2013-10-24 19:34:00 PDT
Comment on attachment 215134 [details]
Patch

Attachment 215134 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/10348245
Comment 5 Build Bot 2013-10-24 19:49:16 PDT
Comment on attachment 215134 [details]
Patch

Attachment 215134 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/10288251
Comment 6 Sam Weinig 2013-10-24 20:57:21 PDT
Comment on attachment 215134 [details]
Patch

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

> Source/WebCore/rendering/InlineTextBox.cpp:69
> +static FloatRect computeBoundsForUnderline(GraphicsContext &context, const FloatPoint& point, float width, bool printing, bool &shouldAntialias)

The & in "GraphicsContext &context" and "bool &shouldAntialias" are on the wrong sides.

> Source/WebCore/rendering/InlineTextBox.cpp:71
> +    // This function should be side-effect free

This comment doesn't really add anything.

> Source/WebCore/rendering/InlineTextBox.cpp:78
> +    float thickness = max(context.strokeThickness(), 0.5f);

We have started using an explicit std::max.

> Source/WebCore/rendering/InlineTextBox.cpp:84
> +        float adjustedThickness = max(thickness, 1.0f);

Again, std::max please.

> Source/WebCore/rendering/InlineTextBox.cpp:103
> +static void drawLineForText(GraphicsContext &context, const FloatPoint& point, float width, bool printing)

The & in "GraphicsContext &context" is on the wrong sides.

> Source/WebCore/rendering/InlineTextBox.cpp:105
> +    bool shouldAntialias;

This can move down to after the if-statement.
Comment 7 EFL EWS Bot 2013-10-25 02:08:27 PDT
Comment on attachment 215134 [details]
Patch

Attachment 215134 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/11918060
Comment 8 Myles C. Maxfield 2013-10-25 10:08:09 PDT
Comment on attachment 215134 [details]
Patch

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

>> Source/WebCore/rendering/InlineTextBox.cpp:69
>> +static FloatRect computeBoundsForUnderline(GraphicsContext &context, const FloatPoint& point, float width, bool printing, bool &shouldAntialias)
> 
> The & in "GraphicsContext &context" and "bool &shouldAntialias" are on the wrong sides.

Done.

>> Source/WebCore/rendering/InlineTextBox.cpp:71
>> +    // This function should be side-effect free
> 
> This comment doesn't really add anything.

Done.

>> Source/WebCore/rendering/InlineTextBox.cpp:78
>> +    float thickness = max(context.strokeThickness(), 0.5f);
> 
> We have started using an explicit std::max.

Done.

>> Source/WebCore/rendering/InlineTextBox.cpp:84
>> +        float adjustedThickness = max(thickness, 1.0f);
> 
> Again, std::max please.

Done.

>> Source/WebCore/rendering/InlineTextBox.cpp:103
>> +static void drawLineForText(GraphicsContext &context, const FloatPoint& point, float width, bool printing)
> 
> The & in "GraphicsContext &context" is on the wrong sides.

Done.

>> Source/WebCore/rendering/InlineTextBox.cpp:105
>> +    bool shouldAntialias;
> 
> This can move down to after the if-statement.

Done.
Comment 9 Myles C. Maxfield 2013-10-25 10:44:20 PDT
Created attachment 215189 [details]
Patch
Comment 10 Simon Fraser (smfr) 2013-10-25 10:50:59 PDT
Comment on attachment 215189 [details]
Patch

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

> Source/WebCore/rendering/InlineTextBox.cpp:69
> +static FloatRect computeBoundsForUnderline(GraphicsContext& context, const FloatPoint& point, float width, bool printing, bool& shouldAntialias)

I think "point" should be called "start" or "origin". "width" should be "length". Is it up or down from the origin?

> Source/WebCore/rendering/InlineTextBox.cpp:73
> +    float thickness = std::max(context.strokeThickness(), 0.5f);

But that bug added a 0.5 thickness only when printing. I think the comment has bitrotted.

> Source/WebCore/rendering/InlineTextBox.cpp:79
> +    if (!printing && !context.paintingDisabled() && context.getCTM(GraphicsContext::DefinitelyIncludeDeviceScale).preservesAxisAlignment()) {

It would be better to early return here.
Comment 11 EFL EWS Bot 2013-10-25 11:12:06 PDT
Comment on attachment 215189 [details]
Patch

Attachment 215189 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/10828022
Comment 12 Myles C. Maxfield 2013-10-25 11:38:24 PDT
Comment on attachment 215189 [details]
Patch

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

>> Source/WebCore/rendering/InlineTextBox.cpp:69
>> +static FloatRect computeBoundsForUnderline(GraphicsContext& context, const FloatPoint& point, float width, bool printing, bool& shouldAntialias)
> 
> I think "point" should be called "start" or "origin". "width" should be "length". Is it up or down from the origin?

Done.

>> Source/WebCore/rendering/InlineTextBox.cpp:73
>> +    float thickness = std::max(context.strokeThickness(), 0.5f);
> 
> But that bug added a 0.5 thickness only when printing. I think the comment has bitrotted.

I've traced this back to r14112 (from 2006), entitled "Move WebTextRenderer into WebCore" but can't seem to figure out where WebTextRenderer came from. My guess is that, when printing, the 0.5 comes from that bug, and when not printing, setting the minimum to 0.5 makes sure that when we round to pixel boundaries, the underline disappear (assuming an identity CTM). I think the best thing to do is to just delete the comment. Thoughts?

>> Source/WebCore/rendering/InlineTextBox.cpp:79
>> +    if (!printing && !context.paintingDisabled() && context.getCTM(GraphicsContext::DefinitelyIncludeDeviceScale).preservesAxisAlignment()) {
> 
> It would be better to early return here.

Done.
Comment 13 Myles C. Maxfield 2013-10-25 11:38:59 PDT
**the underline doesn't disappear

(In reply to comment #12)
> (From update of attachment 215189 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=215189&action=review
> 
> >> Source/WebCore/rendering/InlineTextBox.cpp:69
> >> +static FloatRect computeBoundsForUnderline(GraphicsContext& context, const FloatPoint& point, float width, bool printing, bool& shouldAntialias)
> > 
> > I think "point" should be called "start" or "origin". "width" should be "length". Is it up or down from the origin?
> 
> Done.
> 
> >> Source/WebCore/rendering/InlineTextBox.cpp:73
> >> +    float thickness = std::max(context.strokeThickness(), 0.5f);
> > 
> > But that bug added a 0.5 thickness only when printing. I think the comment has bitrotted.
> 
> I've traced this back to r14112 (from 2006), entitled "Move WebTextRenderer into WebCore" but can't seem to figure out where WebTextRenderer came from. My guess is that, when printing, the 0.5 comes from that bug, and when not printing, setting the minimum to 0.5 makes sure that when we round to pixel boundaries, the underline disappear (assuming an identity CTM). I think the best thing to do is to just delete the comment. Thoughts?
> 
> >> Source/WebCore/rendering/InlineTextBox.cpp:79
> >> +    if (!printing && !context.paintingDisabled() && context.getCTM(GraphicsContext::DefinitelyIncludeDeviceScale).preservesAxisAlignment()) {
> > 
> > It would be better to early return here.
> 
> Done.
Comment 14 Myles C. Maxfield 2013-10-25 13:18:25 PDT
Created attachment 215203 [details]
Patch
Comment 15 Myles C. Maxfield 2013-10-25 13:31:58 PDT
Created attachment 215205 [details]
Patch
Comment 16 Myles C. Maxfield 2013-10-25 15:46:53 PDT
Created attachment 215223 [details]
Patch
Comment 17 Build Bot 2013-10-25 16:29:22 PDT
Comment on attachment 215223 [details]
Patch

Attachment 215223 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/11948047
Comment 18 Myles C. Maxfield 2013-10-25 16:31:43 PDT
The win port is failing to build the Netscape plugin, which is completely irrelevant to this patch. Is there something I can do about this?
Comment 19 Myles C. Maxfield 2013-10-29 15:01:25 PDT
Created attachment 215433 [details]
Patch
Comment 20 Build Bot 2013-10-29 16:02:12 PDT
Comment on attachment 215433 [details]
Patch

Attachment 215433 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/17068179
Comment 21 Myles C. Maxfield 2013-10-29 16:17:10 PDT
Nevermind; I misread it. The Windows build calls drawLineForText in a place I didn't expect.
Comment 22 Myles C. Maxfield 2013-10-29 17:56:22 PDT
Created attachment 215457 [details]
Patch
Comment 23 WebKit Commit Bot 2013-10-29 18:49:31 PDT
Comment on attachment 215457 [details]
Patch

Clearing flags on attachment: 215457

Committed r158243: <http://trac.webkit.org/changeset/158243>
Comment 24 WebKit Commit Bot 2013-10-29 18:49:34 PDT
All reviewed patches have been landed.  Closing bug.
Comment 25 Darin Adler 2013-10-30 09:04:15 PDT
This patch moved code that was specific to CG into cross-platform code. Do we know that all the other platforms want this code?
Comment 26 WebKit Commit Bot 2013-10-30 11:44:54 PDT
Re-opened since this is blocked by bug 123520
Comment 27 Myles C. Maxfield 2013-10-30 13:58:22 PDT
Created attachment 215561 [details]
Patch
Comment 28 Tim Horton 2013-10-30 17:17:55 PDT
Comment on attachment 215561 [details]
Patch

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

> Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:1261
> +    if (lineRect.height() < initialBounds.height() * 2.0) {

We tend not to use f or .0
Comment 29 Myles C. Maxfield 2013-10-31 13:15:30 PDT
Created attachment 215668 [details]
Patch
Comment 30 Dean Jackson 2013-10-31 13:48:33 PDT
Comment on attachment 215668 [details]
Patch

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

> Source/WebCore/ChangeLog:32
> +        * platform/graphics/GraphicsContext.h: Signature of new computeLineBoundsForText
> +        function
> +        * platform/graphics/blackberry/PathBlackBerry.cpp:
> +        (WebCore::GraphicsContext::computeLineBoundsForText): Implement new function
> +        * platform/graphics/cairo/GraphicsContextCairo.cpp:
> +        (WebCore::GraphicsContext::computeLineBoundsForText): Ditto
> +        (WebCore::GraphicsContext::drawLineForText): Use computeLineBoundsForText
> +        * platform/graphics/cg/GraphicsContextCG.cpp:
> +        (WebCore::computeLineBoundsAndAntialiasingModeForText): Static function that
> +        performs the actual bounds computation
> +        (WebCore::GraphicsContext::computeLineBoundsForText): Calls
> +        computeLineBoundsAndAntialiasingModeForText
> +        (WebCore::GraphicsContext::drawLineForText): Use new function
> +        * platform/graphics/wince/GraphicsContextWinCE.cpp:
> +        (WebCore::GraphicsContext::computeLineBoundsForText): Implement new function

Super nit: end comments with periods.
Comment 31 WebKit Commit Bot 2013-10-31 14:12:38 PDT
Comment on attachment 215668 [details]
Patch

Clearing flags on attachment: 215668

Committed r158392: <http://trac.webkit.org/changeset/158392>
Comment 32 WebKit Commit Bot 2013-10-31 14:12:42 PDT
All reviewed patches have been landed.  Closing bug.