Пример #1
0
void RangeInputType::sanitizeValueInResponseToMinOrMaxAttributeChange()
{
    if (element().hasDirtyValue())
        element().setValue(element().value());

    sliderThumbElement()->setPositionFromValue();
}
Пример #2
0
void RangeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
{
    InputType::setValue(value, valueChanged, eventBehavior);

    if (!valueChanged)
        return;

    sliderThumbElement()->setPositionFromValue();
}
Пример #3
0
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();
}
Пример #4
0
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();
}
Пример #5
0
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);
}
Пример #6
0
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();
    }
}
Пример #7
0
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());
}
Пример #8
0
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());
}
Пример #9
0
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;
}
Пример #10
0
void RangeInputType::disabledAttributeChanged()
{
    if (element().isDisabledFormControl())
        sliderThumbElement()->stopDragging();
}
Пример #11
0
bool RenderSlider::inDragMode() const
{
    SliderThumbElement* thumbElement = sliderThumbElement();
    return thumbElement && thumbElement->inDragMode();
}
Пример #12
0
void RangeInputType::updateView() {
  sliderThumbElement()->setPositionFromValue();
}
Пример #13
0
bool RenderSlider::inDragMode() const
{
    return sliderThumbElement()->active();
}