Bug 105188

Summary: Text Autosizing - elements much narrower than its parent autosizing clusters should be autosized separately.
Product: WebKit Reporter: Anton Vayvod <avayvod>
Component: Layout and RenderingAssignee: Anton Vayvod <avayvod>
Status: RESOLVED FIXED    
Severity: Normal CC: eric, jchaffraix, johnme, kenneth, ojan.autocc, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 103627    
Bug Blocks: 84186, 102409    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Anton Vayvod 2012-12-17 09:30:20 PST
Text Autosizing - elements much narrower than its parent autosizing clusters should be autosized separately.
Comment 1 Anton Vayvod 2012-12-17 09:30:51 PST
Created attachment 179760 [details]
Patch
Comment 2 Anton Vayvod 2012-12-17 09:40:19 PST
Based on patch for bug 103627.
Comment 3 Anton Vayvod 2012-12-17 10:28:35 PST
Created attachment 179765 [details]
Patch
Comment 4 John Mellor 2012-12-17 10:55:09 PST
Comment on attachment 179760 [details]
Patch

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

Looks good. Some comments on the tests below. Also you need to add a ChangeLog for this patch.

> Source/WebCore/rendering/TextAutosizer.cpp:217
> +    // Additionally, any containers that are wider or at least 200px shhorter than

s/shhorter/narrower/

> Source/WebCore/rendering/TextAutosizer.cpp:228
> +        float parentBlockTextWidth = parentBlockContainingAllText->contentLogicalWidth();

"parentBlockTextWidth" sounds like "the width of the text of the parent block", when really it is "the width of the blockContainingAllText of the enclosing cluster" which is quite different. How about calling this "clusterTextWidth"?

> LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-expected.html:15
>      This text should be autosized to just 20px computed font size (16 * 400/320), since the float:left causes this to be a new cluster, and it is only 400px wide.

This div is supposed to be testing that float:left makes this a cluster. But really it'd happen anyway due to the width now. See suggestion below.

> LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-expected.html:-18
> -<div style="width: 320px; font-size: 2.5rem">

It would be nice to have two versions of this paragraph - one with width:600px which exhibits the old behavior. I checked, and you should be able to fit the following 4 divs onscreen at once:

<div style="width: 600px; float: left; font-size: 1.875rem"> ... </div>
<div style="width: 400px; font-size: 1.25rem"> ... </div>
<div style="width: 600px; font-size: 2.5rem"> ... </div>
<div style="font-size: 2.5rem"> ... </div>

> LayoutTests/fast/text-autosizing/narrow-child.html:25
>      <div style="width: 320px">

Might be easiest to make this width:600px, since this was initially supposed to be a simple cluster-less test, and cluster-narrow-in-wide already covers the case where we expect the narrow child to make a new cluster.
Comment 5 Anton Vayvod 2012-12-17 13:13:13 PST
Created attachment 179788 [details]
Patch
Comment 6 Anton Vayvod 2012-12-17 13:48:32 PST
Comment on attachment 179760 [details]
Patch

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

>> Source/WebCore/rendering/TextAutosizer.cpp:217
>> +    // Additionally, any containers that are wider or at least 200px shhorter than
> 
> s/shhorter/narrower/

Done

>> Source/WebCore/rendering/TextAutosizer.cpp:228
>> +        float parentBlockTextWidth = parentBlockContainingAllText->contentLogicalWidth();
> 
> "parentBlockTextWidth" sounds like "the width of the text of the parent block", when really it is "the width of the blockContainingAllText of the enclosing cluster" which is quite different. How about calling this "clusterTextWidth"?

Done.

>> LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-expected.html:15
>>      This text should be autosized to just 20px computed font size (16 * 400/320), since the float:left causes this to be a new cluster, and it is only 400px wide.
> 
> This div is supposed to be testing that float:left makes this a cluster. But really it'd happen anyway due to the width now. See suggestion below.

Done.

>> LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-expected.html:-18
>> -<div style="width: 320px; font-size: 2.5rem">
> 
> It would be nice to have two versions of this paragraph - one with width:600px which exhibits the old behavior. I checked, and you should be able to fit the following 4 divs onscreen at once:
> 
> <div style="width: 600px; float: left; font-size: 1.875rem"> ... </div>
> <div style="width: 400px; font-size: 1.25rem"> ... </div>
> <div style="width: 600px; font-size: 2.5rem"> ... </div>
> <div style="font-size: 2.5rem"> ... </div>

Done.

>> LayoutTests/fast/text-autosizing/narrow-child.html:25
>>      <div style="width: 320px">
> 
> Might be easiest to make this width:600px, since this was initially supposed to be a simple cluster-less test, and cluster-narrow-in-wide already covers the case where we expect the narrow child to make a new cluster.

Done.
Comment 7 Anton Vayvod 2013-01-07 03:35:13 PST
Created attachment 181491 [details]
Patch
Comment 8 John Mellor 2013-01-09 11:00:32 PST
Comment on attachment 181491 [details]
Patch

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

Minor nits with the test.

> LayoutTests/fast/text-autosizing/narrow-child-expected.html:16
> +    <div style="width: 600px; font-size: 2.5rem">

Nit: you don't need the font-size: 2.5rem, since the font size from the parent element is inherited.

> LayoutTests/fast/text-autosizing/narrow-child-expected.html:17
> +    	This text should be autosized to 40px computed font-size as part of the same cluster as the div above.<br>

Please use spaces not tabs to indent. Also s/as part/as it is part/ and s/div above/parent div/

> LayoutTests/fast/text-autosizing/narrow-child-expected.html:20
> +    This text is autosized to 40px computed font-size, similarly to the text at the top.<br>

Nit: s/is/should be/
Comment 9 John Mellor 2013-01-09 11:03:33 PST
Code looks good to me, apart from the very minor nits above.

This significantly improves the rendering of a large number of sites. The only downside is that is causes us to regress bug 102409, but we have a plan for fixing that later, and it's not worth blocking all the sites that this does fix.

Kenneth/Julien, do you think this is ready?
Comment 10 Kenneth Rohde Christiansen 2013-01-09 11:05:31 PST
Comment on attachment 181491 [details]
Patch

LGTM with the nits fixed
Comment 11 Anton Vayvod 2013-01-10 09:22:33 PST
Created attachment 182155 [details]
Patch
Comment 12 Anton Vayvod 2013-01-10 09:23:21 PST
The nits are fixed.
Comment 13 Anton Vayvod 2013-01-11 05:49:30 PST
Hey Kenneth!

Could you r+ this, please?

Thanks in advance,
Anton.
Comment 14 WebKit Review Bot 2013-01-11 05:58:01 PST
Comment on attachment 182155 [details]
Patch

Clearing flags on attachment: 182155

Committed r139435: <http://trac.webkit.org/changeset/139435>
Comment 15 WebKit Review Bot 2013-01-11 05:58:06 PST
All reviewed patches have been landed.  Closing bug.