void MediaControlTimelineElement::defaultEventHandler(Event* event) { // Left button is 0. Rejects mouse events not from left button. if (event->isMouseEvent() && static_cast<MouseEvent*>(event)->button()) return; if (!attached()) return; if (event->type() == eventNames().mousedownEvent) mediaController()->beginScrubbing(); if (event->type() == eventNames().mouseupEvent) mediaController()->endScrubbing(); MediaControlInputElement::defaultEventHandler(event); if (event->type() == eventNames().mouseoverEvent || event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mousemoveEvent) return; float time = narrowPrecisionToFloat(value().toDouble()); if (event->type() == eventNames().inputEvent && time != mediaController()->currentTime()) { ExceptionCode ec; mediaController()->setCurrentTime(time, ec); } RenderSlider* slider = toRenderSlider(renderer()); if (slider && slider->inDragMode()) m_controls->updateCurrentTimeDisplay(); }
unsigned RenderThemeChromiumWin::determineSliderThumbState(RenderObject* o) { unsigned result = TUS_NORMAL; if (!isEnabled(o->parent())) result = TUS_DISABLED; else if (supportsFocus(o->style()->appearance()) && isFocused(o->parent())) result = TUS_FOCUSED; else if (toRenderSlider(o->parent())->inDragMode()) result = TUS_PRESSED; else if (isHovered(o)) result = TUS_HOT; return result; }
bool RenderThemeChromiumSkia::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) { // Make a thumb similar to the scrollbar thumb. const bool hovered = isHovered(o) || toRenderSlider(o->parent())->inDragMode(); const int midx = rect.x() + rect.width() / 2; const int midy = rect.y() + rect.height() / 2; const bool vertical = (o->style()->appearance() == SliderThumbVerticalPart); SkCanvas* const canvas = i.context->platformContext()->canvas(); const SkColor thumbLightGrey = SkColorSetARGB(0xff, 0xf4, 0xf2, 0xef); const SkColor thumbDarkGrey = SkColorSetARGB(0xff, 0xea, 0xe5, 0xe0); SkPaint paint; paint.setColor(hovered ? SK_ColorWHITE : thumbLightGrey); SkIRect skrect; if (vertical) skrect.set(rect.x(), rect.y(), midx + 1, rect.bottom()); else skrect.set(rect.x(), rect.y(), rect.right(), midy + 1); canvas->drawIRect(skrect, paint); paint.setColor(hovered ? thumbLightGrey : thumbDarkGrey); if (vertical) skrect.set(midx + 1, rect.y(), rect.right(), rect.bottom()); else skrect.set(rect.x(), midy + 1, rect.right(), rect.bottom()); canvas->drawIRect(skrect, paint); const SkColor borderDarkGrey = SkColorSetARGB(0xff, 0x9d, 0x96, 0x8e); paint.setColor(borderDarkGrey); drawBox(canvas, rect, paint); if (rect.height() > 10 && rect.width() > 10) { drawHorizLine(canvas, midx - 2, midx + 2, midy, paint); drawHorizLine(canvas, midx - 2, midx + 2, midy - 3, paint); drawHorizLine(canvas, midx - 2, midx + 2, midy + 3, paint); } return false; }
unsigned RenderThemeChromiumWin::determineClassicState(RenderObject* o, ControlSubPart subPart) { unsigned result = 0; ControlPart part = o->style()->appearance(); // Sliders are always in the normal state. if (part == SliderHorizontalPart || part == SliderVerticalPart) return result; // So are readonly text fields. if (isReadOnlyControl(o) && (part == TextFieldPart || part == TextAreaPart || part == SearchFieldPart)) return result; if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) { if (!isEnabled(o->parent())) result = DFCS_INACTIVE; else if (toRenderSlider(o->parent())->inDragMode()) // Active supersedes hover result = DFCS_PUSHED; else if (isHovered(o)) result = DFCS_HOT; } else { if (!isEnabled(o) || isReadOnlyControl(o)) result = DFCS_INACTIVE; // Active supersedes hover else if (isPressed(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartPressed(o)) result = DFCS_PUSHED; else if (supportsFocus(part) && isFocused(o)) // So does focused result = 0; else if (isHovered(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartHovered(o)) result = DFCS_HOT; // Classic theme can't represent indeterminate states. Use unchecked appearance. if (isChecked(o) && !isIndeterminate(o)) result |= DFCS_CHECKED; } return result; }