[iOS] Issue initial paint soon after the visuallyNonEmpty milestone is fired.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2018 16:38:36 +0000 (16:38 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2018 16:38:36 +0000 (16:38 +0000)
commit110a779646b79beb557160dc1a27aefc51fa9d47
treec4c5da87e9ae1969dd001ca97dbd48d43756b003
parent54b9383a130db7d3550346079faaf15ab5945b69
[iOS] Issue initial paint soon after the visuallyNonEmpty milestone is fired.
https://bugs.webkit.org/show_bug.cgi?id=191078
<rdar://problem/45736178>

Reviewed by Antti Koivisto.

Source/WebCore:

1. Improve visuallyNonEmpty milestone confidence level.
    Ignore whitespace and non visible text content.
    Parsing the main document should not necessarily fire the milestone. Check if there's any pending scripts/css/font loading.
    Check if the html/body is actually visible.

2. Issue initial paint soon after the milestone fires.
    Use a 0ms timer to flush the initial paint.
    Throttle additional flushes for 500ms (remove the non-initial 1.5 throttling)

3. Suspend optional style recalcs and layouts while painting is being throttled.
   When parsing yields we initiate a 0ms style recalc/layout timer.
   These optional layouts produce content that we have no intention to paint.

* dom/Document.cpp:
(WebCore::Document::scheduleStyleRecalc):
(WebCore::Document::shouldScheduleLayout):
* page/ChromeClient.h:
* page/FrameView.cpp:
(WebCore::FrameView::resetLayoutMilestones):
(WebCore::FrameView::qualifiesAsVisuallyNonEmpty const):
(WebCore::FrameView::updateSignificantRenderedTextMilestoneIfNeeded):
(WebCore::FrameView::updateIsVisuallyNonEmpty):
* page/FrameView.h:
(WebCore::FrameView::incrementVisuallyNonEmptyCharacterCount): Ignore whitespace characters. Some pages start with plenty of whitespace only content.
* platform/graphics/FontCascade.h:
* rendering/RenderText.cpp: Check whether the text is actually visible at this point.
(WebCore::RenderText::RenderText):

Source/WebKit:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::layerFlushThrottlingIsActive const):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/AcceleratedDrawingArea.cpp:
(WebKit::AcceleratedDrawingArea::scheduleInitialDeferredPaint):
* WebProcess/WebPage/AcceleratedDrawingArea.h:
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::layerFlushThrottlingIsActive const):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
(WebKit::RemoteLayerTreeDrawingArea::setLayerTreeStateIsFrozen):
(WebKit::RemoteLayerTreeDrawingArea::initialDeferredPaint):
(WebKit::RemoteLayerTreeDrawingArea::scheduleInitialDeferredPaint):
(WebKit::RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::scheduleInitialDeferredPaint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237785 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/graphics/FontCascade.h
Source/WebCore/rendering/RenderText.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp
Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h
Source/WebKit/WebProcess/WebPage/DrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm