https://bugs.webkit.org/show_bug.cgi?id=101001
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2012 23:31:58 +0000 (23:31 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2012 23:31:58 +0000 (23:31 +0000)
commitcaceee5ab51e714caf429ae4585d4b8dc9424778
treee6c506d180201bae3e31ef267fd7e5a18fb199e2
parentb62686a41ae0926a313c6457096335c9e193933d
https://bugs.webkit.org/show_bug.cgi?id=101001
Pages with position:fixed elements should still be able to scroll on
the scrolling thread
-and corresponding-
<rdar://problem/10857315>

Reviewed by Simon Fraser.

Source/WebCore:

This patch adds two new classes. ScrollingStateFixedNode is a class
to represent fixed nodes in the state tree, and
ScrollingTreeFixedNode represents fixed node in the scrolling tree
over on the scrolling thread.
* WebCore.xcodeproj/project.pbxproj:

When we are (non-programatically) scrolling fixed objects on the
scrolling thread, we do not want to do any work here.
* page/FrameView.cpp:
(WebCore::FrameView::updateFixedElementsAfterScrolling):

Whenever we sync the position of the main frame's layer, we have to
do the same for scrolling tree children.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::updateMainFrameScrollPosition):

New ScrollingNodeType -- FixedNode, yay! And two new functions
specific to dealing with FixedNodes.
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::updateViewportConstrainedNode):
(WebCore::ScrollingCoordinator::syncChildPositions):

This is the new class that represents fixed nodes in the state tree.
All of the changed properties are stored within
FixedPositionViewportConstraints.
* page/scrolling/ScrollingStateFixedNode.cpp: Added.
(WebCore):
(WebCore::ScrollingStateFixedNode::create):
(WebCore::ScrollingStateFixedNode::ScrollingStateFixedNode):
(WebCore::ScrollingStateFixedNode::~ScrollingStateFixedNode):
(WebCore::ScrollingStateFixedNode::updateConstraints):
(WebCore::ScrollingStateFixedNode::dumpProperties):
* page/scrolling/ScrollingStateFixedNode.h: Added.
(WebCore):
(ScrollingStateFixedNode):
(WebCore::ScrollingStateFixedNode::viewportConstraints):
(WebCore::toScrollingStateFixedNode):

Make sure to create the right type of clone for each node.
* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::cloneAndReset):

Now that m_children may be anything other than null, I found this
bug. We encounter it when the parameter to removeChild is this and we
want to remove all of our children. In that case, this is obviously
not found in its own child array.
(WebCore::ScrollingStateNode::removeChild):

ScrollingStateNode now caches the GraphicsLayer in addition to the
PlatformLayer. This will allow us to sync the GraphicsLayer position
at the appropriate times.
* page/scrolling/ScrollingStateNode.h:
(WebCore::ScrollingStateNode::isScrollingStateFixedNode):
(WebCore::ScrollingStateNode::graphicsLayer):
(ScrollingStateNode):

Handle fixed nodes.
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::updateTreeFromStateNode):

New function parentScrollPositionDidChange() is called on children
when the parent has scrolled.
* page/scrolling/ScrollingTreeNode.h:
(ScrollingTreeNode):
* page/scrolling/ScrollingTreeScrollingNode.h:
(ScrollingTreeScrollingNode):

Return true for supportsFixedPositionLayers().
* page/scrolling/mac/ScrollingCoordinatorMac.h:
(ScrollingCoordinatorMac):

Handle fixed nodes.
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::attachToStateTree):

Now that m_children can be non-null I caught this pre-existing bug
where we would come times remove a node without updating the HashMap.
This patch fixes that by consolidating the removal into one function.
(WebCore::ScrollingCoordinatorMac::removeNode):
(WebCore::ScrollingCoordinatorMac::detachFromStateTree):
(WebCore::ScrollingCoordinatorMac::clearStateTree):

Update the GraphicsLayers to reflect the new position that the
Scrolling thread has moved the underlying CALayer to already.
(WebCore::ScrollingCoordinatorMac::syncChildPositions):

Pass new constraints over to the appropriate state node.
(WebCore::ScrollingCoordinatorMac::updateViewportConstrainedNode):

Cache the GraphicsLayer in addition to the PlatformLayer.
* page/scrolling/mac/ScrollingStateNodeMac.mm:
(WebCore::ScrollingStateNode::setScrollLayer):

Here is the new class that represents fixed nodes over on the
scrolling thread.
* page/scrolling/mac/ScrollingTreeFixedNode.h: Added.
(WebCore):
(ScrollingTreeFixedNode):
* page/scrolling/mac/ScrollingTreeFixedNode.mm: Added.
(WebCore):
(WebCore::ScrollingTreeFixedNode::create):
(WebCore::ScrollingTreeFixedNode::ScrollingTreeFixedNode):
(WebCore::ScrollingTreeFixedNode::~ScrollingTreeFixedNode):
(WebCore::ScrollingTreeFixedNode::update):

This is where the magic happens. re-position the fixed object when
its parent has scrolled so that it appears to have not moved at all.
(WebCore::ScrollingTreeFixedNode::parentScrollPositionDidChange):

Whenever we change the position of a scrolling layer, tell our
children.
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::setScrollLayerPosition):

Handle fixed nodes.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::attachToScrollingCoordinator):

detachFromScrollingCoordinator() needs to be public so that it can be
called from RenderLayerCompositor for fixed nodes.
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):

RenderLayerCompositor takes control of attaching and detaching fixed
nodes to/from the ScrollingCoordinator.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::flushPendingLayerChanges):
(WebCore::RenderLayerCompositor::didFlushChangesForLayer):
(WebCore::RenderLayerCompositor::updateBacking):
(WebCore::RenderLayerCompositor::layerWillBeRemoved):
(WebCore::RenderLayerCompositor::didMoveOnscreen):
(WebCore::RenderLayerCompositor::willMoveOffscreen):
(WebCore::RenderLayerCompositor::clearBackingForLayerIncludingDescendants):
(WebCore::isRootmostFixedOrStickyLayer):
(WebCore):
(WebCore::RenderLayerCompositor::updateViewportConstraintStatus):
(WebCore::RenderLayerCompositor::addViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::removeViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::computeViewportConstraints):
(WebCore::nearestScrollingCoordinatorAncestor):
(WebCore::RenderLayerCompositor::registerOrUpdateViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::unregisterViewportConstrainedLayer):
(WebCore::RenderLayerCompositor::registerAllViewportConstrainedLayers):
(WebCore::RenderLayerCompositor::unregisterAllViewportConstrainedLayers):
* rendering/RenderLayerCompositor.h:
(WebCore):
(RenderLayerCompositor):

LayoutTests:

New tests.
* platform/mac/tiled-drawing/fixed: Added.
* platform/mac/tiled-drawing/fixed/absolute-inside-fixed-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/absolute-inside-fixed.html: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex.html: Added.
* platform/mac/tiled-drawing/fixed/fixed-position-out-of-view.html: Added.
* platform/mac/tiled-drawing/fixed/four-bars-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/four-bars.html: Added.
* platform/mac/tiled-drawing/fixed/nested-fixed-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/nested-fixed.html: Added.
* platform/mac/tiled-drawing/fixed/percentage-inside-fixed-expected.txt: Added.
* platform/mac/tiled-drawing/fixed/percentage-inside-fixed.html: Added.

These two tests are supposed to be in "slow scrolling" mode. Now that
fixed elements can scroll "fast," we need something else to force
slow scrolling. We should probably just add something to
window.internals to do that, but in the meantime,
background-attachment:fixed will work.
* platform/mac/tiled-drawing/scrolling-tree-slow-scrolling-expected.txt:
* platform/mac/tiled-drawing/scrolling-tree-slow-scrolling.html:
* platform/mac/tiled-drawing/tile-coverage-slow-scrolling-expected.txt:
* platform/mac/tiled-drawing/tile-coverage-slow-scrolling.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@133536 268f45cc-cd09-0410-ab3c-d52691b4dbfc
46 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/tiled-drawing/fixed/absolute-inside-fixed-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/absolute-inside-fixed.html [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/fixed-in-overflow-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/fixed-in-overflow.html [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex.html [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/fixed-position-out-of-view.html [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/four-bars-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/four-bars.html [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/nested-fixed-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/nested-fixed.html [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/percentage-inside-fixed-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed/percentage-inside-fixed.html [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/scrolling-tree-slow-scrolling-expected.txt
LayoutTests/platform/mac/tiled-drawing/scrolling-tree-slow-scrolling.html
LayoutTests/platform/mac/tiled-drawing/tile-coverage-slow-scrolling-expected.txt
LayoutTests/platform/mac/tiled-drawing/tile-coverage-slow-scrolling.html
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/page/scrolling/ScrollingConstraints.h
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp [new file with mode: 0644]
Source/WebCore/page/scrolling/ScrollingStateFixedNode.h [new file with mode: 0644]
Source/WebCore/page/scrolling/ScrollingStateNode.cpp
Source/WebCore/page/scrolling/ScrollingStateNode.h
Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/ScrollingTreeNode.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
Source/WebCore/page/scrolling/mac/ScrollingStateNodeMac.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.h [new file with mode: 0644]
Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.mm [new file with mode: 0644]
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h