Changeset 178156 in webkit
- Timestamp:
- Jan 8, 2015 9:29:09 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r178150 r178156 1 2015-01-08 Chris Dumez <cdumez@apple.com> 2 3 ASSERTION FAILED: !valueWithCalculation.calculation() in WebCore::CSSParser::validateCalculationUnit 4 https://bugs.webkit.org/show_bug.cgi?id=140251 5 6 Reviewed by Darin Adler. 7 8 Add a layout test to check that using calculated values for 9 'text-shadow' CSS doesn't crash and works as intended. Also check 10 that the CSS parser is correctly validating the blur-radius, which 11 is supposed to be non-negative, as per the specification: 12 - http://dev.w3.org/csswg/css-text-decor-3/#text-shadow-property 13 - http://dev.w3.org/csswg/css-backgrounds-3/#shadow 14 15 * fast/css/text-shadow-calc-value-expected.txt: Added. 16 * fast/css/text-shadow-calc-value.html: Added. 17 1 18 2015-01-08 Benjamin Poulain <bpoulain@apple.com> 2 19 -
trunk/Source/WebCore/ChangeLog
r178154 r178156 1 2015-01-08 Chris Dumez <cdumez@apple.com> 2 3 ASSERTION FAILED: !valueWithCalculation.calculation() in WebCore::CSSParser::validateCalculationUnit 4 https://bugs.webkit.org/show_bug.cgi?id=140251 5 6 Reviewed by Darin Adler. 7 8 Using a calculated value for text-shadow's blur-radius was hitting an 9 assertion in CSSParser::validateCalculationUnit() because validUnit() 10 is called twice, first with 'FLength' unit, then more stricly with 11 'FLength|FNonNeg' if parsing the blur-radius as it cannot be negative 12 as per the specification: 13 - http://dev.w3.org/csswg/css-text-decor-3/#text-shadow-property 14 - http://dev.w3.org/csswg/css-backgrounds-3/#shadow 15 16 On the second call, the ValueWithCalculation's m_calculation member 17 was already initialized and the code did not handle this. This patch 18 updates validateCalculationUnit() to teach it to reuse the previously 19 parsed calculation in this case. All it needs to do is to update the 20 existing CSSCalcValue's range to allow negative values or not. 21 22 When writing the layout test for this, I also noticed that the CSS 23 parser was not rejecting negative calculated values for blur-radius 24 (only negative non-calculated ones). This is because 25 validateCalculationUnit() was ignoring FNonNeg if the calculated 26 value is a Length. This patch also addresses the issue. 27 28 Test: fast/css/text-shadow-calc-value.html 29 30 * css/CSSCalculationValue.h: 31 (WebCore::CSSCalcValue::setPermittedValueRange): 32 Add a setter to update the CSSCalculationValue's permitted value range 33 so that the CSS parser does not need to fully reparse the calculation 34 only to update the permitted value range. 35 36 * css/CSSParser.cpp: 37 (WebCore::CSSParser::validateCalculationUnit): 38 - Teach the code to reuse the previously parsed calculation value. 39 - Do the FNonNeg check for Length calculations as well. 40 1 41 2015-01-08 Darin Adler <darin@apple.com> 2 42 -
trunk/Source/WebCore/css/CSSCalculationValue.h
r177947 r178156 98 98 99 99 Ref<CalculationValue> createCalculationValue(const CSSToLengthConversionData&) const; 100 void setPermittedValueRange(CalculationPermittedValueRange); 100 101 101 102 String customCSSText() const; … … 108 109 109 110 const Ref<CSSCalcExpressionNode> m_expression; 110 constbool m_shouldClampToNonNegative;111 bool m_shouldClampToNonNegative; 111 112 }; 112 113 … … 124 125 } 125 126 127 inline void CSSCalcValue::setPermittedValueRange(CalculationPermittedValueRange range) 128 { 129 m_shouldClampToNonNegative = range != CalculationRangeAll; 130 } 131 126 132 } // namespace WebCore 127 133 -
trunk/Source/WebCore/css/CSSParser.cpp
r178010 r178156 1587 1587 bool mustBeNonNegative = unitFlags & FNonNeg; 1588 1588 1589 ASSERT(!valueWithCalculation.calculation()); 1590 RefPtr<CSSCalcValue> calculation = parseCalculation(valueWithCalculation, mustBeNonNegative ? CalculationRangeNonNegative : CalculationRangeAll); 1591 if (!calculation) 1592 return false; 1589 RefPtr<CSSCalcValue> calculation; 1590 if (valueWithCalculation.calculation()) { 1591 // The calculation value was already parsed so we reuse it. However, we may need to update its range. 1592 calculation = valueWithCalculation.calculation(); 1593 calculation->setPermittedValueRange(mustBeNonNegative ? CalculationRangeNonNegative : CalculationRangeAll); 1594 } else { 1595 valueWithCalculation.setCalculation(parseCalculation(valueWithCalculation, mustBeNonNegative ? CalculationRangeNonNegative : CalculationRangeAll)); 1596 calculation = valueWithCalculation.calculation(); 1597 if (!calculation) 1598 return false; 1599 } 1593 1600 1594 1601 bool isValid = false; … … 1605 1612 case CalcLength: 1606 1613 isValid = (unitFlags & FLength); 1614 if (isValid && mustBeNonNegative && calculation->isNegative()) 1615 isValid = false; 1607 1616 break; 1608 1617 case CalcPercent: … … 1629 1638 break; 1630 1639 } 1631 if (isValid) 1632 valueWithCalculation.setCalculation(WTF::move(calculation)); 1640 1633 1641 return isValid; 1634 1642 }
Note: See TracChangeset
for help on using the changeset viewer.