Esempio n. 1
0
StepRange RangeInputType::createStepRange(AnyStepHandling anyStepHandling) const
{
    DEPRECATED_DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (rangeDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor));

    const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), rangeDefaultMinimum);
    const Decimal maximum = ensureMaximum(parseToNumber(element().fastGetAttribute(maxAttr), rangeDefaultMaximum), minimum, rangeDefaultMaximum);

    const AtomicString& precisionValue = element().fastGetAttribute(precisionAttr);
    if (!precisionValue.isNull()) {
        const Decimal step = equalIgnoringCase(precisionValue, "float") ? Decimal::nan() : 1;
        return StepRange(minimum, minimum, maximum, step, stepDescription);
    }

    const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
    return StepRange(minimum, minimum, maximum, step, stepDescription);
}
Esempio n. 2
0
StepRange RangeInputType::createStepRange(
    AnyStepHandling anyStepHandling) const {
  DEFINE_STATIC_LOCAL(
      const StepRange::StepDescription, stepDescription,
      (rangeDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor));

  const Decimal stepBase = findStepBase(rangeDefaultStepBase);
  const Decimal minimum =
      parseToNumber(element().fastGetAttribute(minAttr), rangeDefaultMinimum);
  const Decimal maximum = ensureMaximum(
      parseToNumber(element().fastGetAttribute(maxAttr), rangeDefaultMaximum),
      minimum, rangeDefaultMaximum);

  const Decimal step = StepRange::parseStep(
      anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
  // Range type always has range limitations because it has default
  // minimum/maximum.
  // https://html.spec.whatwg.org/multipage/forms.html#range-state-(type=range):concept-input-min-default
  const bool hasRangeLimitations = true;
  return StepRange(stepBase, minimum, maximum, hasRangeLimitations, step,
                   stepDescription);
}