Skip to content

Commit

Permalink
AsyncScrolling: add ScrollingTreePositionedNode base class
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246453

Reviewed by Žan Doberšek.

Make Cocoa and Nicosia implementations inherit from the base class and move the common code there.

* Source/WebCore/Sources.txt:
* Source/WebCore/SourcesCocoa.txt:
* Source/WebCore/SourcesGTK.txt:
* Source/WebCore/SourcesWPE.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/page/scrolling/ScrollingTreePositionedNode.cpp: Renamed from Source/WebCore/page/scrolling/cocoa/ScrollingTreePositionedNode.mm.
(WebCore::ScrollingTreePositionedNode::commitStateBeforeChildren):
(WebCore::ScrollingTreePositionedNode::scrollDeltaSinceLastCommit const):
* Source/WebCore/page/scrolling/ScrollingTreePositionedNode.h: Copied from Source/WebCore/page/scrolling/cocoa/ScrollingTreePositionedNode.h.
* Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm:
(WebCore::ScrollingTreeFixedNode::applyLayerPositions):
* Source/WebCore/page/scrolling/cocoa/ScrollingTreePositionedNodeCocoa.h: Renamed from Source/WebCore/page/scrolling/cocoa/ScrollingTreePositionedNode.h.
(WebCore::ScrollingTreePositionedNodeCocoa::layer const):
* Source/WebCore/page/scrolling/cocoa/ScrollingTreePositionedNodeCocoa.mm: Added.
(WebCore::ScrollingTreePositionedNodeCocoa::create):
(WebCore::ScrollingTreePositionedNodeCocoa::ScrollingTreePositionedNodeCocoa):
(WebCore::ScrollingTreePositionedNodeCocoa::commitStateBeforeChildren):
(WebCore::ScrollingTreePositionedNodeCocoa::applyLayerPositions):
* Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm:
(ScrollingTreeMac::createScrollingTreeNode):
* Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp:
(WebCore::ScrollingTreeFixedNode::applyLayerPositions):
* Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp:
(WebCore::ScrollingTreeNicosia::createScrollingTreeNode):
* Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNodeNicosia.cpp: Renamed from Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.cpp.
(WebCore::ScrollingTreePositionedNodeNicosia::create):
(WebCore::ScrollingTreePositionedNodeNicosia::ScrollingTreePositionedNodeNicosia):
(WebCore::ScrollingTreePositionedNodeNicosia::commitStateBeforeChildren):
(WebCore::ScrollingTreePositionedNodeNicosia::applyLayerPositions):
* Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNodeNicosia.h: Renamed from Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.h.
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
(WebKit::RemoteScrollingTree::createScrollingTreeNode):

Canonical link: https://commits.webkit.org/255724@main
  • Loading branch information
carlosgcampos committed Oct 19, 2022
1 parent 2fe2393 commit 8df9660
Show file tree
Hide file tree
Showing 18 changed files with 188 additions and 130 deletions.
1 change: 1 addition & 0 deletions Source/WebCore/Sources.txt
Expand Up @@ -1918,6 +1918,7 @@ page/scrolling/ScrollingTreeGestureState.cpp
page/scrolling/ScrollingTreeLatchingController.cpp
page/scrolling/ScrollingTreeNode.cpp
page/scrolling/ScrollingTreeOverflowScrollingNode.cpp
page/scrolling/ScrollingTreePositionedNode.cpp
page/scrolling/ScrollingTreeScrollingNode.cpp
page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp
page/scrolling/ScrollingTreeStickyNode.cpp
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/SourcesCocoa.txt
Expand Up @@ -230,7 +230,7 @@ page/mac/WheelEventDeltaFilterMac.mm
page/scrolling/cocoa/ScrollingStateNode.mm
page/scrolling/cocoa/ScrollingTreeFixedNode.mm
page/scrolling/cocoa/ScrollingTreeOverflowScrollProxyNode.mm
page/scrolling/cocoa/ScrollingTreePositionedNode.mm
page/scrolling/cocoa/ScrollingTreePositionedNodeCocoa.mm
page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm
page/scrolling/mac/ScrollingCoordinatorMac.mm
page/scrolling/mac/ScrollingStateScrollingNodeMac.mm
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/SourcesGTK.txt
Expand Up @@ -57,7 +57,7 @@ page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreeNicosia.cpp
page/scrolling/nicosia/ScrollingTreeOverflowScrollProxyNode.cpp
page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreePositionedNode.cpp
page/scrolling/nicosia/ScrollingTreePositionedNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp
page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/SourcesWPE.txt
Expand Up @@ -53,7 +53,7 @@ page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreeNicosia.cpp
page/scrolling/nicosia/ScrollingTreeOverflowScrollProxyNode.cpp
page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreePositionedNode.cpp
page/scrolling/nicosia/ScrollingTreePositionedNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp
page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp

Expand Down
18 changes: 12 additions & 6 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Expand Up @@ -344,7 +344,6 @@
0F94B6472208FE3600157014 /* ScrollingTreeFixedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6422208F70100157014 /* ScrollingTreeFixedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F94B6492208FE3B00157014 /* ScrollingTreeStickyNodeCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6432208F70200157014 /* ScrollingTreeStickyNodeCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F94B6522209150600157014 /* ScrollingStatePositionedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B651220914FF00157014 /* ScrollingStatePositionedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F94B655220931E400157014 /* ScrollingTreePositionedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F94F37E23661626003AA5C7 /* StyleRuleType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94F37C23661131003AA5C7 /* StyleRuleType.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F98C8F8286AA8FE00C7F4B2 /* ProcessCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F98C8F6286AA8FA00C7F4B2 /* ProcessCapabilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F99059A26F6BE850054FBE0 /* ScrollingMomentumCalculator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F99059926F6BE7F0054FBE0 /* ScrollingMomentumCalculator.h */; };
Expand Down Expand Up @@ -2524,6 +2523,8 @@
7A6D3C8028A4053D00C5C6EC /* NotificationResources.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A6D3C7F28A4053D00C5C6EC /* NotificationResources.h */; settings = {ATTRIBUTES = (Private, ); }; };
7A6D3C8428A4056400C5C6EC /* NotificationResourcesLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A6D3C8328A4056300C5C6EC /* NotificationResourcesLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
7A7C8B5827F32EF70008E234 /* ComputedStylePropertyMapReadOnly.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A7C8B5727F32E7D0008E234 /* ComputedStylePropertyMapReadOnly.h */; };
7A81DB9928F82C8000F66898 /* ScrollingTreePositionedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A81DB9828F82C5E00F66898 /* ScrollingTreePositionedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
7A81DB9C28F82CDA00F66898 /* ScrollingTreePositionedNodeCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A81DB9A28F82CA800F66898 /* ScrollingTreePositionedNodeCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
7A8DCBA228DC5EA0003AB8F6 /* ThreadedScrollingCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A8DCBA128DC5E8B003AB8F6 /* ThreadedScrollingCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
7A929CA71C598AA9004DF226 /* ResourceLoadStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A929CA21C598378004DF226 /* ResourceLoadStatistics.h */; settings = {ATTRIBUTES = (Private, ); }; };
7A93868618DCC14500B8263D /* VTTScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A93868318DCC14500B8263D /* VTTScanner.h */; };
Expand Down Expand Up @@ -6625,8 +6626,6 @@
0F94B6452208F70300157014 /* ScrollingTreeStickyNodeCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeStickyNodeCocoa.mm; sourceTree = "<group>"; };
0F94B64F220914FE00157014 /* ScrollingStatePositionedNode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingStatePositionedNode.cpp; sourceTree = "<group>"; };
0F94B651220914FF00157014 /* ScrollingStatePositionedNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingStatePositionedNode.h; sourceTree = "<group>"; };
0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingTreePositionedNode.h; sourceTree = "<group>"; };
0F94B6542209156C00157014 /* ScrollingTreePositionedNode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreePositionedNode.mm; sourceTree = "<group>"; };
0F94F37C23661131003AA5C7 /* StyleRuleType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StyleRuleType.h; sourceTree = "<group>"; };
0F9510F024F4769C001F52DC /* ScrollLatchingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollLatchingController.h; sourceTree = "<group>"; };
0F9510F224F4769C001F52DC /* ScrollLatchingController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollLatchingController.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -11960,6 +11959,10 @@
7A7C8B5427F32D2B0008E234 /* Element+ComputedStyleMap.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = "Element+ComputedStyleMap.idl"; sourceTree = "<group>"; };
7A7C8B5627F32E690008E234 /* ComputedStylePropertyMapReadOnly.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ComputedStylePropertyMapReadOnly.cpp; sourceTree = "<group>"; };
7A7C8B5727F32E7D0008E234 /* ComputedStylePropertyMapReadOnly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ComputedStylePropertyMapReadOnly.h; sourceTree = "<group>"; };
7A81DB9728F82C4800F66898 /* ScrollingTreePositionedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreePositionedNode.cpp; sourceTree = "<group>"; };
7A81DB9828F82C5E00F66898 /* ScrollingTreePositionedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreePositionedNode.h; sourceTree = "<group>"; };
7A81DB9A28F82CA800F66898 /* ScrollingTreePositionedNodeCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreePositionedNodeCocoa.h; sourceTree = "<group>"; };
7A81DB9B28F82CC400F66898 /* ScrollingTreePositionedNodeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreePositionedNodeCocoa.mm; sourceTree = "<group>"; };
7A8DCBA028DC5E7C003AB8F6 /* ThreadedScrollingCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadedScrollingCoordinator.cpp; sourceTree = "<group>"; };
7A8DCBA128DC5E8B003AB8F6 /* ThreadedScrollingCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadedScrollingCoordinator.h; sourceTree = "<group>"; };
7A929CA11C598378004DF226 /* ResourceLoadStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatistics.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -20587,6 +20590,8 @@
1AAADDE214DC8C8F00AF64B3 /* ScrollingTreeNode.h */,
0FEA3E7D191B3169000F1B55 /* ScrollingTreeOverflowScrollingNode.cpp */,
0FEA3E7E191B3169000F1B55 /* ScrollingTreeOverflowScrollingNode.h */,
7A81DB9728F82C4800F66898 /* ScrollingTreePositionedNode.cpp */,
7A81DB9828F82C5E00F66898 /* ScrollingTreePositionedNode.h */,
9391A99A1629D6FF00297330 /* ScrollingTreeScrollingNode.cpp */,
9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */,
A6D5A99A1629D6FF00297330 /* ScrollingTreeScrollingNodeDelegate.cpp */,
Expand Down Expand Up @@ -26886,8 +26891,8 @@
0F94B6442208F70200157014 /* ScrollingTreeFixedNode.mm */,
0FC4B00422B9A02C00CF3B1E /* ScrollingTreeOverflowScrollProxyNode.h */,
0FC4B00522B9A02D00CF3B1E /* ScrollingTreeOverflowScrollProxyNode.mm */,
0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */,
0F94B6542209156C00157014 /* ScrollingTreePositionedNode.mm */,
7A81DB9A28F82CA800F66898 /* ScrollingTreePositionedNodeCocoa.h */,
7A81DB9B28F82CC400F66898 /* ScrollingTreePositionedNodeCocoa.mm */,
0F94B6432208F70200157014 /* ScrollingTreeStickyNodeCocoa.h */,
0F94B6452208F70300157014 /* ScrollingTreeStickyNodeCocoa.mm */,
);
Expand Down Expand Up @@ -38351,7 +38356,8 @@
0FEA3E80191B3169000F1B55 /* ScrollingTreeOverflowScrollingNode.h in Headers */,
0F73B769222B3A0C00805316 /* ScrollingTreeOverflowScrollingNodeMac.h in Headers */,
0FC4B00622B9A02D00CF3B1E /* ScrollingTreeOverflowScrollProxyNode.h in Headers */,
0F94B655220931E400157014 /* ScrollingTreePositionedNode.h in Headers */,
7A81DB9928F82C8000F66898 /* ScrollingTreePositionedNode.h in Headers */,
7A81DB9C28F82CDA00F66898 /* ScrollingTreePositionedNodeCocoa.h in Headers */,
9391A99D1629D70000297330 /* ScrollingTreeScrollingNode.h in Headers */,
A6D5A99D1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h in Headers */,
0F37F0852202BF9800A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h in Headers */,
Expand Down
6 changes: 6 additions & 0 deletions Source/WebCore/page/scrolling/ScrollingTreeNode.h
Expand Up @@ -53,6 +53,12 @@ class ScrollingTreeNode : public ThreadSafeRefCounted<ScrollingTreeNode> {
bool isFixedNode() const { return nodeType() == ScrollingNodeType::Fixed; }
bool isStickyNode() const { return nodeType() == ScrollingNodeType::Sticky; }
bool isPositionedNode() const { return nodeType() == ScrollingNodeType::Positioned; }
#if PLATFORM(COCOA)
bool isPositionedNodeCocoa() const { return isPositionedNode(); }
#endif
#if USE(NICOSIA)
bool isPositionedNodeNicosia() const { return isPositionedNode(); }
#endif
bool isScrollingNode() const { return isFrameScrollingNode() || isOverflowScrollingNode(); }
bool isFrameScrollingNode() const { return nodeType() == ScrollingNodeType::MainFrame || nodeType() == ScrollingNodeType::Subframe; }
bool isFrameHostingNode() const { return nodeType() == ScrollingNodeType::FrameHosting; }
Expand Down
Expand Up @@ -23,26 +23,20 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "ScrollingTreePositionedNode.h"
#include "config.h"
#include "ScrollingTreePositionedNode.h"

#if ENABLE(ASYNC_SCROLLING)

#import "Logging.h"
#import "ScrollingStatePositionedNode.h"
#import "ScrollingTree.h"
#import "ScrollingTreeOverflowScrollingNode.h"
#import "ScrollingTreeScrollingNode.h"
#import "WebCoreCALayerExtras.h"
#import <wtf/text/TextStream.h>
#include "Logging.h"
#include "ScrollingStatePositionedNode.h"
#include "ScrollingTree.h"
#include "ScrollingTreeOverflowScrollingNode.h"
#include "ScrollingTreeScrollingNode.h"
#include <wtf/text/TextStream.h>

namespace WebCore {

Ref<ScrollingTreePositionedNode> ScrollingTreePositionedNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
{
return adoptRef(*new ScrollingTreePositionedNode(scrollingTree, nodeID));
}

ScrollingTreePositionedNode::ScrollingTreePositionedNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
: ScrollingTreeNode(scrollingTree, ScrollingNodeType::Positioned, nodeID)
{
Expand All @@ -54,9 +48,6 @@
{
const ScrollingStatePositionedNode& positionedStateNode = downcast<ScrollingStatePositionedNode>(stateNode);

if (positionedStateNode.hasChangedProperty(ScrollingStateNode::Property::Layer))
m_layer = static_cast<CALayer*>(positionedStateNode.layer());

if (positionedStateNode.hasChangedProperty(ScrollingStateNode::Property::RelatedOverflowScrollingNodes))
m_relatedOverflowScrollingNodes = positionedStateNode.relatedOverflowScrollingNodes();

Expand All @@ -78,21 +69,11 @@
}
}
}

// Positioned nodes compensate for scrolling, so negate the scroll delta.
return -delta;
}

void ScrollingTreePositionedNode::applyLayerPositions()
{
auto delta = scrollDeltaSinceLastCommit();
auto layerPosition = m_constraints.layerPositionAtLastLayout() - delta;

LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreePositionedNode " << scrollingNodeID() << " applyLayerPositions: overflow delta " << delta << " moving layer to " << layerPosition);

[m_layer _web_setLayerTopLeftPosition:layerPosition - m_constraints.alignmentOffset()];
}

void ScrollingTreePositionedNode::dumpProperties(TextStream& ts, OptionSet<ScrollingStateTreeAsTextBehavior> behavior) const
{
ts << "positioned node";
Expand Down
Expand Up @@ -29,36 +29,26 @@

#include "ScrollingConstraints.h"
#include "ScrollingTreeNode.h"
#include <wtf/RetainPtr.h>

OBJC_CLASS CALayer;

namespace WebCore {

class ScrollingTreePositionedNode : public ScrollingTreeNode {
public:
WEBCORE_EXPORT static Ref<ScrollingTreePositionedNode> create(ScrollingTree&, ScrollingNodeID);

virtual ~ScrollingTreePositionedNode();

CALayer *layer() const { return m_layer.get(); }

const Vector<ScrollingNodeID>& relatedOverflowScrollingNodes() const { return m_relatedOverflowScrollingNodes; }

FloatSize scrollDeltaSinceLastCommit() const;

private:
protected:
ScrollingTreePositionedNode(ScrollingTree&, ScrollingNodeID);

void commitStateBeforeChildren(const ScrollingStateNode&) override;

void applyLayerPositions() override;

WEBCORE_EXPORT void dumpProperties(WTF::TextStream&, OptionSet<ScrollingStateTreeAsTextBehavior>) const override;

Vector<ScrollingNodeID> m_relatedOverflowScrollingNodes;
AbsolutePositionConstraints m_constraints;
RetainPtr<CALayer> m_layer;
};

} // namespace WebCore
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm
Expand Up @@ -35,7 +35,7 @@
#import "ScrollingTreeFrameScrollingNode.h"
#import "ScrollingTreeOverflowScrollProxyNode.h"
#import "ScrollingTreeOverflowScrollingNode.h"
#import "ScrollingTreePositionedNode.h"
#import "ScrollingTreePositionedNodeCocoa.h"
#import "ScrollingTreeStickyNodeCocoa.h"
#import "WebCoreCALayerExtras.h"
#import <wtf/text/TextStream.h>
Expand Down Expand Up @@ -97,7 +97,7 @@
}

if (is<ScrollingTreePositionedNode>(*ancestor)) {
auto& positioningAncestor = downcast<ScrollingTreePositionedNode>(*ancestor);
auto& positioningAncestor = downcast<ScrollingTreePositionedNodeCocoa>(*ancestor);
// See if sticky node already handled this positioning node.
// FIXME: Include positioning node information to sticky/fixed node to avoid these tests.
if (lastStickyNode && lastStickyNode->layer() == positioningAncestor.layer())
Expand Down
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#if ENABLE(ASYNC_SCROLLING)

#include "ScrollingTreePositionedNode.h"
#include <wtf/RetainPtr.h>

OBJC_CLASS CALayer;

namespace WebCore {

class ScrollingTreePositionedNodeCocoa : public ScrollingTreePositionedNode {
public:
WEBCORE_EXPORT static Ref<ScrollingTreePositionedNodeCocoa> create(ScrollingTree&, ScrollingNodeID);

virtual ~ScrollingTreePositionedNodeCocoa();

CALayer *layer() const { return m_layer.get(); }

private:
ScrollingTreePositionedNodeCocoa(ScrollingTree&, ScrollingNodeID);

void commitStateBeforeChildren(const ScrollingStateNode&) override;

void applyLayerPositions() override;

RetainPtr<CALayer> m_layer;
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreePositionedNodeCocoa, isPositionedNodeCocoa())

#endif // ENABLE(ASYNC_SCROLLING)

0 comments on commit 8df9660

Please sign in to comment.