Title: [152401] trunk/Source/WebCore
Revision
152401
Author
an...@apple.com
Date
2013-07-04 08:51:44 -0700 (Thu, 04 Jul 2013)

Log Message

Take document height into account when determining when it is considered visually non-empy
https://bugs.webkit.org/show_bug.cgi?id=118272

Reviewed by Darin Adler.

The current visually non-empy mechanism takes into account only the amount of contents in renderers. 
Add a simple layout dependency so that we don't consider page non-empty until the document height
exceed a (low) height threshold (or the load completes).

* page/FrameView.cpp:
(WebCore::FrameView::performPostLayoutTasks):
        
    Don't send layout callbacks until we have actually some content.

(WebCore::FrameView::qualifiesAsVisuallyNonEmpty):
(WebCore::FrameView::updateIsVisuallyNonEmpty):
        
    Factor into functions.

* page/FrameView.h:
(WebCore::FrameView::incrementVisuallyNonEmptyCharacterCount):
(WebCore::FrameView::incrementVisuallyNonEmptyPixelCount):
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::RenderEmbeddedObject):
* rendering/RenderHTMLCanvas.cpp:
(WebCore::RenderHTMLCanvas::RenderHTMLCanvas):
        
     The size is not known but the estimate provided here is always bigger than the threshold so
     the functionality is unchanged.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152400 => 152401)


--- trunk/Source/WebCore/ChangeLog	2013-07-04 15:33:32 UTC (rev 152400)
+++ trunk/Source/WebCore/ChangeLog	2013-07-04 15:51:44 UTC (rev 152401)
@@ -1,3 +1,35 @@
+2013-07-01  Antti Koivisto  <an...@apple.com>
+
+        Take document height into account when determining when it is considered visually non-empy
+        https://bugs.webkit.org/show_bug.cgi?id=118272
+
+        Reviewed by Darin Adler.
+
+        The current visually non-empy mechanism takes into account only the amount of contents in renderers. 
+        Add a simple layout dependency so that we don't consider page non-empty until the document height
+        exceed a (low) height threshold (or the load completes).
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::performPostLayoutTasks):
+        
+            Don't send layout callbacks until we have actually some content.
+
+        (WebCore::FrameView::qualifiesAsVisuallyNonEmpty):
+        (WebCore::FrameView::updateIsVisuallyNonEmpty):
+        
+            Factor into functions.
+
+        * page/FrameView.h:
+        (WebCore::FrameView::incrementVisuallyNonEmptyCharacterCount):
+        (WebCore::FrameView::incrementVisuallyNonEmptyPixelCount):
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::RenderEmbeddedObject):
+        * rendering/RenderHTMLCanvas.cpp:
+        (WebCore::RenderHTMLCanvas::RenderHTMLCanvas):
+        
+             The size is not known but the estimate provided here is always bigger than the threshold so
+             the functionality is unchanged.
+
 2013-07-04  Christophe Dumez  <ch.du...@sisa.samsung.com>
 
         Unreviewed build fix after r152399.

Modified: trunk/Source/WebCore/page/FrameView.cpp (152400 => 152401)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-07-04 15:33:32 UTC (rev 152400)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-07-04 15:51:44 UTC (rev 152401)
@@ -2749,7 +2749,7 @@
     if (page)
         requestedMilestones = page->requestedLayoutMilestones();
 
-    if (m_nestedLayoutCount <= 1) {
+    if (m_nestedLayoutCount <= 1 && m_frame->document()->documentElement()) {
         if (m_firstLayoutCallbackPending) {
             m_firstLayoutCallbackPending = false;
             m_frame->loader()->didFirstLayout();
@@ -2760,11 +2760,8 @@
                     page->startCountingRelevantRepaintedObjects();
             }
         }
+        updateIsVisuallyNonEmpty();
 
-        // Ensure that we always send this eventually.
-        if (!m_frame->document()->parsing() && m_frame->loader()->stateMachine()->committedFirstRealDocumentLoad())
-            m_isVisuallyNonEmpty = true;
-
         // If the layout was done with pending sheets, we are not in fact visually non-empty yet.
         if (m_isVisuallyNonEmpty && !m_frame->document()->didLayoutWithPendingStylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) {
             m_firstVisuallyNonEmptyLayoutCallbackPending = false;
@@ -3734,8 +3731,37 @@
     ASSERT(!needsLayout());
 }
 
-void FrameView::setIsVisuallyNonEmpty()
+bool FrameView::qualifiesAsVisuallyNonEmpty() const
 {
+    // No content yet.
+    Element* documentElement = m_frame->document()->documentElement();
+    if (!documentElement || !documentElement->renderer())
+        return false;
+
+    // Ensure that we always get marked visually non-empty eventually.
+    if (!m_frame->document()->parsing() && m_frame->loader()->stateMachine()->committedFirstRealDocumentLoad())
+        return true;
+
+    // Require the document to grow a bit.
+    static const int documentHeightThreshold = 200;
+    if (documentElement->renderBox()->layoutOverflowRect().pixelSnappedHeight() < documentHeightThreshold)
+        return false;
+
+    // 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;
+    return false;
+}
+
+void FrameView::updateIsVisuallyNonEmpty()
+{
+    if (m_isVisuallyNonEmpty)
+        return;
+    if (!qualifiesAsVisuallyNonEmpty())
+        return;
     m_isVisuallyNonEmpty = true;
     adjustTiledBackingCoverage();
 }

Modified: trunk/Source/WebCore/page/FrameView.h (152400 => 152401)


--- trunk/Source/WebCore/page/FrameView.h	2013-07-04 15:33:32 UTC (rev 152400)
+++ trunk/Source/WebCore/page/FrameView.h	2013-07-04 15:51:44 UTC (rev 152401)
@@ -294,7 +294,7 @@
 
     void incrementVisuallyNonEmptyCharacterCount(unsigned);
     void incrementVisuallyNonEmptyPixelCount(const IntSize&);
-    void setIsVisuallyNonEmpty();
+    void updateIsVisuallyNonEmpty();
     bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
     void enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize);
 
@@ -531,6 +531,8 @@
 
     bool doLayoutWithFrameFlattening(bool allowSubtree);
 
+    bool qualifiesAsVisuallyNonEmpty() const;
+
     virtual AXObjectCache* axObjectCache() const;
     void notifyWidgetsInAllFrames(WidgetNotification);
     void removeFromAXObjectCache();
@@ -645,6 +647,9 @@
     static double s_maxDeferredRepaintDelayDuringLoading;
     static double s_deferredRepaintDelayIncrementDuringLoading;
 
+    static const unsigned visualCharacterThreshold = 200;
+    static const unsigned visualPixelThreshold = 32 * 32;
+
 #if ENABLE(CSS_FILTERS)
     bool m_hasSoftwareFilters;
 #endif
@@ -662,11 +667,9 @@
     if (m_isVisuallyNonEmpty)
         return;
     m_visuallyNonEmptyCharacterCount += count;
-    // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout.
-    // The first few hundred characters rarely contain the interesting content of the page.
-    static const unsigned visualCharacterThreshold = 200;
-    if (m_visuallyNonEmptyCharacterCount > visualCharacterThreshold)
-        setIsVisuallyNonEmpty();
+    if (m_visuallyNonEmptyCharacterCount <= visualCharacterThreshold)
+        return;
+    updateIsVisuallyNonEmpty();
 }
 
 inline void FrameView::incrementVisuallyNonEmptyPixelCount(const IntSize& size)
@@ -674,10 +677,9 @@
     if (m_isVisuallyNonEmpty)
         return;
     m_visuallyNonEmptyPixelCount += size.width() * size.height();
-    // Use a threshold value to prevent very small amounts of visible content from triggering didFirstVisuallyNonEmptyLayout
-    static const unsigned visualPixelThreshold = 32 * 32;
-    if (m_visuallyNonEmptyPixelCount > visualPixelThreshold)
-        setIsVisuallyNonEmpty();
+    if (m_visuallyNonEmptyPixelCount <= visualPixelThreshold)
+        return;
+    updateIsVisuallyNonEmpty();
 }
 
 inline int FrameView::mapFromLayoutToCSSUnits(LayoutUnit value)

Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp (152400 => 152401)


--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2013-07-04 15:33:32 UTC (rev 152400)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2013-07-04 15:51:44 UTC (rev 152401)
@@ -87,7 +87,8 @@
     , m_unavailablePluginIndicatorIsPressed(false)
     , m_mouseDownWasInUnavailablePluginIndicator(false)
 {
-    view()->frameView()->setIsVisuallyNonEmpty();
+    // Actual size is not known yet, report the default intrinsic size.
+    view()->frameView()->incrementVisuallyNonEmptyPixelCount(roundedIntSize(intrinsicSize()));
 }
 
 RenderEmbeddedObject::~RenderEmbeddedObject()

Modified: trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp (152400 => 152401)


--- trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp	2013-07-04 15:33:32 UTC (rev 152400)
+++ trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp	2013-07-04 15:51:44 UTC (rev 152401)
@@ -44,7 +44,8 @@
 RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement* element)
     : RenderReplaced(element, element->size())
 {
-    view()->frameView()->setIsVisuallyNonEmpty();
+    // Actual size is not known yet, report the default intrinsic size.
+    view()->frameView()->incrementVisuallyNonEmptyPixelCount(roundedIntSize(intrinsicSize()));
 }
 
 bool RenderHTMLCanvas::requiresLayer() const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to