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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 } | 150 } |
151 | 151 |
152 static AttrNodeList* attrNodeListForElement(Element* element) | 152 static AttrNodeList* attrNodeListForElement(Element* element) |
153 { | 153 { |
154 if (!element->hasSyntheticAttrChildNodes()) | 154 if (!element->hasSyntheticAttrChildNodes()) |
155 return 0; | 155 return 0; |
156 ASSERT(attrNodeListMap().contains(element)); | 156 ASSERT(attrNodeListMap().contains(element)); |
157 return attrNodeListMap().get(element); | 157 return attrNodeListMap().get(element); |
158 } | 158 } |
159 | 159 |
160 static AttrNodeList* ensureAttrNodeListForElement(Element* element) | 160 static AttrNodeList& ensureAttrNodeListForElement(Element* element) |
161 { | 161 { |
162 if (element->hasSyntheticAttrChildNodes()) { | 162 if (element->hasSyntheticAttrChildNodes()) { |
163 ASSERT(attrNodeListMap().contains(element)); | 163 ASSERT(attrNodeListMap().contains(element)); |
164 return attrNodeListMap().get(element); | 164 return *attrNodeListMap().get(element); |
165 } | 165 } |
166 ASSERT(!attrNodeListMap().contains(element)); | 166 ASSERT(!attrNodeListMap().contains(element)); |
167 element->setHasSyntheticAttrChildNodes(true); | 167 element->setHasSyntheticAttrChildNodes(true); |
168 AttrNodeListMap::AddResult result = attrNodeListMap().add(element, adoptPtr( new AttrNodeList)); | 168 AttrNodeListMap::AddResult result = attrNodeListMap().add(element, adoptPtr( new AttrNodeList)); |
169 return result.iterator->value.get(); | 169 return *result.iterator->value; |
170 } | 170 } |
171 | 171 |
172 static void removeAttrNodeListForElement(Element* element) | 172 static void removeAttrNodeListForElement(Element* element) |
173 { | 173 { |
174 ASSERT(element->hasSyntheticAttrChildNodes()); | 174 ASSERT(element->hasSyntheticAttrChildNodes()); |
175 ASSERT(attrNodeListMap().contains(element)); | 175 ASSERT(attrNodeListMap().contains(element)); |
176 attrNodeListMap().remove(element); | 176 attrNodeListMap().remove(element); |
177 element->setHasSyntheticAttrChildNodes(false); | 177 element->setHasSyntheticAttrChildNodes(false); |
178 } | 178 } |
179 | 179 |
180 static Attr* findAttrNodeInList(AttrNodeList* attrNodeList, const QualifiedName& name) | 180 static Attr* findAttrNodeInList(AttrNodeList& attrNodeList, const QualifiedName& name) |
181 { | 181 { |
182 for (unsigned i = 0; i < attrNodeList->size(); ++i) { | 182 for (unsigned i = 0; i < attrNodeList.size(); ++i) { |
183 if (attrNodeList->at(i)->qualifiedName() == name) | 183 if (attrNodeList.at(i)->qualifiedName() == name) |
adamk
2013/10/18 15:54:26
Nit: you can take advantage of having a reference
Inactive
2013/10/18 16:06:51
Done.
| |
184 return attrNodeList->at(i).get(); | 184 return attrNodeList.at(i).get(); |
adamk
2013/10/18 15:54:26
Same here
Inactive
2013/10/18 16:06:51
Done.
| |
185 } | 185 } |
186 return 0; | 186 return 0; |
187 } | 187 } |
188 | 188 |
189 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu ment) | 189 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu ment) |
190 { | 190 { |
191 return adoptRef(new Element(tagName, document, CreateElement)); | 191 return adoptRef(new Element(tagName, document, CreateElement)); |
192 } | 192 } |
193 | 193 |
194 Element::~Element() | 194 Element::~Element() |
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1929 if (oldAttrNode) | 1929 if (oldAttrNode) |
1930 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a ttributeItem(index)->value()); | 1930 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a ttributeItem(index)->value()); |
1931 else | 1931 else |
1932 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el ementData->attributeItem(index)->value()); | 1932 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el ementData->attributeItem(index)->value()); |
1933 } | 1933 } |
1934 | 1934 |
1935 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No tInSynchronizationOfLazyAttribute); | 1935 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No tInSynchronizationOfLazyAttribute); |
1936 | 1936 |
1937 attrNode->attachToElement(this); | 1937 attrNode->attachToElement(this); |
1938 treeScope().adoptIfNeeded(attrNode); | 1938 treeScope().adoptIfNeeded(attrNode); |
1939 ensureAttrNodeListForElement(this)->append(attrNode); | 1939 ensureAttrNodeListForElement(this).append(attrNode); |
1940 | 1940 |
1941 return oldAttrNode.release(); | 1941 return oldAttrNode.release(); |
1942 } | 1942 } |
1943 | 1943 |
1944 PassRefPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionState& es) | 1944 PassRefPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionState& es) |
1945 { | 1945 { |
1946 return setAttributeNode(attr, es); | 1946 return setAttributeNode(attr, es); |
1947 } | 1947 } |
1948 | 1948 |
1949 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& es) | 1949 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& es) |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3049 void Element::setSavedLayerScrollOffset(const IntSize& size) | 3049 void Element::setSavedLayerScrollOffset(const IntSize& size) |
3050 { | 3050 { |
3051 if (size.isZero() && !hasRareData()) | 3051 if (size.isZero() && !hasRareData()) |
3052 return; | 3052 return; |
3053 ensureElementRareData().setSavedLayerScrollOffset(size); | 3053 ensureElementRareData().setSavedLayerScrollOffset(size); |
3054 } | 3054 } |
3055 | 3055 |
3056 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name) | 3056 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name) |
3057 { | 3057 { |
3058 if (AttrNodeList* attrNodeList = attrNodeListForElement(this)) | 3058 if (AttrNodeList* attrNodeList = attrNodeListForElement(this)) |
3059 return findAttrNodeInList(attrNodeList, name); | 3059 return findAttrNodeInList(*attrNodeList, name); |
3060 return 0; | 3060 return 0; |
3061 } | 3061 } |
3062 | 3062 |
3063 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name) | 3063 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name) |
3064 { | 3064 { |
3065 AttrNodeList* attrNodeList = ensureAttrNodeListForElement(this); | 3065 AttrNodeList& attrNodeList = ensureAttrNodeListForElement(this); |
3066 RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name); | 3066 RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name); |
3067 if (!attrNode) { | 3067 if (!attrNode) { |
3068 attrNode = Attr::create(*this, name); | 3068 attrNode = Attr::create(*this, name); |
3069 treeScope().adoptIfNeeded(attrNode.get()); | 3069 treeScope().adoptIfNeeded(attrNode.get()); |
3070 attrNodeList->append(attrNode); | 3070 attrNodeList.append(attrNode); |
3071 } | 3071 } |
3072 return attrNode.release(); | 3072 return attrNode.release(); |
3073 } | 3073 } |
3074 | 3074 |
3075 void Element::detachAttrNodeFromElementWithValue(Attr* attrNode, const AtomicStr ing& value) | 3075 void Element::detachAttrNodeFromElementWithValue(Attr* attrNode, const AtomicStr ing& value) |
3076 { | 3076 { |
3077 ASSERT(hasSyntheticAttrChildNodes()); | 3077 ASSERT(hasSyntheticAttrChildNodes()); |
3078 attrNode->detachFromElementWithValue(value); | 3078 attrNode->detachFromElementWithValue(value); |
3079 | 3079 |
3080 AttrNodeList* attrNodeList = attrNodeListForElement(this); | 3080 AttrNodeList* attrNodeList = attrNodeListForElement(this); |
3081 for (unsigned i = 0; i < attrNodeList->size(); ++i) { | 3081 for (unsigned i = 0; i < attrNodeList->size(); ++i) { |
3082 if (attrNodeList->at(i)->qualifiedName() == attrNode->qualifiedName()) { | 3082 if (attrNodeList->at(i)->qualifiedName() == attrNode->qualifiedName()) { |
3083 attrNodeList->remove(i); | 3083 attrNodeList->remove(i); |
3084 if (attrNodeList->isEmpty()) | 3084 if (attrNodeList->isEmpty()) |
3085 removeAttrNodeListForElement(this); | 3085 removeAttrNodeListForElement(this); |
3086 return; | 3086 return; |
3087 } | 3087 } |
3088 } | 3088 } |
3089 ASSERT_NOT_REACHED(); | 3089 ASSERT_NOT_REACHED(); |
3090 } | 3090 } |
3091 | 3091 |
3092 void Element::detachAllAttrNodesFromElement() | 3092 void Element::detachAllAttrNodesFromElement() |
3093 { | 3093 { |
3094 AttrNodeList* attrNodeList = attrNodeListForElement(this); | 3094 AttrNodeList* attrNodeList = attrNodeListForElement(this); |
3095 ASSERT(attrNodeList); | 3095 ASSERT(attrNodeList); |
3096 | 3096 |
3097 for (unsigned i = 0; i < attributeCount(); ++i) { | 3097 for (unsigned i = 0; i < attributeCount(); ++i) { |
3098 const Attribute* attribute = attributeItem(i); | 3098 const Attribute* attribute = attributeItem(i); |
3099 if (RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, attribute-> name())) | 3099 if (RefPtr<Attr> attrNode = findAttrNodeInList(*attrNodeList, attribute- >name())) |
3100 attrNode->detachFromElementWithValue(attribute->value()); | 3100 attrNode->detachFromElementWithValue(attribute->value()); |
3101 } | 3101 } |
3102 | 3102 |
3103 removeAttrNodeListForElement(this); | 3103 removeAttrNodeListForElement(this); |
3104 } | 3104 } |
3105 | 3105 |
3106 void Element::willRecalcStyle(StyleRecalcChange) | 3106 void Element::willRecalcStyle(StyleRecalcChange) |
3107 { | 3107 { |
3108 ASSERT(hasCustomStyleCallbacks()); | 3108 ASSERT(hasCustomStyleCallbacks()); |
3109 } | 3109 } |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3612 return 0; | 3612 return 0; |
3613 } | 3613 } |
3614 | 3614 |
3615 Attribute* UniqueElementData::attributeItem(unsigned index) | 3615 Attribute* UniqueElementData::attributeItem(unsigned index) |
3616 { | 3616 { |
3617 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); | 3617 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); |
3618 return &m_attributeVector.at(index); | 3618 return &m_attributeVector.at(index); |
3619 } | 3619 } |
3620 | 3620 |
3621 } // namespace WebCore | 3621 } // namespace WebCore |
OLD | NEW |