ScrollingTreeFrameScrollingNode.cpp [plain text]
#include "config.h"
#include "ScrollingTreeFrameScrollingNode.h"
#if ENABLE(ASYNC_SCROLLING)
#include "ScrollingStateTree.h"
#include "ScrollingTree.h"
namespace WebCore {
ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
: ScrollingTreeScrollingNode(scrollingTree, FrameScrollingNode, nodeID)
{
}
ScrollingTreeFrameScrollingNode::~ScrollingTreeFrameScrollingNode()
{
}
void ScrollingTreeFrameScrollingNode::updateBeforeChildren(const ScrollingStateNode& stateNode)
{
ScrollingTreeScrollingNode::updateBeforeChildren(stateNode);
const ScrollingStateFrameScrollingNode& state = downcast<ScrollingStateFrameScrollingNode>(stateNode);
if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::FrameScaleFactor))
m_frameScaleFactor = state.frameScaleFactor();
if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling))
m_synchronousScrollingReasons = state.synchronousScrollingReasons();
if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderHeight))
m_headerHeight = state.headerHeight();
if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterHeight))
m_footerHeight = state.footerHeight();
if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::BehaviorForFixedElements))
m_behaviorForFixed = state.scrollBehaviorForFixedElements();
if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::TopContentInset))
m_topContentInset = state.topContentInset();
if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::FixedElementsLayoutRelativeToFrame))
m_fixedElementsLayoutRelativeToFrame = state.fixedElementsLayoutRelativeToFrame();
}
void ScrollingTreeFrameScrollingNode::scrollBy(const FloatSize& offset)
{
setScrollPosition(scrollPosition() + offset);
}
void ScrollingTreeFrameScrollingNode::scrollByWithoutContentEdgeConstraints(const FloatSize& offset)
{
setScrollPositionWithoutContentEdgeConstraints(scrollPosition() + offset);
}
void ScrollingTreeFrameScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
{
FloatPoint newScrollPosition = scrollPosition;
newScrollPosition = newScrollPosition.shrunkTo(maximumScrollPosition());
newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
}
FloatSize ScrollingTreeFrameScrollingNode::viewToContentsOffset(const FloatPoint& scrollOffset) const
{
return toFloatSize(scrollOffset) - FloatSize(0, headerHeight() + topContentInset());
}
}
#endif // ENABLE(ASYNC_SCROLLING)