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

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: modifying the layout testcase 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
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 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 if (index != notFound) 860 if (index != notFound)
861 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); 861 removeAttributeInternal(index, inSynchronizationOfLazyAttribute);
862 return; 862 return;
863 } 863 }
864 864
865 if (index == notFound) { 865 if (index == notFound) {
866 addAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute); 866 addAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute);
867 return; 867 return;
868 } 868 }
869 869
870 const QualifiedName& existingAttributeName = attributeItem(index)->name();
871
870 if (!inSynchronizationOfLazyAttribute) 872 if (!inSynchronizationOfLazyAttribute)
871 willModifyAttribute(name, attributeItem(index)->value(), newValue); 873 willModifyAttribute(existingAttributeName, attributeItem(index)->value() , newValue);
872 874
873 if (newValue != attributeItem(index)->value()) { 875 if (newValue != attributeItem(index)->value()) {
874 // If there is an Attr node hooked to this attribute, the Attr::setValue () call below 876 // If there is an Attr node hooked to this attribute, the Attr::setValue () call below
875 // will write into the ElementData. 877 // will write into the ElementData.
876 // FIXME: Refactor this so it makes some sense. 878 // FIXME: Refactor this so it makes some sense.
877 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? 0 : attrI fExists(name)) 879 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? 0 : attrI fExists(existingAttributeName))
878 attrNode->setValue(newValue); 880 attrNode->setValue(newValue);
879 else 881 else
880 ensureUniqueElementData()->attributeItem(index)->setValue(newValue); 882 ensureUniqueElementData()->attributeItem(index)->setValue(newValue);
881 } 883 }
882 884
883 if (!inSynchronizationOfLazyAttribute) 885 if (!inSynchronizationOfLazyAttribute)
884 didModifyAttribute(name, newValue); 886 didModifyAttribute(existingAttributeName, newValue);
885 } 887 }
886 888
887 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode) 889 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b ool inQuirksMode)
888 { 890 {
889 if (inQuirksMode) 891 if (inQuirksMode)
890 return value.lower(); 892 return value.lower();
891 return value; 893 return value;
892 } 894 }
893 895
894 static bool checkNeedsStyleInvalidationForIdChange(const AtomicString& oldId, co nst AtomicString& newId, const RuleFeatureSet& features) 896 static bool checkNeedsStyleInvalidationForIdChange(const AtomicString& oldId, co nst AtomicString& newId, const RuleFeatureSet& features)
(...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after
3630 return 0; 3632 return 0;
3631 } 3633 }
3632 3634
3633 Attribute* UniqueElementData::attributeItem(unsigned index) 3635 Attribute* UniqueElementData::attributeItem(unsigned index)
3634 { 3636 {
3635 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); 3637 ASSERT_WITH_SECURITY_IMPLICATION(index < length());
3636 return &m_attributeVector.at(index); 3638 return &m_attributeVector.at(index);
3637 } 3639 }
3638 3640
3639 } // namespace WebCore 3641 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698