WebNodeCollection WebInputElement::dataListOptions() const { #if ENABLE(DATALIST_ELEMENT) HTMLDataListElement* dataList = static_cast<HTMLDataListElement*>(constUnwrap<HTMLInputElement>()->list()); if (dataList) return WebNodeCollection(dataList->options()); #endif return WebNodeCollection(); }
Vector<Color> ColorInputType::suggestions() const { Vector<Color> suggestions; if (RuntimeEnabledFeatures::dataListElementEnabled()) { HTMLDataListElement* dataList = element()->dataList(); if (dataList) { RefPtr<HTMLCollection> options = dataList->options(); for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(options->item(i)); i++) { if (!element()->isValidValue(option->value())) continue; Color color(option->value()); if (!color.isValid()) continue; suggestions.append(color); } } } return suggestions; }
Vector<Color> ColorInputType::suggestions() const { Vector<Color> suggestions; #if ENABLE(DATALIST_ELEMENT) HTMLDataListElement* dataList = element().dataList(); if (dataList) { RefPtr<HTMLCollection> options = dataList->options(); for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(options->item(i)); i++) { if (!element().isValidValue(option->value())) continue; Color color(option->value()); if (!color.isValid()) continue; suggestions.append(color); } } #endif return suggestions; }
Vector<ColorSuggestion> ColorInputType::suggestions() const { Vector<ColorSuggestion> suggestions; HTMLDataListElement* dataList = element().dataList(); if (dataList) { RefPtrWillBeRawPtr<HTMLDataListOptionsCollection> options = dataList->options(); for (unsigned i = 0; HTMLOptionElement* option = options->item(i); i++) { if (!element().isValidValue(option->value())) continue; Color color; if (!color.setFromString(option->value())) continue; ColorSuggestion suggestion(color, option->label().left(maxSuggestionLabelLength)); suggestions.append(suggestion); if (suggestions.size() >= maxSuggestions) break; } } return suggestions; }
void RangeInputType::updateTickMarkValues() { if (!m_tickMarkValuesDirty) return; m_tickMarkValues.clear(); m_tickMarkValuesDirty = false; HTMLDataListElement* dataList = element().dataList(); if (!dataList) return; HTMLDataListOptionsCollection* options = dataList->options(); m_tickMarkValues.reserveCapacity(options->length()); for (unsigned i = 0; i < options->length(); ++i) { HTMLOptionElement* optionElement = options->item(i); String optionValue = optionElement->value(); if (!this->element().isValidValue(optionValue)) continue; m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan())); } m_tickMarkValues.shrinkToFit(); nonCopyingSort(m_tickMarkValues.begin(), m_tickMarkValues.end(), decimalCompare); }
void RangeInputType::updateTickMarkValues() { if (!m_tickMarkValuesDirty) return; m_tickMarkValues.clear(); m_tickMarkValuesDirty = false; HTMLDataListElement* dataList = element().dataList(); if (!dataList) return; Ref<HTMLCollection> options = dataList->options(); m_tickMarkValues.reserveCapacity(options->length()); for (unsigned i = 0; i < options->length(); ++i) { Node* node = options->item(i); HTMLOptionElement& optionElement = downcast<HTMLOptionElement>(*node); String optionValue = optionElement.value(); if (!element().isValidValue(optionValue)) continue; m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan())); } m_tickMarkValues.shrinkToFit(); std::sort(m_tickMarkValues.begin(), m_tickMarkValues.end()); }
void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) { Node* node = o->node(); if (!node) return; HTMLInputElement* input = node->toInputElement(); if (!input) return; HTMLDataListElement* dataList = static_cast<HTMLDataListElement*>(input->list()); if (!dataList) return; double min = input->minimum(); double max = input->maximum(); ControlPart part = o->style()->appearance(); // We don't support ticks on alternate sliders like MediaVolumeSliders. if (part != SliderHorizontalPart && part != SliderVerticalPart) return; bool isHorizontal = part == SliderHorizontalPart; IntSize thumbSize; RenderObject* thumbRenderer = input->sliderThumbElement()->renderer(); if (thumbRenderer) { RenderStyle* thumbStyle = thumbRenderer->style(); int thumbWidth = thumbStyle->width().intValue(); int thumbHeight = thumbStyle->height().intValue(); thumbSize.setWidth(isHorizontal ? thumbWidth : thumbHeight); thumbSize.setHeight(isHorizontal ? thumbHeight : thumbWidth); } IntSize tickSize = sliderTickSize(); float zoomFactor = o->style()->effectiveZoom(); FloatRect tickRect; int tickRegionSideMargin = 0; int tickRegionWidth = 0; IntRect trackBounds; RenderObject* trackRenderer = input->sliderTrackElement()->renderer(); // We can ignoring transforms because transform is handled by the graphics context. if (trackRenderer) trackBounds = trackRenderer->absoluteBoundingBoxRectIgnoringTransforms(); IntRect sliderBounds = o->absoluteBoundingBoxRectIgnoringTransforms(); // Make position relative to the transformed ancestor element. trackBounds.setX(trackBounds.x() - sliderBounds.x() + rect.x()); trackBounds.setY(trackBounds.y() - sliderBounds.y() + rect.y()); if (isHorizontal) { tickRect.setWidth(floor(tickSize.width() * zoomFactor)); tickRect.setHeight(floor(tickSize.height() * zoomFactor)); tickRect.setY(floor(rect.y() + rect.height() / 2.0 + sliderTickOffsetFromTrackCenter() * zoomFactor)); tickRegionSideMargin = trackBounds.x() + (thumbSize.width() - tickSize.width() * zoomFactor) / 2.0; tickRegionWidth = trackBounds.width() - thumbSize.width(); } else { tickRect.setWidth(floor(tickSize.height() * zoomFactor)); tickRect.setHeight(floor(tickSize.width() * zoomFactor)); tickRect.setX(floor(rect.x() + rect.width() / 2.0 + sliderTickOffsetFromTrackCenter() * zoomFactor)); tickRegionSideMargin = trackBounds.y() + (thumbSize.width() - tickSize.width() * zoomFactor) / 2.0; tickRegionWidth = trackBounds.height() - thumbSize.width(); } RefPtr<HTMLCollection> options = dataList->options(); GraphicsContextStateSaver stateSaver(*paintInfo.context); paintInfo.context->setFillColor(o->style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); for (unsigned i = 0; Node* node = options->item(i); i++) { ASSERT(node->hasTagName(optionTag)); HTMLOptionElement* optionElement = toHTMLOptionElement(node); String value = optionElement->value(); if (!input->isValidValue(value)) continue; double parsedValue = parseToDoubleForNumberType(input->sanitizeValue(value)); double tickFraction = (parsedValue - min) / (max - min); double tickRatio = isHorizontal && o->style()->isLeftToRightDirection() ? tickFraction : 1.0 - tickFraction; double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tickRatio); if (isHorizontal) tickRect.setX(tickPosition); else tickRect.setY(tickPosition); paintInfo.context->fillRect(tickRect); } }
static v8::Handle<v8::Value> optionsAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.HTMLDataListElement.options._get"); HTMLDataListElement* imp = V8HTMLDataListElement::toNative(info.Holder()); return toV8(imp->options()); }