Changeset 102705 in webkit
- Timestamp:
- Dec 13, 2011 2:05:00 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r102702 r102705 1 2011-12-13 Adam Klein <adamk@chromium.org> 2 3 Update variable names in NamedNodeMap methods to match WebKit style 4 https://bugs.webkit.org/show_bug.cgi?id=74437 5 6 Reviewed by Ojan Vafai. 7 8 While reading these methods in preparation for a refactor, I found 9 them hard to understand due to short or confusing variable names. 10 I think the new names are much clearer, and match WebKit style. 11 12 * dom/NamedNodeMap.cpp: 13 (WebCore::NamedNodeMap::setNamedItem): 14 (WebCore::NamedNodeMap::removeNamedItem): 15 1 16 2011-12-13 Xingnan Wang <xingnan.wang@intel.com> 2 17 -
trunk/Source/WebCore/dom/NamedNodeMap.cpp
r102431 r102705 94 94 } 95 95 96 PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* arg, ExceptionCode& ec)97 { 98 if (!m_element || ! arg) {96 PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionCode& ec) 97 { 98 if (!m_element || !node) { 99 99 ec = NOT_FOUND_ERR; 100 100 return 0; … … 102 102 103 103 // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node 104 if (! arg->isAttributeNode()) {104 if (!node->isAttributeNode()) { 105 105 ec = HIERARCHY_REQUEST_ERR; 106 106 return 0; 107 107 } 108 Attr *attr = static_cast<Attr*>(arg);109 110 Attribute* a = attr->attr();111 Attribute* old = getAttributeItem(a->name());112 if (old == a)113 return RefPtr<Node>(arg); // we know about it already114 115 // INUSE_ATTRIBUTE_ERR: Raised if argis an Attr that is already an attribute of another Element object.108 Attr* attr = static_cast<Attr*>(node); 109 110 Attribute* attribute = attr->attr(); 111 Attribute* oldAttribute = getAttributeItem(attribute->name()); 112 if (oldAttribute == attribute) 113 return node; // we know about it already 114 115 // INUSE_ATTRIBUTE_ERR: Raised if node is an Attr that is already an attribute of another Element object. 116 116 // The DOM user must explicitly clone Attr nodes to re-use them in other elements. 117 117 if (attr->ownerElement()) { … … 121 121 122 122 if (attr->isId()) 123 m_element->updateId(old ? old->value() : nullAtom, a->value());123 m_element->updateId(oldAttribute ? oldAttribute->value() : nullAtom, attribute->value()); 124 124 125 125 // ### slightly inefficient - resizes attribute array twice. 126 RefPtr< Node>r;127 if (old ) {128 r = old->createAttrIfNeeded(m_element);129 removeAttribute(a ->name());130 } 131 132 addAttribute(a );133 return r.release();126 RefPtr<Attr> oldAttr; 127 if (oldAttribute) { 128 oldAttr = oldAttribute->createAttrIfNeeded(m_element); 129 removeAttribute(attribute->name()); 130 } 131 132 addAttribute(attribute); 133 return oldAttr.release(); 134 134 } 135 135 … … 144 144 PassRefPtr<Node> NamedNodeMap::removeNamedItem(const QualifiedName& name, ExceptionCode& ec) 145 145 { 146 Attribute* a = getAttributeItem(name);147 if (!a ) {146 Attribute* attribute = getAttributeItem(name); 147 if (!attribute) { 148 148 ec = NOT_FOUND_ERR; 149 149 return 0; 150 150 } 151 151 152 RefPtr<Attr> r = a->createAttrIfNeeded(m_element);153 154 if ( r->isId())155 m_element->updateId(a ->value(), nullAtom);152 RefPtr<Attr> attr = attribute->createAttrIfNeeded(m_element); 153 154 if (attr->isId()) 155 m_element->updateId(attribute->value(), nullAtom); 156 156 157 157 removeAttribute(name); 158 return r.release();158 return attr.release(); 159 159 } 160 160
Note: See TracChangeset
for help on using the changeset viewer.