Diff
Modified: trunk/Source/WebCore/ChangeLog (264599 => 264600)
--- trunk/Source/WebCore/ChangeLog 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/ChangeLog 2020-07-20 14:13:36 UTC (rev 264600)
@@ -1,5 +1,49 @@
2020-07-20 Rob Buis <[email protected]>
+ Make AnyStepHandling an enum class
+ https://bugs.webkit.org/show_bug.cgi?id=214423
+
+ Reviewed by Youenn Fablet.
+
+ Make AnyStepHandling an enum class since this is more readable
+ and allows us to have less includes in header files.
+
+ * html/BaseDateAndTimeInputType.cpp:
+ * html/DateInputType.cpp:
+ * html/DateTimeLocalInputType.cpp:
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setupDateTimeChooserParameters):
+ * html/HTMLInputElement.h:
+ * html/InputType.cpp:
+ (WebCore::InputType::rangeUnderflow const):
+ (WebCore::InputType::rangeOverflow const):
+ (WebCore::InputType::minimum const):
+ (WebCore::InputType::maximum const):
+ (WebCore::InputType::isInRange const):
+ (WebCore::InputType::isOutOfRange const):
+ (WebCore::InputType::stepMismatch const):
+ (WebCore::InputType::validationMessage const):
+ (WebCore::InputType::getAllowedValueStep const):
+ (WebCore::InputType::stepUp):
+ (WebCore::InputType::stepUpFromRenderer):
+ * html/InputType.h:
+ * html/MonthInputType.cpp:
+ * html/NumberInputType.cpp:
+ * html/RangeInputType.cpp:
+ (WebCore::RangeInputType::handleKeydownEvent):
+ (WebCore::RangeInputType::fallbackValue const):
+ (WebCore::RangeInputType::sanitizeValue const):
+ * html/StepRange.cpp:
+ (WebCore::StepRange::parseStep):
+ * html/StepRange.h:
+ * html/TimeInputType.cpp:
+ * html/WeekInputType.cpp:
+ * html/shadow/SliderThumbElement.cpp:
+ (WebCore::sliderPosition):
+ (WebCore::SliderThumbElement::setPositionFromPoint):
+
+2020-07-20 Rob Buis <[email protected]>
+
Setting URL.hash to '#' should set empty fragment
https://bugs.webkit.org/show_bug.cgi?id=214318
Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -34,6 +34,7 @@
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
+#include "Decimal.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "KeyboardEvent.h"
Modified: trunk/Source/WebCore/html/DateInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/DateInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/DateInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -35,6 +35,7 @@
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
+#include "StepRange.h"
namespace WebCore {
Modified: trunk/Source/WebCore/html/DateTimeLocalInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/DateTimeLocalInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/DateTimeLocalInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -33,9 +33,11 @@
#if ENABLE(INPUT_TYPE_DATETIMELOCAL)
+#include "Decimal.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
+#include "StepRange.h"
namespace WebCore {
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -62,6 +62,7 @@
#include "ScopedEventQueue.h"
#include "SearchInputType.h"
#include "Settings.h"
+#include "StepRange.h"
#include "StyleGeneratedImage.h"
#include "TextControlInnerElements.h"
#include <wtf/IsoMallocInlines.h>
@@ -2119,7 +2120,7 @@
parameters.locale = computedLocale.isEmpty() ? AtomString(defaultLanguage()) : computedLocale;
}
- StepRange stepRange = createStepRange(RejectAny);
+ auto stepRange = createStepRange(AnyStepHandling::Reject);
if (stepRange.hasStep()) {
parameters.step = stepRange.step().toDouble();
parameters.stepBase = stepRange.stepBase().toDouble();
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (264599 => 264600)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2020-07-20 14:13:36 UTC (rev 264600)
@@ -27,12 +27,12 @@
#include "DateComponents.h"
#include "FileChooser.h"
#include "HTMLTextFormControlElement.h"
-#include "StepRange.h"
#include <memory>
#include <wtf/WeakPtr.h>
namespace WebCore {
+class Decimal;
class DragData;
class FileList;
class HTMLDataListElement;
@@ -41,6 +41,7 @@
class InputType;
class ListAttributeTargetObserver;
class RadioButtonGroups;
+class StepRange;
struct DateTimeChooserParameters;
@@ -51,6 +52,8 @@
RefPtr<HTMLInputElement> checkedRadioButton;
};
+enum class AnyStepHandling;
+
class HTMLInputElement : public HTMLTextFormControlElement {
WTF_MAKE_ISO_ALLOCATED(HTMLInputElement);
public:
Modified: trunk/Source/WebCore/html/InputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/InputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/InputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -37,6 +37,7 @@
#include "DateComponents.h"
#include "DateInputType.h"
#include "DateTimeLocalInputType.h"
+#include "Decimal.h"
#include "EmailInputType.h"
#include "EventNames.h"
#include "FileInputType.h"
@@ -65,6 +66,7 @@
#include "SearchInputType.h"
#include "Settings.h"
#include "ShadowRoot.h"
+#include "StepRange.h"
#include "SubmitInputType.h"
#include "TelephoneInputType.h"
#include "TextControlInnerElements.h"
@@ -284,7 +286,7 @@
if (!numericValue.isFinite())
return false;
- return numericValue < createStepRange(RejectAny).minimum();
+ return numericValue < createStepRange(AnyStepHandling::Reject).minimum();
}
bool InputType::rangeOverflow(const String& value) const
@@ -296,7 +298,7 @@
if (!numericValue.isFinite())
return false;
- return numericValue > createStepRange(RejectAny).maximum();
+ return numericValue > createStepRange(AnyStepHandling::Reject).maximum();
}
Decimal InputType::defaultValueForStepUp() const
@@ -306,12 +308,12 @@
double InputType::minimum() const
{
- return createStepRange(RejectAny).minimum().toDouble();
+ return createStepRange(AnyStepHandling::Reject).minimum().toDouble();
}
double InputType::maximum() const
{
- return createStepRange(RejectAny).maximum().toDouble();
+ return createStepRange(AnyStepHandling::Reject).maximum().toDouble();
}
bool InputType::sizeShouldIncludeDecoration(int, int& preferredSize) const
@@ -331,7 +333,7 @@
if (!isSteppable())
return false;
- StepRange stepRange(createStepRange(RejectAny));
+ StepRange stepRange(createStepRange(AnyStepHandling::Reject));
if (!stepRange.hasRangeLimitations())
return false;
@@ -347,7 +349,7 @@
if (!isSteppable() || value.isEmpty())
return false;
- StepRange stepRange(createStepRange(RejectAny));
+ StepRange stepRange(createStepRange(AnyStepHandling::Reject));
if (!stepRange.hasRangeLimitations())
return false;
@@ -367,7 +369,7 @@
if (!numericValue.isFinite())
return false;
- return createStepRange(RejectAny).stepMismatch(numericValue);
+ return createStepRange(AnyStepHandling::Reject).stepMismatch(numericValue);
}
String InputType::badInputText() const
@@ -418,7 +420,7 @@
if (!numericValue.isFinite())
return emptyString();
- StepRange stepRange(createStepRange(RejectAny));
+ StepRange stepRange(createStepRange(AnyStepHandling::Reject));
if (numericValue < stepRange.minimum())
return validationMessageRangeUnderflowText(serialize(stepRange.minimum()));
@@ -993,7 +995,7 @@
bool InputType::getAllowedValueStep(Decimal* step) const
{
- StepRange stepRange(createStepRange(RejectAny));
+ StepRange stepRange(createStepRange(AnyStepHandling::Reject));
*step = stepRange.step();
return stepRange.hasStep();
}
@@ -1008,7 +1010,7 @@
{
if (!isSteppable())
return Exception { InvalidStateError };
- return applyStep(n, RejectAny, DispatchNoEvent);
+ return applyStep(n, AnyStepHandling::Reject, DispatchNoEvent);
}
void InputType::stepUpFromRenderer(int n)
@@ -1055,7 +1057,7 @@
if (!n)
return;
- StepRange stepRange(createStepRange(AnyIsDefaultStep));
+ StepRange stepRange(createStepRange(AnyStepHandling::Default));
// FIXME: Not any changes after stepping, even if it is an invalid value, may be better.
// (e.g. Stepping-up for <input type="number" value="foo" step="any" /> => "foo")
@@ -1106,11 +1108,11 @@
setValueAsDecimal(newValue, n == 1 || n == -1 ? DispatchInputAndChangeEvent : DispatchNoEvent);
if (n > 1)
- applyStep(n - 1, AnyIsDefaultStep, DispatchInputAndChangeEvent);
+ applyStep(n - 1, AnyStepHandling::Default, DispatchInputAndChangeEvent);
else if (n < -1)
- applyStep(n + 1, AnyIsDefaultStep, DispatchInputAndChangeEvent);
+ applyStep(n + 1, AnyStepHandling::Default, DispatchInputAndChangeEvent);
} else
- applyStep(n, AnyIsDefaultStep, DispatchInputAndChangeEvent);
+ applyStep(n, AnyStepHandling::Default, DispatchInputAndChangeEvent);
}
}
Modified: trunk/Source/WebCore/html/InputType.h (264599 => 264600)
--- trunk/Source/WebCore/html/InputType.h 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/InputType.h 2020-07-20 14:13:36 UTC (rev 264600)
@@ -35,7 +35,6 @@
#include "HTMLInputElement.h"
#include "HTMLTextFormControlElement.h"
#include "RenderPtr.h"
-#include "StepRange.h"
#include <wtf/FastMalloc.h>
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
@@ -61,11 +60,14 @@
class MouseEvent;
class Node;
class RenderStyle;
+class StepRange;
class TextControlInnerTextElement;
class TouchEvent;
struct InputElementClickState;
+enum class AnyStepHandling;
+
// An InputType object represents the type-specific part of an HTMLInputElement.
// Do not expose instances of InputType and classes derived from it to classes
// other than HTMLInputElement.
Modified: trunk/Source/WebCore/html/MonthInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/MonthInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/MonthInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -32,9 +32,11 @@
#if ENABLE(INPUT_TYPE_MONTH)
#include "MonthInputType.h"
+#include "Decimal.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
+#include "StepRange.h"
#include <wtf/DateMath.h>
#include <wtf/MathExtras.h>
#include <wtf/NeverDestroyed.h>
Modified: trunk/Source/WebCore/html/NumberInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/NumberInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/NumberInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -32,6 +32,7 @@
#include "config.h"
#include "NumberInputType.h"
+#include "Decimal.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
@@ -40,6 +41,7 @@
#include "LocalizedStrings.h"
#include "PlatformLocale.h"
#include "RenderTextControl.h"
+#include "StepRange.h"
#include <limits>
#include <wtf/ASCIICType.h>
#include <wtf/MathExtras.h>
Modified: trunk/Source/WebCore/html/RangeInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/RangeInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/RangeInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -33,6 +33,7 @@
#include "RangeInputType.h"
#include "AXObjectCache.h"
+#include "Decimal.h"
#include "ElementChildIterator.h"
#include "EventNames.h"
#include "HTMLCollection.h"
@@ -47,6 +48,7 @@
#include "ScopedEventQueue.h"
#include "ShadowRoot.h"
#include "SliderThumbElement.h"
+#include "StepRange.h"
#include <limits>
#include <wtf/MathExtras.h>
@@ -203,7 +205,7 @@
const Decimal current = parseToNumberOrNaN(element()->value());
ASSERT(current.isFinite());
- StepRange stepRange(createStepRange(RejectAny));
+ auto stepRange = createStepRange(AnyStepHandling::Reject);
// FIXME: We can't use stepUp() for the step value "any". So, we increase
// or decrease the value by 1/100 of the value range. Is it reasonable?
@@ -353,12 +355,12 @@
String RangeInputType::fallbackValue() const
{
- return serializeForNumberType(createStepRange(RejectAny).defaultValue());
+ return serializeForNumberType(createStepRange(AnyStepHandling::Reject).defaultValue());
}
String RangeInputType::sanitizeValue(const String& proposedValue) const
{
- StepRange stepRange(createStepRange(RejectAny));
+ StepRange stepRange(createStepRange(AnyStepHandling::Reject));
const Decimal proposedNumericValue = parseToNumber(proposedValue, stepRange.defaultValue());
return serializeForNumberType(stepRange.clampValue(proposedNumericValue));
}
Modified: trunk/Source/WebCore/html/StepRange.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/StepRange.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/StepRange.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -101,9 +101,9 @@
if (equalLettersIgnoringASCIICase(stepString, "any")) {
switch (anyStepHandling) {
- case RejectAny:
+ case AnyStepHandling::Reject:
return Decimal::nan();
- case AnyIsDefaultStep:
+ case AnyStepHandling::Default:
return stepDescription.defaultValue();
default:
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/html/StepRange.h (264599 => 264600)
--- trunk/Source/WebCore/html/StepRange.h 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/StepRange.h 2020-07-20 14:13:36 UTC (rev 264600)
@@ -25,7 +25,10 @@
namespace WebCore {
-enum AnyStepHandling { RejectAny, AnyIsDefaultStep };
+enum class AnyStepHandling {
+ Reject,
+ Default
+};
enum class RangeLimitations {
Valid,
Modified: trunk/Source/WebCore/html/TimeInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/TimeInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/TimeInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -32,9 +32,11 @@
#if ENABLE(INPUT_TYPE_TIME)
#include "TimeInputType.h"
+#include "Decimal.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
+#include "StepRange.h"
#include <wtf/DateMath.h>
#include <wtf/MathExtras.h>
Modified: trunk/Source/WebCore/html/WeekInputType.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/WeekInputType.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/WeekInputType.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -32,9 +32,11 @@
#if ENABLE(INPUT_TYPE_WEEK)
#include "WeekInputType.h"
+#include "Decimal.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
+#include "StepRange.h"
namespace WebCore {
Modified: trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp (264599 => 264600)
--- trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp 2020-07-20 13:51:14 UTC (rev 264599)
+++ trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp 2020-07-20 14:13:36 UTC (rev 264600)
@@ -34,6 +34,7 @@
#include "SliderThumbElement.h"
#include "CSSValueKeywords.h"
+#include "Decimal.h"
#include "Event.h"
#include "EventHandler.h"
#include "EventNames.h"
@@ -45,6 +46,7 @@
#include "RenderSlider.h"
#include "RenderTheme.h"
#include "ShadowRoot.h"
+#include "StepRange.h"
#include "StyleResolver.h"
#include <wtf/IsoMallocInlines.h>
@@ -64,7 +66,7 @@
inline static Decimal sliderPosition(HTMLInputElement& element)
{
- const StepRange stepRange(element.createStepRange(RejectAny));
+ const StepRange stepRange(element.createStepRange(AnyStepHandling::Reject));
const Decimal oldValue = parseToDecimalForNumberType(element.value(), stepRange.defaultValue());
return stepRange.proportionFromValue(stepRange.clampValue(oldValue));
}
@@ -290,7 +292,7 @@
position = std::max<LayoutUnit>(0, std::min(position, trackLength));
auto ratio = Decimal::fromDouble(static_cast<double>(position) / trackLength);
auto fraction = isVertical || !isLeftToRightDirection ? Decimal(1) - ratio : ratio;
- auto stepRange = input->createStepRange(RejectAny);
+ auto stepRange = input->createStepRange(AnyStepHandling::Reject);
auto value = stepRange.clampValue(stepRange.valueFromProportion(fraction));
#if ENABLE(DATALIST_ELEMENT)