OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 25 matching lines...) Expand all Loading... | |
36 #include "platform/scroll/ScrollbarTheme.h" | 36 #include "platform/scroll/ScrollbarTheme.h" |
37 | 37 |
38 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN)) | 38 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN)) |
39 // The position of the scrollbar thumb affects the appearance of the steppers, s o | 39 // The position of the scrollbar thumb affects the appearance of the steppers, s o |
40 // when the thumb moves, we have to invalidate them for painting. | 40 // when the thumb moves, we have to invalidate them for painting. |
41 #define THUMB_POSITION_AFFECTS_BUTTONS | 41 #define THUMB_POSITION_AFFECTS_BUTTONS |
42 #endif | 42 #endif |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 PassRefPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, Scrollba rOrientation orientation, ScrollbarControlSize size) | 46 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr ea, ScrollbarOrientation orientation, ScrollbarControlSize size) |
47 { | 47 { |
48 return adoptRef(new Scrollbar(scrollableArea, orientation, size)); | 48 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size)); |
49 } | 49 } |
50 | 50 |
51 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient ation, ScrollbarControlSize controlSize, ScrollbarTheme* theme) | 51 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient ation, ScrollbarControlSize controlSize, ScrollbarTheme* theme) |
52 : m_scrollableArea(scrollableArea) | 52 : m_scrollableArea(scrollableArea) |
53 , m_orientation(orientation) | 53 , m_orientation(orientation) |
54 , m_controlSize(controlSize) | 54 , m_controlSize(controlSize) |
55 , m_theme(theme) | 55 , m_theme(theme) |
56 , m_visibleSize(0) | 56 , m_visibleSize(0) |
57 , m_totalSize(0) | 57 , m_totalSize(0) |
58 , m_currentPos(0) | 58 , m_currentPos(0) |
(...skipping 15 matching lines...) Expand all Loading... | |
74 | 74 |
75 m_theme->registerScrollbar(this); | 75 m_theme->registerScrollbar(this); |
76 | 76 |
77 // FIXME: This is ugly and would not be necessary if we fix cross-platform c ode to actually query for | 77 // FIXME: This is ugly and would not be necessary if we fix cross-platform c ode to actually query for |
78 // scrollbar thickness and use it when sizing scrollbars (rather than leavin g one dimension of the scrollbar | 78 // scrollbar thickness and use it when sizing scrollbars (rather than leavin g one dimension of the scrollbar |
79 // alone when sizing). | 79 // alone when sizing). |
80 int thickness = m_theme->scrollbarThickness(controlSize); | 80 int thickness = m_theme->scrollbarThickness(controlSize); |
81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); | 81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); |
82 | 82 |
83 m_currentPos = scrollableAreaCurrentPos(); | 83 m_currentPos = scrollableAreaCurrentPos(); |
84 | |
85 #if ENABLE(OILPAN) | |
86 if (m_scrollableArea) | |
87 m_animator = m_scrollableArea->scrollAnimator(); | |
88 #endif | |
84 } | 89 } |
85 | 90 |
86 Scrollbar::~Scrollbar() | 91 Scrollbar::~Scrollbar() |
87 { | 92 { |
88 stopTimerIfNeeded(); | 93 stopTimerIfNeeded(); |
89 | 94 |
90 m_theme->unregisterScrollbar(this); | 95 m_theme->unregisterScrollbar(this); |
96 | |
97 #if ENABLE(OILPAN) | |
98 if (!m_animator) | |
99 return; | |
100 | |
haraken
2014/09/26 09:19:25
Shall we add ASSERT(m_scrollableArea) ?
sof
2014/09/28 21:11:25
Sure, why not.
| |
101 if (m_orientation == VerticalScrollbar) | |
102 m_animator->willRemoveVerticalScrollbar(this); | |
103 else | |
104 m_animator->willRemoveHorizontalScrollbar(this); | |
105 #endif | |
91 } | 106 } |
92 | 107 |
93 void Scrollbar::removeFromParent() | 108 void Scrollbar::removeFromParent() |
94 { | 109 { |
95 if (parent()) | 110 if (parent()) |
96 toScrollView(parent())->removeChild(this); | 111 toScrollView(parent())->removeChild(this); |
97 } | 112 } |
98 | 113 |
99 ScrollView* Scrollbar::parentScrollView() const | 114 ScrollView* Scrollbar::parentScrollView() const |
100 { | 115 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 if (position == m_currentPos) | 152 if (position == m_currentPos) |
138 return; | 153 return; |
139 | 154 |
140 int oldThumbPosition = theme()->thumbPosition(this); | 155 int oldThumbPosition = theme()->thumbPosition(this); |
141 m_currentPos = position; | 156 m_currentPos = position; |
142 updateThumbPosition(); | 157 updateThumbPosition(); |
143 if (m_pressedPart == ThumbPart) | 158 if (m_pressedPart == ThumbPart) |
144 setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPosi tion); | 159 setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPosi tion); |
145 } | 160 } |
146 | 161 |
162 void Scrollbar::disconnectFromScrollableArea() | |
163 { | |
164 m_scrollableArea = nullptr; | |
165 #if ENABLE(OILPAN) | |
166 m_animator = nullptr; | |
167 #endif | |
168 } | |
169 | |
147 void Scrollbar::setProportion(int visibleSize, int totalSize) | 170 void Scrollbar::setProportion(int visibleSize, int totalSize) |
148 { | 171 { |
149 if (visibleSize == m_visibleSize && totalSize == m_totalSize) | 172 if (visibleSize == m_visibleSize && totalSize == m_totalSize) |
150 return; | 173 return; |
151 | 174 |
152 m_visibleSize = visibleSize; | 175 m_visibleSize = visibleSize; |
153 m_totalSize = totalSize; | 176 m_totalSize = totalSize; |
154 | 177 |
155 updateThumbProportion(); | 178 updateThumbProportion(); |
156 } | 179 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 if (!m_scrollableArea) | 608 if (!m_scrollableArea) |
586 return 0; | 609 return 0; |
587 | 610 |
588 if (m_orientation == HorizontalScrollbar) | 611 if (m_orientation == HorizontalScrollbar) |
589 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x(); | 612 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x(); |
590 | 613 |
591 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y(); | 614 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y(); |
592 } | 615 } |
593 | 616 |
594 } // namespace blink | 617 } // namespace blink |
OLD | NEW |