Changeset 120154 in webkit
- Timestamp:
- Jun 12, 2012 8:31:39 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 27 edited
-
ChangeLog (modified) (1 diff)
-
GNUmakefile.list.am (modified) (2 diffs)
-
Target.pri (modified) (2 diffs)
-
WebCore.gypi (modified) (2 diffs)
-
WebCore.vcproj/WebCore.vcproj (modified) (2 diffs)
-
WebCore.xcodeproj/project.pbxproj (modified) (8 diffs)
-
css/CSSComputedStyleDeclaration.cpp (modified) (1 diff)
-
css/CSSGrammar.y (modified) (5 diffs)
-
css/CSSParser.cpp (modified) (10 diffs)
-
css/CSSParser.h (modified) (1 diff)
-
css/CSSParserValues.cpp (modified) (2 diffs)
-
css/CSSPrimitiveValue.cpp (modified) (5 diffs)
-
css/CSSPrimitiveValue.h (modified) (3 diffs)
-
css/CSSProperty.cpp (modified) (1 diff)
-
css/CSSValue.cpp (modified) (4 diffs)
-
css/CSSValue.h (modified) (3 diffs)
-
css/CSSValueList.cpp (modified) (1 diff)
-
css/CSSValueList.h (modified) (1 diff)
-
css/CSSVariableValue.h (added)
-
css/StyleResolver.cpp (modified) (7 diffs)
-
css/StyleResolver.h (modified) (3 diffs)
-
css/WebKitCSSTransformValue.cpp (modified) (1 diff)
-
css/WebKitCSSTransformValue.h (modified) (1 diff)
-
css/makeprop.pl (modified) (1 diff)
-
rendering/style/RenderStyle.cpp (modified) (1 diff)
-
rendering/style/RenderStyle.h (modified) (1 diff)
-
rendering/style/StyleRareInheritedData.cpp (modified) (3 diffs)
-
rendering/style/StyleRareInheritedData.h (modified) (2 diffs)
-
rendering/style/StyleVariableData.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r120147 r120154 1 2012-06-12 Luke Macpherson <macpherson@chromium.org> 2 3 WIP: Implement CSS Variables Standard. 4 https://bugs.webkit.org/show_bug.cgi?id=85580 5 6 Reviewed by Ojan Vafai. 7 8 Implement CSS Variables Module Level 1. (See http://www.w3.org/TR/css-variables/) 9 10 A HashMap of properties is referenced by RenderStyle, and used to store variables as strings. 11 That HashMap is copy-on-write, and unless new variables are defined is simply a pointer to the 12 parent's definitions. At usage time the variable's value is parsed according to the CSS property 13 where it is used. 14 Variables can: 15 Define lists of values (ie. entire shorthand values). 16 Define individual values. 17 Refer to other variables. (Cycle detection is implemented). 18 Please see the supplied test cases for example usage. 19 20 Missing features: 21 CSS variables cannot yet be used inside some functions such as -webkit-calc. 22 23 Covered by existing test suite under fast/css/variables. 24 25 * GNUmakefile.list.am: 26 * Target.pri: 27 * WebCore.gypi: 28 * WebCore.vcproj/WebCore.vcproj: 29 * WebCore.xcodeproj/project.pbxproj: 30 * css/CSSComputedStyleDeclaration.cpp: 31 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): 32 * css/CSSGrammar.y: 33 * css/CSSParser.cpp: 34 (WebCore): 35 (WebCore::filterProperties): 36 (WebCore::CSSParser::createStylePropertySet): 37 (WebCore::CSSParser::validUnit): 38 (WebCore::CSSParser::createPrimitiveNumericValue): 39 (WebCore::CSSParser::parseValue): 40 (WebCore::CSSParser::storeVariableDeclaration): 41 (WebCore::CSSParser::detectDashToken): 42 (WebCore::CSSParser::lex): 43 * css/CSSParser.h: 44 (CSSParser): 45 * css/CSSParserValues.cpp: 46 (WebCore::CSSParserValue::createCSSValue): 47 * css/CSSPrimitiveValue.cpp: 48 (WebCore::isValidCSSUnitTypeForDoubleConversion): 49 (WebCore::CSSPrimitiveValue::getStringValue): 50 (WebCore::CSSPrimitiveValue::customSerializeResolvingVariables): 51 (WebCore): 52 * css/CSSPrimitiveValue.h: 53 (CSSPrimitiveValue): 54 (WebCore::CSSPrimitiveValue::isVariableName): 55 * css/CSSProperty.cpp: 56 (WebCore::CSSProperty::isInheritedProperty): 57 * css/CSSValue.cpp: 58 (WebCore::CSSValue::serializeResolvingVariables): 59 (WebCore): 60 (WebCore::CSSValue::destroy): 61 * css/CSSValue.h: 62 (CSSValue): 63 (WebCore::CSSValue::isVariableValue): 64 * css/CSSValueList.cpp: 65 (WebCore): 66 (WebCore::CSSValueList::customSerializeResolvingVariables): 67 * css/CSSValueList.h: 68 (CSSValueList): 69 * css/CSSVariableValue.h: Added. 70 (WebCore): 71 (CSSVariableValue): 72 (WebCore::CSSVariableValue::create): 73 (WebCore::CSSVariableValue::name): 74 (WebCore::CSSVariableValue::value): 75 (WebCore::CSSVariableValue::CSSVariableValue): 76 * css/StyleResolver.cpp: 77 (WebCore::StyleResolver::collectMatchingRulesForList): 78 * css/StyleResolver.h: 79 * css/WebKitCSSTransformValue.cpp: 80 (WebCore): 81 (WebCore::WebKitCSSTransformValue::customSerializeResolvingVariables): 82 * css/WebKitCSSTransformValue.h: 83 (WebKitCSSTransformValue): 84 * css/makeprop.pl: 85 * rendering/style/RenderStyle.h: 86 * rendering/style/StyleVariableData.h: Added. 87 (WebCore): 88 (StyleVariableData): 89 (WebCore::StyleVariableData::create): 90 (WebCore::StyleVariableData::copy): 91 (WebCore::StyleVariableData::operator==): 92 (WebCore::StyleVariableData::operator!=): 93 (WebCore::StyleVariableData::setVariable): 94 (WebCore::StyleVariableData::StyleVariableData): 95 1 96 2012-06-12 MORITA Hajime <morrita@google.com> 2 97 -
trunk/Source/WebCore/GNUmakefile.list.am
r120057 r120154 1687 1687 Source/WebCore/css/CSSValuePool.cpp \ 1688 1688 Source/WebCore/css/CSSValuePool.h \ 1689 Source/WebCore/css/CSSVariableValue.h \ 1689 1690 Source/WebCore/css/DashboardRegion.h \ 1690 1691 Source/WebCore/css/FontFeatureValue.cpp \ … … 4036 4037 Source/WebCore/rendering/style/StyleTransformData.cpp \ 4037 4038 Source/WebCore/rendering/style/StyleTransformData.h \ 4039 Source/WebCore/rendering/style/StyleVariableData.h \ 4038 4040 Source/WebCore/rendering/style/StyleVisualData.cpp \ 4039 4041 Source/WebCore/rendering/style/StyleVisualData.h \ -
trunk/Source/WebCore/Target.pri
r120057 r120154 1653 1653 css/CSSValueList.h \ 1654 1654 css/CSSValuePool.h \ 1655 css/CSSVariableValue.h \ 1655 1656 css/CSSWrapShapes.h \ 1656 1657 css/FontFeatureValue.h \ … … 2566 2567 rendering/style/StyleSurroundData.h \ 2567 2568 rendering/style/StyleTransformData.h \ 2569 rendering/style/StyleVariableData.h \ 2568 2570 rendering/style/StyleVisualData.h \ 2569 2571 rendering/style/SVGRenderStyleDefs.h \ -
trunk/Source/WebCore/WebCore.gypi
r120085 r120154 601 601 'rendering/style/StyleSurroundData.h', 602 602 'rendering/style/StyleTransformData.h', 603 'rendering/style/StyleVariableData.h', 603 604 'rendering/style/StyleVisualData.h', 604 605 'rendering/svg/SVGResourcesCache.h', … … 2504 2505 'css/CSSValuePool.cpp', 2505 2506 'css/CSSValuePool.h', 2507 'css/CSSVariableValue.h', 2506 2508 'css/CSSWrapShapes.cpp', 2507 2509 'css/Counter.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r120085 r120154 36852 36852 </File> 36853 36853 <File 36854 RelativePath="..\css\CSSVariableValue.h" 36855 > 36856 </File> 36857 <File 36854 36858 RelativePath="..\css\CSSWrapShapes.cpp" 36855 36859 > … … 45843 45847 /> 45844 45848 </FileConfiguration> 45849 </File> 45850 <File 45851 RelativePath="..\rendering\style\StyleVariableData.h" 45852 > 45845 45853 </File> 45846 45854 <File -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r120057 r120154 5345 5345 BC5EB67D0E81D42000B25965 /* StyleBoxData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5EB67C0E81D42000B25965 /* StyleBoxData.cpp */; }; 5346 5346 BC5EB67F0E81D4A700B25965 /* StyleDashboardRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5EB67E0E81D4A700B25965 /* StyleDashboardRegion.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5347 BC5EB69A0E81DA6300B25966 /* StyleVariableData.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5EB6980E81DA6300B25966 /* StyleVariableData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5347 5348 BC5EB6990E81DA6300B25965 /* StyleVisualData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5EB6970E81DA6300B25965 /* StyleVisualData.cpp */; }; 5348 5349 BC5EB69A0E81DA6300B25965 /* StyleVisualData.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5EB6980E81DA6300B25965 /* StyleVisualData.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 5762 5763 CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */; }; 5763 5764 CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; }; 5765 CAE9F910146441F000C245B1 /* CSSVariableValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B1 /* CSSVariableValue.h */; }; 5764 5766 CD127DED14F3097D00E84779 /* WebCoreFullScreenWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */; }; 5765 5767 CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 12490 12492 BC5EB67C0E81D42000B25965 /* StyleBoxData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleBoxData.cpp; path = style/StyleBoxData.cpp; sourceTree = "<group>"; }; 12491 12493 BC5EB67E0E81D4A700B25965 /* StyleDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleDashboardRegion.h; path = style/StyleDashboardRegion.h; sourceTree = "<group>"; }; 12494 BC5EB6980E81DA6300B25966 /* StyleVariableData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleVariableData.h; path = style/StyleVariableData.h; sourceTree = "<group>"; }; 12492 12495 BC5EB6970E81DA6300B25965 /* StyleVisualData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleVisualData.cpp; path = style/StyleVisualData.cpp; sourceTree = "<group>"; }; 12493 12496 BC5EB6980E81DA6300B25965 /* StyleVisualData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleVisualData.h; path = style/StyleVisualData.h; sourceTree = "<group>"; }; … … 12944 12947 CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAspectRatioValue.cpp; sourceTree = "<group>"; }; 12945 12948 CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; }; 12949 CAE9F90E146441F000C245B1 /* CSSVariableValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSVariableValue.h; sourceTree = "<group>"; }; 12946 12950 CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; }; 12947 12951 CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWindow.mm; sourceTree = "<group>"; }; … … 20159 20163 BC5EB80D0E81F2CE00B25965 /* StyleTransformData.cpp */, 20160 20164 BC5EB80E0E81F2CE00B25965 /* StyleTransformData.h */, 20165 BC5EB6980E81DA6300B25966 /* StyleVariableData.h */, 20161 20166 BC5EB6970E81DA6300B25965 /* StyleVisualData.cpp */, 20162 20167 BC5EB6980E81DA6300B25965 /* StyleVisualData.h */, … … 20818 20823 E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */, 20819 20824 E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */, 20825 CAE9F90E146441F000C245B1 /* CSSVariableValue.h */, 20820 20826 501BAAB11395114B00F7ACEB /* CSSWrapShapes.cpp */, 20821 20827 501BA9E11393CEA000F7ACEB /* CSSWrapShapes.h */, … … 22138 22144 A80E6CE90A1989CA007FB8C5 /* CSSValueList.h in Headers */, 22139 22145 E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */, 22146 CAE9F910146441F000C245B1 /* CSSVariableValue.h in Headers */, 22140 22147 501BA9E21393CEA000F7ACEB /* CSSWrapShapes.h in Headers */, 22141 22148 93F1992F08245E59001E9ABC /* Cursor.h in Headers */, … … 24535 24542 BC5EB5E50E81BF6D00B25965 /* StyleSurroundData.h in Headers */, 24536 24543 BC5EB8100E81F2CE00B25965 /* StyleTransformData.h in Headers */, 24544 BC5EB69A0E81DA6300B25966 /* StyleVariableData.h in Headers */, 24537 24545 BC5EB69A0E81DA6300B25965 /* StyleVisualData.h in Headers */, 24538 24546 D000ED2811C1B9CD00C47726 /* SubframeLoader.h in Headers */, -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r120029 r120154 1363 1363 switch (propertyID) { 1364 1364 case CSSPropertyInvalid: 1365 #if ENABLE(CSS_VARIABLES) 1366 case CSSPropertyVariable: 1367 #endif 1365 1368 break; 1366 1369 -
trunk/Source/WebCore/css/CSSGrammar.y
r119984 r120154 102 102 %} 103 103 104 %expect 59104 %expect 61 105 105 106 106 %nonassoc LOWEST_PREC … … 136 136 %token CHARSET_SYM 137 137 %token NAMESPACE_SYM 138 %token VARFUNCTION 138 139 %token WEBKIT_RULE_SYM 139 140 %token WEBKIT_DECLS_SYM … … 203 204 %token <string> MINFUNCTION 204 205 %token <string> MAXFUNCTION 206 %token <string> VAR_DEFINITION 205 207 206 208 %token <string> UNICODERANGE … … 1298 1300 1299 1301 declaration: 1302 VAR_DEFINITION ':' maybe_space expr prio { 1303 #if ENABLE(CSS_VARIABLES) 1304 CSSParser* p = static_cast<CSSParser*>(parser); 1305 p->storeVariableDeclaration($1, p->sinkFloatingValueList($4), $5); 1306 $$ = true; 1307 p->markPropertyEnd($5, $$); 1308 #else 1309 $$ = false; 1310 #endif 1311 } 1312 | 1300 1313 property ':' maybe_space expr prio { 1301 1314 $$ = false; … … 1430 1443 | HEX maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; } 1431 1444 | '#' maybe_space { $$.id = 0; $$.string = CSSParserString(); $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; } /* Handle error case: "color: #;" */ 1445 | VARFUNCTION maybe_space IDENT ')' maybe_space { 1446 #if ENABLE(CSS_VARIABLES) 1447 $$.id = 0; 1448 $$.string = $3; 1449 $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME; 1450 #endif 1451 } 1432 1452 /* FIXME: according to the specs a function can have a unary_operator in front. I know no case where this makes sense */ 1433 1453 | function { -
trunk/Source/WebCore/css/CSSParser.cpp
r120147 r120154 52 52 #include "CSSValueList.h" 53 53 #include "CSSValuePool.h" 54 #if ENABLE(CSS_VARIABLES) 55 #include "CSSVariableValue.h" 56 #endif 54 57 #include "CSSWrapShapes.h" 55 58 #include "Counter.h" … … 1182 1185 } 1183 1186 1187 #if ENABLE(CSS_VARIABLES) 1188 static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) 1189 #else 1184 1190 static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties) 1191 #endif 1185 1192 { 1186 1193 // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found. … … 1189 1196 if (property.isImportant() != important) 1190 1197 continue; 1198 #if ENABLE(CSS_VARIABLES) 1199 if (property.id() == CSSPropertyVariable) { 1200 const AtomicString& name = static_cast<CSSVariableValue*>(property.value())->name(); 1201 if (seenVariables.contains(name)) 1202 continue; 1203 seenVariables.add(name); 1204 output[--unusedEntries] = property; 1205 continue; 1206 } 1207 #endif 1191 1208 const unsigned propertyIDIndex = property.id() - firstCSSProperty; 1192 1209 if (seenProperties.get(propertyIDIndex)) … … 1204 1221 1205 1222 // Important properties have higher priority, so add them first. Duplicate definitions can then be ignored when found. 1223 #if ENABLE(CSS_VARIABLES) 1224 HashSet<AtomicString> seenVariables; 1225 filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties, seenVariables); 1226 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties, seenVariables); 1227 #else 1206 1228 filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties); 1207 1229 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties); 1208 1230 #endif 1209 1231 if (unusedEntries) 1210 1232 results.remove(0, unusedEntries); … … 1302 1324 bool b = false; 1303 1325 switch (value->unit) { 1326 #if ENABLE(CSS_VARIABLES) 1327 case CSSPrimitiveValue::CSS_VARIABLE_NAME: 1328 // Variables are checked at the point they are dereferenced because unit type is not available here. 1329 b = true; 1330 break; 1331 #endif 1304 1332 case CSSPrimitiveValue::CSS_NUMBER: 1305 1333 b = (unitflags & FNumber); … … 1358 1386 inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveNumericValue(CSSParserValue* value) 1359 1387 { 1388 #if ENABLE(CSS_VARIABLES) 1389 if (value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) 1390 return CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_VARIABLE_NAME); 1391 #endif 1392 1360 1393 if (m_parsedCalculation) { 1361 1394 ASSERT(isCalculation(value)); … … 1530 1563 return true; 1531 1564 } 1565 1566 #if ENABLE(CSS_VARIABLES) 1567 if (!id && value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME && num == 1) { 1568 addProperty(propId, CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_VARIABLE_NAME), important); 1569 m_valueList->next(); 1570 return true; 1571 } 1572 #endif 1532 1573 1533 1574 if (isKeywordPropertyID(propId)) { … … 2827 2868 return true; 2828 2869 } 2870 2871 #if ENABLE(CSS_VARIABLES) 2872 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr<CSSParserValueList> value, bool important) 2873 { 2874 StringBuilder builder; 2875 for (unsigned i = 0, size = value->size(); i < size; i++) { 2876 if (i) 2877 builder.append(' '); 2878 builder.append(value->valueAt(i)->createCSSValue()->cssText()); 2879 } 2880 addProperty(CSSPropertyVariable, CSSVariableValue::create(name, builder.toString()), important, false); 2881 } 2882 #endif 2829 2883 2830 2884 void CSSParser::addAnimationValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval) … … 8428 8482 else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentifier(name + 1, "webkit-ma")) 8429 8483 m_token = MAXFUNCTION; 8484 #if ENABLE(CSS_VARIABLES) 8485 else if (isASCIIAlphaCaselessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va")) 8486 m_token = VARFUNCTION; 8487 #endif 8430 8488 } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) 8431 8489 m_token = CALCFUNCTION; … … 8766 8824 8767 8825 case CharacterDash: 8826 #if ENABLE(CSS_VARIABLES) 8827 if (m_currentCharacter[10] == '-' && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && isIdentifierStartAfterDash(m_currentCharacter + 11)) { 8828 // handle variable declarations 8829 m_currentCharacter += 11; 8830 parseIdentifier(result, hasEscape); 8831 m_token = VAR_DEFINITION; 8832 yylval->string.characters = m_tokenStart; 8833 yylval->string.length = result - m_tokenStart; 8834 } else 8835 #endif 8768 8836 if (isIdentifierStartAfterDash(m_currentCharacter)) { 8769 8837 --m_currentCharacter; -
trunk/Source/WebCore/css/CSSParser.h
r119984 r120154 92 92 bool parseQuotes(CSSPropertyID, bool important); 93 93 94 #if ENABLE(CSS_VARIABLES) 95 void storeVariableDeclaration(const CSSParserString&, PassOwnPtr<CSSParserValueList>, bool important); 96 #endif 97 94 98 PassRefPtr<CSSValue> parseAttr(CSSParserValueList* args); 95 99 -
trunk/Source/WebCore/css/CSSParserValues.cpp
r103498 r120154 26 26 #include "CSSSelector.h" 27 27 #include "CSSSelectorList.h" 28 #if ENABLE(CSS_VARIABLES) 29 #include "CSSVariableValue.h" 30 #endif 28 31 29 32 namespace WebCore { … … 76 79 } else if (unit == CSSParserValue::Function) 77 80 parsedValue = CSSFunctionValue::create(function); 78 else if (unit == CSSPrimitiveValue::CSS_STRING || unit == CSSPrimitiveValue::CSS_URI || unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR) 81 else if (unit == CSSPrimitiveValue::CSS_STRING 82 || unit == CSSPrimitiveValue::CSS_URI 83 #if ENABLE(CSS_VARIABLES) 84 || unit == CSSPrimitiveValue::CSS_VARIABLE_NAME 85 #endif 86 || unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR) 79 87 parsedValue = CSSPrimitiveValue::create(string, (CSSPrimitiveValue::UnitTypes)unit); 80 88 else if (unit >= CSSPrimitiveValue::CSS_NUMBER && unit <= CSSPrimitiveValue::CSS_KHZ) -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r119984 r120154 106 106 case CSSPrimitiveValue:: CSS_UNKNOWN: 107 107 case CSSPrimitiveValue:: CSS_URI: 108 #if ENABLE(CSS_VARIABLES) 109 case CSSPrimitiveValue:: CSS_VARIABLE_NAME: 110 #endif 108 111 return false; 109 112 } … … 712 715 case CSS_ATTR: 713 716 case CSS_URI: 717 #if ENABLE(CSS_VARIABLES) 718 case CSS_VARIABLE_NAME: 719 #endif 714 720 return m_value.string; 715 721 case CSS_IDENT: … … 729 735 case CSS_ATTR: 730 736 case CSS_URI: 731 return m_value.string; 737 #if ENABLE(CSS_VARIABLES) 738 case CSS_VARIABLE_NAME: 739 #endif 740 return m_value.string; 732 741 case CSS_IDENT: 733 742 return valueOrPropertyName(m_value.ident); … … 1076 1085 text = formatNumber(m_value.num) + "vmin"; 1077 1086 break; 1087 #if ENABLE(CSS_VARIABLES) 1088 case CSS_VARIABLE_NAME: 1089 text = "-webkit-var("; 1090 text += m_value.string; 1091 text += ")"; 1092 break; 1093 #endif 1078 1094 } 1079 1095 … … 1083 1099 return text; 1084 1100 } 1101 1102 #if ENABLE(CSS_VARIABLES) 1103 String CSSPrimitiveValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const 1104 { 1105 if (m_primitiveUnitType == CSS_VARIABLE_NAME && variables.contains(m_value.string)) 1106 return variables.get(m_value.string); 1107 return customCssText(); 1108 } 1109 #endif 1085 1110 1086 1111 void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r119984 r120154 124 124 CSS_CALC = 112, 125 125 CSS_CALC_PERCENTAGE_WITH_NUMBER = 113, 126 CSS_CALC_PERCENTAGE_WITH_LENGTH = 114 126 CSS_CALC_PERCENTAGE_WITH_LENGTH = 114, 127 128 #if ENABLE(CSS_VARIABLES) 129 CSS_VARIABLE_NAME = 115, 130 #endif 127 131 }; 128 132 … … 174 178 bool isCalculatedPercentageWithNumber() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_NUMBER; } 175 179 bool isCalculatedPercentageWithLength() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_LENGTH; } 180 #if ENABLE(CSS_VARIABLES) 181 bool isVariableName() const { return primitiveType() == CSS_VARIABLE_NAME; } 182 #endif 176 183 bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMIN; } 177 184 … … 285 292 286 293 String customCssText() const; 294 #if ENABLE(CSS_VARIABLES) 295 String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const; 296 #endif 287 297 288 298 bool isQuirkValue() { return m_isQuirkValue; } -
trunk/Source/WebCore/css/CSSProperty.cpp
r120029 r120154 290 290 case CSSPropertyTextShadow: 291 291 case CSSPropertyTextTransform: 292 #if ENABLE(CSS_VARIABLES) 293 case CSSPropertyVariable: 294 #endif 292 295 case CSSPropertyVisibility: 293 296 case CSSPropertyWebkitAspectRatio: -
trunk/Source/WebCore/css/CSSValue.cpp
r120044 r120154 48 48 #include "CSSUnicodeRangeValue.h" 49 49 #include "CSSValueList.h" 50 #if ENABLE(CSS_VARIABLES) 51 #include "CSSVariableValue.h" 52 #endif 50 53 #include "FontValue.h" 51 54 #include "FontFeatureValue.h" … … 186 189 #endif 187 190 #endif 191 #if ENABLE(CSS_VARIABLES) 192 case VariableClass: 193 return static_cast<const CSSVariableValue*>(this)->value(); 194 #endif 188 195 #if ENABLE(SVG) 189 196 case SVGColorClass: … … 197 204 } 198 205 206 #if ENABLE(CSS_VARIABLES) 207 String CSSValue::serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const 208 { 209 switch (classType()) { 210 case PrimitiveClass: 211 return static_cast<const CSSPrimitiveValue*>(this)->customSerializeResolvingVariables(variables); 212 case ValueListClass: 213 return static_cast<const CSSValueList*>(this)->customSerializeResolvingVariables(variables); 214 case WebKitCSSTransformClass: 215 return static_cast<const WebKitCSSTransformValue*>(this)->customSerializeResolvingVariables(variables); 216 default: 217 return cssText(); 218 } 219 } 220 #endif 221 199 222 void CSSValue::destroy() 200 223 { … … 296 319 return; 297 320 #endif 321 #endif 322 #if ENABLE(CSS_VARIABLES) 323 case VariableClass: 324 delete static_cast<CSSVariableValue*>(this); 325 return; 298 326 #endif 299 327 #if ENABLE(SVG) -
trunk/Source/WebCore/css/CSSValue.h
r118963 r120154 60 60 String cssText() const; 61 61 void setCssText(const String&, ExceptionCode&) { } // FIXME: Not implemented. 62 #if ENABLE(CSS_VARIABLES) 63 String serializeResolvingVariables(const HashMap<AtomicString, String>&) const; 64 #endif 62 65 63 66 bool isPrimitiveValue() const { return m_classType == PrimitiveClass; } … … 91 94 #endif 92 95 #endif // ENABLE(CSS_FILTERS) 96 #if ENABLE(CSS_VARIABLES) 97 bool isVariableValue() const { return m_classType == VariableClass; } 98 #endif 93 99 #if ENABLE(SVG) 94 100 bool isSVGColor() const { return m_classType == SVGColorClass || m_classType == SVGPaintClass; } … … 149 155 #if ENABLE(CSS_FILTERS) && ENABLE(CSS_SHADERS) 150 156 WebKitCSSShaderClass, 157 #endif 158 #if ENABLE(CSS_VARIABLES) 159 VariableClass, 151 160 #endif 152 161 #if ENABLE(SVG) -
trunk/Source/WebCore/css/CSSValueList.cpp
r118963 r120154 137 137 } 138 138 139 #if ENABLE(CSS_VARIABLES) 140 String CSSValueList::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const 141 { 142 StringBuilder result; 143 String separator; 144 switch (m_valueListSeparator) { 145 case SpaceSeparator: 146 separator = " "; 147 break; 148 case CommaSeparator: 149 separator = ", "; 150 break; 151 case SlashSeparator: 152 separator = " / "; 153 break; 154 default: 155 ASSERT_NOT_REACHED(); 156 } 157 158 unsigned size = m_values.size(); 159 for (unsigned i = 0; i < size; i++) { 160 if (!result.isEmpty()) 161 result.append(separator); 162 result.append(m_values[i]->serializeResolvingVariables(variables)); 163 } 164 165 return result.toString(); 166 } 167 #endif 168 139 169 void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const 140 170 { -
trunk/Source/WebCore/css/CSSValueList.h
r118963 r120154 60 60 61 61 String customCssText() const; 62 #if ENABLE(CSS_VARIABLES) 63 String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const; 64 #endif 62 65 63 66 void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const; -
trunk/Source/WebCore/css/StyleResolver.cpp
r120132 r120154 50 50 #include "CSSTimingFunctionValue.h" 51 51 #include "CSSValueList.h" 52 #if ENABLE(CSS_VARIABLES) 53 #include "CSSVariableValue.h" 54 #endif 52 55 #include "CachedImage.h" 53 56 #include "CalculationValue.h" … … 1876 1879 m_lineHeightValue = 0; 1877 1880 bool inheritedOnly = false; 1881 #if ENABLE(CSS_VARIABLES) 1882 applyMatchedProperties<VariableDefinitions>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 1883 #endif 1878 1884 applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 1879 1885 … … 2718 2724 continue; 2719 2725 2720 if (pass == HighPriorityProperties) { 2726 switch (pass) { 2727 #if ENABLE(CSS_VARIABLES) 2728 case VariableDefinitions: 2729 COMPILE_ASSERT(CSSPropertyVariable < firstCSSProperty, CSS_variable_is_before_first_property); 2730 if (property == CSSPropertyVariable) 2731 applyProperty(current.id(), current.value()); 2732 break; 2733 #endif 2734 case HighPriorityProperties: 2721 2735 COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property); 2722 2736 COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 18, CSS_zoom_is_end_of_first_prop_range); 2723 2737 COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_line_height_is_after_zoom); 2738 #if ENABLE(CSS_VARIABLES) 2739 if (property == CSSPropertyVariable) 2740 continue; 2741 #endif 2724 2742 // give special priority to font-xxx, color properties, etc 2743 if (property < CSSPropertyLineHeight) 2744 applyProperty(current.id(), current.value()); 2745 // we apply line-height later 2746 else if (property == CSSPropertyLineHeight) 2747 m_lineHeightValue = current.value(); 2748 break; 2749 case LowPriorityProperties: 2725 2750 if (property > CSSPropertyLineHeight) 2726 continue; 2727 // we apply line-height later 2728 if (property == CSSPropertyLineHeight) { 2729 m_lineHeightValue = current.value(); 2730 continue; 2731 } 2732 applyProperty(current.id(), current.value()); 2733 continue; 2734 } 2735 if (property > CSSPropertyLineHeight) 2736 applyProperty(current.id(), current.value()); 2751 applyProperty(current.id(), current.value()); 2752 } 2737 2753 } 2738 2754 InspectorInstrumentation::didProcessRule(cookie); … … 2880 2896 applyInheritedOnly = true; 2881 2897 } 2898 2899 #if ENABLE(CSS_VARIABLES) 2900 // First apply all variable definitions, as they may be used during application of later properties. 2901 applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 2902 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 2903 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 2904 applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 2905 #endif 2906 2882 2907 // Now we have all of the matched rules in the appropriate order. Walk the rules and apply 2883 2908 // high-priority properties first, i.e., those properties that other properties depend on. … … 3194 3219 } 3195 3220 3196 void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value) 3197 { 3221 #if ENABLE(CSS_VARIABLES) 3222 static bool hasVariableReference(CSSValue* value) 3223 { 3224 if (value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value)->isVariableName()) 3225 return true; 3226 3227 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { 3228 if (hasVariableReference(i.value())) 3229 return true; 3230 } 3231 3232 return false; 3233 } 3234 3235 void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) 3236 { 3237 std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*style()->variables())); 3238 3239 if (knownExpressions.contains(expression)) 3240 return; // cycle detected. 3241 3242 knownExpressions.append(expression); 3243 3244 // FIXME: It would be faster not to re-parse from strings, but for now CSS property validation lives inside the parser so we do it there. 3245 RefPtr<StylePropertySet> resultSet = StylePropertySet::create(); 3246 if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, CSSStrictMode, 0)) 3247 return; // expression failed to parse. 3248 3249 for (unsigned i = 0; i < resultSet->propertyCount(); i++) { 3250 const CSSProperty& property = resultSet->propertyAt(i); 3251 if (property.id() != CSSPropertyVariable && hasVariableReference(property.value())) 3252 resolveVariables(property.id(), property.value(), knownExpressions); 3253 else 3254 applyProperty(property.id(), property.value()); 3255 } 3256 } 3257 #endif 3258 3259 void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) 3260 { 3261 #if ENABLE(CSS_VARIABLES) 3262 if (id != CSSPropertyVariable && hasVariableReference(value)) { 3263 Vector<std::pair<CSSPropertyID, String> > knownExpressions; 3264 resolveVariables(id, value, knownExpressions); 3265 return; 3266 } 3267 #endif 3268 3198 3269 bool isInherit = m_parentNode && value->isInheritedValue(); 3199 3270 bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue()); … … 3209 3280 m_parentStyle->setHasExplicitlyInheritedProperties(); 3210 3281 3211 // check lookup table for implementations and use when available 3282 #if ENABLE(CSS_VARIABLES) 3283 if (id == CSSPropertyVariable) { 3284 ASSERT(value->isVariableValue()); 3285 CSSVariableValue* variable = static_cast<CSSVariableValue*>(value); 3286 ASSERT(!variable->name().isEmpty()); 3287 ASSERT(!variable->value().isEmpty()); 3288 m_style->setVariable(variable->name(), variable->value()); 3289 return; 3290 } 3291 #endif 3292 3293 // Check lookup table for implementations and use when available. 3212 3294 const PropertyHandler& handler = m_styleBuilder.propertyHandler(id); 3213 3295 if (handler.isValid()) { … … 5252 5334 for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) { 5253 5335 CSSValue* currValue = i.value(); 5336 5254 5337 if (!currValue->isWebKitCSSTransformValue()) 5255 5338 continue; -
trunk/Source/WebCore/css/StyleResolver.h
r119949 r120154 33 33 #include <wtf/RefPtr.h> 34 34 #include <wtf/Vector.h> 35 #include <wtf/text/AtomicStringHash.h> 35 36 #include <wtf/text/StringHash.h> 36 37 … … 356 357 void applyMatchedProperties(const MatchResult&, const Element*); 357 358 enum StyleApplicationPass { 359 #if ENABLE(CSS_VARIABLES) 360 VariableDefinitions, 361 #endif 358 362 HighPriorityProperties, 359 363 LowPriorityProperties … … 363 367 template <StyleApplicationPass pass> 364 368 void applyProperties(const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, bool filterRegionProperties); 365 369 #if ENABLE(CSS_VARIABLES) 370 void resolveVariables(CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions); 371 #endif 366 372 static bool isValidRegionStyleProperty(CSSPropertyID); 367 373 -
trunk/Source/WebCore/css/WebKitCSSTransformValue.cpp
r118885 r120154 79 79 } 80 80 81 #if ENABLE(CSS_VARIABLES) 82 String WebKitCSSTransformValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const 83 { 84 StringBuilder result; 85 if (m_type != UnknownTransformOperation) { 86 ASSERT(static_cast<size_t>(m_type) < WTF_ARRAY_LENGTH(transformName)); 87 result.append(transformName[m_type]); 88 result.append('('); 89 result.append(CSSValueList::customSerializeResolvingVariables(variables)); 90 result.append(')'); 91 } 92 return result.toString(); 93 } 94 #endif 95 81 96 WebKitCSSTransformValue::WebKitCSSTransformValue(const WebKitCSSTransformValue& cloneFrom) 82 97 : CSSValueList(cloneFrom) -
trunk/Source/WebCore/css/WebKitCSSTransformValue.h
r113588 r120154 67 67 68 68 String customCssText() const; 69 #if ENABLE(CSS_VARIABLES) 70 String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const; 71 #endif 69 72 70 73 TransformOperationType operationType() const { return m_type; } -
trunk/Source/WebCore/css/makeprop.pl
r118624 r120154 165 165 enum CSSPropertyID { 166 166 CSSPropertyInvalid = 0, 167 #if ENABLE(CSS_VARIABLES) 168 CSSPropertyVariable = 1, 169 #endif 167 170 EOF 168 171 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r119984 r120154 140 140 rareInheritedData.init(); 141 141 inherited.init(); 142 143 142 #if ENABLE(SVG) 144 143 m_svgStyle.init(); -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r120100 r120154 407 407 408 408 const PseudoStyleCache* cachedPseudoStyles() const { return m_cachedPseudoStyles.get(); } 409 410 #if ENABLE(CSS_VARIABLES) 411 void setVariable(const AtomicString& name, const String& value) { rareInheritedData.access()->m_variables.access()->setVariable(name, value); } 412 const HashMap<AtomicString, String>* variables() { return &(rareInheritedData->m_variables->m_data); } 413 #endif 409 414 410 415 bool affectedByHoverRules() const { return noninherited_flags.affectedByHover(); } -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
r119984 r120154 71 71 #endif 72 72 { 73 #if ENABLE(CSS_VARIABLES) 74 m_variables.init(); 75 #endif 73 76 } 74 77 … … 125 128 , tapHighlightColor(o.tapHighlightColor) 126 129 #endif 130 #if ENABLE(CSS_VARIABLES) 131 , m_variables(o.m_variables) 132 #endif 127 133 { 128 134 } … … 193 199 #endif 194 200 && m_lineSnap == o.m_lineSnap 201 #if ENABLE(CSS_VARIABLES) 202 && m_variables == o.m_variables 203 #endif 195 204 && m_lineAlign == o.m_lineAlign; 196 205 } -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h
r119984 r120154 31 31 #include <wtf/PassRefPtr.h> 32 32 #include <wtf/text/AtomicString.h> 33 34 #if ENABLE(CSS_VARIABLES) 35 #include "DataRef.h" 36 #include "StyleVariableData.h" 37 #endif 33 38 34 39 namespace WebCore { … … 119 124 #endif 120 125 126 #if ENABLE(CSS_VARIABLES) 127 DataRef<StyleVariableData> m_variables; 128 #endif 129 121 130 private: 122 131 StyleRareInheritedData();
Note: See TracChangeset
for help on using the changeset viewer.