Diff
Modified: trunk/Source/WebCore/ChangeLog (119808 => 119809)
--- trunk/Source/WebCore/ChangeLog 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/ChangeLog 2012-06-08 07:51:36 UTC (rev 119809)
@@ -1,3 +1,37 @@
+2012-06-08 Yoshifumi Inoue <[email protected]>
+
+ [Forms] Drop StepRange::NumberWithDecimalPlacesOrMissing
+ https://bugs.webkit.org/show_bug.cgi?id=88621
+
+ Reviewed by Kent Tamura.
+
+ This patch changes NumberWithDecimalPlacesOrMissing to NumberWithDecimalPlaces.
+ We use NaN as indication of having value or not.
+
+ No new tests, because this patch doesn't change behavior.
+
+ * html/DateInputType.cpp:
+ (WebCore::DateInputType::createStepRange): Replace NumberWithDecimalPlacesOrMissing to NumberWithDecimalPlaces.
+ * html/DateTimeInputType.cpp:
+ (WebCore::DateTimeInputType::createStepRange): ditto.
+ * html/DateTimeLocalInputType.cpp:
+ (WebCore::DateTimeLocalInputType::createStepRange): ditto.
+ * html/MonthInputType.cpp:
+ (WebCore::MonthInputType::createStepRange): ditto.
+ * html/NumberInputType.cpp:
+ (WebCore::NumberInputType::createStepRange): ditto.
+ * html/RangeInputType.cpp:
+ (WebCore::RangeInputType::createStepRange): ditto.
+ * html/StepRange.cpp:
+ (WebCore::StepRange::StepRange): Checks value is finite or not.
+ (WebCore::StepRange::parseStep): Replace NumberWithDecimalPlacesOrMissing to NumberWithDecimalPlaces.
+ * html/StepRange.h:
+ (StepRange): Removed NumberWithDecimalPlacesOrMissing.
+ * html/TimeInputType.cpp:
+ (WebCore::TimeInputType::createStepRange): NumberWithDecimalPlacesOrMissing to NumberWithDecimalPlaces.
+ * html/WeekInputType.cpp:
+ (WebCore::WeekInputType::createStepRange): ditto.
+
2012-06-08 Kentaro Hara <[email protected]>
Unreviewed. Fixed a comment, pointed out by ap@.
Modified: trunk/Source/WebCore/html/DateInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/DateInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/DateInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -76,7 +76,7 @@
const InputNumber stepBase = parseToNumber(element()->fastGetAttribute(minAttr), 0);
const InputNumber minimum = parseToNumber(element()->fastGetAttribute(minAttr), convertDoubleToInputNumber(DateComponents::minimumDate()));
const InputNumber maximum = parseToNumber(element()->fastGetAttribute(maxAttr), convertDoubleToInputNumber(DateComponents::maximumDate()));
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
Modified: trunk/Source/WebCore/html/DateTimeInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/DateTimeInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/DateTimeInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -74,7 +74,7 @@
const InputNumber stepBase = parseToNumber(element()->fastGetAttribute(minAttr), 0);
const InputNumber minimum = parseToNumber(element()->fastGetAttribute(minAttr), convertDoubleToInputNumber(DateComponents::minimumDateTime()));
const InputNumber maximum = parseToNumber(element()->fastGetAttribute(maxAttr), convertDoubleToInputNumber(DateComponents::maximumDateTime()));
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
Modified: trunk/Source/WebCore/html/DateTimeLocalInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/DateTimeLocalInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/DateTimeLocalInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -80,7 +80,7 @@
const InputNumber stepBase = parseToNumber(element()->fastGetAttribute(minAttr), 0);
const InputNumber minimum = parseToNumber(element()->fastGetAttribute(minAttr), convertDoubleToInputNumber(DateComponents::minimumDateTime()));
const InputNumber maximum = parseToNumber(element()->fastGetAttribute(maxAttr), convertDoubleToInputNumber(DateComponents::maximumDateTime()));
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
Modified: trunk/Source/WebCore/html/MonthInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/MonthInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/MonthInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -104,7 +104,7 @@
const InputNumber stepBase = parseToNumber(element()->fastGetAttribute(minAttr), convertDoubleToInputNumber(DateComponents::minimumMonth()));
const InputNumber minimum = parseToNumber(element()->fastGetAttribute(minAttr), convertDoubleToInputNumber(DateComponents::minimumMonth()));
const InputNumber maximum = parseToNumber(element()->fastGetAttribute(maxAttr), convertDoubleToInputNumber(DateComponents::maximumMonth()));
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
Modified: trunk/Source/WebCore/html/NumberInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/NumberInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/NumberInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -137,8 +137,7 @@
const InputNumber floatMax = convertDoubleToInputNumber(numeric_limits<float>::max());
const InputNumber minimum = parseToNumber(element()->fastGetAttribute(minAttr), -floatMax);
const InputNumber maximum = parseToNumber(element()->fastGetAttribute(maxAttr), floatMax);
-
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
Modified: trunk/Source/WebCore/html/RangeInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/RangeInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/RangeInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -104,11 +104,11 @@
const AtomicString& precisionValue = element()->fastGetAttribute(precisionAttr);
if (!precisionValue.isNull()) {
- StepRange::NumberWithDecimalPlacesOrMissing step(1, !equalIgnoringCase(precisionValue, "float"));
+ const StepRange::NumberWithDecimalPlaces step(equalIgnoringCase(precisionValue, "float") ? std::numeric_limits<double>::quiet_NaN() : 1);
return StepRange(minimum, minimum, maximum, step, stepDescription);
}
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(minimum, minimum, maximum, step, stepDescription);
}
Modified: trunk/Source/WebCore/html/StepRange.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/StepRange.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/StepRange.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -55,15 +55,15 @@
{
}
-StepRange::StepRange(const NumberWithDecimalPlaces& stepBase, const InputNumber& minimum, const InputNumber& maximum, const NumberWithDecimalPlacesOrMissing& step, const StepDescription& stepDescription)
+StepRange::StepRange(const NumberWithDecimalPlaces& stepBase, const InputNumber& minimum, const InputNumber& maximum, const NumberWithDecimalPlaces& step, const StepDescription& stepDescription)
: m_maximum(maximum)
, m_minimum(minimum)
- , m_step(step.value.value)
- , m_stepBase(stepBase.value)
+ , m_step(isfinite(step.value) ? step.value : 1)
+ , m_stepBase(isfinite(stepBase.value) ? stepBase.value : 1)
, m_stepDescription(stepDescription)
, m_stepBaseDecimalPlaces(stepBase.decimalPlaces)
- , m_stepDecimalPlaces(step.value.decimalPlaces)
- , m_hasStep(step.hasValue)
+ , m_stepDecimalPlaces(step.decimalPlaces)
+ , m_hasStep(isfinite(step.value))
{
ASSERT(isfinite(m_maximum));
ASSERT(isfinite(m_minimum));
@@ -106,46 +106,46 @@
return clampedValue;
}
-StepRange::NumberWithDecimalPlacesOrMissing StepRange::parseStep(AnyStepHandling anyStepHandling, const StepDescription& stepDescription, const String& stepString)
+StepRange::NumberWithDecimalPlaces StepRange::parseStep(AnyStepHandling anyStepHandling, const StepDescription& stepDescription, const String& stepString)
{
if (stepString.isEmpty())
- return NumberWithDecimalPlacesOrMissing(stepDescription.defaultValue());
+ return NumberWithDecimalPlaces(stepDescription.defaultValue());
if (equalIgnoringCase(stepString, "any")) {
switch (anyStepHandling) {
case RejectAny:
- return NumberWithDecimalPlacesOrMissing(NumberWithDecimalPlaces(1), false);
+ return NumberWithDecimalPlaces(std::numeric_limits<double>::quiet_NaN());
case AnyIsDefaultStep:
- return NumberWithDecimalPlacesOrMissing(stepDescription.defaultValue());
+ return NumberWithDecimalPlaces(stepDescription.defaultValue());
default:
ASSERT_NOT_REACHED();
}
}
- NumberWithDecimalPlacesOrMissing step(0);
- step.value.value = parseToDoubleForNumberTypeWithDecimalPlaces(stepString, &step.value.decimalPlaces);
- if (!isfinite(step.value.value) || step.value.value <= 0.0)
- return NumberWithDecimalPlacesOrMissing(stepDescription.defaultValue());
+ NumberWithDecimalPlaces step(0);
+ step.value = parseToDoubleForNumberTypeWithDecimalPlaces(stepString, &step.decimalPlaces);
+ if (!isfinite(step.value) || step.value <= 0.0)
+ return NumberWithDecimalPlaces(stepDescription.defaultValue());
switch (stepDescription.stepValueShouldBe) {
case StepValueShouldBeReal:
- step.value.value *= stepDescription.stepScaleFactor;
+ step.value *= stepDescription.stepScaleFactor;
break;
case ParsedStepValueShouldBeInteger:
// For date, month, and week, the parsed value should be an integer for some types.
- step.value.value = max(round(step.value.value), 1.0);
- step.value.value *= stepDescription.stepScaleFactor;
+ step.value = max(round(step.value), 1.0);
+ step.value *= stepDescription.stepScaleFactor;
break;
case ScaledStepValueShouldBeInteger:
// For datetime, datetime-local, time, the result should be an integer.
- step.value.value *= stepDescription.stepScaleFactor;
- step.value.value = max(round(step.value.value), 1.0);
+ step.value *= stepDescription.stepScaleFactor;
+ step.value = max(round(step.value), 1.0);
break;
default:
ASSERT_NOT_REACHED();
}
- ASSERT(step.value.value > 0);
+ ASSERT(step.value > 0);
return step;
}
Modified: trunk/Source/WebCore/html/StepRange.h (119808 => 119809)
--- trunk/Source/WebCore/html/StepRange.h 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/StepRange.h 2012-06-08 07:51:36 UTC (rev 119809)
@@ -56,17 +56,6 @@
}
};
- struct NumberWithDecimalPlacesOrMissing {
- bool hasValue;
- NumberWithDecimalPlaces value;
-
- NumberWithDecimalPlacesOrMissing(NumberWithDecimalPlaces value, bool hasValue = true)
- : hasValue(hasValue)
- , value(value)
- {
- }
- };
-
enum StepValueShouldBe {
StepValueShouldBeReal,
ParsedStepValueShouldBeInteger,
@@ -103,14 +92,14 @@
StepRange();
StepRange(const StepRange&);
- StepRange(const NumberWithDecimalPlaces& stepBase, const InputNumber& minimum, const InputNumber& maximum, const NumberWithDecimalPlacesOrMissing& step, const StepDescription&);
+ StepRange(const NumberWithDecimalPlaces& stepBase, const InputNumber& minimum, const InputNumber& maximum, const NumberWithDecimalPlaces& step, const StepDescription&);
InputNumber acceptableError() const;
InputNumber alignValueForStep(const InputNumber& currentValue, unsigned currentDecimalPlaces, const InputNumber& newValue) const;
InputNumber clampValue(const InputNumber& value) const;
bool hasStep() const { return m_hasStep; }
InputNumber maximum() const { return m_maximum; }
InputNumber minimum() const { return m_minimum; }
- static NumberWithDecimalPlacesOrMissing parseStep(AnyStepHandling, const StepDescription&, const String&);
+ static NumberWithDecimalPlaces parseStep(AnyStepHandling, const StepDescription&, const String&);
InputNumber step() const { return m_step; }
InputNumber stepBase() const { return m_stepBase; }
unsigned stepBaseDecimalPlaces() const { return m_stepBaseDecimalPlaces; }
Modified: trunk/Source/WebCore/html/TimeInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/TimeInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/TimeInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -86,7 +86,7 @@
const InputNumber stepBase = parseToNumber(element()->fastGetAttribute(minAttr), 0);
const InputNumber minimum = parseToNumber(element()->fastGetAttribute(minAttr), convertDoubleToInputNumber(DateComponents::minimumTime()));
const InputNumber maximum = parseToNumber(element()->fastGetAttribute(maxAttr), convertDoubleToInputNumber(DateComponents::maximumTime()));
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
Modified: trunk/Source/WebCore/html/WeekInputType.cpp (119808 => 119809)
--- trunk/Source/WebCore/html/WeekInputType.cpp 2012-06-08 07:45:52 UTC (rev 119808)
+++ trunk/Source/WebCore/html/WeekInputType.cpp 2012-06-08 07:51:36 UTC (rev 119809)
@@ -68,7 +68,7 @@
const InputNumber stepBase = parseToNumber(element()->fastGetAttribute(minAttr), weekDefaultStepBase);
const InputNumber minimum = parseToNumber(element()->fastGetAttribute(minAttr), convertDoubleToInputNumber(DateComponents::minimumWeek()));
const InputNumber maximum = parseToNumber(element()->fastGetAttribute(maxAttr), convertDoubleToInputNumber(DateComponents::maximumWeek()));
- StepRange::NumberWithDecimalPlacesOrMissing step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const StepRange::NumberWithDecimalPlaces step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}