b99534e166eea9078a2adc384bfa77cc38b454ef
[WebKit-https.git] / Source / WebCore / page / scrolling / ScrollingTreeScrollingNode.cpp
1 /*
2  * Copyright (C) 2012 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #include "ScrollingTreeScrollingNode.h"
28
29 #if ENABLE(THREADED_SCROLLING)
30
31 #include "ScrollingStateTree.h"
32
33 namespace WebCore {
34
35 ScrollingTreeScrollingNode::ScrollingTreeScrollingNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
36     : ScrollingTreeNode(scrollingTree, nodeID)
37     , m_frameScaleFactor(1)
38     , m_shouldUpdateScrollLayerPositionOnMainThread(0)
39     , m_horizontalScrollElasticity(ScrollElasticityNone)
40     , m_verticalScrollElasticity(ScrollElasticityNone)
41     , m_hasEnabledHorizontalScrollbar(false)
42     , m_hasEnabledVerticalScrollbar(false)
43     , m_horizontalScrollbarMode(ScrollbarAuto)
44     , m_verticalScrollbarMode(ScrollbarAuto)
45     , m_headerHeight(0)
46     , m_footerHeight(0)
47 {
48 }
49
50 ScrollingTreeScrollingNode::~ScrollingTreeScrollingNode()
51 {
52 }
53
54 void ScrollingTreeScrollingNode::updateBeforeChildren(ScrollingStateNode* stateNode)
55 {
56     ScrollingStateScrollingNode* state = toScrollingStateScrollingNode(stateNode);
57
58     if (state->hasChangedProperty(ScrollingStateScrollingNode::ViewportRect))
59         m_viewportRect = state->viewportRect();
60
61     if (state->hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize))
62         m_totalContentsSize = state->totalContentsSize();
63
64     if (state->hasChangedProperty(ScrollingStateScrollingNode::FrameScaleFactor))
65         m_frameScaleFactor = state->frameScaleFactor();
66
67     if (state->hasChangedProperty(ScrollingStateScrollingNode::ShouldUpdateScrollLayerPositionOnMainThread))
68         m_shouldUpdateScrollLayerPositionOnMainThread = state->shouldUpdateScrollLayerPositionOnMainThread();
69
70     if (state->hasChangedProperty(ScrollingStateScrollingNode::HorizontalScrollElasticity))
71         m_horizontalScrollElasticity = state->horizontalScrollElasticity();
72
73     if (state->hasChangedProperty(ScrollingStateScrollingNode::VerticalScrollElasticity))
74         m_verticalScrollElasticity = state->verticalScrollElasticity();
75
76     if (state->hasChangedProperty(ScrollingStateScrollingNode::HasEnabledHorizontalScrollbar))
77         m_hasEnabledHorizontalScrollbar = state->hasEnabledHorizontalScrollbar();
78
79     if (state->hasChangedProperty(ScrollingStateScrollingNode::HasEnabledVerticalScrollbar))
80         m_hasEnabledVerticalScrollbar = state->hasEnabledVerticalScrollbar();
81
82     if (state->hasChangedProperty(ScrollingStateScrollingNode::HorizontalScrollbarMode))
83         m_horizontalScrollbarMode = state->horizontalScrollbarMode();
84
85     if (state->hasChangedProperty(ScrollingStateScrollingNode::VerticalScrollbarMode))
86         m_verticalScrollbarMode = state->verticalScrollbarMode();
87
88     if (state->hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin))
89         m_scrollOrigin = state->scrollOrigin();
90
91     if (state->hasChangedProperty(ScrollingStateScrollingNode::HeaderHeight))
92         m_headerHeight = state->headerHeight();
93
94     if (state->hasChangedProperty(ScrollingStateScrollingNode::FooterHeight))
95         m_footerHeight = state->footerHeight();
96 }
97
98 } // namespace WebCore
99
100 #endif // ENABLE(THREADED_SCROLLING)