Title: [238064] trunk/Source
Revision
238064
Author
[email protected]
Date
2018-11-09 22:39:20 -0800 (Fri, 09 Nov 2018)

Log Message

[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 and 1.5s (original behaviour).

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (238063 => 238064)


--- trunk/Source/WebCore/ChangeLog	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebCore/ChangeLog	2018-11-10 06:39:20 UTC (rev 238064)
@@ -1,3 +1,39 @@
+2018-11-09  Zalan Bujtas  <[email protected]>
+
+        [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.
+
+        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 and 1.5s (original behaviour).
+
+        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):
+
 2018-11-09  John Wilander  <[email protected]>
 
         Add ability to configure document.cookie lifetime cap through user defaults

Modified: trunk/Source/WebCore/dom/Document.cpp (238063 => 238064)


--- trunk/Source/WebCore/dom/Document.cpp	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebCore/dom/Document.cpp	2018-11-10 06:39:20 UTC (rev 238064)
@@ -1804,6 +1804,19 @@
 
     ASSERT(childNeedsStyleRecalc() || m_pendingStyleRecalcShouldForce);
 
+    auto shouldThrottleStyleRecalc = [&] {
+        if (m_pendingStyleRecalcShouldForce)
+            return false;
+        if (!view() || !view()->isVisuallyNonEmpty())
+            return false;
+        if (!page() || !page()->chrome().client().layerFlushThrottlingIsActive())
+            return false;
+        return true;
+    };
+
+    if (shouldThrottleStyleRecalc())
+        return;
+
     // FIXME: Why on earth is this here? This is clearly misplaced.
     invalidateAccessKeyMap();
     
@@ -3031,6 +3044,8 @@
         return false;
     if (styleScope().hasPendingSheetsBeforeBody())
         return false;
+    if (page() && page()->chrome().client().layerFlushThrottlingIsActive() && view() && view()->isVisuallyNonEmpty())
+        return false;
 
     return true;
 }

Modified: trunk/Source/WebCore/page/ChromeClient.h (238063 => 238064)


--- trunk/Source/WebCore/page/ChromeClient.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebCore/page/ChromeClient.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -333,6 +333,7 @@
     
     // Returns true if layer tree updates are disabled.
     virtual bool layerTreeStateIsFrozen() const { return false; }
+    virtual bool layerFlushThrottlingIsActive() const { return false; }
 
     virtual bool adjustLayerFlushThrottling(LayerFlushThrottleState::Flags) { return false; }
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (238063 => 238064)


--- trunk/Source/WebCore/page/FrameView.cpp	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebCore/page/FrameView.cpp	2018-11-10 06:39:20 UTC (rev 238064)
@@ -37,6 +37,7 @@
 #include "DOMWindow.h"
 #include "DebugPageOverlays.h"
 #include "DeprecatedGlobalSettings.h"
+#include "DocumentLoader.h"
 #include "DocumentMarkerController.h"
 #include "EventHandler.h"
 #include "EventNames.h"
@@ -57,6 +58,7 @@
 #include "HTMLIFrameElement.h"
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
+#include "HTMLParserIdioms.h"
 #include "HTMLPlugInImageElement.h"
 #include "ImageDocument.h"
 #include "InspectorClient.h"
@@ -87,6 +89,7 @@
 #include "RuntimeEnabledFeatures.h"
 #include "SVGDocument.h"
 #include "SVGSVGElement.h"
+#include "ScriptRunner.h"
 #include "ScriptedAnimationController.h"
 #include "ScrollAnimator.h"
 #include "ScrollingCoordinator.h"
@@ -296,7 +299,7 @@
     m_renderedSignificantAmountOfText = false;
     m_visuallyNonEmptyCharacterCount = 0;
     m_visuallyNonEmptyPixelCount = 0;
-    m_renderTextCountForVisuallyNonEmptyCharacters = 0;
+    m_textRendererCountForVisuallyNonEmptyCharacters = 0;
 }
 
 void FrameView::removeFromAXObjectCache()
@@ -4345,6 +4348,31 @@
     ASSERT(!needsLayout());
 }
 
+void FrameView::incrementVisuallyNonEmptyCharacterCount(const String& inlineText)
+{
+    if (m_isVisuallyNonEmpty && m_renderedSignificantAmountOfText)
+        return;
+
+    ++m_textRendererCountForVisuallyNonEmptyCharacters;
+
+    auto nonWhitespaceLength = [](auto& inlineText) {
+        auto length = inlineText.length();
+        for (unsigned i = 0; i < inlineText.length(); ++i) {
+            if (isNotHTMLSpace(inlineText[i]))
+                continue;
+            --length;
+        }
+        return length;
+    };
+    m_visuallyNonEmptyCharacterCount += nonWhitespaceLength(inlineText);
+
+    if (!m_isVisuallyNonEmpty && m_visuallyNonEmptyCharacterCount > visualCharacterThreshold)
+        updateIsVisuallyNonEmpty();
+
+    if (!m_renderedSignificantAmountOfText)
+        updateSignificantRenderedTextMilestoneIfNeeded();
+}
+
 static bool elementOverflowRectIsLargerThanThreshold(const Element& element)
 {
     // Require the document to grow a bit.
@@ -4363,14 +4391,29 @@
     if (!documentElement || !documentElement->renderer())
         return false;
 
-    // Ensure that we always get marked visually non-empty eventually.
-    if (!frame().document()->parsing() && frame().loader().stateMachine().committedFirstRealDocumentLoad())
-        return true;
-
     // FIXME: We should also ignore renderers with non-final style.
     if (frame().document()->styleScope().hasPendingSheetsBeforeBody())
         return false;
 
+    auto finishedParsingMainDocument = frame().loader().stateMachine().committedFirstRealDocumentLoad() && !frame().document()->parsing();
+    // Ensure that we always fire visually non-empty milestone eventually.
+    if (finishedParsingMainDocument && frame().loader().isComplete())
+        return true;
+
+    auto isVisible = [](const Element* element) {
+        if (!element || !element->renderer())
+            return false;
+        if (!element->renderer()->opacity())
+            return false;
+        return element->renderer()->style().visibility() == Visibility::Visible;
+    };
+
+    if (!isVisible(documentElement))
+        return false;
+
+    if (!isVisible(frame().document()->body()))
+        return false;
+
     if (!elementOverflowRectIsLargerThanThreshold(*documentElement))
         return false;
 
@@ -4377,9 +4420,39 @@
     // The first few hundred characters rarely contain the interesting content of the page.
     if (m_visuallyNonEmptyCharacterCount > visualCharacterThreshold)
         return true;
+
     // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout
     if (m_visuallyNonEmptyPixelCount > visualPixelThreshold)
         return true;
+
+    auto isMoreContentExpected = [&]() {
+        // Pending css/_javascript_/font loading/processing means we should wait a little longer.
+        auto hasPendingScriptExecution = frame().document()->scriptRunner() && frame().document()->scriptRunner()->hasPendingScripts();
+        if (hasPendingScriptExecution)
+            return true;
+
+        auto* documentLoader = frame().loader().documentLoader();
+        if (!documentLoader)
+            return false;
+
+        auto& resourceLoader = documentLoader->cachedResourceLoader();
+        if (!resourceLoader.requestCount())
+            return false;
+
+        auto& resources = resourceLoader.allCachedResources();
+        for (auto& resource : resources) {
+            if (resource.value->isLoaded())
+                continue;
+            if (resource.value->type() == CachedResource::Type::CSSStyleSheet || resource.value->type() == CachedResource::Type::Script || resource.value->type() == CachedResource::Type::FontResource)
+                return true;
+        }
+        return false;
+    };
+
+    // Finished parsing the main document and we still don't yet have enough content. Check if we might be getting some more.
+    if (finishedParsingMainDocument)
+        return !isMoreContentExpected();
+
     return false;
 }
 
@@ -4402,7 +4475,7 @@
     if (m_visuallyNonEmptyCharacterCount < characterThreshold)
         return;
 
-    if (!m_renderTextCountForVisuallyNonEmptyCharacters || m_visuallyNonEmptyCharacterCount / static_cast<float>(m_renderTextCountForVisuallyNonEmptyCharacters) < meanLength)
+    if (!m_textRendererCountForVisuallyNonEmptyCharacters || m_visuallyNonEmptyCharacterCount / static_cast<float>(m_textRendererCountForVisuallyNonEmptyCharacters) < meanLength)
         return;
 
     m_renderedSignificantAmountOfText = true;

Modified: trunk/Source/WebCore/page/FrameView.h (238063 => 238064)


--- trunk/Source/WebCore/page/FrameView.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebCore/page/FrameView.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -393,7 +393,7 @@
     
     WEBCORE_EXPORT void updateLayoutAndStyleIfNeededRecursive();
 
-    void incrementVisuallyNonEmptyCharacterCount(unsigned);
+    void incrementVisuallyNonEmptyCharacterCount(const String&);
     void incrementVisuallyNonEmptyPixelCount(const IntSize&);
     void updateIsVisuallyNonEmpty();
     void updateSignificantRenderedTextMilestoneIfNeeded();
@@ -870,7 +870,7 @@
     bool m_isVisuallyNonEmpty;
     bool m_firstVisuallyNonEmptyLayoutCallbackPending;
 
-    unsigned m_renderTextCountForVisuallyNonEmptyCharacters;
+    unsigned m_textRendererCountForVisuallyNonEmptyCharacters { 0 };
     bool m_renderedSignificantAmountOfText;
     bool m_significantRenderedTextMilestonePending;
 
@@ -937,18 +937,6 @@
     FrameViewLayoutContext m_layoutContext;
 };
 
-inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
-{
-    if (m_isVisuallyNonEmpty && m_renderedSignificantAmountOfText)
-        return;
-    m_visuallyNonEmptyCharacterCount += count;
-    ++m_renderTextCountForVisuallyNonEmptyCharacters;
-    if (!m_isVisuallyNonEmpty && m_visuallyNonEmptyCharacterCount > visualCharacterThreshold)
-        updateIsVisuallyNonEmpty();
-    if (!m_renderedSignificantAmountOfText)
-        updateSignificantRenderedTextMilestoneIfNeeded();
-}
-
 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
 {
     if (m_isVisuallyNonEmpty)

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (238063 => 238064)


--- trunk/Source/WebCore/platform/graphics/FontCascade.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -257,9 +257,9 @@
 
     bool useBackslashAsYenSymbol() const { return m_useBackslashAsYenSymbol; }
     FontCascadeFonts* fonts() const { return m_fonts.get(); }
+    bool isLoadingCustomFonts() const;
 
 private:
-    bool isLoadingCustomFonts() const;
 
     bool advancedTextRenderingMode() const
     {

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (238063 => 238064)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2018-11-10 06:39:20 UTC (rev 238064)
@@ -199,7 +199,16 @@
     ASSERT(!m_text.isNull());
     setIsText();
     m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath();
-    view().frameView().incrementVisuallyNonEmptyCharacterCount(text.impl()->length());
+
+    // FIXME: Find out how to increment the visually non empty character count when the font becomes available.
+    auto isTextVisible = false;
+    if (auto* parentElement = node.parentElement()) {
+        auto* style = parentElement->renderer() ? &parentElement->renderer()->style() : nullptr;
+        isTextVisible = style && style->visibility() == Visibility::Visible && !style->fontCascade().isLoadingCustomFonts();
+    }
+
+    if (isTextVisible)
+        view().frameView().incrementVisuallyNonEmptyCharacterCount(text);
 }
 
 RenderText::RenderText(Text& textNode, const String& text)

Modified: trunk/Source/WebKit/ChangeLog (238063 => 238064)


--- trunk/Source/WebKit/ChangeLog	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/ChangeLog	2018-11-10 06:39:20 UTC (rev 238064)
@@ -1,3 +1,30 @@
+2018-11-09  Zalan Bujtas  <[email protected]>
+
+        [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.
+
+        * 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):
+
 2018-11-09  John Wilander  <[email protected]>
 
         Add ability to configure document.cookie lifetime cap through user defaults

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2018-11-10 06:39:20 UTC (rev 238064)
@@ -931,6 +931,14 @@
     return false;
 }
 
+bool WebChromeClient::layerFlushThrottlingIsActive() const
+{
+    if (m_page.drawingArea())
+        return m_page.drawingArea()->layerFlushThrottlingIsActive();
+
+    return false;
+}
+
 #if ENABLE(ASYNC_SCROLLING)
 
 RefPtr<ScrollingCoordinator> WebChromeClient::createScrollingCoordinator(Page& page) const

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -242,6 +242,7 @@
     }
 
     bool layerTreeStateIsFrozen() const final;
+    bool layerFlushThrottlingIsActive() const final;
 
 #if ENABLE(ASYNC_SCROLLING)
     RefPtr<WebCore::ScrollingCoordinator> createScrollingCoordinator(WebCore::Page&) const final;

Modified: trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp	2018-11-10 06:39:20 UTC (rev 238064)
@@ -223,6 +223,10 @@
         m_layerTreeHost->scheduleLayerFlush();
 }
 
+void AcceleratedDrawingArea::scheduleInitialDeferredPaint()
+{
+}
+
 void AcceleratedDrawingArea::scheduleCompositingLayerFlushImmediately()
 {
     scheduleCompositingLayerFlush();

Modified: trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -56,6 +56,7 @@
 
     WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
+    void scheduleInitialDeferredPaint() override;
     void scheduleCompositingLayerFlush() override;
     void scheduleCompositingLayerFlushImmediately() override;
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -84,6 +84,7 @@
     virtual bool forceRepaintAsync(CallbackID) { return false; }
     virtual void setLayerTreeStateIsFrozen(bool) { }
     virtual bool layerTreeStateIsFrozen() const { return false; }
+    virtual bool layerFlushThrottlingIsActive() const { return false; }
     virtual LayerTreeHost* layerTreeHost() const { return 0; }
 
     virtual void setPaintingEnabled(bool) { }
@@ -111,6 +112,7 @@
     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return nullptr; }
     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
     virtual void scheduleCompositingLayerFlush() = 0;
+    virtual void scheduleInitialDeferredPaint() = 0;
     virtual void scheduleCompositingLayerFlushImmediately() = 0;
 
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -63,6 +63,7 @@
 
     WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
+    void scheduleInitialDeferredPaint() override;
     void scheduleCompositingLayerFlush() override;
     void scheduleCompositingLayerFlushImmediately() override;
     void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
@@ -79,6 +80,8 @@
     bool supportsAsyncScrolling() override { return true; }
 
     void setLayerTreeStateIsFrozen(bool) override;
+    bool layerTreeStateIsFrozen() const override { return m_isFlushingSuspended; }
+    bool layerFlushThrottlingIsActive() const override { return m_isThrottlingLayerFlushes && m_layerFlushTimer.isActive(); }
 
     void forceRepaint() override;
     bool forceRepaintAsync(CallbackID) override { return false; }
@@ -111,6 +114,7 @@
     void updateScrolledExposedRect();
     void updateRootLayers();
 
+    void flushInitialDeferredPaint();
     void flushLayers();
 
     WebCore::TiledBacking* mainFrameTiledBacking() const;
@@ -147,6 +151,7 @@
     WebCore::Timer m_layerFlushTimer;
     bool m_isFlushingSuspended { false };
     bool m_hasDeferredFlush { false };
+    bool m_flushingInitialDeferredPaint { false };
     bool m_isThrottlingLayerFlushes { false };
     bool m_isLayerFlushThrottlingTemporarilyDisabledForInteraction { false };
     bool m_isInitialThrottledLayerFlush { false };

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2018-11-10 06:39:20 UTC (rev 238064)
@@ -185,7 +185,7 @@
 
     if (!m_isFlushingSuspended && m_hasDeferredFlush) {
         m_hasDeferredFlush = false;
-        scheduleCompositingLayerFlush();
+        scheduleInitialDeferredPaint();
     }
 }
 
@@ -273,6 +273,16 @@
     m_layerFlushTimer.startOneShot(0_s);
 }
 
+void RemoteLayerTreeDrawingArea::scheduleInitialDeferredPaint()
+{
+    ASSERT(!m_isFlushingSuspended);
+    m_flushingInitialDeferredPaint = true;
+
+    if (m_layerFlushTimer.isActive())
+        return;
+    scheduleCompositingLayerFlushImmediately();
+}
+
 void RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush()
 {
     if (m_isFlushingSuspended) {
@@ -328,6 +338,13 @@
         return;
     }
 
+    if (m_flushingInitialDeferredPaint) {
+        m_flushingInitialDeferredPaint = false;
+        // Reschedule the flush timer for the second paint if painting is being throttled.
+        if (m_isThrottlingLayerFlushes)
+            scheduleCompositingLayerFlush();
+    }
+
     RELEASE_ASSERT(!m_pendingBackingStoreFlusher || m_pendingBackingStoreFlusher->hasFlushed());
 
     RemoteLayerBackingStoreCollection& backingStoreCollection = m_remoteLayerTreeContext->backingStoreCollection();

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2018-11-10 06:39:20 UTC (rev 238064)
@@ -65,6 +65,7 @@
     void setLayerTreeStateIsFrozen(bool) override;
     bool layerTreeStateIsFrozen() const override;
     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
+    void scheduleInitialDeferredPaint() override;
     void scheduleCompositingLayerFlush() override;
     void scheduleCompositingLayerFlushImmediately() override;
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (238063 => 238064)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2018-11-10 04:50:03 UTC (rev 238063)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2018-11-10 06:39:20 UTC (rev 238064)
@@ -185,6 +185,10 @@
     return m_layerTreeStateIsFrozen;
 }
 
+void TiledCoreAnimationDrawingArea::scheduleInitialDeferredPaint()
+{
+}
+
 void TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlush()
 {
     if (m_layerTreeStateIsFrozen)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to