Changeset 117809 in webkit
- Timestamp:
- May 21, 2012 12:36:39 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r117779 r117809 1 2012-05-21 Andreas Kling <kling@webkit.org> 2 3 CSS: Move duplicate property elimination to parser. 4 <http://webkit.org/b/86948> 5 6 Reviewed by Antti Koivisto. 7 8 Add WTF::BitArray, a simple, malloc free, fixed-size bit array class. 9 10 * GNUmakefile.list.am: 11 * WTF.gypi: 12 * WTF.pro: 13 * WTF.vcproj/WTF.vcproj: 14 * WTF.xcodeproj/project.pbxproj: 15 * wtf/BitArray.h: Added. 16 (WTF): 17 (BitArray): 18 (WTF::BitArray::BitArray): 19 (WTF::BitArray::set): 20 (WTF::BitArray::get): 21 * wtf/CMakeLists.txt: 22 1 23 2012-05-21 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 24 -
trunk/Source/WTF/GNUmakefile.list.am
r115248 r117809 13 13 Source/WTF/wtf/Assertions.h \ 14 14 Source/WTF/wtf/Atomics.h \ 15 Source/WTF/wtf/BitArray.h \ 15 16 Source/WTF/wtf/BitVector.cpp \ 16 17 Source/WTF/wtf/BitVector.h \ -
trunk/Source/WTF/WTF.gypi
r115248 r117809 9 9 'wtf/Assertions.h', 10 10 'wtf/Atomics.h', 11 'wtf/BitArray.h', 11 12 'wtf/BitVector.h', 12 13 'wtf/Bitmap.h', -
trunk/Source/WTF/WTF.pro
r115248 r117809 23 23 AVLTree.h \ 24 24 Bitmap.h \ 25 BitArray.h \ 25 26 BitVector.h \ 26 27 BloomFilter.h \ -
trunk/Source/WTF/WTF.vcproj/WTF.vcproj
r115248 r117809 606 606 </File> 607 607 <File 608 RelativePath="..\wtf\BitArray.h" 609 > 610 </File> 611 <File 608 612 RelativePath="..\wtf\BitVector.cpp" 609 613 > -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r117008 r117809 8 8 9 9 /* Begin PBXBuildFile section */ 10 4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F0321BB156AA8D1006EBAF6 /* BitArray.h */; }; 10 11 A876DBD8151816E500DADB95 /* Platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A876DBD7151816E500DADB95 /* Platform.h */; }; 11 12 A8A4737F151A825B004123FF /* Alignment.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47254151A825A004123FF /* Alignment.h */; }; … … 241 242 242 243 /* Begin PBXFileReference section */ 244 4F0321BB156AA8D1006EBAF6 /* BitArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitArray.h; sourceTree = "<group>"; }; 243 245 5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; }; 244 246 5D247B6E14689C4700E78B76 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; … … 547 549 A8A4725E151A825A004123FF /* AVLTree.h */, 548 550 A8A4725F151A825A004123FF /* Bitmap.h */, 551 4F0321BB156AA8D1006EBAF6 /* BitArray.h */, 549 552 A8A47260151A825A004123FF /* BitVector.cpp */, 550 553 A8A47261151A825A004123FF /* BitVector.h */, … … 861 864 A8A47389151A825B004123FF /* AVLTree.h in Headers */, 862 865 A8A4738A151A825B004123FF /* Bitmap.h in Headers */, 866 4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */, 863 867 A8A4738C151A825B004123FF /* BitVector.h in Headers */, 864 868 A8A4738E151A825B004123FF /* BlockStack.h in Headers */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r115248 r117809 6 6 Assertions.h 7 7 Atomics.h 8 BitArray.h 8 9 BitVector.h 9 10 Bitmap.h -
trunk/Source/WebCore/ChangeLog
r117808 r117809 1 2012-05-21 Andreas Kling <kling@webkit.org> 2 3 CSS: Move duplicate property elimination to parser. 4 <http://webkit.org/b/86948> 5 6 Reviewed by Antti Koivisto. 7 8 Remove the StylePropertySet constructor that handled elimination of duplicate 9 properties and move that to a new parser method, CSSParser::filteredProperties(). 10 Call sites are converted to using StylePropertySet(const Vector<CSSProperty>&). 11 12 Instead of building a hashmap of seen properties, use the new WTF::BitArray class 13 to track whether a given property ID has been seen, and whether we have an 14 !important entry for a given ID. 15 16 * css/CSSParser.cpp: 17 (WebCore::CSSParser::parseValue): 18 (WebCore::CSSParser::parseDeclaration): 19 (WebCore::CSSParser::filteredProperties): 20 (WebCore::CSSParser::createStyleRule): 21 (WebCore::CSSParser::createFontFaceRule): 22 (WebCore::CSSParser::createPageRule): 23 (WebCore::CSSParser::createKeyframe): 24 * css/CSSParser.h: 25 * css/StylePropertySet.cpp: 26 (WebCore::StylePropertySet::StylePropertySet): 27 (WebCore::StylePropertySet::addParsedProperties): 28 * css/StylePropertySet.h: 29 (WebCore::StylePropertySet::create): 30 (StylePropertySet): 31 * svg/SVGFontFaceElement.cpp: 32 (WebCore::SVGFontFaceElement::rebuildFontFace): 33 1 34 2012-05-21 Joshua Bell <jsbell@chromium.org> 2 35 -
trunk/Source/WebCore/css/CSSParser.cpp
r117622 r117809 90 90 #endif 91 91 #include <limits.h> 92 #include <wtf/BitArray.h> 92 93 #include <wtf/HexNumber.h> 93 94 #include <wtf/dtoa.h> … … 978 979 if (!m_parsedProperties.isEmpty()) { 979 980 ok = true; 980 declaration->addParsedProperties(m_parsedProperties .data(), m_parsedProperties.size());981 declaration->addParsedProperties(m_parsedProperties); 981 982 clearProperties(); 982 983 } … … 1074 1075 if (!m_parsedProperties.isEmpty()) { 1075 1076 ok = true; 1076 declaration->addParsedProperties(m_parsedProperties .data(), m_parsedProperties.size());1077 declaration->addParsedProperties(m_parsedProperties); 1077 1078 clearProperties(); 1078 1079 } … … 1108 1109 1109 1110 return m_mediaQuery.release(); 1111 } 1112 1113 Vector<CSSProperty> CSSParser::filteredProperties() const 1114 { 1115 BitArray<numCSSProperties> seenProperties; 1116 BitArray<numCSSProperties> seenImportantProperties; 1117 1118 Vector<CSSProperty> results; 1119 results.reserveInitialCapacity(m_parsedProperties.size()); 1120 1121 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 1122 const CSSProperty& property = m_parsedProperties[i]; 1123 const unsigned propertyIDIndex = property.id() - firstCSSProperty; 1124 1125 // Ignore non-important properties if we already have an important property with the same ID. 1126 if (!property.isImportant() && seenImportantProperties.get(propertyIDIndex)) 1127 continue; 1128 1129 // If we already had this property, this new one takes precedence, so wipe out the old one. 1130 if (seenProperties.get(propertyIDIndex)) { 1131 for (unsigned i = 0; i < results.size(); ++i) { 1132 if (results[i].id() == property.id()) { 1133 results.remove(i); 1134 break; 1135 } 1136 } 1137 } 1138 1139 if (property.isImportant()) 1140 seenImportantProperties.set(propertyIDIndex); 1141 seenProperties.set(propertyIDIndex); 1142 1143 results.append(property); 1144 } 1145 1146 return results; 1110 1147 } 1111 1148 … … 9042 9079 if (m_hasFontFaceOnlyValues) 9043 9080 deleteFontFaceOnlyValues(); 9044 rule->setProperties(StylePropertySet::create( m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));9081 rule->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode)); 9045 9082 result = rule.get(); 9046 9083 m_parsedRules.append(rule.release()); … … 9078 9115 } 9079 9116 RefPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create(); 9080 rule->setProperties(StylePropertySet::create( m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));9117 rule->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode)); 9081 9118 clearProperties(); 9082 9119 StyleRuleFontFace* result = rule.get(); … … 9151 9188 selectorVector.append(pageSelector); 9152 9189 rule->parserAdoptSelectorVector(selectorVector); 9153 rule->setProperties(StylePropertySet::create( m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));9190 rule->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode)); 9154 9191 pageRule = rule.get(); 9155 9192 m_parsedRules.append(rule.release()); … … 9229 9266 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); 9230 9267 keyframe->setKeyText(keyString); 9231 keyframe->setProperties(StylePropertySet::create( m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));9268 keyframe->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode)); 9232 9269 9233 9270 clearProperties(); -
trunk/Source/WebCore/css/CSSParser.h
r117613 r117809 283 283 void clearProperties(); 284 284 285 Vector<CSSProperty> filteredProperties() const; 286 285 287 CSSParserContext m_context; 286 288 -
trunk/Source/WebCore/css/StylePropertySet.cpp
r117369 r117809 57 57 } 58 58 59 StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties )59 StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties, CSSParserMode cssParserMode) 60 60 : m_properties(properties) 61 , m_cssParserMode( CSSStrictMode)61 , m_cssParserMode(cssParserMode) 62 62 , m_ownsCSSOMWrapper(false) 63 63 { 64 64 m_properties.shrinkToFit(); 65 }66 67 StylePropertySet::StylePropertySet(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)68 : m_cssParserMode(cssParserMode)69 , m_ownsCSSOMWrapper(false)70 {71 // FIXME: This logic belongs in CSSParser.72 73 m_properties.reserveInitialCapacity(numProperties);74 HashMap<int, bool> candidates;75 for (int i = 0; i < numProperties; ++i) {76 const CSSProperty& property = properties[i];77 bool important = property.isImportant();78 79 HashMap<int, bool>::iterator it = candidates.find(property.id());80 if (it != candidates.end()) {81 if (!important && it->second)82 continue;83 removeProperty(property.id());84 }85 86 m_properties.append(property);87 candidates.set(property.id(), important);88 }89 65 } 90 66 … … 593 569 } 594 570 595 void StylePropertySet::addParsedProperties(const CSSProperty* properties, int numProperties)596 { 597 m_properties.reserveCapacity( numProperties);598 for ( int i = 0; i < numProperties; ++i)571 void StylePropertySet::addParsedProperties(const Vector<CSSProperty>& properties) 572 { 573 m_properties.reserveCapacity(m_properties.size() + properties.size()); 574 for (unsigned i = 0; i < properties.size(); ++i) 599 575 addParsedProperty(properties[i]); 600 576 } -
trunk/Source/WebCore/css/StylePropertySet.h
r117369 r117809 48 48 return adoptRef(new StylePropertySet(cssParserMode)); 49 49 } 50 static PassRefPtr<StylePropertySet> create(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)50 static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties, CSSParserMode cssParserMode = CSSStrictMode) 51 51 { 52 return adoptRef(new StylePropertySet(properties, numProperties, cssParserMode)); 53 } 54 static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties) 55 { 56 return adoptRef(new StylePropertySet(properties)); 52 return adoptRef(new StylePropertySet(properties, cssParserMode)); 57 53 } 58 54 … … 81 77 void parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet); 82 78 83 void addParsedProperties(const CSSProperty*, int numProperties);79 void addParsedProperties(const Vector<CSSProperty>&); 84 80 void addParsedProperty(const CSSProperty&); 85 81 … … 122 118 private: 123 119 StylePropertySet(CSSParserMode); 124 StylePropertySet(const Vector<CSSProperty>& );120 StylePropertySet(const Vector<CSSProperty>&, CSSParserMode); 125 121 StylePropertySet(const StylePropertySet&); 126 StylePropertySet(const CSSProperty*, int numProperties, CSSParserMode);127 122 128 123 void setNeedsStyleRecalc(); -
trunk/Source/WebCore/svg/SVGFontFaceElement.cpp
r117195 r117809 298 298 299 299 // Parse in-memory CSS rules 300 CSSProperty srcProperty(CSSPropertySrc, list); 301 m_fontFaceRule->properties()->addParsedProperties(&srcProperty, 1); 300 m_fontFaceRule->properties()->addParsedProperty(CSSProperty(CSSPropertySrc, list)); 302 301 303 302 if (describesParentFont) {
Note: See TracChangeset
for help on using the changeset viewer.