Changeset 202143 in webkit
- Timestamp:
- Jun 16, 2016 3:47:02 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202132 r202143 1 2016-06-16 Benjamin Poulain <bpoulain@apple.com> 2 3 :in-range & :out-of-range CSS pseudo-classes shouldn't match inputs without range limitations 4 https://bugs.webkit.org/show_bug.cgi?id=156558 5 6 Reviewed by Simon Fraser. 7 8 * fast/css/pseudo-in-range-basics-expected.html: Added. 9 * fast/css/pseudo-in-range-basics.html: Added. 10 * fast/css/pseudo-in-range-out-of-range-trivial-expected.html: Added. 11 * fast/css/pseudo-in-range-out-of-range-trivial.html: Added. 12 * fast/css/pseudo-out-of-range-basics-expected.html: Added. 13 * fast/css/pseudo-out-of-range-basics.html: Added. 14 1 15 2016-06-15 Simon Fraser <simon.fraser@apple.com> 2 16 -
trunk/LayoutTests/imported/w3c/ChangeLog
r202023 r202143 1 2016-06-16 Benjamin Poulain <bpoulain@apple.com> 2 3 :in-range & :out-of-range CSS pseudo-classes shouldn't match inputs without range limitations 4 https://bugs.webkit.org/show_bug.cgi?id=156558 5 6 Reviewed by Simon Fraser. 7 8 * web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange-expected.txt: 9 One of the previous match was erroneous. 10 Our results are still very far from being correct. There are several 11 bugs affecting our range validation. 12 1 13 2016-06-13 Joseph Pecoraro <pecoraro@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/inrange-outofrange-expected.txt
r200309 r202143 1 1 2 2 3 FAIL ':in-range' matches all elements that are candidates for constraint validation, have range limitations, and that are neither suffering from an underflow nor suffering from an overflow assert_array_equals: lengths differ, expected 10 got 83 FAIL ':in-range' matches all elements that are candidates for constraint validation, have range limitations, and that are neither suffering from an underflow nor suffering from an overflow assert_array_equals: lengths differ, expected 10 got 7 4 4 FAIL ':out-of-range' matches all elements that are candidates for constraint validation, have range limitations, and that are either suffering from an underflow or suffering from an overflow assert_array_equals: lengths differ, expected 12 got 2 5 FAIL ':in-range' update number1's value < min assert_array_equals: lengths differ, expected 9 got 75 FAIL ':in-range' update number1's value < min assert_array_equals: lengths differ, expected 9 got 6 6 6 FAIL ':out-of-range' update number1's value < min assert_array_equals: lengths differ, expected 13 got 3 7 FAIL ':in-range' update number3's min < value assert_array_equals: lengths differ, expected 10 got 87 FAIL ':in-range' update number3's min < value assert_array_equals: lengths differ, expected 10 got 7 8 8 FAIL ':out-of-range' update number3's min < value assert_array_equals: lengths differ, expected 12 got 2 9 9 -
trunk/Source/WebCore/ChangeLog
r202142 r202143 1 2016-06-16 Benjamin Poulain <bpoulain@apple.com> 2 3 :in-range & :out-of-range CSS pseudo-classes shouldn't match inputs without range limitations 4 https://bugs.webkit.org/show_bug.cgi?id=156558 5 6 Reviewed by Simon Fraser. 7 8 The pseudo selectors :in-range and :out-of-range should only 9 apply if: 10 -minimum/maximum are defined for the input type 11 -the input value is/is-not suffering from underflow/overflow. 12 13 Only certain types have a valid minimum and maximum: 14 -number 15 -range 16 -date 17 -month 18 -week 19 -time 20 -datetime-local 21 22 Of those, only one has a default minimum and maximum: range. 23 For all the others, the minimum or maximum is only defined 24 if the min/max attribute is defined and valid. 25 26 This patch addresses these constraints for number and range. 27 The date types range validation is severely broken and is 28 left untouched. It really needs a clean rewrite. 29 30 Tests: fast/css/pseudo-in-range-basics.html 31 fast/css/pseudo-in-range-out-of-range-trivial.html 32 fast/css/pseudo-out-of-range-basics.html 33 34 * html/DateInputType.cpp: 35 (WebCore::DateInputType::createStepRange): 36 * html/DateTimeInputType.cpp: 37 (WebCore::DateTimeInputType::createStepRange): 38 * html/DateTimeLocalInputType.cpp: 39 (WebCore::DateTimeLocalInputType::createStepRange): 40 * html/InputType.cpp: 41 (WebCore::InputType::isInRange): 42 (WebCore::InputType::isOutOfRange): 43 Notice the isEmpty() shortcut. 44 A value can only overflow/underflow if it is not empty. 45 46 * html/MonthInputType.cpp: 47 (WebCore::MonthInputType::createStepRange): 48 * html/NumberInputType.cpp: 49 (WebCore::NumberInputType::createStepRange): 50 * html/RangeInputType.cpp: 51 (WebCore::RangeInputType::createStepRange): 52 * html/StepRange.cpp: 53 (WebCore::StepRange::StepRange): 54 * html/StepRange.h: 55 (WebCore::StepRange::hasRangeLimitations): 56 * html/WeekInputType.cpp: 57 (WebCore::WeekInputType::createStepRange): 58 1 59 2016-06-16 Anders Carlsson <andersca@apple.com> 2 60 -
trunk/Source/WebCore/html/DateInputType.cpp
r194819 r202143 69 69 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumDate())); 70 70 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 71 return StepRange(stepBase, minimum, maximum, step, stepDescription);71 return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 72 72 } 73 73 -
trunk/Source/WebCore/html/DateTimeInputType.cpp
r194819 r202143 70 70 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumDateTime())); 71 71 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 72 return StepRange(stepBase, minimum, maximum, step, stepDescription);72 return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 73 73 } 74 74 -
trunk/Source/WebCore/html/DateTimeLocalInputType.cpp
r194819 r202143 76 76 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumDateTime())); 77 77 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 78 return StepRange(stepBase, minimum, maximum, step, stepDescription);78 return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 79 79 } 80 80 -
trunk/Source/WebCore/html/InputType.cpp
r202105 r202143 340 340 return false; 341 341 342 StepRange stepRange(createStepRange(RejectAny)); 343 if (!stepRange.hasRangeLimitations()) 344 return false; 345 342 346 const Decimal numericValue = parseToNumberOrNaN(value); 343 347 if (!numericValue.isFinite()) 344 348 return true; 345 349 350 return numericValue >= stepRange.minimum() && numericValue <= stepRange.maximum(); 351 } 352 353 bool InputType::isOutOfRange(const String& value) const 354 { 355 if (!isSteppable() || value.isEmpty()) 356 return false; 357 346 358 StepRange stepRange(createStepRange(RejectAny)); 347 return numericValue >= stepRange.minimum() && numericValue <= stepRange.maximum(); 348 } 349 350 bool InputType::isOutOfRange(const String& value) const 351 { 352 if (!isSteppable()) 359 if (!stepRange.hasRangeLimitations()) 353 360 return false; 354 361 … … 357 364 return true; 358 365 359 StepRange stepRange(createStepRange(RejectAny));360 366 return numericValue < stepRange.minimum() || numericValue > stepRange.maximum(); 361 367 } -
trunk/Source/WebCore/html/MonthInputType.cpp
r194819 r202143 98 98 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumMonth())); 99 99 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 100 return StepRange(stepBase, minimum, maximum, step, stepDescription);100 return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 101 101 } 102 102 -
trunk/Source/WebCore/html/NumberInputType.cpp
r195452 r202143 157 157 // FIXME: We should use numeric_limits<double>::max for number input type. 158 158 const Decimal floatMax = Decimal::fromDouble(std::numeric_limits<float>::max()); 159 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), -floatMax); 160 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), floatMax); 161 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 162 return StepRange(stepBase, minimum, maximum, step, stepDescription); 159 const Element& element = this->element(); 160 161 RangeLimitations rangeLimitations = RangeLimitations::Invalid; 162 auto extractBound = [&] (const QualifiedName& attributeName, const Decimal& defaultValue) -> Decimal { 163 const AtomicString& attributeValue = element.fastGetAttribute(attributeName); 164 Decimal valueFromAttribute = parseToNumberOrNaN(attributeValue); 165 if (valueFromAttribute.isFinite()) { 166 rangeLimitations = RangeLimitations::Valid; 167 return valueFromAttribute; 168 } 169 return defaultValue; 170 }; 171 Decimal minimum = extractBound(minAttr, -floatMax); 172 Decimal maximum = extractBound(maxAttr, floatMax); 173 174 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element.fastGetAttribute(stepAttr)); 175 return StepRange(stepBase, rangeLimitations, minimum, maximum, step, stepDescription); 163 176 } 164 177 -
trunk/Source/WebCore/html/RangeInputType.cpp
r202105 r202143 124 124 if (!precisionValue.isNull()) { 125 125 const Decimal step = equalLettersIgnoringASCIICase(precisionValue, "float") ? Decimal::nan() : 1; 126 return StepRange(minimum, minimum, maximum, step, stepDescription);126 return StepRange(minimum, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 127 127 } 128 128 129 129 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 130 return StepRange(minimum, minimum, maximum, step, stepDescription);130 return StepRange(minimum, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 131 131 } 132 132 -
trunk/Source/WebCore/html/StepRange.cpp
r195452 r202143 36 36 , m_step(1) 37 37 , m_stepBase(0) 38 , m_hasStep(false)39 38 { 40 39 } … … 46 45 , m_stepBase(stepRange.m_stepBase) 47 46 , m_stepDescription(stepRange.m_stepDescription) 47 , m_hasRangeLimitations(stepRange.m_hasRangeLimitations) 48 48 , m_hasStep(stepRange.m_hasStep) 49 49 { 50 50 } 51 51 52 StepRange::StepRange(const Decimal& stepBase, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription)52 StepRange::StepRange(const Decimal& stepBase, RangeLimitations rangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription) 53 53 : m_maximum(maximum) 54 54 , m_minimum(minimum) … … 56 56 , m_stepBase(stepBase.isFinite() ? stepBase : 1) 57 57 , m_stepDescription(stepDescription) 58 , m_hasRangeLimitations(rangeLimitations == RangeLimitations::Valid) 58 59 , m_hasStep(step.isFinite()) 59 60 { -
trunk/Source/WebCore/html/StepRange.h
r128572 r202143 31 31 32 32 enum AnyStepHandling { RejectAny, AnyIsDefaultStep }; 33 34 enum class RangeLimitations { 35 Valid, 36 Invalid 37 }; 33 38 34 39 class StepRange { … … 72 77 StepRange(); 73 78 StepRange(const StepRange&); 74 StepRange(const Decimal& stepBase, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription&);79 StepRange(const Decimal& stepBase, RangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription&); 75 80 Decimal acceptableError() const; 76 81 Decimal alignValueForStep(const Decimal& currentValue, const Decimal& newValue) const; 77 82 Decimal clampValue(const Decimal& value) const; 78 83 bool hasStep() const { return m_hasStep; } 84 bool hasRangeLimitations() const { return m_hasRangeLimitations; } 79 85 Decimal maximum() const { return m_maximum; } 80 86 Decimal minimum() const { return m_minimum; } … … 115 121 const Decimal m_stepBase; 116 122 const StepDescription m_stepDescription; 117 const bool m_hasStep; 123 const bool m_hasRangeLimitations { false }; 124 const bool m_hasStep { false }; 118 125 }; 119 126 -
trunk/Source/WebCore/html/TimeInputType.cpp
r194819 r202143 85 85 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumTime())); 86 86 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 87 return StepRange(stepBase, minimum, maximum, step, stepDescription);87 return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 88 88 } 89 89 -
trunk/Source/WebCore/html/WeekInputType.cpp
r194819 r202143 64 64 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumWeek())); 65 65 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 66 return StepRange(stepBase, minimum, maximum, step, stepDescription);66 return StepRange(stepBase, RangeLimitations::Valid, minimum, maximum, step, stepDescription); 67 67 } 68 68
Note: See TracChangeset
for help on using the changeset viewer.