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

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

Issue 22842013: setAttributeNode() does not set the new value to an existing attribute if specified attribute is in… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Modified for fixing the crash Created 7 years, 3 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
« no previous file with comments | « LayoutTests/fast/dom/Element/setAttributeNode-for-existing-attribute-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 if (index != notFound) 861 if (index != notFound)
862 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); 862 removeAttributeInternal(index, inSynchronizationOfLazyAttribute);
863 return; 863 return;
864 } 864 }
865 865
866 if (index == notFound) { 866 if (index == notFound) {
867 addAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute); 867 addAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute);
868 return; 868 return;
869 } 869 }
870 870
871 QualifiedName existingAttributeName = attributeItem(index)->name();
872
871 if (!inSynchronizationOfLazyAttribute) 873 if (!inSynchronizationOfLazyAttribute)
872 willModifyAttribute(name, attributeItem(index)->value(), newValue); 874 willModifyAttribute(existingAttributeName, attributeItem(index)->value() , newValue);
873 875
874 if (newValue != attributeItem(index)->value()) { 876 if (newValue != attributeItem(index)->value()) {
875 // If there is an Attr node hooked to this attribute, the Attr::setValue () call below 877 // If there is an Attr node hooked to this attribute, the Attr::setValue () call below
876 // will write into the ElementData. 878 // will write into the ElementData.
877 // FIXME: Refactor this so it makes some sense. 879 // FIXME: Refactor this so it makes some sense.
878 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? 0 : attrI fExists(name)) 880 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? 0 : attrI fExists(existingAttributeName))
879 attrNode->setValue(newValue); 881 attrNode->setValue(newValue);
880 else 882 else
881 ensureUniqueElementData()->attributeItem(index)->setValue(newValue); 883 ensureUniqueElementData()->attributeItem(index)->setValue(newValue);
882 } 884 }
883 885
884 if (!inSynchronizationOfLazyAttribute) 886 if (!inSynchronizationOfLazyAttribute)
885 didModifyAttribute(name, newValue); 887 didModifyAttribute(existingAttributeName, newValue);
886 } 888 }
887 889
888 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode) 890 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode)
889 { 891 {
890 if (inQuirksMode) 892 if (inQuirksMode)
891 return value.lower(); 893 return value.lower();
892 return value; 894 return value;
893 } 895 }
894 896
895 static bool checkNeedsStyleInvalidationForIdChange(const AtomicString& oldId, co nst AtomicString& newId, const RuleFeatureSet& features) 897 static bool checkNeedsStyleInvalidationForIdChange(const AtomicString& oldId, co nst AtomicString& newId, const RuleFeatureSet& features)
(...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after
3640 return 0; 3642 return 0;
3641 } 3643 }
3642 3644
3643 Attribute* UniqueElementData::attributeItem(unsigned index) 3645 Attribute* UniqueElementData::attributeItem(unsigned index)
3644 { 3646 {
3645 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); 3647 ASSERT_WITH_SECURITY_IMPLICATION(index < length());
3646 return &m_attributeVector.at(index); 3648 return &m_attributeVector.at(index);
3647 } 3649 }
3648 3650
3649 } // namespace WebCore 3651 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/Element/setAttributeNode-for-existing-attribute-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698