void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { if (m_pressedPart == ThumbPart) { moveThumb(m_orientation == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y()); return; } if (m_pressedPart != NoPart) m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y(); // FIXME(sky): Cleanup this code now that part is always NoPart. ScrollbarPart part = NoPart; if (part != m_hoveredPart) { if (m_pressedPart != NoPart) { if (part == m_pressedPart) { // The mouse is moving back over the pressed part. We // need to start up the timer action again. startTimerIfNeeded(autoscrollTimerDelay()); invalidatePart(m_pressedPart); } else if (m_hoveredPart == m_pressedPart) { // The mouse is leaving the pressed part. Kill our timer // if needed. stopTimerIfNeeded(); invalidatePart(m_pressedPart); } } setHoveredPart(part); } return; }
IntPoint Widget::convertFromRootView(const IntPoint& rootPoint) const { if (const ScrollView* parentScrollView = parent()) { IntPoint parentPoint = parentScrollView->convertFromRootView(rootPoint); return convertFromContainingView(parentPoint); } return rootPoint; }
IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const { if (const ScrollView* parentScrollView = parent()) { IntPoint parentPoint = parentScrollView->convertFromContainingWindow(windowPoint); return convertFromContainingView(parentPoint); } return convertFromContainingWindowToRoot(this, windowPoint); }
IntRect Widget::convertFromRootView(const IntRect& rootRect) const { if (const Widget* parentWidget = parent()) { IntRect parentRect = parentWidget->convertFromRootView(rootRect); return convertFromContainingView(parentRect); } return rootRect; }
IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const { if (const Widget* parentWidget = parent()) { IntPoint parentPoint = parentWidget->convertFromContainingWindow(windowPoint); return convertFromContainingView(parentPoint); } return windowPoint; }
void Scrollbar::mouseDown(const PlatformMouseEvent& evt) { // Early exit for right click if (evt.button() == RightButton) return; // FIXME(sky): Do we still need setPressedPart now that we only set it to NoPart? setPressedPart(NoPart); int pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y(); if (m_pressedPart == ThumbPart) m_dragOrigin = m_currentPos; m_pressedPos = pressedPos; autoscrollPressedPart(initialAutoscrollTimerDelay()); }
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt) { switch (evt.type()) { case PlatformEvent::GestureTapDown: // FIXME(sky): Is setting the pressed part needed since we only have overlay scrollbars? setPressedPart(NoPart); m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y(); return true; case PlatformEvent::GestureTapDownCancel: case PlatformEvent::GestureScrollBegin: if (m_pressedPart != ThumbPart) return false; m_scrollPos = m_pressedPos; return true; case PlatformEvent::GestureScrollUpdate: case PlatformEvent::GestureScrollUpdateWithoutPropagation: if (m_pressedPart != ThumbPart) return false; m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt.deltaY(); moveThumb(m_scrollPos); return true; case PlatformEvent::GestureScrollEnd: case PlatformEvent::GestureLongPress: case PlatformEvent::GestureFlingStart: m_scrollPos = 0; m_pressedPos = 0; setPressedPart(NoPart); return false; case PlatformEvent::GestureTap: { if (m_pressedPart != ThumbPart && m_pressedPart != NoPart && m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) { return true; } m_scrollPos = 0; m_pressedPos = 0; setPressedPart(NoPart); return false; } default: // By default, we assume that gestures don't deselect the scrollbar. return true; } }