#include "platform/PlatformGestureEvent.h"
#include "platform/PlatformMouseEvent.h"
#include "platform/scroll/ScrollAnimator.h"
-#include "platform/scroll/ScrollView.h"
#include "platform/scroll/ScrollableArea.h"
#include "platform/scroll/ScrollbarTheme.h"
-using namespace std;
-
#if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN))
// The position of the scrollbar thumb affects the appearance of the steppers, so
// when the thumb moves, we have to invalidate them for painting.
#define THUMB_POSITION_AFFECTS_BUTTONS
#endif
-namespace WebCore {
+namespace blink {
-PassRefPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size)
+PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size)
{
- return adoptRef(new Scrollbar(scrollableArea, orientation, size));
+ return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size));
}
Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, ScrollbarTheme* theme)
Widget::setFrameRect(IntRect(0, 0, thickness, thickness));
m_currentPos = scrollableAreaCurrentPos();
+
+#if ENABLE(OILPAN)
+ if (m_scrollableArea)
+ m_animator = m_scrollableArea->scrollAnimator();
+#endif
}
Scrollbar::~Scrollbar()
stopTimerIfNeeded();
m_theme->unregisterScrollbar(this);
-}
-void Scrollbar::removeFromParent()
-{
- if (parent())
- toScrollView(parent())->removeChild(this);
-}
-
-ScrollView* Scrollbar::parentScrollView() const
-{
- return toScrollView(parent());
-}
+#if ENABLE(OILPAN)
+ if (!m_animator)
+ return;
-ScrollView* Scrollbar::rootScrollView() const
-{
- return toScrollView(root());
+ ASSERT(m_scrollableArea);
+ if (m_orientation == VerticalScrollbar)
+ m_animator->willRemoveVerticalScrollbar(this);
+ else
+ m_animator->willRemoveHorizontalScrollbar(this);
+#endif
}
ScrollbarOverlayStyle Scrollbar::scrollbarOverlayStyle() const
return m_scrollableArea && m_scrollableArea->isActive();
}
-bool Scrollbar::isScrollViewScrollbar() const
-{
- return parent() && parent()->isFrameView() && toScrollView(parent())->isScrollViewScrollbar(this);
-}
-
bool Scrollbar::isLeftSideVerticalScrollbar() const
{
if (m_orientation == VerticalScrollbar && m_scrollableArea)
setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPosition);
}
+void Scrollbar::disconnectFromScrollableArea()
+{
+ m_scrollableArea = nullptr;
+#if ENABLE(OILPAN)
+ m_animator = nullptr;
+#endif
+}
+
void Scrollbar::setProportion(int visibleSize, int totalSize)
{
if (visibleSize == m_visibleSize && totalSize == m_totalSize)
void Scrollbar::paint(GraphicsContext* context, const IntRect& damageRect)
{
- if (context->updatingControlTints() && theme()->supportsControlTints()) {
- invalidate();
- return;
- }
-
- if (context->paintingDisabled() || !frameRect().intersects(damageRect))
+ if (!frameRect().intersects(damageRect))
return;
if (!theme()->paint(this, context, damageRect))
int thumbLen = theme()->thumbLength(this);
int trackLen = theme()->trackLength(this);
if (delta > 0)
- delta = min(trackLen - thumbLen - thumbPos, delta);
+ delta = std::min(trackLen - thumbLen - thumbPos, delta);
else if (delta < 0)
- delta = max(-thumbPos, delta);
+ delta = std::max(-thumbPos, delta);
float minPos = m_scrollableArea->minimumScrollPosition(m_orientation);
float maxPos = m_scrollableArea->maximumScrollPosition(m_orientation);
autoscrollPressedPart(theme()->initialAutoscrollTimerDelay());
}
-void Scrollbar::setFrameRect(const IntRect& rect)
-{
- // Get our window resizer rect and see if we overlap. Adjust to avoid the overlap
- // if necessary.
- IntRect adjustedRect(rect);
- bool overlapsResizer = false;
- ScrollView* view = parentScrollView();
- if (view && !rect.isEmpty() && !view->windowResizerRect().isEmpty()) {
- IntRect resizerRect = view->convertFromContainingWindow(view->windowResizerRect());
- if (rect.intersects(resizerRect)) {
- if (orientation() == HorizontalScrollbar) {
- int overlap = rect.maxX() - resizerRect.x();
- if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) {
- adjustedRect.setWidth(rect.width() - overlap);
- overlapsResizer = true;
- }
- } else {
- int overlap = rect.maxY() - resizerRect.y();
- if (overlap > 0 && resizerRect.maxY() >= rect.maxY()) {
- adjustedRect.setHeight(rect.height() - overlap);
- overlapsResizer = true;
- }
- }
- }
- }
- if (overlapsResizer != m_overlapsResizer) {
- m_overlapsResizer = overlapsResizer;
- if (view)
- view->adjustScrollbarsAvoidingResizerCount(m_overlapsResizer ? 1 : -1);
- }
-
- Widget::setFrameRect(adjustedRect);
-}
-
-void Scrollbar::setParent(Widget* parentView)
-{
- if (!parentView && m_overlapsResizer && parentScrollView())
- parentScrollView()->adjustScrollbarsAvoidingResizerCount(-1);
- Widget::setParent(parentView);
-}
-
void Scrollbar::setEnabled(bool e)
{
if (m_enabled == e)
return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScrollPosition().y();
}
-} // namespace WebCore
+} // namespace blink