Title: [240519] trunk/Source/WebCore
Revision
240519
Author
[email protected]
Date
2019-01-25 15:40:23 -0800 (Fri, 25 Jan 2019)

Log Message

Remove FrameView::m_significantRenderedTextMilestonePending
https://bugs.webkit.org/show_bug.cgi?id=193842

Reviewed by Wenson Hsieh.

Currently we keep processing the incoming text content until after the "SignificantRenderedTextMilestone" has been reached.
We can actually stop doing it right when the text content is above the threshold (regardless of whether all the conditions are met for the milestone).
This patch also ensures that we don't update Document::m_mainArticleElement once the threshold is reached.

* page/FrameView.cpp:
(WebCore::FrameView::resetLayoutMilestones):
(WebCore::FrameView::incrementVisuallyNonEmptyCharacterCount):
(WebCore::FrameView::hasReachedSignificantRenderedTextThreashold):
(WebCore::FrameView::qualifiesAsSignificantRenderedText const):
(WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
(WebCore::FrameView::updateSignificantRenderedTextMilestoneIfNeeded): Deleted.
* page/FrameView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240518 => 240519)


--- trunk/Source/WebCore/ChangeLog	2019-01-25 23:31:17 UTC (rev 240518)
+++ trunk/Source/WebCore/ChangeLog	2019-01-25 23:40:23 UTC (rev 240519)
@@ -1,3 +1,23 @@
+2019-01-25  Zalan Bujtas  <[email protected]>
+
+        Remove FrameView::m_significantRenderedTextMilestonePending
+        https://bugs.webkit.org/show_bug.cgi?id=193842
+
+        Reviewed by Wenson Hsieh.
+
+        Currently we keep processing the incoming text content until after the "SignificantRenderedTextMilestone" has been reached.
+        We can actually stop doing it right when the text content is above the threshold (regardless of whether all the conditions are met for the milestone).
+        This patch also ensures that we don't update Document::m_mainArticleElement once the threshold is reached.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::resetLayoutMilestones):
+        (WebCore::FrameView::incrementVisuallyNonEmptyCharacterCount):
+        (WebCore::FrameView::hasReachedSignificantRenderedTextThreashold):
+        (WebCore::FrameView::qualifiesAsSignificantRenderedText const):
+        (WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
+        (WebCore::FrameView::updateSignificantRenderedTextMilestoneIfNeeded): Deleted.
+        * page/FrameView.h:
+
 2019-01-25  Keith Rollin  <[email protected]>
 
         Update Xcode projects with "Apply Configuration to XCFileLists" build target

Modified: trunk/Source/WebCore/page/FrameView.cpp (240518 => 240519)


--- trunk/Source/WebCore/page/FrameView.cpp	2019-01-25 23:31:17 UTC (rev 240518)
+++ trunk/Source/WebCore/page/FrameView.cpp	2019-01-25 23:40:23 UTC (rev 240519)
@@ -293,7 +293,7 @@
 {
     m_firstLayoutCallbackPending = false;
     m_isVisuallyNonEmpty = false;
-    m_significantRenderedTextMilestonePending = true;
+    m_hasReachedSignificantRenderedTextThreshold = false;
     m_renderedSignificantAmountOfText = false;
     m_visuallyNonEmptyCharacterCount = 0;
     m_visuallyNonEmptyPixelCount = 0;
@@ -3307,8 +3307,7 @@
 {
     // FIXME: We should not run any _javascript_ code in this function.
     LOG(Layout, "FrameView %p performPostLayoutTasks", this);
-
-    frame().document()->updateMainArticleElementAfterLayout();
+    updateHasReachedSignificantRenderedTextThreshold();
     frame().selection().updateAppearanceAfterLayout();
 
     flushPostLayoutTasksQueue();
@@ -4387,11 +4386,9 @@
 
 void FrameView::incrementVisuallyNonEmptyCharacterCount(const String& inlineText)
 {
-    if (m_visuallyNonEmptyCharacterCount > visualCharacterThreshold && m_renderedSignificantAmountOfText)
+    if (m_visuallyNonEmptyCharacterCount > visualCharacterThreshold && m_hasReachedSignificantRenderedTextThreshold)
         return;
 
-    ++m_textRendererCountForVisuallyNonEmptyCharacters;
-
     auto nonWhitespaceLength = [](auto& inlineText) {
         auto length = inlineText.length();
         for (unsigned i = 0; i < inlineText.length(); ++i) {
@@ -4402,9 +4399,7 @@
         return length;
     };
     m_visuallyNonEmptyCharacterCount += nonWhitespaceLength(inlineText);
-
-    if (!m_renderedSignificantAmountOfText)
-        updateSignificantRenderedTextMilestoneIfNeeded();
+    ++m_textRendererCountForVisuallyNonEmptyCharacters;
 }
 
 static bool elementOverflowRectIsLargerThanThreshold(const Element& element)
@@ -4418,6 +4413,42 @@
     return false;
 }
 
+void FrameView::updateHasReachedSignificantRenderedTextThreshold()
+{
+    if (m_hasReachedSignificantRenderedTextThreshold)
+        return;
+
+    auto* document = frame().document();
+    if (!document)
+        return;
+
+    document->updateMainArticleElementAfterLayout();
+    auto hasMainArticleElement = document->hasMainArticleElement();
+    auto characterThreshold = hasMainArticleElement ? mainArticleSignificantRenderedTextCharacterThreshold : defaultSignificantRenderedTextCharacterThreshold;
+    if (m_visuallyNonEmptyCharacterCount < characterThreshold)
+        return;
+
+    auto meanLength = hasMainArticleElement ? mainArticleSignificantRenderedTextMeanLength : defaultSignificantRenderedTextMeanLength;
+    if (!m_textRendererCountForVisuallyNonEmptyCharacters || m_visuallyNonEmptyCharacterCount / static_cast<float>(m_textRendererCountForVisuallyNonEmptyCharacters) < meanLength)
+        return;
+
+    m_hasReachedSignificantRenderedTextThreshold = true;
+}
+
+bool FrameView::qualifiesAsSignificantRenderedText() const
+{
+    ASSERT(!m_renderedSignificantAmountOfText);
+    auto* document = frame().document();
+    if (!document || document->styleScope().hasPendingSheetsBeforeBody())
+        return false;
+
+    auto* documentElement = document->documentElement();
+    if (!documentElement || !elementOverflowRectIsLargerThanThreshold(*documentElement))
+        return false;
+
+    return m_hasReachedSignificantRenderedTextThreshold;
+}
+
 bool FrameView::qualifiesAsVisuallyNonEmpty() const
 {
     // No content yet.
@@ -4490,31 +4521,6 @@
     return false;
 }
 
-void FrameView::updateSignificantRenderedTextMilestoneIfNeeded()
-{
-    if (m_renderedSignificantAmountOfText)
-        return;
-
-    auto* document = frame().document();
-    if (!document || document->styleScope().hasPendingSheetsBeforeBody())
-        return;
-
-    auto* documentElement = document->documentElement();
-    if (!documentElement || !elementOverflowRectIsLargerThanThreshold(*documentElement))
-        return;
-
-    auto characterThreshold = document->hasMainArticleElement() ? mainArticleSignificantRenderedTextCharacterThreshold : defaultSignificantRenderedTextCharacterThreshold;
-    auto meanLength = document->hasMainArticleElement() ? mainArticleSignificantRenderedTextMeanLength : defaultSignificantRenderedTextMeanLength;
-
-    if (m_visuallyNonEmptyCharacterCount < characterThreshold)
-        return;
-
-    if (!m_textRendererCountForVisuallyNonEmptyCharacters || m_visuallyNonEmptyCharacterCount / static_cast<float>(m_textRendererCountForVisuallyNonEmptyCharacters) < meanLength)
-        return;
-
-    m_renderedSignificantAmountOfText = true;
-}
-
 bool FrameView::isViewForDocumentInFrame() const
 {
     RenderView* renderView = this->renderView();
@@ -5136,7 +5142,6 @@
         if (frame().isMainFrame())
             page->startCountingRelevantRepaintedObjects();
     }
-    updateSignificantRenderedTextMilestoneIfNeeded();
 
     if (!m_isVisuallyNonEmpty && qualifiesAsVisuallyNonEmpty()) {
         m_isVisuallyNonEmpty = true;
@@ -5145,8 +5150,8 @@
             milestonesAchieved.add(DidFirstVisuallyNonEmptyLayout);
     }
 
-    if (m_renderedSignificantAmountOfText && m_significantRenderedTextMilestonePending) {
-        m_significantRenderedTextMilestonePending = false;
+    if (!m_renderedSignificantAmountOfText && qualifiesAsSignificantRenderedText()) {
+        m_renderedSignificantAmountOfText = true;
         if (requestedMilestones & DidRenderSignificantAmountOfText)
             milestonesAchieved.add(DidRenderSignificantAmountOfText);
     }

Modified: trunk/Source/WebCore/page/FrameView.h (240518 => 240519)


--- trunk/Source/WebCore/page/FrameView.h	2019-01-25 23:31:17 UTC (rev 240518)
+++ trunk/Source/WebCore/page/FrameView.h	2019-01-25 23:40:23 UTC (rev 240519)
@@ -793,6 +793,9 @@
     void markRootOrBodyRendererDirty() const;
 
     bool qualifiesAsVisuallyNonEmpty() const;
+    bool qualifiesAsSignificantRenderedText() const;
+    void updateHasReachedSignificantRenderedTextThreshold();
+
     bool isViewForDocumentInFrame() const;
 
     AXObjectCache* axObjectCache() const;
@@ -883,8 +886,8 @@
     unsigned m_visuallyNonEmptyPixelCount { 0 };
 
     unsigned m_textRendererCountForVisuallyNonEmptyCharacters { 0 };
-    bool m_renderedSignificantAmountOfText;
-    bool m_significantRenderedTextMilestonePending;
+    bool m_renderedSignificantAmountOfText { false };
+    bool m_hasReachedSignificantRenderedTextThreshold { false };
 
     bool m_needsDeferredScrollbarsUpdate { false };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to