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

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

Issue 316583002: Correctly handle accessing a replaced Attr object's attribute value. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
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 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 elementAttribute().setValue(newValue); 171 elementAttribute().setValue(newValue);
172 else 172 else
173 m_standaloneValue = newValue; 173 m_standaloneValue = newValue;
174 174
175 if (m_element) 175 if (m_element)
176 m_element->attributeChanged(qualifiedName(), newValue); 176 m_element->attributeChanged(qualifiedName(), newValue);
177 } 177 }
178 178
179 const AtomicString& Attr::value() const 179 const AtomicString& Attr::value() const
180 { 180 {
181 if (m_element) 181 if (m_element) {
182 return m_element->getAttribute(qualifiedName()); 182 const AtomicString& value = m_element->getAttribute(qualifiedName());
183 if (value != nullAtom || !m_element->shouldIgnoreAttributeCase())
184 return value;
185 return m_element->getAttribute(QualifiedName(prefix(), localName().lower (), namespaceURI()));
186 }
183 return m_standaloneValue; 187 return m_standaloneValue;
184 } 188 }
185 189
186 Attribute& Attr::elementAttribute() 190 Attribute& Attr::elementAttribute()
187 { 191 {
188 ASSERT(m_element); 192 ASSERT(m_element);
189 ASSERT(m_element->elementData()); 193 ASSERT(m_element->elementData());
190 return *m_element->ensureUniqueElementData().getAttributeItem(qualifiedName( )); 194 return *m_element->ensureUniqueElementData().getAttributeItem(qualifiedName( ), m_element->shouldIgnoreAttributeCase());
191 } 195 }
192 196
193 void Attr::detachFromElementWithValue(const AtomicString& value) 197 void Attr::detachFromElementWithValue(const AtomicString& value)
194 { 198 {
195 ASSERT(m_element); 199 ASSERT(m_element);
196 ASSERT(m_standaloneValue.isNull()); 200 ASSERT(m_standaloneValue.isNull());
197 m_standaloneValue = value; 201 m_standaloneValue = value;
198 m_element = nullptr; 202 m_element = nullptr;
199 } 203 }
200 204
201 void Attr::attachToElement(Element* element) 205 void Attr::attachToElement(Element* element)
202 { 206 {
203 ASSERT(!m_element); 207 ASSERT(!m_element);
204 m_element = element; 208 m_element = element;
205 m_standaloneValue = nullAtom; 209 m_standaloneValue = nullAtom;
206 } 210 }
207 211
208 void Attr::trace(Visitor* visitor) 212 void Attr::trace(Visitor* visitor)
209 { 213 {
210 visitor->trace(m_element); 214 visitor->trace(m_element);
211 ContainerNode::trace(visitor); 215 ContainerNode::trace(visitor);
212 } 216 }
213 217
214 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698