Changeset 107688 in webkit
- Timestamp:
- Feb 14, 2012 1:46:48 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r107686 r107688 1 2012-02-14 Mike Lawther <mikelawther@chromium.org> 2 3 CSS3 calc: embed calc expressions in CSSPrimitiveValue 4 https://bugs.webkit.org/show_bug.cgi?id=78446 5 6 Reviewed by Ojan Vafai. 7 8 * css3/calc/block-mask-overlay-image-outset-expected.html: Renamed from LayoutTests/css3/calc/block-mask-overlay-image-outset-expected-mismatch.html. 9 * css3/calc/border-expected.txt: 10 * css3/calc/calc-errors-expected.txt: 11 * css3/calc/css3-radial-gradients-expected.html: Renamed from LayoutTests/css3/calc/css3-radial-gradients-expected-mismatch.html. 12 * css3/calc/font-expected.txt: 13 * css3/calc/font-monospace-expected.txt: 14 * css3/calc/font-size-expected.txt: 15 * css3/calc/font-size-fractional-expected.txt: 16 * css3/calc/getComputedStyle-margin-percentage-expected.txt: 17 * css3/calc/gradient-color-stops-expected.html: Renamed from LayoutTests/css3/calc/gradient-color-stops-expected-mismatch.html. 18 * css3/calc/line-height-expected.txt: 19 * css3/calc/margin-expected.txt: 20 * css3/calc/padding-expected.txt: 21 * css3/calc/simple-calcs-expected.txt: 22 * css3/calc/table-border-spacing-expected.txt: 23 1 24 2012-02-14 Philippe Normand <pnormand@igalia.com> 2 25 -
trunk/LayoutTests/css3/calc/border-expected.txt
r104428 r107688 1 This element should have an overall border of 25 pixels. => FAIL: wrong width, wrong height1 This element should have an overall border of 25 pixels. => PASS 2 2 3 This element should have a left border of 25 pixels. => FAIL: wrong width3 This element should have a left border of 25 pixels. => PASS 4 4 5 This element should have a right border of 25 pixels. => FAIL: wrong width5 This element should have a right border of 25 pixels. => PASS 6 6 7 This element should have a top border of 25 pixels. => FAIL: wrong height7 This element should have a top border of 25 pixels. => PASS 8 8 9 This element should have a bottom border of 25 pixels. => FAIL: wrong height9 This element should have a bottom border of 25 pixels. => PASS -
trunk/LayoutTests/css3/calc/calc-errors-expected.txt
r83415 r107688 4 4 unclosed calc with garbage => PASS 5 5 garbage => PASS 6 zero division => PASS6 zero division => FAIL: expected width of 100, but was 0 7 7 non length => PASS 8 8 number + length => PASS -
trunk/LayoutTests/css3/calc/font-expected.txt
r107420 r107688 4 4 5 5 6 FAIL getComputedStyle(document.getElementById("calc-size"), null).lineHeight should be 63px. Was normal. 7 FAIL getComputedStyle(document.getElementById("calc-size"), null).fontSize should be 24px. Was 16px. 8 FAIL getComputedStyle(document.getElementById("calc-height"), null).lineHeight should be 63px. Was normal. 6 PASS getComputedStyle(document.getElementById("calc-size"), null).lineHeight is "63px" 7 PASS getComputedStyle(document.getElementById("calc-size"), null).fontSize is "24px" 8 PASS getComputedStyle(document.getElementById("calc-height"), null).lineHeight is "63px" 9 9 PASS getComputedStyle(document.getElementById("calc-height"), null).fontSize is "24px" 10 FAIL getComputedStyle(document.getElementById("calc-both"), null).lineHeight should be 63px. Was normal. 11 FAIL getComputedStyle(document.getElementById("calc-both"), null).fontSize should be 24px. Was 16px. 12 FAIL getComputedStyle(document.getElementById("calc-percent-size"), null).lineHeight should be 63px. Was normal. 10 PASS getComputedStyle(document.getElementById("calc-both"), null).lineHeight is "63px" 11 PASS getComputedStyle(document.getElementById("calc-both"), null).fontSize is "24px" 12 PASS getComputedStyle(document.getElementById("calc-percent-size"), null).lineHeight is "63px" 13 13 FAIL getComputedStyle(document.getElementById("calc-percent-size"), null).fontSize should be 24px. Was 16px. 14 14 PASS successfullyParsed is true -
trunk/LayoutTests/css3/calc/font-monospace-expected.txt
r104431 r107688 1 1 The font size and line height of these lines should be identical 2 2 The font size and line height of these lines should be identical 3 FAIL 4 Line heights do not match 5 6 Font sizes do not match 3 PASS -
trunk/LayoutTests/css3/calc/font-size-expected.txt
r107425 r107688 4 4 5 5 6 FAIL getComputedStyle(document.getElementById("calc-percent"), null).fontSize should be 40px. Was 20px. 6 PASS getComputedStyle(document.getElementById("calc-percent"), null).fontSize is "40px" 7 7 FAIL getComputedStyle(document.getElementById("calc-percent-pixels"), null).fontSize should be 40px. Was 20px. 8 8 PASS successfullyParsed is true -
trunk/LayoutTests/css3/calc/font-size-fractional-expected.txt
r107464 r107688 4 4 5 5 6 FAIL getComputedStyle(document.getElementById("calc-reduce"), null).lineHeight should be 24px. Was normal. 7 FAIL getComputedStyle(document.getElementById("calc-reduce"), null).fontSize should be 10px. Was 12px. 6 PASS getComputedStyle(document.getElementById("calc-reduce"), null).lineHeight is "24px" 7 PASS getComputedStyle(document.getElementById("calc-reduce"), null).fontSize is "10px" 8 8 PASS successfullyParsed is true 9 9 -
trunk/LayoutTests/css3/calc/getComputedStyle-margin-percentage-expected.txt
r105647 r107688 4 4 5 5 6 FAIL getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-left') should be 253px. Was 0px. 7 FAIL getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-top') should be 76px. Was 0px. 8 FAIL getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-right') should be 346px. Was 0px. 9 FAIL getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-bottom') should be 530px. Was 0px. 6 PASS getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-left') is getComputedStyle(document.getElementById('control', null)).getPropertyValue('margin-left') 7 PASS getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-top') is getComputedStyle(document.getElementById('control', null)).getPropertyValue('margin-top') 8 PASS getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-right') is getComputedStyle(document.getElementById('control', null)).getPropertyValue('margin-right') 9 PASS getComputedStyle(document.getElementById('calc'), null).getPropertyValue('margin-bottom') is getComputedStyle(document.getElementById('control', null)).getPropertyValue('margin-bottom') 10 10 PASS successfullyParsed is true 11 11 -
trunk/LayoutTests/css3/calc/line-height-expected.txt
r104752 r107688 4 4 5 5 6 FAIL getComputedStyle(document.getElementById("calc-percent"), null).lineHeight should be 32px. Was normal. 6 PASS getComputedStyle(document.getElementById("calc-percent"), null).lineHeight is getComputedStyle(document.getElementById("control"), null).lineHeight 7 7 FAIL getComputedStyle(document.getElementById("calc-percent-pixels"), null).lineHeight should be 32px. Was normal. 8 8 PASS successfullyParsed is true -
trunk/LayoutTests/css3/calc/margin-expected.txt
r104783 r107688 1 FAIL document.getElementById("simple-all").parentNode.offsetWidth should be 250. Was 200. 2 FAIL document.getElementById("simple-all").parentNode.offsetHeight should be 170. Was 120. 3 FAIL document.getElementById("simple-left").parentNode.offsetWidth should be 225. Was 200. 1 PASS document.getElementById("simple-all").parentNode.offsetWidth is 250 2 PASS document.getElementById("simple-all").parentNode.offsetHeight is 170 3 PASS document.getElementById("simple-left").parentNode.offsetWidth is 225 4 4 PASS document.getElementById("simple-left").parentNode.offsetHeight is 120 5 FAIL document.getElementById("simple-right").parentNode.offsetWidth should be 225. Was 200. 5 PASS document.getElementById("simple-right").parentNode.offsetWidth is 225 6 6 PASS document.getElementById("simple-right").parentNode.offsetHeight is 120 7 7 PASS document.getElementById("simple-top").parentNode.offsetWidth is 200 8 FAIL document.getElementById("simple-top").parentNode.offsetHeight should be 145. Was 120. 8 PASS document.getElementById("simple-top").parentNode.offsetHeight is 145 9 9 PASS document.getElementById("simple-bottom").parentNode.offsetWidth is 200 10 FAIL document.getElementById("simple-bottom").parentNode.offsetHeight should be 145. Was 120. 10 PASS document.getElementById("simple-bottom").parentNode.offsetHeight is 145 11 11 FAIL document.getElementById("percent-all").parentNode.offsetWidth should be 250. Was 200. 12 12 FAIL document.getElementById("percent-all").parentNode.offsetHeight should be 170. Was 120. -
trunk/LayoutTests/css3/calc/padding-expected.txt
r104653 r107688 1 This element should have an overall padding of 25 pixels. => FAIL: wrong width, wrong height1 This element should have an overall padding of 25 pixels. => PASS 2 2 3 This element should have a left padding of 25 pixels. => FAIL: wrong width3 This element should have a left padding of 25 pixels. => PASS 4 4 5 This element should have a right padding of 25 pixels. => FAIL: wrong width5 This element should have a right padding of 25 pixels. => PASS 6 6 7 This element should have a top padding of 25 pixels. => FAIL: wrong height7 This element should have a top padding of 25 pixels. => PASS 8 8 9 This element should have a bottom padding of 25 pixels. => FAIL: wrong height9 This element should have a bottom padding of 25 pixels. => PASS 10 10 11 11 This element should have an overall padding of 25 pixels (10% of parent width of 300px minus 5px). => FAIL: wrong width, wrong height -
trunk/LayoutTests/css3/calc/simple-calcs-expected.txt
r107259 r107688 2 2 3 3 control => PASS 4 50px + 50px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 2565 150px - 50px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 2566 50px + 50px (2 spaces around operator) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 2567 150px - 50px (2 spaces around operator) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 2568 50px*2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 2569 50px *2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25610 50px* 2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25611 200px/2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25612 200px /2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25613 200px/ 2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25614 50px*(2) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25615 50px *(2) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25616 50px* (2) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25617 50px*(1 + 1) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25618 50px*(12 - 10) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25619 50px*(10 / 5) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25620 10px* (5 * 2) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25621 50px + 10px * 5 (operation order) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25622 100%/2 (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 2564 50px + 50px => PASS 5 150px - 50px => PASS 6 50px + 50px (2 spaces around operator) => PASS 7 150px - 50px (2 spaces around operator) => PASS 8 50px*2 => PASS 9 50px *2 => PASS 10 50px* 2 => PASS 11 200px/2 => PASS 12 200px /2 => PASS 13 200px/ 2 => PASS 14 50px*(2) => PASS 15 50px *(2) => PASS 16 50px* (2) => PASS 17 50px*(1 + 1) => PASS 18 50px*(12 - 10) => PASS 19 50px*(10 / 5) => PASS 20 10px* (5 * 2) => PASS 21 50px + 10px * 5 (operation order) => PASS 22 100%/2 (where 100% is 200px) => PASS 23 23 100% + -100px (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 256 24 24 80% - 60px (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 256 25 25 300px - 100% (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 256 26 26 -100px + 100% (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 256 27 20% + 30% (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25628 80% - 30% (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25629 10% * 5 (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25630 5 * 10% (where 100% is 200px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25631 (100px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25632 (50px + 50px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25633 (50px) + 50px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25634 50px + (50px) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25635 50px + 50px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25636 50px + 25px * 2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25637 (25px + 25px) * 2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25638 2 * 50px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25639 2 * 100px / 2 => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25640 (1em - 1em) + 100px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25641 50px + +50px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25642 -50px + 150px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25643 -50px - -150px => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25644 (((((((100px))))))) => FAIL: @zoom=1 expected width of 100, but was 256; @zoom=1.2 expected width of 100, but was 256; @zoom=2 expected width of 100, but was 25645 100px => FAIL: @zoom=1 expected height of 100, but was 50; @zoom=1.2 expected height of 100, but was 50; @zoom=2 expected height of 100, but was 5046 100% * 2 => FAIL: @zoom=1 expected height of 100, but was 50; @zoom=1.2 expected height of 100, but was 50; @zoom=2 expected height of 100, but was 5027 20% + 30% (where 100% is 200px) => PASS 28 80% - 30% (where 100% is 200px) => PASS 29 10% * 5 (where 100% is 200px) => PASS 30 5 * 10% (where 100% is 200px) => PASS 31 (100px) => PASS 32 (50px + 50px) => PASS 33 (50px) + 50px => PASS 34 50px + (50px) => PASS 35 50px + 50px => PASS 36 50px + 25px * 2 => PASS 37 (25px + 25px) * 2 => PASS 38 2 * 50px => PASS 39 2 * 100px / 2 => PASS 40 (1em - 1em) + 100px => PASS 41 50px + +50px => PASS 42 -50px + 150px => PASS 43 -50px - -150px => PASS 44 (((((((100px))))))) => PASS 45 100px => PASS 46 100% * 2 => PASS -
trunk/LayoutTests/css3/calc/table-border-spacing-expected.txt
r105869 r107688 1 FAIL document.getElementById("stimulus").offsetWidth should be 416. Was 278. 2 FAIL document.getElementById("stimulus").offsetHeight should be 205. Was 136. 1 PASS document.getElementById("stimulus").offsetWidth is 416 2 PASS document.getElementById("stimulus").offsetHeight is 205 3 3 PASS successfullyParsed is true 4 4 -
trunk/Source/WebCore/ChangeLog
r107687 r107688 1 2012-02-14 Mike Lawther <mikelawther@chromium.org> 2 3 CSS3 calc: embed calc expressions in CSSPrimitiveValue 4 https://bugs.webkit.org/show_bug.cgi?id=78446 5 6 Reviewed by Ojan Vafai. 7 8 Adds calc expressions to CSSPrimitiveValue. This enables simple (ie no mixing of 9 percents with numbers/lengths) expressions to be evaluated on most properties. 10 11 Tests: css3/calc/block-mask-overlay-image-outset-expected.html 12 css3/calc/css3-radial-gradients-expected.html 13 css3/calc/gradient-color-stops-expected.html 14 15 * css/CSSCalculationValue.cpp: 16 (WebCore::CSSCalcValue::computeLengthPx): 17 (WebCore): 18 (WebCore::CSSCalcPrimitiveValue::doubleValue): 19 (CSSCalcPrimitiveValue): 20 (WebCore::CSSCalcPrimitiveValue::computeLengthPx): 21 (CSSCalcBinaryOperation): 22 (WebCore::CSSCalcBinaryOperation::computeLengthPx): 23 * css/CSSCalculationValue.h: 24 (CSSCalcExpressionNode): 25 (CSSCalcValue): 26 * css/CSSParser.cpp: 27 (WebCore::CSSParser::createPrimitiveNumericValue): 28 (WebCore::CSSParser::parseValidPrimitive): 29 * css/CSSPrimitiveValue.cpp: 30 (WebCore::isValidCSSUnitTypeForDoubleConversion): 31 (WebCore::CSSPrimitiveValue::primitiveType): 32 (WebCore::CSSPrimitiveValue::init): 33 (WebCore): 34 (WebCore::CSSPrimitiveValue::cleanup): 35 (WebCore::CSSPrimitiveValue::computeLengthDouble): 36 (WebCore::CSSPrimitiveValue::getDoubleValue): 37 (WebCore::CSSPrimitiveValue::getDoubleValueInternal): 38 (WebCore::CSSPrimitiveValue::customCssText): 39 * css/CSSPrimitiveValue.h: 40 (WebCore): 41 (WebCore::CSSPrimitiveValue::isLength): 42 (WebCore::CSSPrimitiveValue::isNumber): 43 (WebCore::CSSPrimitiveValue::isPercentage): 44 (WebCore::CSSPrimitiveValue::isPx): 45 (WebCore::CSSPrimitiveValue::isCalculated): 46 (WebCore::CSSPrimitiveValue::isCalculatedPercentageNumber): 47 (WebCore::CSSPrimitiveValue::isCalculatedPercentageLength): 48 (CSSPrimitiveValue): 49 (WebCore::CSSPrimitiveValue::getValue): 50 (WebCore::CSSPrimitiveValue::cssCalcValue): 51 * css/CSSStyleApplyProperty.cpp: 52 (WebCore::ApplyPropertyBorderRadius::applyValue): 53 1 54 2012-02-14 Pavel Feldman <pfeldman@chromium.org> 2 55 -
trunk/Source/WebCore/css/CSSCalculationValue.cpp
r107259 r107688 1 1 /* 2 * Copyright (C) 2011 Google Inc. All rights reserved.2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 83 83 } 84 84 85 double CSSCalcValue::computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const 86 { 87 return m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize); 88 } 89 85 90 CSSCalcExpressionNode::~CSSCalcExpressionNode() 86 91 { … … 114 119 } 115 120 return 0; 116 } 121 } 122 123 virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const 124 { 125 switch (m_category) { 126 case CalcLength: 127 return m_value->computeLength<double>(currentStyle, rootStyle, multiplier, computingFontSize); 128 case CalcPercent: 129 case CalcNumber: 130 return m_value->getDoubleValue(); 131 case CalcPercentLength: 132 case CalcPercentNumber: 133 case CalcOther: 134 ASSERT_NOT_REACHED(); 135 break; 136 } 137 return 0; 138 } 139 117 140 private: 118 141 explicit CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger) … … 175 198 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue()); 176 199 } 200 201 virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const 202 { 203 const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize); 204 const double rightValue = m_rightSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize); 205 return evaluate(leftValue, rightValue); 206 } 177 207 178 208 private: -
trunk/Source/WebCore/css/CSSCalculationValue.h
r107030 r107688 1 1 /* 2 * Copyright (C) 2011 Google Inc. All rights reserved.2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 61 61 virtual ~CSSCalcExpressionNode() = 0; 62 62 virtual double doubleValue() const = 0; 63 virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0; 63 64 64 65 CalculationCategory category() const { return m_category; } … … 84 85 bool isInt() const { return m_expression->isInteger(); } 85 86 double doubleValue() const; 87 double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const; 86 88 87 89 String customCssText() const; -
trunk/Source/WebCore/css/CSSParser.cpp
r107516 r107688 801 801 if (m_parsedCalculation) { 802 802 ASSERT(isCalculation(value)); 803 // FIXME calc() http://webkit.org/b/16662: create a CSSPrimitiveValue here, ie 804 // return CSSPrimitiveValue::create(m_parsedCalculation.release()); 805 m_parsedCalculation.release(); 806 return 0; 803 return CSSPrimitiveValue::create(m_parsedCalculation.release()); 807 804 } 808 805 … … 905 902 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS); 906 903 if (isCalculation(value)) 907 // FIXME calc() http://webkit.org/b/16662: create a primitive value here, ie 908 // return CSSPrimitiveValue::create(m_parsedCalculation.release()); 909 m_parsedCalculation.release(); 904 return CSSPrimitiveValue::create(m_parsedCalculation.release()); 910 905 911 906 return 0; -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r106251 r107688 22 22 #include "CSSPrimitiveValue.h" 23 23 24 #include "CSSCalculationValue.h" 24 25 #include "CSSHelper.h" 25 26 #include "CSSParser.h" … … 28 29 #include "CSSValueKeywords.h" 29 30 #include "CSSWrapShapes.h" 31 #include "CalculationValue.h" 30 32 #include "Color.h" 31 33 #include "Counter.h" … … 53 55 { 54 56 switch (unitType) { 57 case CSSPrimitiveValue:: CSS_CALC: 58 case CSSPrimitiveValue:: CSS_CALC_PERCENTAGE_WITH_NUMBER: 59 case CSSPrimitiveValue:: CSS_CALC_PERCENTAGE_WITH_LENGTH: 55 60 case CSSPrimitiveValue:: CSS_CM: 56 61 case CSSPrimitiveValue:: CSS_DEG: … … 138 143 } 139 144 145 unsigned short CSSPrimitiveValue::primitiveType() const 146 { 147 if (m_primitiveUnitType != CSSPrimitiveValue::CSS_CALC) 148 return m_primitiveUnitType; 149 150 switch (m_value.calc->category()) { 151 case CalcNumber: 152 return CSSPrimitiveValue::CSS_NUMBER; 153 case CalcPercent: 154 return CSSPrimitiveValue::CSS_PERCENTAGE; 155 case CalcLength: 156 return CSSPrimitiveValue::CSS_PX; 157 case CalcPercentNumber: 158 return CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER; 159 case CalcPercentLength: 160 return CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH; 161 case CalcOther: 162 return CSSPrimitiveValue::CSS_UNKNOWN; 163 } 164 return CSSPrimitiveValue::CSS_UNKNOWN; 165 } 140 166 static const AtomicString& valueOrPropertyName(int valueOrPropertyID) 141 167 { … … 283 309 m_hasCachedCSSText = false; 284 310 m_value.pair = p.leakRef(); 311 } 312 313 void CSSPrimitiveValue::init(PassRefPtr<CSSCalcValue> c) 314 { 315 m_primitiveUnitType = CSS_CALC; 316 m_hasCachedCSSText = false; 317 m_value.calc = c.leakRef(); 285 318 } 286 319 … … 325 358 break; 326 359 #endif 360 case CSS_CALC: 361 m_value.calc->deref(); 362 break; 327 363 case CSS_SHAPE: 328 364 m_value.shape->deref(); … … 438 474 factor = cssPixelsPerInch * 12.0 / 72.0; 439 475 break; 476 case CSS_CALC_PERCENTAGE_WITH_LENGTH: 477 case CSS_CALC_PERCENTAGE_WITH_NUMBER: 478 ASSERT_NOT_REACHED(); 479 return -1.0; 440 480 default: 441 481 ASSERT_NOT_REACHED(); … … 443 483 } 444 484 445 double result = getDoubleValue() * factor; 485 double computedValue; 486 if (m_primitiveUnitType == CSS_CALC) 487 // The multiplier is passed in as 1.0 here to ensure it is only applied once 488 computedValue = m_value.calc->computeLengthPx(style, rootStyle, 1.0, computingFontSize); 489 else 490 computedValue = getDoubleValue(); 491 492 double result = computedValue * factor; 446 493 if (!applyZoomMultiplier || multiplier == 1.0f) 447 494 return result; … … 527 574 getDoubleValueInternal(static_cast<UnitTypes>(unitType), &result); 528 575 return result; 576 } 577 578 double CSSPrimitiveValue::getDoubleValue() const 579 { 580 return m_primitiveUnitType != CSS_CALC ? m_value.num : m_value.calc->doubleValue(); 529 581 } 530 582 … … 555 607 if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitTypes>(m_primitiveUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType)) 556 608 return false; 557 if (requestedUnitType == static_cast<UnitTypes>(m_primitiveUnitType) || requestedUnitType == CSS_DIMENSION) { 558 *result = m_value.num; 609 610 UnitTypes sourceUnitType = static_cast<UnitTypes>(primitiveType()); 611 if (requestedUnitType == sourceUnitType || requestedUnitType == CSS_DIMENSION) { 612 *result = getDoubleValue(); 559 613 return true; 560 614 } 561 615 562 UnitTypes sourceUnitType = static_cast<UnitTypes>(m_primitiveUnitType);563 616 UnitCategory sourceCategory = unitCategory(sourceUnitType); 564 617 ASSERT(sourceCategory != UOther); … … 586 639 } 587 640 588 double convertedValue = m_value.num;641 double convertedValue = getDoubleValue(); 589 642 590 643 // First convert the value from m_primitiveUnitType to canonical type. … … 959 1012 text = quoteCSSStringIfNeeded(m_value.string); 960 1013 break; 1014 case CSS_CALC: 1015 text = m_value.calc->cssText(); 1016 break; 961 1017 case CSS_SHAPE: 962 1018 text = m_value.shape->cssText(); -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r105693 r107688 31 31 namespace WebCore { 32 32 33 class CSSCalcValue; 33 34 class Counter; 34 35 class DashboardRegion; … … 103 104 104 105 // Used by border images. 105 CSS_QUAD = 111 106 CSS_QUAD = 111, 107 108 CSS_CALC = 112, 109 CSS_CALC_PERCENTAGE_WITH_NUMBER = 113, 110 CSS_CALC_PERCENTAGE_WITH_LENGTH = 114 106 111 }; 107 112 … … 134 139 bool isLength() const 135 140 { 136 return (m_primitiveUnitType >= CSS_EMS && m_primitiveUnitType <= CSS_PC)137 || m_primitiveUnitType == CSS_REMS;138 } 139 bool isNumber() const { return m_primitiveUnitType== CSS_NUMBER; }140 bool isPercentage() const { return m_primitiveUnitType== CSS_PERCENTAGE; }141 bool isPx() const { return m_primitiveUnitType== CSS_PX; }141 unsigned short type = primitiveType(); 142 return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS; 143 } 144 bool isNumber() const { return primitiveType() == CSS_NUMBER; } 145 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; } 146 bool isPx() const { return primitiveType() == CSS_PX; } 142 147 bool isRect() const { return m_primitiveUnitType == CSS_RECT; } 143 148 bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; } … … 146 151 bool isTime() const { return m_primitiveUnitType == CSS_S || m_primitiveUnitType == CSS_MS; } 147 152 bool isURI() const { return m_primitiveUnitType == CSS_URI; } 148 153 bool isCalculated() const { return m_primitiveUnitType == CSS_CALC; } 154 bool isCalculatedPercentageWithNumber() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_NUMBER; } 155 bool isCalculatedPercentageWithLength() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_LENGTH; } 149 156 150 157 static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); } … … 173 180 void cleanup(); 174 181 175 unsigned short primitiveType() const { return m_primitiveUnitType; }182 unsigned short primitiveType() const; 176 183 177 184 double computeDegrees(); … … 212 219 double getDoubleValue(unsigned short unitType, ExceptionCode&) const; 213 220 double getDoubleValue(unsigned short unitType) const; 214 double getDoubleValue() const { return m_value.num; }221 double getDoubleValue() const; 215 222 216 223 void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&); … … 225 232 template<typename T> inline T getValue(unsigned short unitType, ExceptionCode& ec) const { return clampTo<T>(getDoubleValue(unitType, ec)); } 226 233 template<typename T> inline T getValue(unsigned short unitType) const { return clampTo<T>(getDoubleValue(unitType)); } 227 template<typename T> inline T getValue() const { return clampTo<T>( m_value.num); }234 template<typename T> inline T getValue() const { return clampTo<T>(getDoubleValue()); } 228 235 229 236 void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&); … … 249 256 250 257 CSSWrapShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? 0 : m_value.shape; } 258 259 CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; } 251 260 252 261 int getIdent() const { return m_primitiveUnitType == CSS_IDENT ? m_value.ident : 0; } … … 302 311 void init(PassRefPtr<DashboardRegion>); // FIXME: Dashboard region should not be a primitive value. 303 312 void init(PassRefPtr<CSSWrapShape>); 304 313 void init(PassRefPtr<CSSCalcValue>); 305 314 bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const; 306 315 … … 318 327 DashboardRegion* region; 319 328 CSSWrapShape* shape; 329 CSSCalcValue* calc; 320 330 } m_value; 321 331 }; -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r107528 r107688 441 441 if (pair->first()->isPercentage()) 442 442 radiusWidth = Length(pair->first()->getDoubleValue(), Percent); 443 else 443 else if (pair->first()->isCalculatedPercentageWithLength()) { 444 // FIXME calc(): http://webkit.org/b/16662 445 // handle this case 446 return; 447 } else 444 448 radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed); 445 449 if (pair->second()->isPercentage()) 446 450 radiusHeight = Length(pair->second()->getDoubleValue(), Percent); 447 else 451 else if (pair->second()->isCalculatedPercentageWithLength()) { 452 // FIXME calc(): http://webkit.org/b/16662 453 // handle this case 454 return; 455 } else 448 456 radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed); 449 457 int width = radiusWidth.value();
Note: See TracChangeset
for help on using the changeset viewer.