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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return m_scrollableArea && m_scrollableArea->isActive(); | 119 return m_scrollableArea && m_scrollableArea->isActive(); |
120 } | 120 } |
121 | 121 |
122 bool Scrollbar::isLeftSideVerticalScrollbar() const | 122 bool Scrollbar::isLeftSideVerticalScrollbar() const |
123 { | 123 { |
124 if (m_orientation == VerticalScrollbar && m_scrollableArea) | 124 if (m_orientation == VerticalScrollbar && m_scrollableArea) |
125 return m_scrollableArea->shouldPlaceVerticalScrollbarOnLeft(); | 125 return m_scrollableArea->shouldPlaceVerticalScrollbarOnLeft(); |
126 return false; | 126 return false; |
127 } | 127 } |
128 | 128 |
129 bool Scrollbar::offsetDidChange() | 129 void Scrollbar::offsetDidChange() |
130 { | 130 { |
131 ASSERT(m_scrollableArea); | 131 ASSERT(m_scrollableArea); |
132 | 132 |
133 float position = scrollableAreaCurrentPos(); | 133 float position = scrollableAreaCurrentPos(); |
134 if (position == m_currentPos) | 134 if (position == m_currentPos) |
135 return false; | 135 return; |
136 | 136 |
137 float oldPosition = m_currentPos; | |
138 int oldThumbPosition = theme().thumbPosition(*this); | 137 int oldThumbPosition = theme().thumbPosition(*this); |
139 m_currentPos = position; | 138 m_currentPos = position; |
140 | 139 updateThumbPosition(); |
141 ScrollbarPart invalidParts = theme().invalidateOnThumbPositionChange( | |
142 *this, oldPosition, position); | |
143 if (invalidParts != NoPart) | |
144 setNeedsPaintInvalidation(invalidParts); | |
145 | |
146 if (m_pressedPart == ThumbPart) | 140 if (m_pressedPart == ThumbPart) |
147 setPressedPos(m_pressedPos + theme().thumbPosition(*this) - oldThumbPosi
tion); | 141 setPressedPos(m_pressedPos + theme().thumbPosition(*this) - oldThumbPosi
tion); |
148 | |
149 return true; | |
150 } | 142 } |
151 | 143 |
152 void Scrollbar::disconnectFromScrollableArea() | 144 void Scrollbar::disconnectFromScrollableArea() |
153 { | 145 { |
154 m_scrollableArea = nullptr; | 146 m_scrollableArea = nullptr; |
155 } | 147 } |
156 | 148 |
157 void Scrollbar::setProportion(int visibleSize, int totalSize) | 149 void Scrollbar::setProportion(int visibleSize, int totalSize) |
158 { | 150 { |
159 if (visibleSize == m_visibleSize && totalSize == m_totalSize) | 151 if (visibleSize == m_visibleSize && totalSize == m_totalSize) |
160 return; | 152 return; |
161 | 153 |
162 m_visibleSize = visibleSize; | 154 m_visibleSize = visibleSize; |
163 m_totalSize = totalSize; | 155 m_totalSize = totalSize; |
164 | 156 |
| 157 updateThumbProportion(); |
| 158 } |
| 159 |
| 160 void Scrollbar::updateThumb() |
| 161 { |
165 setNeedsPaintInvalidation(); | 162 setNeedsPaintInvalidation(); |
166 } | 163 } |
167 | 164 |
| 165 void Scrollbar::updateThumbPosition() |
| 166 { |
| 167 updateThumb(); |
| 168 } |
| 169 |
| 170 void Scrollbar::updateThumbProportion() |
| 171 { |
| 172 updateThumb(); |
| 173 } |
| 174 |
168 void Scrollbar::paint(GraphicsContext& context, const CullRect& cullRect) const | 175 void Scrollbar::paint(GraphicsContext& context, const CullRect& cullRect) const |
169 { | 176 { |
170 if (!cullRect.intersectsCullRect(frameRect())) | 177 if (!cullRect.intersectsCullRect(frameRect())) |
171 return; | 178 return; |
172 | 179 |
173 if (!theme().paint(*this, context, cullRect)) | 180 if (!theme().paint(*this, context, cullRect)) |
174 Widget::paint(context, cullRect); | 181 Widget::paint(context, cullRect); |
175 } | 182 } |
176 | 183 |
177 void Scrollbar::autoscrollTimerFired(Timer<Scrollbar>*) | 184 void Scrollbar::autoscrollTimerFired(Timer<Scrollbar>*) |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 310 } |
304 | 311 |
305 void Scrollbar::setHoveredPart(ScrollbarPart part) | 312 void Scrollbar::setHoveredPart(ScrollbarPart part) |
306 { | 313 { |
307 if (part == m_hoveredPart) | 314 if (part == m_hoveredPart) |
308 return; | 315 return; |
309 | 316 |
310 if (((m_hoveredPart == NoPart || part == NoPart) && theme().invalidateOnMous
eEnterExit()) | 317 if (((m_hoveredPart == NoPart || part == NoPart) && theme().invalidateOnMous
eEnterExit()) |
311 // When there's a pressed part, we don't draw a hovered state, so there'
s no reason to invalidate. | 318 // When there's a pressed part, we don't draw a hovered state, so there'
s no reason to invalidate. |
312 || m_pressedPart == NoPart) | 319 || m_pressedPart == NoPart) |
313 setNeedsPaintInvalidation(static_cast<ScrollbarPart>(m_hoveredPart | par
t)); | 320 setNeedsPaintInvalidation(); |
314 | 321 |
315 m_hoveredPart = part; | 322 m_hoveredPart = part; |
316 } | 323 } |
317 | 324 |
318 void Scrollbar::setPressedPart(ScrollbarPart part) | 325 void Scrollbar::setPressedPart(ScrollbarPart part) |
319 { | 326 { |
320 if (m_pressedPart != NoPart | 327 if (m_pressedPart != NoPart |
321 // When we no longer have a pressed part, we can start drawing a hovered
state on the hovered part. | 328 // When we no longer have a pressed part, we can start drawing a hovered
state on the hovered part. |
322 || m_hoveredPart != NoPart) | 329 || m_hoveredPart != NoPart) |
323 setNeedsPaintInvalidation(static_cast<ScrollbarPart>(m_pressedPart | m_h
overedPart | part)); | 330 setNeedsPaintInvalidation(); |
324 m_pressedPart = part; | 331 m_pressedPart = part; |
325 } | 332 } |
326 | 333 |
327 bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt) | 334 bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt) |
328 { | 335 { |
329 switch (evt.type()) { | 336 switch (evt.type()) { |
330 case PlatformEvent::GestureTapDown: | 337 case PlatformEvent::GestureTapDown: |
331 setPressedPart(theme().hitTest(*this, evt.position())); | 338 setPressedPart(theme().hitTest(*this, evt.position())); |
332 m_pressedPos = orientation() == HorizontalScrollbar ? convertFromRootFra
me(evt.position()).x() : convertFromRootFrame(evt.position()).y(); | 339 m_pressedPos = orientation() == HorizontalScrollbar ? convertFromRootFra
me(evt.position()).x() : convertFromRootFrame(evt.position()).y(); |
333 return true; | 340 return true; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 { | 555 { |
549 if (!m_scrollableArea) | 556 if (!m_scrollableArea) |
550 return 0; | 557 return 0; |
551 | 558 |
552 if (m_orientation == HorizontalScrollbar) | 559 if (m_orientation == HorizontalScrollbar) |
553 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu
mScrollPosition().x(); | 560 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu
mScrollPosition().x(); |
554 | 561 |
555 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr
ollPosition().y(); | 562 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr
ollPosition().y(); |
556 } | 563 } |
557 | 564 |
558 void Scrollbar::setNeedsPaintInvalidation(ScrollbarPart parts) | 565 void Scrollbar::setNeedsPaintInvalidation() |
559 { | 566 { |
560 if (m_theme.shouldRepaintAllPartsOnInvalidation()) | 567 if (m_theme.shouldRepaintAllPartsOnInvalidation()) { |
561 parts = AllParts; | |
562 if (parts & ~ThumbPart) | |
563 m_trackNeedsRepaint = true; | 568 m_trackNeedsRepaint = true; |
564 if (parts & ThumbPart) | |
565 m_thumbNeedsRepaint = true; | 569 m_thumbNeedsRepaint = true; |
| 570 } |
566 if (m_scrollableArea) | 571 if (m_scrollableArea) |
567 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); | 572 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); |
568 } | 573 } |
569 | 574 |
570 } // namespace blink | 575 } // namespace blink |
OLD | NEW |