コード例 #1
0
void RangeInputType::handleMouseDownEvent(MouseEvent* event)
{
    Node* targetNode = event->target()->toNode();
    if (event->button() != LeftButton || !targetNode || (targetNode != element() && !targetNode->isDescendantOf(element()->shadowRoot())))
        return;

    SliderThumbElement* thumb = sliderThumbElementOf(element());
    thumb->dragFrom(event->absoluteLocation());
    event->setDefaultHandled();
}
コード例 #2
0
void RenderSlider::layout()
{
    ASSERT(needsLayout());

    SliderThumbElement* thumbElement = shadowSliderThumb();
    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, IntSize(x(), y()), 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);
}
コード例 #3
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());
}
コード例 #4
0
ファイル: RangeInputType.cpp プロジェクト: ollie314/chromium
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());
}
コード例 #5
0
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();
    }
}
コード例 #6
0
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();
      }
    }
  }
}
コード例 #7
0
IntRect RenderSlider::thumbRect()
{
    SliderThumbElement* thumbElement = shadowSliderThumb();
    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;
}
コード例 #8
0
bool RenderSlider::inDragMode() const
{
    SliderThumbElement* thumbElement = shadowSliderThumb();
    return thumbElement && thumbElement->inDragMode();
}
コード例 #9
0
SliderThumbElement* SliderThumbElement::create(Document& document) {
  SliderThumbElement* element = new SliderThumbElement(document);
  element->setAttribute(idAttr, ShadowElementNames::sliderThumb());
  return element;
}