Changeset 107030 in webkit
- Timestamp:
- Feb 7, 2012 7:40:33 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r107023 r107030 1 2012-02-07 Mike Lawther <mikelawther@chromium.org> 2 3 CSS3 calc() - simple parse time evaluation 4 https://bugs.webkit.org/show_bug.cgi?id=77960 5 6 Reviewed by Ojan Vafai. 7 8 * css3/calc/color-hsl-expected.txt: 9 * css3/calc/color-rgb-expected.txt: 10 1 11 2012-02-07 Chris Palmer <palmer@google.com> 2 12 -
trunk/LayoutTests/css3/calc/color-hsl-expected.txt
r104432 r107030 3 3 These two sentences should be the same color (alpha) 4 4 These two sentences should be the same color (alpha) 5 FAIL 5 PASS -
trunk/LayoutTests/css3/calc/color-rgb-expected.txt
r104432 r107030 7 7 These two sentences should be the same color (percent alpha) 8 8 These two sentences should be the same color (percent alpha) 9 FAIL 9 PASS -
trunk/Source/WebCore/ChangeLog
r107029 r107030 1 2012-02-07 Mike Lawther <mikelawther@chromium.org> 2 3 CSS3 calc() - simple parse time evaluation 4 https://bugs.webkit.org/show_bug.cgi?id=77960 5 6 Adds simple number/percent expression evaluation. rgb() and hsl() functions now 7 allow simple calc() expressions. 8 9 Reviewed by Ojan Vafai. 10 11 * css/CSSCalculationValue.cpp: 12 (WebCore): 13 (WebCore::CSSCalcValue::doubleValue): 14 (WebCore::CSSCalcPrimitiveValue::doubleValue): 15 (WebCore::CSSCalcBinaryOperation::doubleValue): 16 (CSSCalcBinaryOperation): 17 (WebCore::CSSCalcBinaryOperation::evaluate): 18 * css/CSSCalculationValue.h: 19 (CSSCalcExpressionNode): 20 (WebCore::CSSCalcValue::isInt): 21 (CSSCalcValue): 22 * css/CSSParser.cpp: 23 (WebCore::CSSParser::parsedDouble): 24 1 25 2012-02-07 Andreas Kling <awesomekling@apple.com> 2 26 -
trunk/Source/WebCore/css/CSSCalculationValue.cpp
r106166 r107030 77 77 return ""; 78 78 } 79 80 double CSSCalcValue::doubleValue() const 81 { 82 return m_expression->doubleValue(); 83 } 79 84 80 85 CSSCalcExpressionNode::~CSSCalcExpressionNode() … … 95 100 } 96 101 97 102 virtual double doubleValue() const 103 { 104 switch (m_category) { 105 case CalcNumber: 106 case CalcPercent: 107 return m_value->getDoubleValue(); 108 case CalcLength: 109 case CalcPercentLength: 110 case CalcPercentNumber: 111 case CalcOther: 112 ASSERT_NOT_REACHED(); 113 break; 114 } 115 return 0; 116 } 98 117 private: 99 118 explicit CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger) … … 153 172 } 154 173 174 virtual double doubleValue() const 175 { 176 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue()); 177 } 178 155 179 private: 156 180 CSSCalcBinaryOperation(PassRefPtr<CSSCalcExpressionNode> leftSide, PassRefPtr<CSSCalcExpressionNode> rightSide, CalcOperator op, CalculationCategory category) … … 160 184 , m_operator(op) 161 185 { 186 } 187 188 double evaluate(double leftValue, double rightValue) const 189 { 190 switch (m_operator) { 191 case CalcAdd: 192 return leftValue + rightValue; 193 case CalcSubtract: 194 return leftValue - rightValue; 195 case CalcMultiply: 196 return leftValue * rightValue; 197 case CalcDivide: 198 if (rightValue) 199 return leftValue / rightValue; 200 return std::numeric_limits<double>::quiet_NaN(); 201 case CalcMod: 202 // FIXME calc() : mod has been removed from the spec, need to remove 203 // this enum value 204 return 0; 205 } 206 return 0; 162 207 } 163 208 -
trunk/Source/WebCore/css/CSSCalculationValue.h
r106166 r107030 59 59 public: 60 60 61 virtual ~CSSCalcExpressionNode() = 0; 61 virtual ~CSSCalcExpressionNode() = 0; 62 virtual double doubleValue() const = 0; 62 63 63 64 CalculationCategory category() const { return m_category; } … … 81 82 82 83 CalculationCategory category() const { return m_expression->category(); } 83 bool isInt() const { return m_expression->isInteger(); } 84 bool isInt() const { return m_expression->isInteger(); } 85 double doubleValue() const; 84 86 85 87 String customCssText() const; -
trunk/Source/WebCore/css/CSSParser.cpp
r106756 r107030 4950 4950 inline double CSSParser::parsedDouble(CSSParserValue *v, ReleaseParsedCalcValueCondition releaseCalc) 4951 4951 { 4952 // FIXME calc (http://webkit.org/b/16662): evaluate calc here, eg 4953 // const double result = m_parsedCalculation ? m_parsedCalculation->doubleValue() : v->fValue; 4954 const double result = m_parsedCalculation ? 0 : v->fValue; 4952 const double result = m_parsedCalculation ? m_parsedCalculation->doubleValue() : v->fValue; 4955 4953 if (releaseCalc == ReleaseParsedCalcValue) 4956 4954 m_parsedCalculation.release();
Note: See TracChangeset
for help on using the changeset viewer.