Title: [102705] trunk/Source/WebCore
Revision
102705
Author
ad...@chromium.org
Date
2011-12-13 14:05:00 -0800 (Tue, 13 Dec 2011)

Log Message

Update variable names in NamedNodeMap methods to match WebKit style
https://bugs.webkit.org/show_bug.cgi?id=74437

Reviewed by Ojan Vafai.

While reading these methods in preparation for a refactor, I found
them hard to understand due to short or confusing variable names.
I think the new names are much clearer, and match WebKit style.

* dom/NamedNodeMap.cpp:
(WebCore::NamedNodeMap::setNamedItem):
(WebCore::NamedNodeMap::removeNamedItem):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102704 => 102705)


--- trunk/Source/WebCore/ChangeLog	2011-12-13 21:50:52 UTC (rev 102704)
+++ trunk/Source/WebCore/ChangeLog	2011-12-13 22:05:00 UTC (rev 102705)
@@ -1,3 +1,18 @@
+2011-12-13  Adam Klein  <ad...@chromium.org>
+
+        Update variable names in NamedNodeMap methods to match WebKit style
+        https://bugs.webkit.org/show_bug.cgi?id=74437
+
+        Reviewed by Ojan Vafai.
+
+        While reading these methods in preparation for a refactor, I found
+        them hard to understand due to short or confusing variable names.
+        I think the new names are much clearer, and match WebKit style.
+
+        * dom/NamedNodeMap.cpp:
+        (WebCore::NamedNodeMap::setNamedItem):
+        (WebCore::NamedNodeMap::removeNamedItem):
+
 2011-12-13  Xingnan Wang  <xingnan.w...@intel.com>
 
         Implement a function of vector multiply with SSE2 optimization in VectorMath.cpp.

Modified: trunk/Source/WebCore/dom/NamedNodeMap.cpp (102704 => 102705)


--- trunk/Source/WebCore/dom/NamedNodeMap.cpp	2011-12-13 21:50:52 UTC (rev 102704)
+++ trunk/Source/WebCore/dom/NamedNodeMap.cpp	2011-12-13 22:05:00 UTC (rev 102705)
@@ -93,26 +93,26 @@
     return a->createAttrIfNeeded(m_element);
 }
 
-PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* arg, ExceptionCode& ec)
+PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionCode& ec)
 {
-    if (!m_element || !arg) {
+    if (!m_element || !node) {
         ec = NOT_FOUND_ERR;
         return 0;
     }
 
     // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node
-    if (!arg->isAttributeNode()) {
+    if (!node->isAttributeNode()) {
         ec = HIERARCHY_REQUEST_ERR;
         return 0;
     }
-    Attr *attr = static_cast<Attr*>(arg);
+    Attr* attr = static_cast<Attr*>(node);
 
-    Attribute* a = attr->attr();
-    Attribute* old = getAttributeItem(a->name());
-    if (old == a)
-        return RefPtr<Node>(arg); // we know about it already
+    Attribute* attribute = attr->attr();
+    Attribute* oldAttribute = getAttributeItem(attribute->name());
+    if (oldAttribute == attribute)
+        return node; // we know about it already
 
-    // INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object.
+    // INUSE_ATTRIBUTE_ERR: Raised if node is an Attr that is already an attribute of another Element object.
     // The DOM user must explicitly clone Attr nodes to re-use them in other elements.
     if (attr->ownerElement()) {
         ec = INUSE_ATTRIBUTE_ERR;
@@ -120,17 +120,17 @@
     }
 
     if (attr->isId())
-        m_element->updateId(old ? old->value() : nullAtom, a->value());
+        m_element->updateId(oldAttribute ? oldAttribute->value() : nullAtom, attribute->value());
 
     // ### slightly inefficient - resizes attribute array twice.
-    RefPtr<Node> r;
-    if (old) {
-        r = old->createAttrIfNeeded(m_element);
-        removeAttribute(a->name());
+    RefPtr<Attr> oldAttr;
+    if (oldAttribute) {
+        oldAttr = oldAttribute->createAttrIfNeeded(m_element);
+        removeAttribute(attribute->name());
     }
 
-    addAttribute(a);
-    return r.release();
+    addAttribute(attribute);
+    return oldAttr.release();
 }
 
 PassRefPtr<Node> NamedNodeMap::setNamedItemNS(Node* node, ExceptionCode& ec)
@@ -143,19 +143,19 @@
 // because of removeNamedItem, removeNamedItemNS, and removeAttributeNode.
 PassRefPtr<Node> NamedNodeMap::removeNamedItem(const QualifiedName& name, ExceptionCode& ec)
 {
-    Attribute* a = getAttributeItem(name);
-    if (!a) {
+    Attribute* attribute = getAttributeItem(name);
+    if (!attribute) {
         ec = NOT_FOUND_ERR;
         return 0;
     }
 
-    RefPtr<Attr> r = a->createAttrIfNeeded(m_element);
+    RefPtr<Attr> attr = attribute->createAttrIfNeeded(m_element);
 
-    if (r->isId())
-        m_element->updateId(a->value(), nullAtom);
+    if (attr->isId())
+        m_element->updateId(attribute->value(), nullAtom);
 
     removeAttribute(name);
-    return r.release();
+    return attr.release();
 }
 
 PassRefPtr<Node> NamedNodeMap::item(unsigned index) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to