Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 1158433004: Remove Attr child nodes (making Attr a Node, not a ContainerNode) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address feedback Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute ); 1077 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute );
1078 return; 1078 return;
1079 } 1079 }
1080 1080
1081 const Attribute& existingAttribute = elementData()->attributes().at(index); 1081 const Attribute& existingAttribute = elementData()->attributes().at(index);
1082 AtomicString existingAttributeValue = existingAttribute.value(); 1082 AtomicString existingAttributeValue = existingAttribute.value();
1083 QualifiedName existingAttributeName = existingAttribute.name(); 1083 QualifiedName existingAttributeName = existingAttribute.name();
1084 1084
1085 if (!inSynchronizationOfLazyAttribute) 1085 if (!inSynchronizationOfLazyAttribute)
1086 willModifyAttribute(existingAttributeName, existingAttributeValue, newVa lue); 1086 willModifyAttribute(existingAttributeName, existingAttributeValue, newVa lue);
1087 1087 if (newValue != existingAttributeValue)
1088 if (newValue != existingAttributeValue) { 1088 ensureUniqueElementData().attributes().at(index).setValue(newValue);
1089 // If there is an Attr node hooked to this attribute, the Attr::setValue () call below
1090 // will write into the ElementData.
1091 // FIXME: Refactor this so it makes some sense.
1092 if (RefPtrWillBeRawPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? nullptr : attrIfExists(existingAttributeName))
1093 attrNode->setValue(newValue);
1094 else
1095 ensureUniqueElementData().attributes().at(index).setValue(newValue);
1096 }
1097
1098 if (!inSynchronizationOfLazyAttribute) 1089 if (!inSynchronizationOfLazyAttribute)
1099 didModifyAttribute(existingAttributeName, newValue); 1090 didModifyAttribute(existingAttributeName, newValue);
1100 } 1091 }
1101 1092
1102 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode) 1093 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode)
1103 { 1094 {
1104 if (inQuirksMode) 1095 if (inQuirksMode)
1105 return value.lower(); 1096 return value.lower();
1106 return value; 1097 return value;
1107 } 1098 }
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 { 2662 {
2672 return document().getCachedLocale(computeInheritedLanguage()); 2663 return document().getCachedLocale(computeInheritedLanguage());
2673 } 2664 }
2674 2665
2675 void Element::cancelFocusAppearanceUpdate() 2666 void Element::cancelFocusAppearanceUpdate()
2676 { 2667 {
2677 if (document().focusedElement() == this) 2668 if (document().focusedElement() == this)
2678 document().cancelFocusAppearanceUpdate(); 2669 document().cancelFocusAppearanceUpdate();
2679 } 2670 }
2680 2671
2681 void Element::normalizeAttributes()
2682 {
2683 if (!hasAttributes())
2684 return;
2685 AttrNodeList* attrNodes = attrNodeList();
2686 if (!attrNodes)
2687 return;
2688 // Copy the Attr Vector because Node::normalize() can fire synchronous JS
2689 // events (e.g. DOMSubtreeModified) and a JS listener could add / remove
2690 // attributes while we are iterating.
2691 AttrNodeList attrNodesCopy(*attrNodes);
2692 for (size_t i = 0; i < attrNodesCopy.size(); ++i)
2693 attrNodesCopy[i]->normalize();
2694 }
2695
2696 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) 2672 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
2697 { 2673 {
2698 ASSERT(!needsStyleRecalc()); 2674 ASSERT(!needsStyleRecalc());
2699 PseudoElement* element = pseudoElement(pseudoId); 2675 PseudoElement* element = pseudoElement(pseudoId);
2700 2676
2701 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { 2677 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) {
2702 if (pseudoId == FIRST_LETTER && updateFirstLetter(element)) 2678 if (pseudoId == FIRST_LETTER && updateFirstLetter(element))
2703 return; 2679 return;
2704 2680
2705 // Need to clear the cached style if the PseudoElement wants a recalc so it 2681 // Need to clear the cached style if the PseudoElement wants a recalc so it
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 { 3446 {
3471 #if ENABLE(OILPAN) 3447 #if ENABLE(OILPAN)
3472 if (hasRareData()) 3448 if (hasRareData())
3473 visitor->trace(elementRareData()); 3449 visitor->trace(elementRareData());
3474 visitor->trace(m_elementData); 3450 visitor->trace(m_elementData);
3475 #endif 3451 #endif
3476 ContainerNode::trace(visitor); 3452 ContainerNode::trace(visitor);
3477 } 3453 }
3478 3454
3479 } // namespace blink 3455 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698