Changeset 102770 in webkit
- Timestamp:
- Dec 14, 2011 5:51:58 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r102768 r102770 1 2011-12-14 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 3 Add different salt to different types of selectors. So the CSS fast 4 path can tell the different between tags and class attributes with 5 otherwise identical values. 6 https://bugs.webkit.org/show_bug.cgi?id=74284 7 8 Reviewed by Antti Koivisto. 9 10 * css/SelectorChecker.cpp: 11 (WebCore::collectElementIdentifierHashes): 12 (WebCore::collectDescendantSelectorIdentifierHashes): 13 * css/SelectorChecker.h: 14 1 15 2011-12-14 Pierre Rossi <pierre.rossi@gmail.com> 2 16 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r102606 r102770 79 79 } 80 80 81 // Salt to separate otherwise identical string hashes so a class-selector like .article won't match <article> elements. 82 enum { TagNameSalt = 13, IdAttributeSalt = 17, ClassAttributeSalt = 19 }; 83 81 84 static inline void collectElementIdentifierHashes(const Element* element, Vector<unsigned, 4>& identifierHashes) 82 85 { 83 identifierHashes.append(element->localName().impl()->existingHash() );86 identifierHashes.append(element->localName().impl()->existingHash() * TagNameSalt); 84 87 if (element->hasID()) 85 identifierHashes.append(element->idForStyleResolution().impl()->existingHash() );88 identifierHashes.append(element->idForStyleResolution().impl()->existingHash() * IdAttributeSalt); 86 89 const StyledElement* styledElement = element->isStyledElement() ? static_cast<const StyledElement*>(element) : 0; 87 90 if (styledElement && styledElement->hasClass()) { … … 89 92 size_t count = classNames.size(); 90 93 for (size_t i = 0; i < count; ++i) 91 identifierHashes.append(classNames[i].impl()->existingHash() );94 identifierHashes.append(classNames[i].impl()->existingHash() * ClassAttributeSalt); 92 95 } 93 96 } … … 163 166 static inline void collectDescendantSelectorIdentifierHashes(const CSSSelector* selector, unsigned*& hash, const unsigned* end) 164 167 { 165 if ((selector->m_match == CSSSelector::Id || selector->m_match == CSSSelector::Class) && !selector->value().isEmpty()) 166 (*hash++) = selector->value().impl()->existingHash(); 168 switch (selector->m_match) { 169 case CSSSelector::Id: 170 if (!selector->value().isEmpty()) 171 (*hash++) = selector->value().impl()->existingHash() * IdAttributeSalt; 172 break; 173 case CSSSelector::Class: 174 if (!selector->value().isEmpty()) 175 (*hash++) = selector->value().impl()->existingHash() * ClassAttributeSalt; 176 break; 177 default: 178 break; 179 } 167 180 if (hash == end) 168 181 return; 169 182 const AtomicString& localName = selector->tag().localName(); 170 183 if (localName != starAtom) 171 (*hash++) = localName.impl()->existingHash() ;184 (*hash++) = localName.impl()->existingHash() * TagNameSalt; 172 185 } 173 186 -
trunk/Source/WebCore/css/SelectorChecker.h
r97854 r102770 119 119 }; 120 120 Vector<ParentStackFrame> m_parentStack; 121 121 122 122 // With 100 unique strings in the filter, 2^12 slot table has false positive rate of ~0.2%. 123 123 static const unsigned bloomFilterKeyBits = 12;
Note: See TracChangeset
for help on using the changeset viewer.