Bug 187412 - Introduce a layout milestone to track when the document contains a large number of rendered characters
Summary: Introduce a layout milestone to track when the document contains a large numb...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-07-06 14:28 PDT by Wenson Hsieh
Modified: 2018-07-11 17:03 PDT (History)
9 users (show)

See Also:


Attachments
Patch (29.65 KB, patch)
2018-07-06 14:54 PDT, Wenson Hsieh
rniwa: review+
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff
v2 (29.58 KB, patch)
2018-07-06 20:51 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews201 for win-future (12.89 MB, application/zip)
2018-07-06 20:54 PDT, EWS Watchlist
no flags Details
Archive of layout-test-results from ews201 for win-future (12.77 MB, application/zip)
2018-07-07 05:38 PDT, EWS Watchlist
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2018-07-06 14:28:12 PDT
<rdar://problem/41744338>
Comment 1 Wenson Hsieh 2018-07-06 14:54:09 PDT
Created attachment 344462 [details]
Patch
Comment 2 Ryosuke Niwa 2018-07-06 19:21:05 PDT
Comment on attachment 344462 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        Implements a new layout milestone: `DidReachSignificantRenderedTextThreshold`. This is similar to the existing

Why not DidReachSignificantAmoutOfTextRenderedThreshold or DidRenderedSignificantAmoutOfText?
I don't think "Threshold" adds much value here since everything is heuristics based.

> Source/WebCore/page/FrameView.cpp:4364
> +    if (!m_numberOfTextRenderers || m_visuallyNonEmptyCharacterCount / (float)m_numberOfTextRenderers < significantRenderedTextMeanLength)

Use static_cast<float>

> Source/WebCore/page/FrameView.h:934
> +    ++m_numberOfTextRenderers;

I think more canonical way of naming this variable would be m_renderTextCount.
But this is the total number of render text ever created since FrameView::reset() is last called
so that's not quite right either.
How about m_renderTextCountForVisuallyNonEmptyCharacters?
Comment 3 Wenson Hsieh 2018-07-06 19:26:16 PDT
Comment on attachment 344462 [details]
Patch

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

>> Source/WebCore/ChangeLog:9
>> +        Implements a new layout milestone: `DidReachSignificantRenderedTextThreshold`. This is similar to the existing
> 
> Why not DidReachSignificantAmoutOfTextRenderedThreshold or DidRenderedSignificantAmoutOfText?
> I don't think "Threshold" adds much value here since everything is heuristics based.

Sounds good — I'll go with DidRenderSignificantAmountOfText

>> Source/WebCore/page/FrameView.cpp:4364
>> +    if (!m_numberOfTextRenderers || m_visuallyNonEmptyCharacterCount / (float)m_numberOfTextRenderers < significantRenderedTextMeanLength)
> 
> Use static_cast<float>

👍

>> Source/WebCore/page/FrameView.h:934
>> +    ++m_numberOfTextRenderers;
> 
> I think more canonical way of naming this variable would be m_renderTextCount.
> But this is the total number of render text ever created since FrameView::reset() is last called
> so that's not quite right either.
> How about m_renderTextCountForVisuallyNonEmptyCharacters?

Sounds good — I'll go with m_renderTextCountForVisuallyNonEmptyCharacters.
Comment 4 zalan 2018-07-06 19:56:58 PDT
Comment on attachment 344462 [details]
Patch

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

> Source/WebCore/ChangeLog:16
> +        being capable of Reader mode. In many article-like pages, the average length of an uninterrupted text node is

page is capable of being capable of

> Source/WebCore/ChangeLog:17
> +        significantly longer than other types of pages; thus, on pages where the average length of a text node is very

What's an uninterrupted text node?

> Source/WebCore/ChangeLog:19
> +        Safari reader mode on watchOS.

Is this a watchOS only feature?

> Source/WebCore/ChangeLog:38
> +        layout, this milestone is never guaranteed to fire.

What if an iframe fires this milestone and not the main frame? The page is still considered Reader like?

> Source/WebCore/page/FrameView.cpp:4315
> +    return snappedIntRect(element.renderBox()->layoutOverflowRect()).height() >= documentHeightThreshold;

on trunk it is guaranteed that element.renderBox != nullptr since qualifiesAsVisuallyNonEmpty early returns, but now I can just call this function when element->renderer() is nullptr.
Comment 5 Wenson Hsieh 2018-07-06 20:50:56 PDT
Comment on attachment 344462 [details]
Patch

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

>> Source/WebCore/ChangeLog:16
>> +        being capable of Reader mode. In many article-like pages, the average length of an uninterrupted text node is
> 
> page is capable of being capable of

Oops! Fixed.

>> Source/WebCore/ChangeLog:17
>> +        significantly longer than other types of pages; thus, on pages where the average length of a text node is very
> 
> What's an uninterrupted text node?

I really just meant "text node" here — the "uninterrupted" part should've just been omitted.

>> Source/WebCore/ChangeLog:19
>> +        Safari reader mode on watchOS.
> 
> Is this a watchOS only feature?

It'll fire on iOS and macOS as well if the SPI client opts into the milestone (the API test included in this patch even exercises this using the iOS simulator).
That being said, Safari on watchOS is the only client that might make use of this layout milestone at the moment.

>> Source/WebCore/ChangeLog:38
>> +        layout, this milestone is never guaranteed to fire.
> 
> What if an iframe fires this milestone and not the main frame? The page is still considered Reader like?

That's...an interesting point. At the moment, an iframe isn't capable of firing this milestone (since FrameView::fireLayoutRelatedMilestonesIfNeeded limits firing layout milestones to the main frame). I'm not certain what our eventual policy should be regarding layout milestones for subframes. FWIW, we disable cross-origin subframes altogether on watchOS, so I don't think this will matter much for the time being.

>> Source/WebCore/page/FrameView.cpp:4315
>> +    return snappedIntRect(element.renderBox()->layoutOverflowRect()).height() >= documentHeightThreshold;
> 
> on trunk it is guaranteed that element.renderBox != nullptr since qualifiesAsVisuallyNonEmpty early returns, but now I can just call this function when element->renderer() is nullptr.

Fair point. I'll make this robust when `!element.renderBox()`.
Comment 6 Wenson Hsieh 2018-07-06 20:51:06 PDT
Created attachment 344507 [details]
v2
Comment 7 EWS Watchlist 2018-07-06 20:54:00 PDT Comment hidden (obsolete)
Comment 8 EWS Watchlist 2018-07-06 20:54:13 PDT Comment hidden (obsolete)
Comment 9 EWS Watchlist 2018-07-07 05:38:42 PDT Comment hidden (obsolete)
Comment 10 EWS Watchlist 2018-07-07 05:38:53 PDT Comment hidden (obsolete)
Comment 11 WebKit Commit Bot 2018-07-07 14:05:52 PDT
Comment on attachment 344507 [details]
v2

Clearing flags on attachment: 344507

Committed r233623: <https://trac.webkit.org/changeset/233623>