void RenderListBox::autoscroll() { IntPoint pos = document()->frame()->view()->windowToContents(document()->frame()->eventHandler()->currentMousePosition()); int endIndex = scrollToward(pos); if (endIndex >= 0) { SelectElement* select = toSelectElement(static_cast<Element*>(node())); m_inAutoscroll = true; if (!select->multiple()) select->setActiveSelectionAnchorIndex(endIndex); select->setActiveSelectionEndIndex(endIndex); select->updateListBoxSelection(!select->multiple()); m_inAutoscroll = false; } }
void RenderListBox::panScroll(const IntPoint& panStartMousePosition) { const int maxSpeed = 20; const int iconRadius = 7; const int speedReducer = 4; // FIXME: This doesn't work correctly with transforms. FloatPoint absOffset = localToAbsolute(); IntPoint currentMousePosition = document()->frame()->eventHandler()->currentMousePosition(); // We need to check if the current mouse position is out of the window. When the mouse is out of the window, the position is incoherent static IntPoint previousMousePosition; if (currentMousePosition.y() < 0) currentMousePosition = previousMousePosition; else previousMousePosition = currentMousePosition; int yDelta = currentMousePosition.y() - panStartMousePosition.y(); // If the point is too far from the center we limit the speed yDelta = max(min(yDelta, maxSpeed), -maxSpeed); if (abs(yDelta) < iconRadius) // at the center we let the space for the icon return; if (yDelta > 0) //offsetY = view()->viewHeight(); absOffset.move(0, listHeight()); else if (yDelta < 0) yDelta--; // Let's attenuate the speed yDelta /= speedReducer; IntPoint scrollPoint(0, 0); scrollPoint.setY(absOffset.y() + yDelta); int newOffset = scrollToward(scrollPoint); if (newOffset < 0) return; m_inAutoscroll = true; SelectElement* select = toSelectElement(static_cast<Element*>(node())); select->updateListBoxSelection(!select->multiple()); m_inAutoscroll = false; }
bool RenderMenuList::multiple() { SelectElement* select = toSelectElement(static_cast<Element*>(node())); return select->multiple(); }