Title: [127783] trunk/Source/WebCore
Revision
127783
Author
[email protected]
Date
2012-09-06 14:04:34 -0700 (Thu, 06 Sep 2012)

Log Message

Move RenderView::setFixedPositionedObjectsNeedLayout to FrameView
https://bugs.webkit.org/show_bug.cgi?id=96017

Reviewed by James Robinson.

FrameView already has a HashSet of RenderObjects whose position
is affected by the viewport rect; this contains fixed and sticky-postion
objects. RenderView::setFixedPositionedObjectsNeedLayout() was using
the RenderView's list of postioned objects, but this omitted sticky-position
objects whose container was not the RenderView. So it's simpler to use
FrameView's set of fixed/sticky objects.

Changed the terminology from "fixed" to "viewport-constrained" for this set
of objects.

* page/FrameView.cpp:
(WebCore::FrameView::useSlowRepaints):
(WebCore::FrameView::addViewportConstrainedObject):
(WebCore::FrameView::removeViewportConstrainedObject):
(WebCore::FrameView::scrollContentsFastPath):
(WebCore::FrameView::setFixedVisibleContentRect):
(WebCore::FrameView::setViewportConstrainedObjectsNeedLayout):
(WebCore::FrameView::repaintFixedElementsAfterScrolling):
(WebCore::FrameView::updateFixedElementsAfterScrolling):
* page/FrameView.h:
(WebCore::FrameView::viewportConstrainedObjects):
(WebCore::FrameView::hasViewportConstrainedObjects):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::hasNonLayerFixedObjects):
(WebCore::ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::willBeDestroyed):
(WebCore::RenderBoxModelObject::styleDidChange):
* rendering/RenderView.cpp:
* rendering/RenderView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127782 => 127783)


--- trunk/Source/WebCore/ChangeLog	2012-09-06 21:00:43 UTC (rev 127782)
+++ trunk/Source/WebCore/ChangeLog	2012-09-06 21:04:34 UTC (rev 127783)
@@ -1,3 +1,41 @@
+2012-09-06  Simon Fraser  <[email protected]>
+
+        Move RenderView::setFixedPositionedObjectsNeedLayout to FrameView
+        https://bugs.webkit.org/show_bug.cgi?id=96017
+
+        Reviewed by James Robinson.
+
+        FrameView already has a HashSet of RenderObjects whose position
+        is affected by the viewport rect; this contains fixed and sticky-postion
+        objects. RenderView::setFixedPositionedObjectsNeedLayout() was using
+        the RenderView's list of postioned objects, but this omitted sticky-position
+        objects whose container was not the RenderView. So it's simpler to use
+        FrameView's set of fixed/sticky objects.
+        
+        Changed the terminology from "fixed" to "viewport-constrained" for this set
+        of objects.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::useSlowRepaints):
+        (WebCore::FrameView::addViewportConstrainedObject):
+        (WebCore::FrameView::removeViewportConstrainedObject):
+        (WebCore::FrameView::scrollContentsFastPath):
+        (WebCore::FrameView::setFixedVisibleContentRect):
+        (WebCore::FrameView::setViewportConstrainedObjectsNeedLayout):
+        (WebCore::FrameView::repaintFixedElementsAfterScrolling):
+        (WebCore::FrameView::updateFixedElementsAfterScrolling):
+        * page/FrameView.h:
+        (WebCore::FrameView::viewportConstrainedObjects):
+        (WebCore::FrameView::hasViewportConstrainedObjects):
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::hasNonLayerFixedObjects):
+        (WebCore::ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::willBeDestroyed):
+        (WebCore::RenderBoxModelObject::styleDidChange):
+        * rendering/RenderView.cpp:
+        * rendering/RenderView.h:
+
 2012-09-06  Andrei Poenaru  <[email protected]>
 
         Web Inspector: Protocol Extension: Add "regionLayoutUpdate" event

Modified: trunk/Source/WebCore/page/FrameView.cpp (127782 => 127783)


--- trunk/Source/WebCore/page/FrameView.cpp	2012-09-06 21:00:43 UTC (rev 127782)
+++ trunk/Source/WebCore/page/FrameView.cpp	2012-09-06 21:04:34 UTC (rev 127783)
@@ -1336,7 +1336,7 @@
 
 bool FrameView::useSlowRepaints(bool considerOverlap) const
 {
-    bool mustBeSlow = m_slowRepaintObjectCount > 0 || (platformWidget() && hasFixedObjects());
+    bool mustBeSlow = m_slowRepaintObjectCount > 0 || (platformWidget() && hasViewportConstrainedObjects());
 
     // FIXME: WidgetMac.mm makes the assumption that useSlowRepaints ==
     // m_contentIsOpaque, so don't take the fast path for composited layers
@@ -1421,13 +1421,13 @@
     }
 }
 
-void FrameView::addFixedObject(RenderObject* object)
+void FrameView::addViewportConstrainedObject(RenderObject* object)
 {
-    if (!m_fixedObjects)
-        m_fixedObjects = adoptPtr(new FixedObjectSet);
+    if (!m_viewportConstrainedObjects)
+        m_viewportConstrainedObjects = adoptPtr(new ViewportConstrainedObjectSet);
 
-    if (!m_fixedObjects->contains(object)) {
-        m_fixedObjects->add(object);
+    if (!m_viewportConstrainedObjects->contains(object)) {
+        m_viewportConstrainedObjects->add(object);
         if (platformWidget())
             updateCanBlitOnScrollRecursively();
 
@@ -1438,10 +1438,10 @@
     }
 }
 
-void FrameView::removeFixedObject(RenderObject* object)
+void FrameView::removeViewportConstrainedObject(RenderObject* object)
 {
-    if (m_fixedObjects && m_fixedObjects->contains(object)) {
-        m_fixedObjects->remove(object);
+    if (m_viewportConstrainedObjects && m_viewportConstrainedObjects->contains(object)) {
+        m_viewportConstrainedObjects->remove(object);
         if (Page* page = m_frame->page()) {
             if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
                 scrollingCoordinator->frameViewFixedObjectsDidChange(this);
@@ -1510,7 +1510,7 @@
 
 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
 {
-    if (!m_fixedObjects || m_fixedObjects->isEmpty()) {
+    if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()) {
         hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
         return true;
     }
@@ -1519,8 +1519,8 @@
 
     // Get the rects of the fixed objects visible in the rectToScroll
     Region regionToUpdate;
-    FixedObjectSet::const_iterator end = m_fixedObjects->end();
-    for (FixedObjectSet::const_iterator it = m_fixedObjects->begin(); it != end; ++it) {
+    ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
+    for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
         RenderObject* renderer = *it;
         if (!renderer->style()->hasViewportConstrainedPosition())
             continue;
@@ -1553,8 +1553,8 @@
 
     // 2) update the area of fixed objects that has been invalidated
     Vector<IntRect> subRectsToUpdate = regionToUpdate.rects();
-    size_t fixObjectsCount = subRectsToUpdate.size();
-    for (size_t i = 0; i < fixObjectsCount; ++i) {
+    size_t viewportConstrainedObjectsCount = subRectsToUpdate.size();
+    for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) {
         IntRect updateRect = subRectsToUpdate[i];
         IntRect scrolledRect = updateRect;
         scrolledRect.move(scrollDelta);
@@ -1774,9 +1774,8 @@
     bool visibleContentSizeDidChange = false;
     if (visibleContentRect.size() != this->fixedVisibleContentRect().size()) {
         // When the viewport size changes or the content is scaled, we need to
-        // reposition the fixed positioned elements.
-        if (RenderView* root = rootRenderer(this))
-            root->setFixedPositionedObjectsNeedLayout();
+        // reposition the fixed and sticky positioned elements.
+        setViewportConstrainedObjectsNeedLayout();
         visibleContentSizeDidChange = true;
     }
 
@@ -1795,6 +1794,19 @@
     frame()->loader()->client()->didChangeScrollOffset();
 }
 
+void FrameView::setViewportConstrainedObjectsNeedLayout()
+{
+    if (!hasViewportConstrainedObjects())
+        return;
+
+    ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
+    for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
+        RenderObject* renderer = *it;
+        renderer->setNeedsLayout(true);
+    }
+}
+
+
 void FrameView::scrollPositionChangedViaPlatformWidget()
 {
     repaintFixedElementsAfterScrolling();
@@ -1819,7 +1831,7 @@
 {
     // For fixed position elements, update widget positions and compositing layers after scrolling,
     // but only if we're not inside of layout.
-    if (!m_nestedLayoutCount && hasFixedObjects()) {
+    if (!m_nestedLayoutCount && hasViewportConstrainedObjects()) {
         if (RenderView* root = rootRenderer(this)) {
             root->updateWidgetPositions();
             root->layer()->updateLayerPositionsAfterScroll();
@@ -1830,7 +1842,7 @@
 void FrameView::updateFixedElementsAfterScrolling()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    if (m_nestedLayoutCount <= 1 && hasFixedObjects()) {
+    if (m_nestedLayoutCount <= 1 && hasViewportConstrainedObjects()) {
         if (RenderView* root = rootRenderer(this)) {
             root->compositor()->updateCompositingLayers(CompositingUpdateOnScroll);
         }

Modified: trunk/Source/WebCore/page/FrameView.h (127782 => 127783)


--- trunk/Source/WebCore/page/FrameView.h	2012-09-06 21:00:43 UTC (rev 127782)
+++ trunk/Source/WebCore/page/FrameView.h	2012-09-06 21:04:34 UTC (rev 127783)
@@ -197,12 +197,12 @@
     void removeSlowRepaintObject();
     bool hasSlowRepaintObjects() const { return m_slowRepaintObjectCount; }
 
-    // This includes position:fixed and sticky objects.
-    typedef HashSet<RenderObject*> FixedObjectSet;
-    void addFixedObject(RenderObject*);
-    void removeFixedObject(RenderObject*);
-    const FixedObjectSet* fixedObjects() const { return m_fixedObjects.get(); }
-    bool hasFixedObjects() const { return m_fixedObjects && m_fixedObjects->size() > 0; }
+    // Includes fixed- and sticky-position objects.
+    typedef HashSet<RenderObject*> ViewportConstrainedObjectSet;
+    void addViewportConstrainedObject(RenderObject*);
+    void removeViewportConstrainedObject(RenderObject*);
+    const ViewportConstrainedObjectSet* viewportConstrainedObjects() const { return m_viewportConstrainedObjects.get(); }
+    bool hasViewportConstrainedObjects() const { return m_viewportConstrainedObjects && m_viewportConstrainedObjects->size() > 0; }
 
     // Functions for querying the current scrolled position, negating the effects of overhang
     // and adjusting for page scale.
@@ -446,6 +446,8 @@
 
     bool doLayoutWithFrameFlattening(bool allowSubtree);
 
+    void setViewportConstrainedObjectsNeedLayout();
+
     virtual AXObjectCache* axObjectCache() const;
     void notifyWidgetsInAllFrames(WidgetNotification);
     
@@ -544,7 +546,7 @@
     IntSize m_maxAutoSize;
 
     OwnPtr<ScrollableAreaSet> m_scrollableAreas;
-    OwnPtr<FixedObjectSet> m_fixedObjects;
+    OwnPtr<ViewportConstrainedObjectSet> m_viewportConstrainedObjects;
 
     static double s_normalDeferredRepaintDelay;
     static double s_initialDeferredRepaintDelayDuringLoading;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (127782 => 127783)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2012-09-06 21:00:43 UTC (rev 127782)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2012-09-06 21:04:34 UTC (rev 127783)
@@ -361,22 +361,22 @@
 
 bool ScrollingCoordinator::hasNonLayerFixedObjects(FrameView* frameView)
 {
-    const FrameView::FixedObjectSet* fixedObjects = frameView->fixedObjects();
-    if (!fixedObjects)
+    const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects();
+    if (!viewportConstrainedObjects)
         return false;
 
 #if USE(ACCELERATED_COMPOSITING)
-    for (FrameView::FixedObjectSet::const_iterator it = fixedObjects->begin(), end = fixedObjects->end(); it != end; ++it) {
-        RenderObject* fixedObject = *it;
-        if (!fixedObject->isBoxModelObject() || !fixedObject->hasLayer())
+    for (FrameView::ViewportConstrainedObjectSet::const_iterator it = viewportConstrainedObjects->begin(), end = viewportConstrainedObjects->end(); it != end; ++it) {
+        RenderObject* viewportConstrainedObject = *it;
+        if (!viewportConstrainedObject->isBoxModelObject() || !viewportConstrainedObject->hasLayer())
             return true;
-        RenderBoxModelObject* fixedBoxModelObject = toRenderBoxModelObject(fixedObject);
-        if (!fixedBoxModelObject->layer()->backing())
+        RenderBoxModelObject* viewportConstrainedBoxModelObject = toRenderBoxModelObject(viewportConstrainedObject);
+        if (!viewportConstrainedBoxModelObject->layer()->backing())
             return true;
     }
     return false;
 #else
-    return fixedObjects->size();
+    return viewportConstrainedObjects->size();
 #endif
 }
 
@@ -386,7 +386,7 @@
 
     setShouldUpdateScrollLayerPositionOnMainThread(m_forceMainThreadScrollLayerPositionUpdates
         || frameView->hasSlowRepaintObjects()
-        || (!supportsFixedPositionLayers() && frameView->hasFixedObjects())
+        || (!supportsFixedPositionLayers() && frameView->hasViewportConstrainedObjects())
         || (supportsFixedPositionLayers() && hasNonLayerFixedObjects(frameView))
         || m_page->mainFrame()->document()->isImageDocument());
 }

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (127782 => 127783)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-09-06 21:00:43 UTC (rev 127782)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-09-06 21:04:34 UTC (rev 127783)
@@ -352,7 +352,7 @@
         if (RenderView* view = this->view()) {
             if (FrameView* frameView = view->frameView()) {
                 if (style()->hasViewportConstrainedPosition())
-                    frameView->removeFixedObject(this);
+                    frameView->removeViewportConstrainedObject(this);
             }
         }
     }
@@ -461,9 +461,9 @@
         bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition();
         if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) {
             if (newStyleIsViewportConstained && layer())
-                frameView->addFixedObject(this);
+                frameView->addViewportConstrainedObject(this);
             else
-                frameView->removeFixedObject(this);
+                frameView->removeViewportConstrainedObject(this);
         }
     }
 }

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (127782 => 127783)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2012-09-06 21:00:43 UTC (rev 127782)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2012-09-06 21:04:34 UTC (rev 127783)
@@ -937,19 +937,4 @@
     return m_intervalArena.get();
 }
 
-void RenderView::setFixedPositionedObjectsNeedLayout()
-{
-    ASSERT(m_frameView);
-
-    TrackedRendererListHashSet* positionedObjects = this->positionedObjects();
-    if (!positionedObjects)
-        return;
-
-    TrackedRendererListHashSet::const_iterator end = positionedObjects->end();
-    for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) {
-        RenderBox* currBox = *it;
-        currBox->setNeedsLayout(true);
-    }
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderView.h (127782 => 127783)


--- trunk/Source/WebCore/rendering/RenderView.h	2012-09-06 21:00:43 UTC (rev 127782)
+++ trunk/Source/WebCore/rendering/RenderView.h	2012-09-06 21:04:34 UTC (rev 127783)
@@ -193,8 +193,6 @@
 
     IntSize viewportSize() const { return document()->viewportSize(); }
 
-    void setFixedPositionedObjectsNeedLayout();
-
     void setRenderQuoteHead(RenderQuote* head) { m_renderQuoteHead = head; }
     RenderQuote* renderQuoteHead() const { return m_renderQuoteHead; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to