OLD | NEW |
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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 if (index != kNotFound) | 930 if (index != kNotFound) |
931 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); | 931 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); |
932 return; | 932 return; |
933 } | 933 } |
934 | 934 |
935 if (index == kNotFound) { | 935 if (index == kNotFound) { |
936 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute
); | 936 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute
); |
937 return; | 937 return; |
938 } | 938 } |
939 | 939 |
940 const Attribute& existingAttribute = attributeAt(index); | 940 const Attribute& existingAttribute = attributes().at(index); |
941 QualifiedName existingAttributeName = existingAttribute.name(); | 941 QualifiedName existingAttributeName = existingAttribute.name(); |
942 | 942 |
943 if (!inSynchronizationOfLazyAttribute) | 943 if (!inSynchronizationOfLazyAttribute) |
944 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne
wValue); | 944 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne
wValue); |
945 | 945 |
946 if (newValue != existingAttribute.value()) { | 946 if (newValue != existingAttribute.value()) { |
947 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below | 947 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below |
948 // will write into the ElementData. | 948 // will write into the ElementData. |
949 // FIXME: Refactor this so it makes some sense. | 949 // FIXME: Refactor this so it makes some sense. |
950 if (RefPtrWillBeRawPtr<Attr> attrNode = inSynchronizationOfLazyAttribute
? nullptr : attrIfExists(existingAttributeName)) | 950 if (RefPtrWillBeRawPtr<Attr> attrNode = inSynchronizationOfLazyAttribute
? nullptr : attrIfExists(existingAttributeName)) |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicStrin
g& qualifiedName, const AtomicString& value, ExceptionState& exceptionState) | 1986 void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicStrin
g& qualifiedName, const AtomicString& value, ExceptionState& exceptionState) |
1987 { | 1987 { |
1988 QualifiedName parsedName = anyName; | 1988 QualifiedName parsedName = anyName; |
1989 if (!parseAttributeName(parsedName, namespaceURI, qualifiedName, exceptionSt
ate)) | 1989 if (!parseAttributeName(parsedName, namespaceURI, qualifiedName, exceptionSt
ate)) |
1990 return; | 1990 return; |
1991 setAttribute(parsedName, value); | 1991 setAttribute(parsedName, value); |
1992 } | 1992 } |
1993 | 1993 |
1994 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) | 1994 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) |
1995 { | 1995 { |
1996 ASSERT_WITH_SECURITY_IMPLICATION(index < attributeCount()); | 1996 UniqueElementData& elementData = ensureUniqueElementData(); |
| 1997 AttributeCollection attributes = elementData.attributes(); |
| 1998 ASSERT_WITH_SECURITY_IMPLICATION(index < attributes.size()); |
1997 | 1999 |
1998 UniqueElementData& elementData = ensureUniqueElementData(); | 2000 QualifiedName name = attributes[index].name(); |
1999 | 2001 AtomicString valueBeingRemoved = attributes[index].value(); |
2000 QualifiedName name = elementData.attributeAt(index).name(); | |
2001 AtomicString valueBeingRemoved = elementData.attributeAt(index).value(); | |
2002 | 2002 |
2003 if (!inSynchronizationOfLazyAttribute) { | 2003 if (!inSynchronizationOfLazyAttribute) { |
2004 if (!valueBeingRemoved.isNull()) | 2004 if (!valueBeingRemoved.isNull()) |
2005 willModifyAttribute(name, valueBeingRemoved, nullAtom); | 2005 willModifyAttribute(name, valueBeingRemoved, nullAtom); |
2006 } | 2006 } |
2007 | 2007 |
2008 if (RefPtrWillBeRawPtr<Attr> attrNode = attrIfExists(name)) | 2008 if (RefPtrWillBeRawPtr<Attr> attrNode = attrIfExists(name)) |
2009 detachAttrNodeFromElementWithValue(attrNode.get(), elementData.attribute
At(index).value()); | 2009 detachAttrNodeFromElementWithValue(attrNode.get(), attributes[index].val
ue()); |
2010 | 2010 |
2011 elementData.removeAttributeAt(index); | 2011 elementData.removeAttributeAt(index); |
2012 | 2012 |
2013 if (!inSynchronizationOfLazyAttribute) | 2013 if (!inSynchronizationOfLazyAttribute) |
2014 didRemoveAttribute(name); | 2014 didRemoveAttribute(name); |
2015 } | 2015 } |
2016 | 2016 |
2017 void Element::appendAttributeInternal(const QualifiedName& name, const AtomicStr
ing& value, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute) | 2017 void Element::appendAttributeInternal(const QualifiedName& name, const AtomicStr
ing& value, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute) |
2018 { | 2018 { |
2019 if (!inSynchronizationOfLazyAttribute) | 2019 if (!inSynchronizationOfLazyAttribute) |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 if (document().focusedElement() == this) | 2515 if (document().focusedElement() == this) |
2516 document().cancelFocusAppearanceUpdate(); | 2516 document().cancelFocusAppearanceUpdate(); |
2517 } | 2517 } |
2518 | 2518 |
2519 void Element::normalizeAttributes() | 2519 void Element::normalizeAttributes() |
2520 { | 2520 { |
2521 if (!hasAttributes()) | 2521 if (!hasAttributes()) |
2522 return; | 2522 return; |
2523 // attributeCount() cannot be cached before the loop because the attributes | 2523 // attributeCount() cannot be cached before the loop because the attributes |
2524 // list is altered while iterating. | 2524 // list is altered while iterating. |
2525 for (unsigned i = 0; i < attributeCount(); ++i) { | 2525 AttributeCollection attributes = this->attributes(); |
2526 if (RefPtrWillBeRawPtr<Attr> attr = attrIfExists(attributeAt(i).name())) | 2526 AttributeCollection::const_iterator end = attributes.end(); |
| 2527 for (AttributeCollection::const_iterator it = attributes.begin(); it < end;
++it) { |
| 2528 if (RefPtrWillBeRawPtr<Attr> attr = attrIfExists(it->name())) |
2527 attr->normalize(); | 2529 attr->normalize(); |
2528 } | 2530 } |
2529 } | 2531 } |
2530 | 2532 |
2531 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) | 2533 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) |
2532 { | 2534 { |
2533 ASSERT(!needsStyleRecalc()); | 2535 ASSERT(!needsStyleRecalc()); |
2534 PseudoElement* element = pseudoElement(pseudoId); | 2536 PseudoElement* element = pseudoElement(pseudoId); |
2535 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS
tyle(change))) { | 2537 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS
tyle(change))) { |
2536 | 2538 |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3337 | 3339 |
3338 void Element::trace(Visitor* visitor) | 3340 void Element::trace(Visitor* visitor) |
3339 { | 3341 { |
3340 if (hasRareData()) | 3342 if (hasRareData()) |
3341 visitor->trace(elementRareData()); | 3343 visitor->trace(elementRareData()); |
3342 visitor->trace(m_elementData); | 3344 visitor->trace(m_elementData); |
3343 ContainerNode::trace(visitor); | 3345 ContainerNode::trace(visitor); |
3344 } | 3346 } |
3345 | 3347 |
3346 } // namespace WebCore | 3348 } // namespace WebCore |
OLD | NEW |