Changeset 133451 in webkit
- Timestamp:
- Nov 5, 2012 2:47:35 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r133447 r133451 1 2012-11-05 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r133286, r133385, and r133394. 4 http://trac.webkit.org/changeset/133286 5 http://trac.webkit.org/changeset/133385 6 http://trac.webkit.org/changeset/133394 7 https://bugs.webkit.org/show_bug.cgi?id=101198 8 9 Broke image placement on some web sites. (Requested by kling 10 on #webkit). 11 12 * css/StyleResolver.cpp: 13 (WebCore::StyleResolver::sweepMatchedPropertiesCache): 14 (WebCore::StyleResolver::matchAllRules): 15 (WebCore::StyleResolver::canShareStyleWithElement): 16 * dom/Attr.cpp: 17 (WebCore::Attr::detachFromElementWithValue): 18 * dom/Element.cpp: 19 (WebCore::Element::~Element): 20 (WebCore::Element::detachAttribute): 21 (WebCore::Element::getAttribute): 22 (WebCore::Element::setAttributeNode): 23 (WebCore::Element::removeAttributeInternal): 24 (WebCore::Element::getAttributeNode): 25 (WebCore::Element::getAttributeNodeNS): 26 (WebCore::Element::normalizeAttributes): 27 (WebCore::Element::attrIfExists): 28 (WebCore::Element::ensureAttr): 29 (WebCore::Element::cloneAttributesFromElement): 30 * dom/Element.h: 31 (Element): 32 (WebCore::Element::updateInvalidAttributes): 33 * dom/ElementAttributeData.cpp: 34 (WebCore::MutableElementAttributeData::MutableElementAttributeData): 35 (WebCore): 36 (WebCore::attrListMap): 37 (WebCore::attrListForElement): 38 (WebCore::ensureAttrListForElement): 39 (WebCore::removeAttrListForElement): 40 (WebCore::findAttrInList): 41 (WebCore::ElementAttributeData::attrIfExists): 42 (WebCore::ElementAttributeData::ensureAttr): 43 (WebCore::ElementAttributeData::setAttr): 44 (WebCore::ElementAttributeData::removeAttr): 45 (WebCore::ElementAttributeData::detachAttrObjectsFromElement): 46 (WebCore::ElementAttributeData::reportMemoryUsage): 47 (WebCore::ElementAttributeData::cloneDataFrom): 48 (WebCore::ElementAttributeData::clearAttributes): 49 (WebCore::ElementAttributeData::getAttributeNode): 50 * dom/ElementAttributeData.h: 51 (WebCore): 52 (WebCore::ElementAttributeData::attributeStyle): 53 (WebCore::ElementAttributeData::setAttributeStyle): 54 (ElementAttributeData): 55 (WebCore::ElementAttributeData::ElementAttributeData): 56 * dom/Node.h: 57 (WebCore): 58 (WebCore::Node::hasAttrList): 59 (WebCore::Node::attributeStyleDirty): 60 (WebCore::Node::setAttributeStyleDirty): 61 (WebCore::Node::clearAttributeStyleDirty): 62 (Node): 63 (WebCore::Node::setHasAttrList): 64 (WebCore::Node::clearHasAttrList): 65 (WebCore::Node::isStyleAttributeValid): 66 (WebCore::Node::setIsStyleAttributeValid): 67 (WebCore::Node::clearIsStyleAttributeValid): 68 * dom/StyledElement.cpp: 69 (WebCore::StyledElement::updateStyleAttribute): 70 (WebCore::StyledElement::attributeChanged): 71 (WebCore::StyledElement::styleAttributeChanged): 72 (WebCore::StyledElement::inlineStyleChanged): 73 (WebCore::StyledElement::updateAttributeStyle): 74 * dom/StyledElement.h: 75 (StyledElement): 76 (WebCore::StyledElement::invalidateStyleAttribute): 77 (WebCore::StyledElement::attributeStyle): 78 * inspector/InspectorCSSAgent.cpp: 79 (WebCore::InspectorCSSAgent::buildObjectForAttributesStyle): 80 1 81 2012-11-05 Simon Hausmann <simon.hausmann@digia.com> 2 82 -
trunk/Source/WebCore/css/StyleResolver.cpp
r133324 r133451 479 479 { 480 480 // Look for cache entries containing a style declaration with a single ref and remove them. 481 // This may happen when an element attribute mutation causes it to generate a new presentationAttributeStyle(),481 // This may happen when an element attribute mutation causes it to generate a new attributeStyle(), 482 482 // potentially leaving this cache with the last ref on the old one. 483 483 Vector<unsigned, 16> toRemove; … … 928 928 // Now check author rules, beginning first with presentational attributes mapped from HTML. 929 929 if (m_styledElement) { 930 addElementStyleProperties(result, m_styledElement-> presentationAttributeStyle());930 addElementStyleProperties(result, m_styledElement->attributeStyle()); 931 931 932 932 // Now we check additional mapped declarations. … … 1180 1180 return false; 1181 1181 #endif 1182 if (!!element-> presentationAttributeStyle() != !!m_styledElement->presentationAttributeStyle())1182 if (!!element->attributeStyle() != !!m_styledElement->attributeStyle()) 1183 1183 return false; 1184 1184 const StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle(); … … 1267 1267 } 1268 1268 1269 if (element-> presentationAttributeStyle() && !attributeStylesEqual(element->presentationAttributeStyle(), m_styledElement->presentationAttributeStyle()))1269 if (element->attributeStyle() && !attributeStylesEqual(element->attributeStyle(), m_styledElement->attributeStyle())) 1270 1270 return false; 1271 1271 -
trunk/Source/WebCore/dom/Attr.cpp
r133394 r133451 219 219 ASSERT(m_element); 220 220 ASSERT(m_standaloneValue.isNull()); 221 m_element->attributeData()->removeAttr(m_element, qualifiedName()); 221 222 m_standaloneValue = value; 222 223 m_element = 0; -
trunk/Source/WebCore/dom/Element.cpp
r133428 r133451 125 125 }; 126 126 127 typedef Vector<RefPtr<Attr> > AttrNodeList;128 typedef HashMap<Element*, OwnPtr<AttrNodeList> > AttrNodeListMap;129 130 static AttrNodeListMap& attrNodeListMap()131 {132 DEFINE_STATIC_LOCAL(AttrNodeListMap, map, ());133 return map;134 }135 136 static AttrNodeList* attrNodeListForElement(Element* element)137 {138 if (!element->hasSyntheticAttrChildNodes())139 return 0;140 ASSERT(attrNodeListMap().contains(element));141 return attrNodeListMap().get(element);142 }143 144 static AttrNodeList* ensureAttrNodeListForElement(Element* element)145 {146 if (element->hasSyntheticAttrChildNodes()) {147 ASSERT(attrNodeListMap().contains(element));148 return attrNodeListMap().get(element);149 }150 ASSERT(!attrNodeListMap().contains(element));151 element->setHasSyntheticAttrChildNodes(true);152 AttrNodeListMap::AddResult result = attrNodeListMap().add(element, adoptPtr(new AttrNodeList));153 return result.iterator->value.get();154 }155 156 static void removeAttrNodeListForElement(Element* element)157 {158 ASSERT(element->hasSyntheticAttrChildNodes());159 ASSERT(attrNodeListMap().contains(element));160 attrNodeListMap().remove(element);161 element->setHasSyntheticAttrChildNodes(false);162 }163 164 static Attr* findAttrNodeInList(AttrNodeList* attrNodeList, const QualifiedName& name)165 {166 for (unsigned i = 0; i < attrNodeList->size(); ++i) {167 if (attrNodeList->at(i)->qualifiedName() == name)168 return attrNodeList->at(i).get();169 }170 return 0;171 }172 173 127 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* document) 174 128 { … … 192 146 } 193 147 194 if (hasSyntheticAttrChildNodes()) 195 detachAllAttrNodesFromElement(); 148 if (hasAttrList()) { 149 ASSERT(m_attributeData); 150 m_attributeData->detachAttrObjectsFromElement(this); 151 } 196 152 } 197 153 … … 252 208 ASSERT(attribute); 253 209 254 RefPtr<Attr> attr Node= attrIfExists(attribute->name());255 if (attr Node)256 detachAttrNodeFromElementWithValue(attrNode.get(),attribute->value());210 RefPtr<Attr> attr = attrIfExists(attribute->name()); 211 if (attr) 212 attr->detachFromElementWithValue(attribute->value()); 257 213 else 258 attr Node= Attr::create(document(), attribute->name(), attribute->value());214 attr = Attr::create(document(), attribute->name(), attribute->value()); 259 215 260 216 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); 261 return attr Node.release();217 return attr.release(); 262 218 } 263 219 … … 305 261 const AtomicString& Element::getAttribute(const QualifiedName& name) const 306 262 { 307 if (UNLIKELY(name == styleAttr) && styleAttributeIsDirty())263 if (UNLIKELY(name == styleAttr) && !isStyleAttributeValid()) 308 264 updateStyleAttribute(); 309 265 … … 663 619 664 620 // Update the 'style' attribute if it's invalid and being requested: 665 if ( styleAttributeIsDirty() && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase))621 if (!isStyleAttributeValid() && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase)) 666 622 updateStyleAttribute(); 667 623 … … 1529 1485 #endif 1530 1486 1531 PassRefPtr<Attr> Element::setAttributeNode(Attr* attr Node, ExceptionCode& ec)1532 { 1533 if (!attr Node) {1487 PassRefPtr<Attr> Element::setAttributeNode(Attr* attr, ExceptionCode& ec) 1488 { 1489 if (!attr) { 1534 1490 ec = TYPE_MISMATCH_ERR; 1535 1491 return 0; 1536 1492 } 1537 1493 1538 RefPtr<Attr> oldAttr Node = attrIfExists(attrNode->qualifiedName());1539 if (oldAttr Node.get() == attrNode)1540 return attr Node; // This Attr is already attached to the element.1494 RefPtr<Attr> oldAttr = attrIfExists(attr->qualifiedName()); 1495 if (oldAttr.get() == attr) 1496 return attr; // This Attr is already attached to the element. 1541 1497 1542 1498 // INUSE_ATTRIBUTE_ERR: Raised if node is an Attr that is already an attribute of another Element object. 1543 1499 // The DOM user must explicitly clone Attr nodes to re-use them in other elements. 1544 if (attr Node->ownerElement()) {1500 if (attr->ownerElement()) { 1545 1501 ec = INUSE_ATTRIBUTE_ERR; 1546 1502 return 0; … … 1550 1506 ElementAttributeData* attributeData = mutableAttributeData(); 1551 1507 1552 size_t index = attributeData->getAttributeItemIndex(attr Node->qualifiedName());1508 size_t index = attributeData->getAttributeItemIndex(attr->qualifiedName()); 1553 1509 if (index != notFound) { 1554 if (oldAttr Node)1555 detachAttrNodeFromElementWithValue(oldAttrNode.get(),attributeData->attributeItem(index)->value());1510 if (oldAttr) 1511 oldAttr->detachFromElementWithValue(attributeData->attributeItem(index)->value()); 1556 1512 else 1557 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), attributeData->attributeItem(index)->value()); 1558 } 1559 1560 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), NotInSynchronizationOfLazyAttribute); 1561 1562 attrNode->attachToElement(this); 1563 ensureAttrNodeListForElement(this)->append(attrNode); 1564 1565 return oldAttrNode.release(); 1513 oldAttr = Attr::create(document(), attr->qualifiedName(), attributeData->attributeItem(index)->value()); 1514 } 1515 1516 setAttributeInternal(index, attr->qualifiedName(), attr->value(), NotInSynchronizationOfLazyAttribute); 1517 attributeData->setAttr(this, attr->qualifiedName(), attr); 1518 return oldAttr.release(); 1566 1519 } 1567 1520 … … 1636 1589 } 1637 1590 1638 if (RefPtr<Attr> attrNode = attrIfExists(name)) 1639 detachAttrNodeFromElementWithValue(attrNode.get(), attributeData->attributeItem(index)->value()); 1591 if (hasAttrList()) { 1592 if (RefPtr<Attr> attr = attributeData->attrIfExists(this, name)) 1593 attr->detachFromElementWithValue(attributeData->attributeItem(index)->value()); 1594 } 1640 1595 1641 1596 attributeData->removeAttribute(index); … … 1679 1634 if (!attributeData) 1680 1635 return 0; 1681 const Attribute* attribute = attributeData->getAttributeItem(name, shouldIgnoreAttributeCase(this)); 1682 if (!attribute) 1683 return 0; 1684 return ensureAttr(attribute->name()); 1636 return attributeData->getAttributeNode(name, shouldIgnoreAttributeCase(this), this); 1685 1637 } 1686 1638 … … 1690 1642 if (!attributeData) 1691 1643 return 0; 1692 const Attribute* attribute = attributeData->getAttributeItem(QualifiedName(nullAtom, localName, namespaceURI)); 1693 if (!attribute) 1694 return 0; 1695 return ensureAttr(attribute->name()); 1644 return attributeData->getAttributeNode(QualifiedName(nullAtom, localName, namespaceURI), this); 1696 1645 } 1697 1646 … … 1929 1878 void Element::normalizeAttributes() 1930 1879 { 1931 if (AttrNodeList* attrNodeList = attrNodeListForElement(this)) { 1932 for (unsigned i = 0; i < attrNodeList->size(); ++i) 1933 attrNodeList->at(i)->normalize(); 1880 if (!hasAttrList()) 1881 return; 1882 1883 const ElementAttributeData* attributeData = updatedAttributeData(); 1884 ASSERT(attributeData); 1885 1886 for (size_t i = 0; i < attributeData->length(); ++i) { 1887 if (RefPtr<Attr> attr = attrIfExists(attributeData->attributeItem(i)->name())) 1888 attr->normalize(); 1934 1889 } 1935 1890 } … … 2381 2336 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name) 2382 2337 { 2383 if (AttrNodeList* attrNodeList = attrNodeListForElement(this)) 2384 return findAttrNodeInList(attrNodeList, name); 2385 return 0; 2338 if (!hasAttrList()) 2339 return 0; 2340 ASSERT(attributeData()); 2341 return attributeData()->attrIfExists(this, name); 2386 2342 } 2387 2343 2388 2344 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name) 2389 2345 { 2390 AttrNodeList* attrNodeList = ensureAttrNodeListForElement(this); 2391 RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name); 2392 if (!attrNode) { 2393 attrNode = Attr::create(this, name); 2394 attrNodeList->append(attrNode); 2395 } 2396 return attrNode.release(); 2397 } 2398 2399 void Element::detachAttrNodeFromElementWithValue(Attr* attrNode, const AtomicString& value) 2400 { 2401 ASSERT(hasSyntheticAttrChildNodes()); 2402 attrNode->detachFromElementWithValue(value); 2403 2404 AttrNodeList* attrNodeList = attrNodeListForElement(this); 2405 for (unsigned i = 0; i < attrNodeList->size(); ++i) { 2406 if (attrNodeList->at(i)->qualifiedName() == attrNode->qualifiedName()) { 2407 attrNodeList->remove(i); 2408 if (attrNodeList->isEmpty()) 2409 removeAttrNodeListForElement(this); 2410 return; 2411 } 2412 } 2413 ASSERT_NOT_REACHED(); 2414 } 2415 2416 void Element::detachAllAttrNodesFromElement() 2417 { 2418 AttrNodeList* attrNodeList = attrNodeListForElement(this); 2419 ASSERT(attrNodeList); 2420 2421 for (unsigned i = 0; i < attributeCount(); ++i) { 2422 const Attribute* attribute = attributeItem(i); 2423 if (RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, attribute->name())) 2424 attrNode->detachFromElementWithValue(attribute->value()); 2425 } 2426 2427 removeAttrNodeListForElement(this); 2346 ASSERT(attributeData()); 2347 return attributeData()->ensureAttr(this, name); 2428 2348 } 2429 2349 … … 2449 2369 void Element::cloneAttributesFromElement(const Element& other) 2450 2370 { 2451 if (hasSyntheticAttrChildNodes())2452 detachAllAttrNodesFromElement();2453 2454 2371 if (const ElementAttributeData* attributeData = other.updatedAttributeData()) 2455 2372 mutableAttributeData()->cloneDataFrom(*attributeData, other, *this); 2456 2373 else if (m_attributeData) { 2457 m_attributeData->clearAttributes( );2374 m_attributeData->clearAttributes(this); 2458 2375 m_attributeData.clear(); 2459 2376 } -
trunk/Source/WebCore/dom/Element.h
r133394 r133451 4 4 * (C) 2001 Peter Kelly (pmk@post.com) 5 5 * (C) 2001 Dirk Mueller (mueller@kde.org) 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 , 2012Apple Inc. All rights reserved.6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 7 7 * 8 8 * This library is free software; you can redistribute it and/or … … 466 466 void classAttributeChanged(const AtomicString& newClassString); 467 467 468 bool styleAttributeIsDirty() const;469 470 468 private: 471 469 // FIXME: Remove the need for Attr to call willModifyAttribute/didModifyAttribute. … … 530 528 ElementRareData* elementRareData() const; 531 529 ElementRareData* ensureElementRareData(); 532 533 void detachAllAttrNodesFromElement();534 void detachAttrNodeFromElementWithValue(Attr*, const AtomicString& value);535 530 536 531 RefPtr<ElementAttributeData> m_attributeData; … … 734 729 } 735 730 736 inline bool Element::styleAttributeIsDirty() const737 {738 return m_attributeData && m_attributeData->styleAttributeIsDirty();739 }740 741 731 inline void Element::updateInvalidAttributes() const 742 732 { 743 if ( styleAttributeIsDirty())733 if (!isStyleAttributeValid()) 744 734 updateStyleAttribute(); 745 735 -
trunk/Source/WebCore/dom/ElementAttributeData.cpp
r133394 r133451 36 36 namespace WebCore { 37 37 38 struct SameSizeAsElementAttributeData : public RefCounted<SameSizeAsElementAttributeData> {39 unsigned bitfield;40 void* pointers[4];41 };42 COMPILE_ASSERT(sizeof(ElementAttributeData) == sizeof(ElementAttributeData), element_attribute_data_should_stay_small);43 44 38 static size_t sizeForImmutableElementAttributeDataWithAttributeCount(unsigned count) 45 39 { … … 70 64 71 65 m_inlineStyleDecl = baseOther.m_inlineStyleDecl; 72 m_ presentationAttributeStyle = baseOther.m_presentationAttributeStyle;66 m_attributeStyle = baseOther.m_attributeStyle; 73 67 m_classNames = baseOther.m_classNames; 74 68 m_idForStyleResolution = baseOther.m_idForStyleResolution; … … 92 86 ASSERT(!isMutable()); 93 87 return adoptRef(new MutableElementAttributeData(static_cast<const ImmutableElementAttributeData&>(*this))); 88 } 89 90 typedef Vector<RefPtr<Attr> > AttrList; 91 typedef HashMap<Element*, OwnPtr<AttrList> > AttrListMap; 92 93 static AttrListMap& attrListMap() 94 { 95 DEFINE_STATIC_LOCAL(AttrListMap, map, ()); 96 return map; 97 } 98 99 static AttrList* attrListForElement(Element* element) 100 { 101 ASSERT(element); 102 if (!element->hasAttrList()) 103 return 0; 104 ASSERT(attrListMap().contains(element)); 105 return attrListMap().get(element); 106 } 107 108 static AttrList* ensureAttrListForElement(Element* element) 109 { 110 ASSERT(element); 111 if (element->hasAttrList()) { 112 ASSERT(attrListMap().contains(element)); 113 return attrListMap().get(element); 114 } 115 ASSERT(!attrListMap().contains(element)); 116 element->setHasAttrList(); 117 AttrListMap::AddResult result = attrListMap().add(element, adoptPtr(new AttrList)); 118 return result.iterator->value.get(); 119 } 120 121 static void removeAttrListForElement(Element* element) 122 { 123 ASSERT(element); 124 ASSERT(element->hasAttrList()); 125 ASSERT(attrListMap().contains(element)); 126 attrListMap().remove(element); 127 element->clearHasAttrList(); 128 } 129 130 static Attr* findAttrInList(AttrList* attrList, const QualifiedName& name) 131 { 132 for (unsigned i = 0; i < attrList->size(); ++i) { 133 if (attrList->at(i)->qualifiedName() == name) 134 return attrList->at(i).get(); 135 } 136 return 0; 137 } 138 139 PassRefPtr<Attr> ElementAttributeData::attrIfExists(Element* element, const QualifiedName& name) const 140 { 141 if (AttrList* attrList = attrListForElement(element)) 142 return findAttrInList(attrList, name); 143 return 0; 144 } 145 146 PassRefPtr<Attr> ElementAttributeData::ensureAttr(Element* element, const QualifiedName& name) const 147 { 148 AttrList* attrList = ensureAttrListForElement(element); 149 RefPtr<Attr> attr = findAttrInList(attrList, name); 150 if (!attr) { 151 attr = Attr::create(element, name); 152 attrList->append(attr); 153 } 154 return attr.release(); 155 } 156 157 void ElementAttributeData::setAttr(Element* element, const QualifiedName& name, Attr* attr) const 158 { 159 AttrList* attrList = ensureAttrListForElement(element); 160 161 if (findAttrInList(attrList, name)) 162 return; 163 164 attrList->append(attr); 165 attr->attachToElement(element); 166 } 167 168 void ElementAttributeData::removeAttr(Element* element, const QualifiedName& name) const 169 { 170 AttrList* attrList = attrListForElement(element); 171 ASSERT(attrList); 172 173 for (unsigned i = 0; i < attrList->size(); ++i) { 174 if (attrList->at(i)->qualifiedName() == name) { 175 attrList->remove(i); 176 if (attrList->isEmpty()) 177 removeAttrListForElement(element); 178 return; 179 } 180 } 181 182 ASSERT_NOT_REACHED(); 94 183 } 95 184 … … 170 259 } 171 260 261 void ElementAttributeData::detachAttrObjectsFromElement(Element* element) const 262 { 263 ASSERT(element->hasAttrList()); 264 265 for (unsigned i = 0; i < length(); ++i) { 266 const Attribute* attribute = attributeItem(i); 267 if (RefPtr<Attr> attr = attrIfExists(element, attribute->name())) 268 attr->detachFromElementWithValue(attribute->value()); 269 } 270 271 // The loop above should have cleaned out this element's Attr map. 272 ASSERT(!element->hasAttrList()); 273 } 274 172 275 void ElementAttributeData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 173 276 { … … 175 278 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM, actualSize); 176 279 info.addMember(m_inlineStyleDecl); 177 info.addMember(m_ presentationAttributeStyle);280 info.addMember(m_attributeStyle); 178 281 info.addMember(m_classNames); 179 282 info.addMember(m_idForStyleResolution); … … 220 323 targetElement.updateName(oldName, newName); 221 324 222 clearAttributes( );325 clearAttributes(&targetElement); 223 326 224 327 if (sourceData.isMutable()) … … 239 342 } 240 343 241 if (!targetElement.isStyledElement()) 242 return; 243 244 m_styleAttributeIsDirty = sourceData.m_styleAttributeIsDirty; 245 m_presentationAttributeStyleIsDirty = sourceData.m_presentationAttributeStyleIsDirty; 246 247 // Clone the source element's inline style unless it's immutable. 248 if (sourceData.m_inlineStyleDecl) 344 if (targetElement.isStyledElement() && sourceData.m_inlineStyleDecl) { 249 345 m_inlineStyleDecl = sourceData.m_inlineStyleDecl->immutableCopyIfNeeded(); 250 251 // Share the presentation attribute style (no need for cloning since it's not accessible via CSSOM.) 252 m_presentationAttributeStyle = sourceData.m_presentationAttributeStyle; 253 } 254 255 void ElementAttributeData::clearAttributes() 256 { 257 ASSERT(isMutable()); 346 targetElement.setIsStyleAttributeValid(sourceElement.isStyleAttributeValid()); 347 } 348 } 349 350 void ElementAttributeData::clearAttributes(Element* element) 351 { 352 ASSERT(isMutable()); 353 354 if (element->hasAttrList()) 355 detachAttrObjectsFromElement(element); 356 258 357 clearClass(); 259 358 mutableAttributeVector().clear(); 260 359 } 261 360 262 } 361 PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const String& name, bool shouldIgnoreAttributeCase, Element* element) const 362 { 363 ASSERT(element); 364 const Attribute* attribute = getAttributeItem(name, shouldIgnoreAttributeCase); 365 if (!attribute) 366 return 0; 367 return ensureAttr(element, attribute->name()); 368 } 369 370 PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const QualifiedName& name, Element* element) const 371 { 372 ASSERT(element); 373 const Attribute* attribute = getAttributeItem(name); 374 if (!attribute) 375 return 0; 376 return ensureAttr(element, attribute->name()); 377 } 378 379 } -
trunk/Source/WebCore/dom/ElementAttributeData.h
r133394 r133451 34 34 namespace WebCore { 35 35 36 class Attr; 36 37 class Element; 37 38 class ImmutableElementAttributeData; … … 63 64 void detachCSSOMWrapperIfNeeded(StyledElement*); 64 65 65 const StylePropertySet* presentationAttributeStyle() const { return m_presentationAttributeStyle.get(); }66 void set PresentationAttributeStyle(PassRefPtr<StylePropertySet> style) const { m_presentationAttributeStyle= style; }66 const StylePropertySet* attributeStyle() const { return m_attributeStyle.get(); } 67 void setAttributeStyle(PassRefPtr<StylePropertySet> style) const { m_attributeStyle = style; } 67 68 68 69 size_t length() const; 69 70 bool isEmpty() const { return !length(); } 71 72 PassRefPtr<Attr> getAttributeNode(const String&, bool shouldIgnoreAttributeCase, Element*) const; 73 PassRefPtr<Attr> getAttributeNode(const QualifiedName&, Element*) const; 70 74 71 75 // Internal interface. … … 86 90 bool isEquivalent(const ElementAttributeData* other) const; 87 91 88 bool styleAttributeIsDirty() const { return m_styleAttributeIsDirty; } 89 void setStyleAttributeIsDirty(bool f) const { m_styleAttributeIsDirty = f; } 90 bool presentationAttributeStyleIsDirty() const { return m_presentationAttributeStyleIsDirty; } 91 void setPresentationAttributeStyleIsDirty(bool f) const { m_presentationAttributeStyleIsDirty = f; } 92 void setAttr(Element*, const QualifiedName&, Attr*) const; 93 void removeAttr(Element*, const QualifiedName&) const; 94 PassRefPtr<Attr> attrIfExists(Element*, const QualifiedName&) const; 95 PassRefPtr<Attr> ensureAttr(Element*, const QualifiedName&) const; 96 void detachAttrObjectsFromElement(Element*) const; 92 97 93 98 void reportMemoryUsage(MemoryObjectInfo*) const; … … 99 104 ElementAttributeData() 100 105 : m_isMutable(true) 101 , m_styleAttributeIsDirty(false)102 , m_presentationAttributeStyleIsDirty(false)103 106 , m_arraySize(0) 104 107 { } … … 106 109 ElementAttributeData(unsigned arraySize) 107 110 : m_isMutable(false) 108 , m_styleAttributeIsDirty(false)109 , m_presentationAttributeStyleIsDirty(false)110 111 , m_arraySize(arraySize) 111 112 { } 112 113 113 114 unsigned m_isMutable : 1; 114 mutable unsigned m_styleAttributeIsDirty : 1; 115 mutable unsigned m_presentationAttributeStyleIsDirty : 1; 116 unsigned m_arraySize : 29; 115 unsigned m_arraySize : 31; 117 116 118 117 mutable RefPtr<StylePropertySet> m_inlineStyleDecl; 119 mutable RefPtr<StylePropertySet> m_ presentationAttributeStyle;118 mutable RefPtr<StylePropertySet> m_attributeStyle; 120 119 mutable SpaceSplitString m_classNames; 121 120 mutable AtomicString m_idForStyleResolution; … … 131 130 size_t getAttributeItemIndexSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const; 132 131 void cloneDataFrom(const ElementAttributeData& sourceData, const Element& sourceElement, Element& targetElement); 133 void clearAttributes( );132 void clearAttributes(Element*); 134 133 135 134 PassRefPtr<ElementAttributeData> makeMutableCopy() const; -
trunk/Source/WebCore/dom/Node.h
r133394 r133451 100 100 typedef int ExceptionCode; 101 101 102 const int nodeStyleChangeShift = 19;102 const int nodeStyleChangeShift = 20; 103 103 104 104 // SyntheticStyleChange means that we need to go through the entire style change logic even though … … 238 238 bool isShadowRoot() const { return getFlag(IsShadowRootFlag); } 239 239 bool inNamedFlow() const { return getFlag(InNamedFlowFlag); } 240 bool hasAttrList() const { return getFlag(HasAttrListFlag); } 240 241 bool hasCustomCallbacks() const { return getFlag(HasCustomCallbacksFlag); } 241 242 bool hasSyntheticAttrChildNodes() const { return getFlag(HasSyntheticAttrChildNodesFlag); }243 void setHasSyntheticAttrChildNodes(bool flag) { setFlag(flag, HasSyntheticAttrChildNodesFlag); }244 242 245 243 // If this node is in a shadow tree, returns its shadow host. Otherwise, returns 0. … … 321 319 virtual void startLoadingDynamicSheet() { ASSERT_NOT_REACHED(); } 322 320 321 bool attributeStyleDirty() const { return getFlag(AttributeStyleDirtyFlag); } 323 322 bool hasName() const { return getFlag(HasNameFlag); } 324 323 bool hasID() const; … … 336 335 bool isLink() const { return getFlag(IsLinkFlag); } 337 336 337 void setAttributeStyleDirty() { setFlag(AttributeStyleDirtyFlag); } 338 void clearAttributeStyleDirty() { clearFlag(AttributeStyleDirtyFlag); } 339 338 340 void setHasName(bool f) { setFlag(f, HasNameFlag); } 339 341 void setChildNeedsStyleRecalc() { setFlag(ChildNeedsStyleRecalcFlag); } … … 353 355 void setInNamedFlow() { setFlag(InNamedFlowFlag); } 354 356 void clearInNamedFlow() { clearFlag(InNamedFlowFlag); } 357 358 void setHasAttrList() { setFlag(HasAttrListFlag); } 359 void clearHasAttrList() { clearFlag(HasAttrListFlag); } 355 360 356 361 bool hasScopedHTMLStyleChild() const { return getFlag(HasScopedHTMLStyleChildFlag); } … … 708 713 // be stored in the same memory word as the Node bits above. 709 714 IsParsingChildrenFinishedFlag = 1 << 15, // Element 715 IsStyleAttributeValidFlag = 1 << 16, // StyledElement 710 716 #if ENABLE(SVG) 711 AreSVGAttributesValidFlag = 1 << 1 6, // Element712 IsSynchronizingSVGAttributesFlag = 1 << 1 7, // SVGElement713 HasSVGRareDataFlag = 1 << 1 8, // SVGElement717 AreSVGAttributesValidFlag = 1 << 17, // Element 718 IsSynchronizingSVGAttributesFlag = 1 << 18, // SVGElement 719 HasSVGRareDataFlag = 1 << 19, // SVGElement 714 720 #endif 715 721 716 722 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1), 717 723 718 SelfOrAncestorHasDirAutoFlag = 1 << 21, 719 720 HasNameFlag = 1 << 22, 721 724 SelfOrAncestorHasDirAutoFlag = 1 << 22, 725 726 HasNameFlag = 1 << 23, 727 728 AttributeStyleDirtyFlag = 1 << 24, 722 729 723 730 #if ENABLE(SVG) 724 DefaultNodeFlags = IsParsingChildrenFinishedFlag | AreSVGAttributesValidFlag,731 DefaultNodeFlags = IsParsingChildrenFinishedFlag | IsStyleAttributeValidFlag | AreSVGAttributesValidFlag, 725 732 #else 726 DefaultNodeFlags = IsParsingChildrenFinishedFlag ,727 #endif 728 InNamedFlowFlag = 1 << 2 3,729 Has SyntheticAttrChildNodesFlag = 1 << 24,730 HasCustomCallbacksFlag = 1 << 2 5,731 HasScopedHTMLStyleChildFlag = 1 << 2 6,732 HasEventTargetDataFlag = 1 << 27,733 DefaultNodeFlags = IsParsingChildrenFinishedFlag | IsStyleAttributeValidFlag, 734 #endif 735 InNamedFlowFlag = 1 << 26, 736 HasAttrListFlag = 1 << 27, 737 HasCustomCallbacksFlag = 1 << 28, 738 HasScopedHTMLStyleChildFlag = 1 << 29, 739 HasEventTargetDataFlag = 1 << 30, 733 740 }; 734 741 735 // 4bits remaining742 // 2 bits remaining 736 743 737 744 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } … … 834 841 } m_data; 835 842 843 public: 844 bool isStyleAttributeValid() const { return getFlag(IsStyleAttributeValidFlag); } 845 void setIsStyleAttributeValid(bool f) { setFlag(f, IsStyleAttributeValidFlag); } 846 void setIsStyleAttributeValid() const { setFlag(IsStyleAttributeValidFlag); } 847 void clearIsStyleAttributeValid() { clearFlag(IsStyleAttributeValidFlag); } 848 836 849 protected: 837 850 bool isParsingChildrenFinished() const { return getFlag(IsParsingChildrenFinishedFlag); } -
trunk/Source/WebCore/dom/StyledElement.cpp
r133286 r133451 127 127 void StyledElement::updateStyleAttribute() const 128 128 { 129 ASSERT(styleAttributeIsDirty()); 130 ASSERT(attributeData()); 131 attributeData()->setStyleAttributeIsDirty(false); 132 if (inlineStyle()) 133 const_cast<StyledElement*>(this)->setSynchronizedLazyAttribute(styleAttr, inlineStyle()->asText()); 129 ASSERT(!isStyleAttributeValid()); 130 setIsStyleAttributeValid(); 131 if (const StylePropertySet* inlineStyle = this->inlineStyle()) 132 const_cast<StyledElement*>(this)->setSynchronizedLazyAttribute(styleAttr, inlineStyle->asText()); 134 133 } 135 134 … … 153 152 { 154 153 if (isPresentationAttribute(name)) { 155 attributeData()->setPresentationAttributeStyleIsDirty(true);154 setAttributeStyleDirty(); 156 155 setNeedsStyleRecalc(InlineStyleChange); 157 156 } … … 170 169 else if (document()->contentSecurityPolicy()->allowInlineStyle(document()->url(), startLineNumber)) 171 170 ensureAttributeData()->updateInlineStyleAvoidingMutation(this, newStyleString); 172 173 attributeData()->setStyleAttributeIsDirty(false); 171 setIsStyleAttributeValid(); 174 172 } 175 173 setNeedsStyleRecalc(); … … 188 186 { 189 187 setNeedsStyleRecalc(InlineStyleChange); 190 attributeData()->setStyleAttributeIsDirty(true);188 setIsStyleAttributeValid(false); 191 189 InspectorInstrumentation::didInvalidateStyleAttr(document(), this); 192 190 } … … 273 271 } 274 272 275 void StyledElement:: rebuildPresentationAttributeStyle()273 void StyledElement::updateAttributeStyle() 276 274 { 277 275 PresentationAttributeCacheKey cacheKey; … … 300 298 } 301 299 } 302 303 attributeData()->setPresentationAttributeStyleIsDirty(false); 304 attributeData()->set PresentationAttributeStyle(style->isEmpty() ? 0 : style);300 clearAttributeStyleDirty(); 301 302 attributeData()->setAttributeStyle(style->isEmpty() ? 0 : style); 305 303 306 304 if (!cacheHash || cacheIterator->value) -
trunk/Source/WebCore/dom/StyledElement.h
r133286 r133451 52 52 virtual CSSStyleDeclaration* style() OVERRIDE; 53 53 54 const StylePropertySet* presentationAttributeStyle();54 const StylePropertySet* attributeStyle(); 55 55 56 56 virtual void collectStyleForAttribute(const Attribute&, StylePropertySet*) { } … … 79 79 80 80 void makePresentationAttributeCacheKey(PresentationAttributeCacheKey&) const; 81 void rebuildPresentationAttributeStyle();81 void updateAttributeStyle(); 82 82 }; 83 83 84 84 inline void StyledElement::invalidateStyleAttribute() 85 85 { 86 ASSERT(attributeData()); 87 attributeData()->setStyleAttributeIsDirty(true); 86 clearIsStyleAttributeValid(); 88 87 } 89 88 90 inline const StylePropertySet* StyledElement:: presentationAttributeStyle()89 inline const StylePropertySet* StyledElement::attributeStyle() 91 90 { 92 if (!attributeData()) 93 return 0; 94 if (attributeData()->presentationAttributeStyleIsDirty()) 95 rebuildPresentationAttributeStyle(); 96 return attributeData()->presentationAttributeStyle(); 91 if (attributeStyleDirty()) 92 updateAttributeStyle(); 93 return attributeData() ? attributeData()->attributeStyle() : 0; 97 94 } 98 95 -
trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp
r133286 r133451 1185 1185 return 0; 1186 1186 1187 const StylePropertySet* presentationAttributeStyle = static_cast<StyledElement*>(element)->presentationAttributeStyle();1188 if (! presentationAttributeStyle)1187 const StylePropertySet* attributeStyle = static_cast<StyledElement*>(element)->attributeStyle(); 1188 if (!attributeStyle) 1189 1189 return 0; 1190 1190 1191 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), const_cast<StylePropertySet*>( presentationAttributeStyle)->ensureCSSStyleDeclaration(), 0);1191 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), const_cast<StylePropertySet*>(attributeStyle)->ensureCSSStyleDeclaration(), 0); 1192 1192 return inspectorStyle->buildObjectForStyle(); 1193 1193 }
Note: See TracChangeset
for help on using the changeset viewer.