Changeset 199844 in webkit
- Timestamp:
- Apr 21, 2016 4:28:48 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r199843 r199844 1 2016-04-21 Chris Dumez <cdumez@apple.com> 2 3 Element::idForStyleResolution() is a foot-gun 4 https://bugs.webkit.org/show_bug.cgi?id=156852 5 6 Reviewed by Darin Adler. 7 8 Element::idForStyleResolution() is a foot-gun. It requires the caller to check 9 Element::hasID() first or it may end up crashing when dereferencing elementData() 10 (e.g. see Bug 156806). 11 12 This patch updates Element::idForStyleResolution() to return nullAtom is the 13 Element does not have an ID. I did not see a performance impact on Speedometer, 14 Dromaeo DOM Core, Dromaeo CSS Selectors and our local performanceTests/. 15 16 * css/ElementRuleCollector.cpp: 17 (WebCore::ElementRuleCollector::collectMatchingRules): 18 * css/SelectorChecker.cpp: 19 (WebCore::SelectorChecker::checkOne): 20 * css/SelectorFilter.cpp: 21 (WebCore::collectElementIdentifierHashes): 22 * dom/Element.h: 23 (WebCore::Element::idForStyleResolution): 24 * rendering/RenderBlockFlow.cpp: 25 (WebCore::needsAppleMailPaginationQuirk): 26 * rendering/RenderTreeAsText.cpp: 27 (WebCore::writeRenderRegionList): 28 * style/StyleSharingResolver.cpp: 29 (WebCore::Style::SharingResolver::canShareStyleWithElement): 30 1 31 2016-04-21 Brady Eidson <beidson@apple.com> 2 32 -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r199291 r199844 154 154 // We need to collect the rules for id, class, tag, and everything else into a buffer and 155 155 // then sort the buffer. 156 if (m_element.hasID()) 157 collectMatchingRulesForList(matchRequest.ruleSet->idRules(m_element.idForStyleResolution().impl()), matchRequest, ruleRange); 156 auto& id = m_element.idForStyleResolution(); 157 if (!id.isNull()) 158 collectMatchingRulesForList(matchRequest.ruleSet->idRules(*id.impl()), matchRequest, ruleRange); 158 159 if (m_element.hasClass()) { 159 160 for (size_t i = 0; i < m_element.classNames().size(); ++i) -
trunk/Source/WebCore/css/RuleSet.h
r197165 r199844 175 175 const RuleFeatureSet& features() const { return m_features; } 176 176 177 const RuleDataVector* idRules(AtomicStringImpl * key) const { return m_idRules.get(key); }177 const RuleDataVector* idRules(AtomicStringImpl& key) const { return m_idRules.get(&key); } 178 178 const RuleDataVector* classRules(AtomicStringImpl* key) const { return m_classRules.get(key); } 179 179 const RuleDataVector* tagRules(AtomicStringImpl* key, bool isHTMLName) const; -
trunk/Source/WebCore/css/SelectorChecker.cpp
r199583 r199844 653 653 return element.hasClass() && element.classNames().contains(selector.value()); 654 654 655 if (selector.match() == CSSSelector::Id) 656 return element.hasID() && element.idForStyleResolution() == selector.value(); 655 if (selector.match() == CSSSelector::Id) { 656 ASSERT(!selector.value().isNull()); 657 return element.idForStyleResolution() == selector.value(); 658 } 657 659 658 660 if (selector.isAttributeSelector()) { -
trunk/Source/WebCore/css/SelectorFilter.cpp
r194762 r199844 44 44 identifierHashes.append(tagLowercaseLocalName.impl()->existingHash() * TagNameSalt); 45 45 46 if (element->hasID()) 47 identifierHashes.append(element->idForStyleResolution().impl()->existingHash() * IdAttributeSalt); 46 auto& id = element->idForStyleResolution(); 47 if (!id.isNull()) 48 identifierHashes.append(id.impl()->existingHash() * IdAttributeSalt); 48 49 const StyledElement* styledElement = element->isStyledElement() ? static_cast<const StyledElement*>(element) : 0; 49 50 if (styledElement && styledElement->hasClass()) { -
trunk/Source/WebCore/dom/Element.h
r199154 r199844 665 665 inline const AtomicString& Element::idForStyleResolution() const 666 666 { 667 ASSERT(hasID()); 668 return elementData()->idForStyleResolution(); 667 return hasID() ? elementData()->idForStyleResolution() : nullAtom; 669 668 } 670 669 -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r199784 r199844 1644 1644 return false; 1645 1645 1646 if (renderer.element() && renderer.element()-> hasID() && renderer.element()->idForStyleResolution() == "messageContentContainer")1646 if (renderer.element() && renderer.element()->idForStyleResolution() == "messageContentContainer") 1647 1647 return true; 1648 1648 -
trunk/Source/WebCore/rendering/RenderTreeAsText.cpp
r198859 r199844 691 691 ts << " {" << tagName.toString() << "}"; 692 692 693 if (generatingElement->hasID()) 694 ts << " #" << generatingElement->idForStyleResolution(); 693 auto& generatingElementId = generatingElement->idForStyleResolution(); 694 if (!generatingElementId.isNull()) 695 ts << " #" << generatingElementId; 695 696 696 697 if (isRenderNamedFlowFragment) -
trunk/Source/WebCore/style/StyleSharingResolver.cpp
r199584 r199844 89 89 return nullptr; 90 90 // Ids stop style sharing if they show up in the stylesheets. 91 if (element.hasID() && m_ruleSets.features().idsInRules.contains(element.idForStyleResolution().impl())) 91 auto& id = element.idForStyleResolution(); 92 if (!id.isNull() && m_ruleSets.features().idsInRules.contains(id.impl())) 92 93 return nullptr; 93 94 if (parentElementPreventsSharing(parentElement)) … … 238 239 return false; 239 240 240 if (candidateElement.hasID() && m_ruleSets.features().idsInRules.contains(candidateElement.idForStyleResolution().impl())) 241 auto& candidateElementId = candidateElement.idForStyleResolution(); 242 if (!candidateElementId.isNull() && m_ruleSets.features().idsInRules.contains(candidateElementId.impl())) 241 243 return false; 242 244
Note: See TracChangeset
for help on using the changeset viewer.