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)
, m_frameScaleFactor(1)
, m_headerHeight(0)
, m_footerHeight(0)
, m_topContentInset(0)
, m_synchronousScrollingReasons(0)
, m_behaviorForFixed(StickToDocumentBounds)
{
}
ScrollingTreeFrameScrollingNode::~ScrollingTreeFrameScrollingNode()
{
}
void ScrollingTreeFrameScrollingNode::updateBeforeChildren(const ScrollingStateNode& stateNode)
{
ScrollingTreeScrollingNode::updateBeforeChildren(stateNode);
const ScrollingStateFrameScrollingNode& state = toScrollingStateFrameScrollingNode(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();
}
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);
}
}
#endif // ENABLE(ASYNC_SCROLLING)