void SliderContainerElement::handleTouchEvent(TouchEvent* event) { HTMLInputElement* input = hostInput(); if (input->isDisabledOrReadOnly()) return; if (event->type() == EventTypeNames::touchend) { input->dispatchFormControlChangeEvent(); event->setDefaultHandled(); m_slidingDirection = NoMove; m_touchStarted = false; return; } // The direction of this series of touch actions has been determined, which is // perpendicular to the slider, so no need to adjust the value. if (!canSlide()) { return; } TouchList* touches = event->targetTouches(); SliderThumbElement* thumb = toSliderThumbElement( treeScope().getElementById(ShadowElementNames::sliderThumb())); if (touches->length() == 1) { if (event->type() == EventTypeNames::touchstart) { m_startPoint = touches->item(0)->absoluteLocation(); m_slidingDirection = NoMove; m_touchStarted = true; thumb->setPositionFromPoint(touches->item(0)->absoluteLocation()); } else if (m_touchStarted) { LayoutPoint currentPoint = touches->item(0)->absoluteLocation(); if (m_slidingDirection == NoMove) { // Still needs to update the direction. m_slidingDirection = getDirection(currentPoint, m_startPoint); } // m_slidingDirection has been updated, so check whether it's okay to // slide again. if (canSlide()) { thumb->setPositionFromPoint(touches->item(0)->absoluteLocation()); event->setDefaultHandled(); } } } }
void RangeInputType::handleTouchEvent(TouchEvent* event) { if (element()->isDisabledOrReadOnly()) return; if (event->type() == eventNames().touchendEvent) { event->setDefaultHandled(); return; } TouchList* touches = event->targetTouches(); if (touches->length() == 1) { Touch* touch = touches->item(0); SliderThumbElement* thumb = sliderThumbElementOf(element()); thumb->setPositionFromPoint(touch->absoluteLocation()); event->setDefaultHandled(); } }