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

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: Created 5 years, 7 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 ensureUniqueElementData().attributes().at(index).setValue(newValue);
davve 2015/05/28 14:32:14 We may want to keep the newValue != existingAttrib
philipj_slow 2015/05/28 15:28:36 Done.
1088 if (newValue != existingAttributeValue) {
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) 1088 if (!inSynchronizationOfLazyAttribute)
1099 didModifyAttribute(existingAttributeName, newValue); 1089 didModifyAttribute(existingAttributeName, newValue);
1100 } 1090 }
1101 1091
1102 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode) 1092 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode)
1103 { 1093 {
1104 if (inQuirksMode) 1094 if (inQuirksMode)
1105 return value.lower(); 1095 return value.lower();
1106 return value; 1096 return value;
1107 } 1097 }
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 { 2660 {
2671 return document().getCachedLocale(computeInheritedLanguage()); 2661 return document().getCachedLocale(computeInheritedLanguage());
2672 } 2662 }
2673 2663
2674 void Element::cancelFocusAppearanceUpdate() 2664 void Element::cancelFocusAppearanceUpdate()
2675 { 2665 {
2676 if (document().focusedElement() == this) 2666 if (document().focusedElement() == this)
2677 document().cancelFocusAppearanceUpdate(); 2667 document().cancelFocusAppearanceUpdate();
2678 } 2668 }
2679 2669
2680 void Element::normalizeAttributes()
2681 {
2682 if (!hasAttributes())
2683 return;
2684 AttrNodeList* attrNodes = attrNodeList();
2685 if (!attrNodes)
2686 return;
2687 // Copy the Attr Vector because Node::normalize() can fire synchronous JS
2688 // events (e.g. DOMSubtreeModified) and a JS listener could add / remove
2689 // attributes while we are iterating.
2690 AttrNodeList attrNodesCopy(*attrNodes);
2691 for (size_t i = 0; i < attrNodesCopy.size(); ++i)
2692 attrNodesCopy[i]->normalize();
2693 }
2694
2695 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) 2670 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
2696 { 2671 {
2697 ASSERT(!needsStyleRecalc()); 2672 ASSERT(!needsStyleRecalc());
2698 PseudoElement* element = pseudoElement(pseudoId); 2673 PseudoElement* element = pseudoElement(pseudoId);
2699 2674
2700 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { 2675 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) {
2701 if (pseudoId == FIRST_LETTER && updateFirstLetter(element)) 2676 if (pseudoId == FIRST_LETTER && updateFirstLetter(element))
2702 return; 2677 return;
2703 2678
2704 // Need to clear the cached style if the PseudoElement wants a recalc so it 2679 // Need to clear the cached style if the PseudoElement wants a recalc so it
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 { 3445 {
3471 #if ENABLE(OILPAN) 3446 #if ENABLE(OILPAN)
3472 if (hasRareData()) 3447 if (hasRareData())
3473 visitor->trace(elementRareData()); 3448 visitor->trace(elementRareData());
3474 visitor->trace(m_elementData); 3449 visitor->trace(m_elementData);
3475 #endif 3450 #endif
3476 ContainerNode::trace(visitor); 3451 ContainerNode::trace(visitor);
3477 } 3452 }
3478 3453
3479 } // namespace blink 3454 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698