void RangeInputType::sanitizeValueInResponseToMinOrMaxAttributeChange() { if (element().hasDirtyValue()) element().setValue(element().value()); sliderThumbElement()->setPositionFromValue(); }
void RangeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior) { InputType::setValue(value, valueChanged, eventBehavior); if (!valueChanged) return; sliderThumbElement()->setPositionFromValue(); }
void RenderSlider::layout() { // FIXME: Find a way to cascade appearance. // http://webkit.org/b/62535 RenderBox* thumbBox = sliderThumbElement()->renderBox(); if (thumbBox && thumbBox->isSliderThumb()) static_cast<RenderSliderThumb*>(thumbBox)->updateAppearance(style()); RenderFlexibleBox::layout(); }
void LayoutSlider::layout() { // FIXME: Find a way to cascade appearance. // http://webkit.org/b/62535 LayoutBox* thumbBox = sliderThumbElement()->layoutBox(); if (thumbBox && thumbBox->isSliderThumb()) toLayoutSliderThumb(thumbBox)->updateAppearance(styleRef()); LayoutFlexibleBox::layout(); }
void RenderSlider::layout() { ASSERT(needsLayout()); SliderThumbElement* thumbElement = sliderThumbElement(); RenderBox* thumb = thumbElement ? toRenderBox(thumbElement->renderer()) : 0; IntSize baseSize(borderAndPaddingWidth(), borderAndPaddingHeight()); if (thumb) { // Allow the theme to set the size of the thumb. if (thumb->style()->hasAppearance()) { // FIXME: This should pass the style, not the renderer, to the theme. theme()->adjustSliderThumbSize(thumb); } baseSize.expand(thumb->style()->width().calcMinValue(0), thumb->style()->height().calcMinValue(0)); } LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); IntSize oldSize = size(); setSize(baseSize); computeLogicalWidth(); computeLogicalHeight(); updateLayerTransform(); if (thumb) { if (oldSize != size()) thumb->setChildNeedsLayout(true, false); LayoutStateMaintainer statePusher(view(), this, size(), style()->isFlippedBlocksWritingMode()); IntRect oldThumbRect = thumb->frameRect(); thumb->layoutIfNeeded(); IntRect rect = thumbRect(); thumb->setFrameRect(rect); if (thumb->checkForRepaintDuringLayout()) thumb->repaintDuringLayoutIfMoved(oldThumbRect); statePusher.pop(); addOverflowFromChild(thumb); } repainter.repaintAfterLayout(); setNeedsLayout(false); }
void RangeInputType::handleTouchEvent(TouchEvent* event) { if (element().isDisabledOrReadOnly()) return; if (event->type() == EventTypeNames::touchend) { event->setDefaultHandled(); return; } TouchList* touches = event->targetTouches(); if (touches->length() == 1) { sliderThumbElement()->setPositionFromPoint(touches->item(0)->absoluteLocation()); event->setDefaultHandled(); } }
void RangeInputType::handleMouseDownEvent(MouseEvent* event) { if (element().isDisabledOrReadOnly()) return; Node* targetNode = event->target()->toNode(); if (event->button() != LeftButton || !targetNode) return; ASSERT(element().shadow()); if (targetNode != element() && !targetNode->isDescendantOf(element().userAgentShadowRoot())) return; SliderThumbElement* thumb = sliderThumbElement(); if (targetNode == thumb) return; thumb->dragFrom(event->absoluteLocation()); }
void RangeInputType::handleMouseDownEvent(MouseEvent* event) { if (element().isDisabledOrReadOnly()) return; Node* targetNode = event->target()->toNode(); if (event->button() != static_cast<short>(WebPointerProperties::Button::Left) || !targetNode) return; DCHECK(element().shadow()); if (targetNode != element() && !targetNode->isDescendantOf(element().userAgentShadowRoot())) return; SliderThumbElement* thumb = sliderThumbElement(); if (targetNode == thumb) return; thumb->dragFrom(event->absoluteLocation()); }
IntRect RenderSlider::thumbRect() { SliderThumbElement* thumbElement = sliderThumbElement(); if (!thumbElement) return IntRect(); IntRect thumbRect; RenderBox* thumb = toRenderBox(thumbElement->renderer()); thumbRect.setWidth(thumb->style()->width().calcMinValue(contentWidth())); thumbRect.setHeight(thumb->style()->height().calcMinValue(contentHeight())); double fraction = sliderPosition(static_cast<HTMLInputElement*>(node())); IntRect contentRect = contentBoxRect(); if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) { thumbRect.setX(contentRect.x() + (contentRect.width() - thumbRect.width()) / 2); thumbRect.setY(contentRect.y() + static_cast<int>(nextafter((contentRect.height() - thumbRect.height()) + 1, 0) * (1 - fraction))); } else { thumbRect.setX(contentRect.x() + static_cast<int>(nextafter((contentRect.width() - thumbRect.width()) + 1, 0) * fraction)); thumbRect.setY(contentRect.y() + (contentRect.height() - thumbRect.height()) / 2); } return thumbRect; }
void RangeInputType::disabledAttributeChanged() { if (element().isDisabledFormControl()) sliderThumbElement()->stopDragging(); }
bool RenderSlider::inDragMode() const { SliderThumbElement* thumbElement = sliderThumbElement(); return thumbElement && thumbElement->inDragMode(); }
void RangeInputType::updateView() { sliderThumbElement()->setPositionFromValue(); }
bool RenderSlider::inDragMode() const { return sliderThumbElement()->active(); }