Bug 197250 - [iOS] Implement idempotent mode for text autosizing
Summary: [iOS] Implement idempotent mode for text autosizing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-04-24 15:22 PDT by Myles C. Maxfield
Modified: 2019-04-25 23:34 PDT (History)
6 users (show)

See Also:


Attachments
WIP (17.50 KB, patch)
2019-04-24 15:24 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (22.78 KB, patch)
2019-04-24 17:17 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (23.87 KB, patch)
2019-04-25 14:55 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (23.78 KB, patch)
2019-04-25 15:03 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (28.08 KB, patch)
2019-04-25 16:00 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (28.63 KB, patch)
2019-04-25 16:06 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews124 for ios-simulator-wk2 (3.11 MB, application/zip)
2019-04-25 19:10 PDT, EWS Watchlist
no flags Details
Patch for committing (28.74 KB, patch)
2019-04-25 22:35 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch for committing (28.50 KB, patch)
2019-04-25 22:55 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 2019-04-24 15:22:09 PDT
[iOS] Implement idempotent mode for text autosizing
Comment 1 Myles C. Maxfield 2019-04-24 15:24:05 PDT
Created attachment 368190 [details]
WIP
Comment 2 Myles C. Maxfield 2019-04-24 17:17:44 PDT
Created attachment 368202 [details]
Patch
Comment 3 Simon Fraser (smfr) 2019-04-24 17:22:56 PDT
Comment on attachment 368202 [details]
Patch

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

> Source/WebCore/rendering/RenderElement.h:201
> +    static bool idempotentMode();

Is this used?
Comment 4 Myles C. Maxfield 2019-04-24 17:38:57 PDT
Comment on attachment 368202 [details]
Patch

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

>> Source/WebCore/rendering/RenderElement.h:201
>> +    static bool idempotentMode();
> 
> Is this used?

Good catch! Nope.
Comment 5 Radar WebKit Bug Importer 2019-04-25 10:54:09 PDT
<rdar://problem/50211034>
Comment 6 Myles C. Maxfield 2019-04-25 14:55:16 PDT
Created attachment 368271 [details]
Patch
Comment 7 Myles C. Maxfield 2019-04-25 15:03:24 PDT
Created attachment 368273 [details]
Patch
Comment 8 Simon Fraser (smfr) 2019-04-25 15:34:04 PDT
Comment on attachment 368273 [details]
Patch

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

> Source/WebCore/rendering/RenderBlockFlow.cpp:3738
> +    pageScale = std::min(std::max(pageScale, 0.5f), 1.0f);
> +    for (auto& point : points) {
> +        float fraction = 3.0f - 3.0f * pageScale;
> +        point.setY(point.x() + (point.y() - point.x()) * fraction);
> +    }

You do this work on every request to adjust text size, and then you skip points[i].x() < specifiedSize, so you only really need to scale two points, right?

> Source/WebCore/rendering/RenderElement.cpp:2127
> +    if (SettingsBase::textAutosizingUsesIdempotentMode() && style.maxHeight().type() == Fixed && is<RenderBlock>(renderer) && style.maxHeight().value() <= downcast<RenderBlock>(renderer).layoutOverflowRect().maxY())
> +        return RenderObject::FixedHeight;

Is this logic covered in your test(s)?

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3033
> +    double initialScale = m_viewportConfiguration.initialScale();
> +    m_page->setInitialScale(initialScale);

Kinda stupid that m_viewportConfiguration isn't on Page in WebCore.
Comment 9 Myles C. Maxfield 2019-04-25 16:00:39 PDT
Created attachment 368281 [details]
Patch
Comment 10 Myles C. Maxfield 2019-04-25 16:06:03 PDT
Created attachment 368283 [details]
Patch
Comment 11 EWS Watchlist 2019-04-25 19:10:08 PDT
Comment on attachment 368283 [details]
Patch

Attachment 368283 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: https://webkit-queues.webkit.org/results/12000513

New failing tests:
fast/text-autosizing/ios/idempotent-autosizing-identity.html
fast/text-autosizing/ios/idempotent-autosizing.html
Comment 12 EWS Watchlist 2019-04-25 19:10:09 PDT
Created attachment 368296 [details]
Archive of layout-test-results from ews124 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews124  Port: ios-simulator-wk2  Platform: Mac OS X 10.13.6
Comment 13 Jon Lee 2019-04-25 20:52:07 PDT
Comment on attachment 368283 [details]
Patch

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

> LayoutTests/fast/text-autosizing/ios/idempotent-autosizing-identity.html:11
> +<script src="../../../../resources/js-test-pre.js"></script>

three .. instead of four ..?
Comment 14 Jon Lee 2019-04-25 20:58:14 PDT
(In reply to Simon Fraser (smfr) from comment #8)
> Comment on attachment 368273 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=368273&action=review
> 
> > Source/WebCore/rendering/RenderBlockFlow.cpp:3738
> > +    pageScale = std::min(std::max(pageScale, 0.5f), 1.0f);
> > +    for (auto& point : points) {
> > +        float fraction = 3.0f - 3.0f * pageScale;
> > +        point.setY(point.x() + (point.y() - point.x()) * fraction);
> > +    }
> 
> You do this work on every request to adjust text size, and then you skip
> points[i].x() < specifiedSize, so you only really need to scale two points,
> right?
> 
> > Source/WebCore/rendering/RenderElement.cpp:2127
> > +    if (SettingsBase::textAutosizingUsesIdempotentMode() && style.maxHeight().type() == Fixed && is<RenderBlock>(renderer) && style.maxHeight().value() <= downcast<RenderBlock>(renderer).layoutOverflowRect().maxY())
> > +        return RenderObject::FixedHeight;
> 
> Is this logic covered in your test(s)?
> 
> > Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3033
> > +    double initialScale = m_viewportConfiguration.initialScale();
> > +    m_page->setInitialScale(initialScale);
> 
> Kinda stupid that m_viewportConfiguration isn't on Page in WebCore.

Can we address these issues in a follow up?
Comment 15 Tim Horton 2019-04-25 21:23:40 PDT
(In reply to Jon Lee from comment #14)
> (In reply to Simon Fraser (smfr) from comment #8)
> > Comment on attachment 368273 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=368273&action=review
> > 
> > > Source/WebCore/rendering/RenderBlockFlow.cpp:3738
> > > +    pageScale = std::min(std::max(pageScale, 0.5f), 1.0f);
> > > +    for (auto& point : points) {
> > > +        float fraction = 3.0f - 3.0f * pageScale;
> > > +        point.setY(point.x() + (point.y() - point.x()) * fraction);
> > > +    }
> > 
> > You do this work on every request to adjust text size, and then you skip
> > points[i].x() < specifiedSize, so you only really need to scale two points,
> > right?
> > 
> > > Source/WebCore/rendering/RenderElement.cpp:2127
> > > +    if (SettingsBase::textAutosizingUsesIdempotentMode() && style.maxHeight().type() == Fixed && is<RenderBlock>(renderer) && style.maxHeight().value() <= downcast<RenderBlock>(renderer).layoutOverflowRect().maxY())
> > > +        return RenderObject::FixedHeight;
> > 
> > Is this logic covered in your test(s)?
> > 
> > > Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3033
> > > +    double initialScale = m_viewportConfiguration.initialScale();
> > > +    m_page->setInitialScale(initialScale);
> > 
> > Kinda stupid that m_viewportConfiguration isn't on Page in WebCore.
> 
> Can we address these issues in a follow up?

I won't speak for the others, but the last one is definitely not something to fix in this patch :P
Comment 16 Myles C. Maxfield 2019-04-25 22:26:58 PDT
Comment on attachment 368273 [details]
Patch

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

>> Source/WebCore/rendering/RenderElement.cpp:2127
>> +        return RenderObject::FixedHeight;
> 
> Is this logic covered in your test(s)?

Nope. I don't think we want to test these details yet, as they are likely to change soon.
Comment 17 Myles C. Maxfield 2019-04-25 22:35:51 PDT
Created attachment 368302 [details]
Patch for committing
Comment 18 Myles C. Maxfield 2019-04-25 22:55:16 PDT
Created attachment 368303 [details]
Patch for committing
Comment 19 Myles C. Maxfield 2019-04-25 23:34:05 PDT
Committed r244682: <https://trac.webkit.org/changeset/244682>