Changeset 106166 in webkit
- Timestamp:
- Jan 27, 2012 4:05:00 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r106156 r106166 433 433 css/CSSBorderImage.cpp 434 434 css/CSSBorderImageSliceValue.cpp 435 css/CSSCalculationValue.cpp 435 436 css/CSSCanvasValue.cpp 436 437 css/CSSCharsetRule.cpp … … 1046 1047 1047 1048 platform/Arena.cpp 1049 platform/CalculationValue.cpp 1048 1050 platform/Clock.cpp 1049 1051 platform/ContextMenu.cpp -
trunk/Source/WebCore/ChangeLog
r106163 r106166 1 2012-01-27 Mike Lawther <mikelawther@chromium.org> 2 3 CSS calc parsing stage 4 https://bugs.webkit.org/show_bug.cgi?id=57082 5 6 This is the parsing stage of calc. The expressions are evaluated and 7 expression trees are generated. CSS values are not created yet - that 8 will happen in a subsequent commit. 9 10 Reviewed by David Hyatt. 11 12 No functional change - covered by existing tests in LayoutTests/css3/calc. 13 14 * CMakeLists.txt: 15 * GNUmakefile.list.am: 16 * Target.pri: 17 * WebCore.gypi: 18 * WebCore.vcproj/WebCore.vcproj: 19 * WebCore.xcodeproj/project.pbxproj: 20 * css/CSSCalculationValue.cpp: Added. 21 (WebCore): 22 (WebCore::unitCategory): 23 (WebCore::CSSCalcValue::customCssText): 24 (WebCore::CSSCalcExpressionNode::~CSSCalcExpressionNode): 25 (CSSCalcPrimitiveValue): 26 (WebCore::CSSCalcPrimitiveValue::create): 27 (WebCore::CSSCalcPrimitiveValue::cssText): 28 (WebCore::CSSCalcPrimitiveValue::CSSCalcPrimitiveValue): 29 (): 30 (CSSCalcBinaryOperation): 31 (WebCore::CSSCalcBinaryOperation::create): 32 (WebCore::CSSCalcBinaryOperation::CSSCalcBinaryOperation): 33 (WebCore::checkDepthAndIndex): 34 (CSSCalcExpressionNodeParser): 35 (WebCore::CSSCalcExpressionNodeParser::parseCalc): 36 (Value): 37 (WebCore::CSSCalcExpressionNodeParser::operatorValue): 38 (WebCore::CSSCalcExpressionNodeParser::parseValue): 39 (WebCore::CSSCalcExpressionNodeParser::parseValueTerm): 40 (WebCore::CSSCalcExpressionNodeParser::parseValueMultiplicativeExpression): 41 (WebCore::CSSCalcExpressionNodeParser::parseAdditiveValueExpression): 42 (WebCore::CSSCalcExpressionNodeParser::parseValueExpression): 43 (WebCore::CSSCalcValue::create): 44 * css/CSSCalculationValue.h: Added. 45 (WebCore): 46 (): 47 (CSSCalcExpressionNode): 48 (WebCore::CSSCalcExpressionNode::category): 49 (WebCore::CSSCalcExpressionNode::isInt): 50 (WebCore::CSSCalcExpressionNode::isZero): 51 (WebCore::CSSCalcExpressionNode::CSSCalcExpressionNode): 52 (CSSCalcValue): 53 (WebCore::CSSCalcValue::category): 54 (WebCore::CSSCalcValue::isInt): 55 (WebCore::CSSCalcValue::CSSCalcValue): 56 * css/CSSParser.cpp: 57 (WebCore::CSSParser::validCalculationUnit): 58 (WebCore): 59 (WebCore::CSSParser::validUnit): 60 (WebCore::CSSParser::createPrimitiveNumericValue): 61 (WebCore::CSSParser::parseValidPrimitive): 62 (WebCore::CSSParser::parseValue): 63 (WebCore::CSSParser::parseFillPositionComponent): 64 (WebCore::CSSParser::parsedDouble): 65 (WebCore::CSSParser::isCalculation): 66 (WebCore::CSSParser::colorIntFromValue): 67 (WebCore::CSSParser::parseColorParameters): 68 (WebCore::CSSParser::parseHSLParameters): 69 (WebCore::ShadowParseContext::ShadowParseContext): 70 (WebCore::ShadowParseContext::commitLength): 71 (WebCore::ShadowParseContext::commitStyle): 72 (ShadowParseContext): 73 (WebCore::CSSParser::parseShadow): 74 (WebCore::BorderImageSliceParseContext::BorderImageSliceParseContext): 75 (WebCore::BorderImageSliceParseContext::commitNumber): 76 (WebCore::BorderImageSliceParseContext::commitBorderImageSlice): 77 (BorderImageSliceParseContext): 78 (WebCore::CSSParser::parseBorderImageSlice): 79 (WebCore::BorderImageQuadParseContext::BorderImageQuadParseContext): 80 (WebCore::BorderImageQuadParseContext::commitNumber): 81 (WebCore::BorderImageQuadParseContext::commitBorderImageQuad): 82 (BorderImageQuadParseContext): 83 (WebCore::CSSParser::parseBorderImageQuad): 84 (WebCore::CSSParser::parseCalculation): 85 * css/CSSParser.h: 86 (): 87 (CSSParser): 88 * css/CSSValue.cpp: 89 (WebCore::CSSValue::cssText): 90 (WebCore::CSSValue::destroy): 91 * css/CSSValue.h: 92 (WebCore::CSSValue::isCalculationValue): 93 (): 94 * css/SVGCSSParser.cpp: 95 (WebCore::CSSParser::parseSVGValue): 96 * platform/CalculationValue.cpp: Added. 97 (WebCore): 98 * platform/CalculationValue.h: Added. 99 (WebCore): 100 (): 101 1 102 2012-01-27 Anders Carlsson <andersca@apple.com> 2 103 -
trunk/Source/WebCore/GNUmakefile.list.am
r106156 r106166 1292 1292 Source/WebCore/css/CSSCharsetRule.cpp \ 1293 1293 Source/WebCore/css/CSSCharsetRule.h \ 1294 Source/WebCore/css/CSSCalculationValue.cpp \ 1295 Source/WebCore/css/CSSCalculationValue.h \ 1294 1296 Source/WebCore/css/CSSComputedStyleDeclaration.cpp \ 1295 1297 Source/WebCore/css/CSSComputedStyleDeclaration.h \ … … 2797 2799 Source/WebCore/platform/AsyncFileSystem.h \ 2798 2800 Source/WebCore/platform/AutodrainedPool.h \ 2801 Source/WebCore/platform/CalculationValue.cpp \ 2802 Source/WebCore/platform/CalculationValue.h \ 2799 2803 Source/WebCore/platform/Clock.cpp \ 2800 2804 Source/WebCore/platform/Clock.h \ -
trunk/Source/WebCore/Target.pri
r106156 r106166 396 396 css/CSSBorderImageSliceValue.cpp \ 397 397 css/CSSBorderImage.cpp \ 398 css/CSSCalculationValue.cpp \ 398 399 css/CSSCanvasValue.cpp \ 399 400 css/CSSCharsetRule.cpp \ … … 1028 1029 platform/text/LocalizedNumberNone.cpp \ 1029 1030 platform/text/QuotedPrintable.cpp \ 1031 platform/CalculationValue.cpp \ 1030 1032 platform/Clock.cpp \ 1031 1033 platform/ClockGeneric.cpp \ … … 1508 1510 css/CSSAspectRatioValue.h \ 1509 1511 css/CSSBorderImageSliceValue.h \ 1512 css/CSSBorderImageValue.h \ 1510 1513 css/CSSBorderImage.h \ 1514 css/CSSBorderImageValue.h \ 1515 css/CSSCalculationValue.h \ 1511 1516 css/CSSCanvasValue.h \ 1512 1517 css/CSSCharsetRule.h \ … … 2078 2083 platform/Arena.h \ 2079 2084 platform/AsyncFileStream.h \ 2085 platform/CalculationValue.h \ 2080 2086 platform/Clock.h \ 2081 2087 platform/ClockGeneric.h \ -
trunk/Source/WebCore/WebCore.gypi
r106156 r106166 1985 1985 'css/CSSCanvasValue.cpp', 1986 1986 'css/CSSCanvasValue.h', 1987 'css/CSSCalculationValue.cpp', 1988 'css/CSSCalculationValue.h', 1987 1989 'css/CSSCharsetRule.cpp', 1988 1990 'css/CSSCharsetRule.h', … … 2717 2719 'platform/AsyncFileSystemCallbacks.h', 2718 2720 'platform/AutodrainedPool.h', 2721 'platform/CalculationValue.cpp', 2722 'platform/CalculationValue.h', 2719 2723 'platform/Clock.cpp', 2720 2724 'platform/Clock.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r106156 r106166 26463 26463 </File> 26464 26464 <File 26465 RelativePath="..\platform\CalculationValue.cpp" 26466 > 26467 </File> 26468 <File 26469 RelativePath="..\platform\CalculationValue.h" 26470 > 26471 </File> 26472 <File 26465 26473 RelativePath="..\platform\Clock.cpp" 26466 26474 > … … 32807 32815 </File> 32808 32816 <File 32817 RelativePath="..\css\CSSCalculationValue.cpp" 32818 > 32819 </File> 32820 <File 32821 RelativePath="..\css\CSSCalculationValue.h" 32822 > 32823 </File> 32824 <File 32809 32825 RelativePath="..\css\CSSCanvasValue.cpp" 32810 32826 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r106156 r106166 1229 1229 499B3ED7128CD31400E726C2 /* GraphicsLayerCA.h in Headers */ = {isa = PBXBuildFile; fileRef = 499B3ED5128CD31400E726C2 /* GraphicsLayerCA.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1230 1230 499B3EDD128DB50200E726C2 /* PlatformCAAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1231 49AE2D8E134EE50C0072920A /* CSSCalculationValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AE2D8C134EE50C0072920A /* CSSCalculationValue.cpp */; }; 1232 49AE2D8F134EE50C0072920A /* CSSCalculationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AE2D8D134EE50C0072920A /* CSSCalculationValue.h */; }; 1233 49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AE2D94134EE5F90072920A /* CalculationValue.cpp */; }; 1234 49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AE2D95134EE5F90072920A /* CalculationValue.h */; }; 1231 1235 49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */; }; 1232 1236 49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */; }; … … 8035 8039 499B3ED5128CD31400E726C2 /* GraphicsLayerCA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GraphicsLayerCA.h; path = ca/GraphicsLayerCA.h; sourceTree = "<group>"; }; 8036 8040 499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCAAnimation.h; path = ca/PlatformCAAnimation.h; sourceTree = "<group>"; }; 8041 49AE2D8C134EE50C0072920A /* CSSCalculationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCalculationValue.cpp; sourceTree = "<group>"; }; 8042 49AE2D8D134EE50C0072920A /* CSSCalculationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCalculationValue.h; sourceTree = "<group>"; }; 8043 49AE2D94134EE5F90072920A /* CalculationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CalculationValue.cpp; sourceTree = "<group>"; }; 8044 49AE2D95134EE5F90072920A /* CalculationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalculationValue.h; sourceTree = "<group>"; }; 8037 8045 49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayRefreshMonitor.h; sourceTree = "<group>"; }; 8038 8046 49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayRefreshMonitorMac.cpp; sourceTree = "<group>"; }; … … 19595 19603 89D08D9E12228451001241DF /* AsyncFileSystemCallbacks.h */, 19596 19604 51E1ECB10C91C55600DC255B /* AutodrainedPool.h */, 19605 49AE2D94134EE5F90072920A /* CalculationValue.cpp */, 19606 49AE2D95134EE5F90072920A /* CalculationValue.h */, 19597 19607 CDEA76331460B462008B31F1 /* Clock.cpp */, 19598 19608 CDEA762C14608224008B31F1 /* Clock.h */, … … 19906 19916 BC274B30140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp */, 19907 19917 BC274B2E140EBEB200EADFA6 /* CSSBorderImageSliceValue.h */, 19918 49AE2D8C134EE50C0072920A /* CSSCalculationValue.cpp */, 19919 49AE2D8D134EE50C0072920A /* CSSCalculationValue.h */, 19908 19920 BC604A420DB5634E00204739 /* CSSCanvasValue.cpp */, 19909 19921 BC6049CB0DB560C200204739 /* CSSCanvasValue.h */, … … 21145 21157 BCB16C280979C3BD00467741 /* CachedXSLStyleSheet.h in Headers */, 21146 21158 93F1995008245E59001E9ABC /* CachePolicy.h in Headers */, 21159 49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */, 21147 21160 B1D5ECB5134B58DA0087C78F /* CallbackFunction.h in Headers */, 21148 21161 6E4E91AD10F7FB3100A2779C /* CanvasContextAttributes.h in Headers */, … … 21233 21246 E16A84FA14C85CCC002977DF /* CSSBorderImage.h in Headers */, 21234 21247 BC274B2F140EBEB200EADFA6 /* CSSBorderImageSliceValue.h in Headers */, 21248 49AE2D8F134EE50C0072920A /* CSSCalculationValue.h in Headers */, 21235 21249 BC6049CC0DB560C200204739 /* CSSCanvasValue.h in Headers */, 21236 21250 A80E6CF90A1989CA007FB8C5 /* CSSCharsetRule.h in Headers */, … … 24170 24184 isa = PBXProject; 24171 24185 attributes = { 24186 BuildIndependentTargetsInParallel = YES; 24172 24187 LastUpgradeCheck = 0440; 24173 24188 }; … … 24560 24575 0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */, 24561 24576 BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */, 24577 49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */, 24562 24578 B1827493134CA4C100B98C2D /* CallbackFunction.cpp in Sources */, 24563 24579 6E4E91AC10F7FB3100A2779C /* CanvasContextAttributes.cpp in Sources */, … … 24635 24651 E16A84F914C85CCC002977DF /* CSSBorderImage.cpp in Sources */, 24636 24652 BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */, 24653 49AE2D8E134EE50C0072920A /* CSSCalculationValue.cpp in Sources */, 24637 24654 BC604A430DB5634E00204739 /* CSSCanvasValue.cpp in Sources */, 24638 24655 E1EBBBD40AAC9B87001FE8E2 /* CSSCharsetRule.cpp in Sources */, -
trunk/Source/WebCore/css/CSSParser.cpp
r105901 r106166 693 693 } 694 694 695 bool CSSParser::validCalculationUnit(CSSParserValue* value, Units unitflags) 696 { 697 if (!parseCalculation(value)) 698 return false; 699 700 bool b = false; 701 switch (m_parsedCalculation->category()) { 702 case CalcLength: 703 b = (unitflags & FLength); 704 break; 705 case CalcPercent: 706 b = (unitflags & FPercent); 707 // FIXME calc (http://webkit.org/b/16662): test FNonNeg here, eg 708 // if (b && (unitflags & FNonNeg) && m_parsedCalculation->doubleValue() < 0) 709 // b = false; 710 break; 711 case CalcNumber: 712 b = (unitflags & FNumber); 713 if (!b && (unitflags & FInteger) && m_parsedCalculation->isInt()) 714 b = true; 715 // FIXME calc (http://webkit.org/b/16662): test FNonNeg here, eg 716 // if (b && (unitflags & FNonNeg) && m_parsedCalculation->doubleValue() < 0) 717 // b = false; 718 break; 719 case CalcPercentLength: 720 b = (unitflags & FPercent) && (unitflags & FLength); 721 break; 722 case CalcPercentNumber: 723 b = (unitflags & FPercent) && (unitflags & FNumber); 724 break; 725 case CalcOther: 726 break; 727 } 728 if (!b) 729 m_parsedCalculation.release(); 730 return b; 731 } 732 695 733 bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict) 696 734 { 735 if (isCalculation(value)) 736 return validCalculationUnit(value, unitflags); 737 697 738 bool b = false; 698 739 switch (value->unit) { 699 740 case CSSPrimitiveValue::CSS_NUMBER: 700 741 b = (unitflags & FNumber); 701 if (!b && ((unitflags & (FLength | FAngle | FTime)) && ( value->fValue == 0|| !strict))) {742 if (!b && ((unitflags & (FLength | FAngle | FTime)) && (!value->fValue || !strict))) { 702 743 value->unit = (unitflags & FLength) ? CSSPrimitiveValue::CSS_PX : 703 744 ((unitflags & FAngle) ? CSSPrimitiveValue::CSS_DEG : CSSPrimitiveValue::CSS_MS); … … 745 786 inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveNumericValue(CSSParserValue* value) 746 787 { 788 if (m_parsedCalculation) { 789 ASSERT(isCalculation(value)); 790 // FIXME calc() http://webkit.org/b/16662: create a CSSPrimitiveValue here, ie 791 // return CSSPrimitiveValue::create(m_parsedCalculation.release()); 792 m_parsedCalculation.release(); 793 return 0; 794 } 795 747 796 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) 748 797 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)); … … 842 891 if (value->unit >= CSSParserValue::Q_EMS) 843 892 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS); 893 if (isCalculation(value)) 894 // FIXME calc() http://webkit.org/b/16662: create a primitive value here, ie 895 // return CSSPrimitiveValue::create(m_parsedCalculation.release()); 896 m_parsedCalculation.release(); 897 844 898 return 0; 845 899 } … … 855 909 return false; 856 910 911 // Note: m_parsedCalculation is used to pass the calc value to validUnit and then cleared at the end of this function. 912 // FIXME: This is to avoid having to pass parsedCalc to all validUnit callers. 913 ASSERT(!m_parsedCalculation); 914 857 915 int id = value->id; 858 916 … … 2282 2340 m_valueList->next(); 2283 2341 } 2342 ASSERT(!m_parsedCalculation); 2284 2343 if (parsedValue) { 2285 2344 if (!m_valueList->current() || inShorthand()) { … … 2989 3048 cumulativeFlags |= YFillPosition; 2990 3049 individualFlag = YFillPosition; 2991 } else 3050 } else { 3051 if (m_parsedCalculation) 3052 m_parsedCalculation.release(); 2992 3053 return 0; 3054 } 2993 3055 return createPrimitiveNumericValue(valueList->current()); 2994 3056 } … … 4872 4934 return false; 4873 4935 } 4874 4875 static inline int colorIntFromValue(CSSParserValue* v) 4876 { 4877 if (v->fValue <= 0.0) 4936 4937 inline double CSSParser::parsedDouble(CSSParserValue *v, ReleaseParsedCalcValueCondition releaseCalc) 4938 { 4939 // FIXME calc (http://webkit.org/b/16662): evaluate calc here, eg 4940 // const double result = m_parsedCalculation ? m_parsedCalculation->doubleValue() : v->fValue; 4941 const double result = m_parsedCalculation ? 0 : v->fValue; 4942 if (releaseCalc == ReleaseParsedCalcValue) 4943 m_parsedCalculation.release(); 4944 return result; 4945 } 4946 4947 bool CSSParser::isCalculation(CSSParserValue* value) 4948 { 4949 return (value->unit == CSSParserValue::Function) 4950 && (equalIgnoringCase(value->function->name, "-webkit-calc(") 4951 || equalIgnoringCase(value->function->name, "-webkit-min(") 4952 || equalIgnoringCase(value->function->name, "-webkit-max(")); 4953 } 4954 4955 inline int CSSParser::colorIntFromValue(CSSParserValue* v) 4956 { 4957 bool isPercent; 4958 4959 if (m_parsedCalculation) 4960 isPercent = m_parsedCalculation->category() == CalcPercent; 4961 else 4962 isPercent = v->unit == CSSPrimitiveValue::CSS_PERCENTAGE; 4963 4964 const double value = parsedDouble(v, ReleaseParsedCalcValue); 4965 4966 if (value <= 0.0) 4878 4967 return 0; 4879 4968 4880 if ( v->unit == CSSPrimitiveValue::CSS_PERCENTAGE) {4881 if (v ->fValue >= 100.0)4969 if (isPercent) { 4970 if (value >= 100.0) 4882 4971 return 255; 4883 return static_cast<int>(v ->fValue * 256.0 / 100.0);4884 } 4885 4886 if (v ->fValue >= 255.0)4972 return static_cast<int>(value * 256.0 / 100.0); 4973 } 4974 4975 if (value >= 255.0) 4887 4976 return 255; 4888 4977 4889 return static_cast<int>(v ->fValue);4978 return static_cast<int>(value); 4890 4979 } 4891 4980 … … 4902 4991 else 4903 4992 return false; 4993 4904 4994 colorArray[0] = colorIntFromValue(v); 4905 4995 for (int i = 1; i < 3; i++) { … … 4919 5009 if (!validUnit(v, FNumber, true)) 4920 5010 return false; 5011 const double value = parsedDouble(v, ReleaseParsedCalcValue); 4921 5012 // Convert the floating pointer number of alpha to an integer in the range [0, 256), 4922 5013 // with an equal distribution across all 256 values. 4923 colorArray[3] = static_cast<int>(max(0.0, min(1.0, v ->fValue)) * nextafter(256.0, 0.0));5014 colorArray[3] = static_cast<int>(max(0.0, min(1.0, value)) * nextafter(256.0, 0.0)); 4924 5015 } 4925 5016 return true; … … 4939 5030 return false; 4940 5031 // normalize the Hue value and change it to be between 0 and 1.0 4941 colorArray[0] = (((static_cast<int>( v->fValue) % 360) + 360) % 360) / 360.0;5032 colorArray[0] = (((static_cast<int>(parsedDouble(v, ReleaseParsedCalcValue)) % 360) + 360) % 360) / 360.0; 4942 5033 for (int i = 1; i < 3; i++) { 4943 5034 v = args->next(); … … 4947 5038 if (!validUnit(v, FPercent, true)) 4948 5039 return false; 4949 colorArray[i] = max(0.0, min(100.0, v->fValue)) / 100.0; // needs to be value between 0 and 1.05040 colorArray[i] = max(0.0, min(100.0, parsedDouble(v, ReleaseParsedCalcValue))) / 100.0; // needs to be value between 0 and 1.0 4950 5041 } 4951 5042 if (parseAlpha) { … … 4956 5047 if (!validUnit(v, FNumber, true)) 4957 5048 return false; 4958 colorArray[3] = max(0.0, min(1.0, v->fValue));5049 colorArray[3] = max(0.0, min(1.0, parsedDouble(v, ReleaseParsedCalcValue))); 4959 5050 } 4960 5051 return true; … … 5024 5115 // without the allowBreak bit being set, then it will clean up all of the objects and destroy them. 5025 5116 struct ShadowParseContext { 5026 ShadowParseContext(CSSPropertyID prop, CSS ValuePool* cssValuePool)5117 ShadowParseContext(CSSPropertyID prop, CSSParser* parser) 5027 5118 : property(prop) 5028 , m_ cssValuePool(cssValuePool)5119 , m_parser(parser) 5029 5120 , allowX(true) 5030 5121 , allowY(false) … … 5069 5160 void commitLength(CSSParserValue* v) 5070 5161 { 5071 RefPtr<CSSPrimitiveValue> val = m_ cssValuePool->createValue(v->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(v->unit));5162 RefPtr<CSSPrimitiveValue> val = m_parser->createPrimitiveNumericValue(v); 5072 5163 5073 5164 if (allowX) { … … 5111 5202 void commitStyle(CSSParserValue* v) 5112 5203 { 5113 style = m_ cssValuePool->createIdentifierValue(v->id);5204 style = m_parser->cssValuePool()->createIdentifierValue(v->id); 5114 5205 allowStyle = false; 5115 5206 if (allowX) … … 5123 5214 5124 5215 CSSPropertyID property; 5125 CSS ValuePool* m_cssValuePool;5216 CSSParser* m_parser; 5126 5217 5127 5218 RefPtr<CSSValueList> values; … … 5144 5235 PassRefPtr<CSSValueList> CSSParser::parseShadow(CSSParserValueList* valueList, int propId) 5145 5236 { 5146 ShadowParseContext context(static_cast<CSSPropertyID>(propId), cssValuePool());5237 ShadowParseContext context(static_cast<CSSPropertyID>(propId), this); 5147 5238 CSSParserValue* val; 5148 5239 while ((val = valueList->current())) { … … 5528 5619 class BorderImageSliceParseContext { 5529 5620 public: 5530 BorderImageSliceParseContext(CSS ValuePool* cssValuePool)5531 : m_ cssValuePool(cssValuePool)5621 BorderImageSliceParseContext(CSSParser* parser) 5622 : m_parser(parser) 5532 5623 , m_allowNumber(true) 5533 5624 , m_allowFill(false) … … 5543 5634 void commitNumber(CSSParserValue* v) 5544 5635 { 5545 RefPtr<CSSPrimitiveValue> val = m_ cssValuePool->createValue(v->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(v->unit));5636 RefPtr<CSSPrimitiveValue> val = m_parser->createPrimitiveNumericValue(v); 5546 5637 if (!m_top) 5547 5638 m_top = val; … … 5589 5680 5590 5681 // Make our new border image value now. 5591 return CSSBorderImageSliceValue::create(m_ cssValuePool->createValue(quad.release()), m_fill);5682 return CSSBorderImageSliceValue::create(m_parser->cssValuePool()->createValue(quad.release()), m_fill); 5592 5683 } 5593 5684 5594 5685 private: 5595 CSS ValuePool* m_cssValuePool;5686 CSSParser* m_parser; 5596 5687 5597 5688 bool m_allowNumber; … … 5609 5700 bool CSSParser::parseBorderImageSlice(int propId, RefPtr<CSSBorderImageSliceValue>& result) 5610 5701 { 5611 BorderImageSliceParseContext context( cssValuePool());5702 BorderImageSliceParseContext context(this); 5612 5703 CSSParserValue* val; 5613 5704 while ((val = m_valueList->current())) { 5614 if (context.allowNumber() && validUnit(val, FInteger | FNonNeg | FPercent, true)) { 5705 // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values are not created yet. 5706 if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInteger | FNonNeg | FPercent, true)) { 5615 5707 context.commitNumber(val); 5616 5708 } else if (context.allowFill() && val->id == CSSValueFill) … … 5645 5737 class BorderImageQuadParseContext { 5646 5738 public: 5647 BorderImageQuadParseContext(CSS ValuePool* cssValuePool)5648 : m_ cssValuePool(cssValuePool)5739 BorderImageQuadParseContext(CSSParser* parser) 5740 : m_parser(parser) 5649 5741 , m_allowNumber(true) 5650 5742 , m_allowFinalCommit(false) … … 5659 5751 RefPtr<CSSPrimitiveValue> val; 5660 5752 if (v->id == CSSValueAuto) 5661 val = m_ cssValuePool->createIdentifierValue(v->id);5753 val = m_parser->cssValuePool()->createIdentifierValue(v->id); 5662 5754 else 5663 val = m_ cssValuePool->createValue(v->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(v->unit));5755 val = m_parser->createPrimitiveNumericValue(v); 5664 5756 5665 5757 if (!m_top) … … 5705 5797 5706 5798 // Make our new value now. 5707 return m_ cssValuePool->createValue(quad.release());5799 return m_parser->cssValuePool()->createValue(quad.release()); 5708 5800 } 5709 5801 5710 5802 private: 5711 CSS ValuePool* m_cssValuePool;5803 CSSParser* m_parser; 5712 5804 5713 5805 bool m_allowNumber; … … 5722 5814 bool CSSParser::parseBorderImageQuad(Units validUnits, RefPtr<CSSPrimitiveValue>& result) 5723 5815 { 5724 BorderImageQuadParseContext context( cssValuePool());5816 BorderImageQuadParseContext context(this); 5725 5817 CSSParserValue* val; 5726 5818 while ((val = m_valueList->current())) { … … 7326 7418 } 7327 7419 7420 bool CSSParser::parseCalculation(CSSParserValue* value) 7421 { 7422 ASSERT(isCalculation(value)); 7423 7424 CSSParserValueList* args = value->function->args.get(); 7425 if (!args || !args->size()) 7426 return false; 7427 7428 ASSERT(!m_parsedCalculation); 7429 m_parsedCalculation = CSSCalcValue::create(value->function->name, args); 7430 7431 if (!m_parsedCalculation) 7432 return false; 7433 7434 return true; 7435 } 7436 7328 7437 static inline int yyerror(const char*) { return 1; } 7329 7438 -
trunk/Source/WebCore/css/CSSParser.h
r105901 r106166 24 24 #define CSSParser_h 25 25 26 #include "CSSCalculationValue.h" 26 27 #include "CSSGradientValue.h" 27 28 #include "CSSParserValues.h" … … 212 213 213 214 bool parseLineBoxContain(bool important); 215 bool parseCalculation(CSSParserValue*); 214 216 215 217 bool parseFontFeatureTag(CSSValueList*); … … 323 325 int lex(); 324 326 327 PassRefPtr<CSSPrimitiveValue> createPrimitiveNumericValue(CSSParserValue*); 328 PassRefPtr<CSSPrimitiveValue> createPrimitiveStringValue(CSSParserValue*); 329 325 330 private: 326 331 void setStyleSheet(CSSStyleSheet*); … … 388 393 Vector<OwnPtr<CSSParserSelector> > m_reusableSelectorVector; 389 394 Vector<OwnPtr<CSSParserSelector> > m_reusableRegionSelectorVector; 395 396 RefPtr<CSSCalcValue> m_parsedCalculation; 390 397 391 398 // defines units allowed for a certain property, used in parseUnit … … 408 415 } 409 416 410 static bool validUnit(CSSParserValue*, Units, bool strict); 417 bool validCalculationUnit(CSSParserValue*, Units); 418 bool validUnit(CSSParserValue*, Units, bool strict); 411 419 412 420 bool parseBorderImageQuad(Units, RefPtr<CSSPrimitiveValue>&); 413 414 PassRefPtr<CSSPrimitiveValue> createPrimitiveNumericValue(CSSParserValue*); 415 PassRefPtr<CSSPrimitiveValue> createPrimitiveStringValue(CSSParserValue*); 416 421 int colorIntFromValue(CSSParserValue*); 422 423 enum ReleaseParsedCalcValueCondition { 424 ReleaseParsedCalcValue, 425 DoNotReleaseParsedCalcValue 426 }; 427 double parsedDouble(CSSParserValue*, ReleaseParsedCalcValueCondition releaseCalc = DoNotReleaseParsedCalcValue); 428 bool isCalculation(CSSParserValue*); 429 417 430 friend class TransformOperationInfo; 418 431 #if ENABLE(CSS_FILTERS) -
trunk/Source/WebCore/css/CSSValue.cpp
r105502 r106166 30 30 #include "CSSAspectRatioValue.h" 31 31 #include "CSSBorderImageSliceValue.h" 32 #include "CSSCalculationValue.h" 32 33 #include "CSSCanvasValue.h" 33 34 #include "CSSCrossfadeValue.h" … … 150 151 case FlexClass: 151 152 return static_cast<const CSSFlexValue*>(this)->customCssText(); 153 case CalculationClass: 154 return static_cast<const CSSCalcValue*>(this)->customCssText(); 152 155 #if ENABLE(CSS_FILTERS) 153 156 case WebKitCSSFilterClass: … … 250 253 delete static_cast<CSSFlexValue*>(this); 251 254 return; 255 case CalculationClass: 256 delete static_cast<CSSCalcValue*>(this); 257 return; 252 258 #if ENABLE(CSS_FILTERS) 253 259 case WebKitCSSFilterClass: -
trunk/Source/WebCore/css/CSSValue.h
r105502 r106166 77 77 bool isCSSLineBoxContainValue() const { return m_classType == LineBoxContainClass; } 78 78 bool isFlexValue() const { return m_classType == FlexClass; } 79 bool isCalculationValue() const {return m_classType == CalculationClass; } 79 80 #if ENABLE(CSS_FILTERS) 80 81 bool isWebKitCSSFilterValue() const { return m_classType == WebKitCSSFilterClass; } … … 127 128 LineBoxContainClass, 128 129 FlexClass, 130 CalculationClass, 129 131 #if ENABLE(CSS_FILTERS) && ENABLE(CSS_SHADERS) 130 132 WebKitCSSShaderClass, -
trunk/Source/WebCore/css/SVGCSSParser.cpp
r103692 r106166 315 315 else if (value->unit >= CSSParserValue::Q_EMS) 316 316 parsedValue = CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS); 317 if (isCalculation(value)) { 318 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPrimitiveValue here, ie 319 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.release()); 320 m_parsedCalculation.release(); 321 parsedValue = 0; 322 } 317 323 m_valueList->next(); 318 324 }
Note: See TracChangeset
for help on using the changeset viewer.