Changeset 102705 in webkit


Ignore:
Timestamp:
Dec 13, 2011 2:05:00 PM (12 years ago)
Author:
adamk@chromium.org
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102702 r102705  
     12011-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
    1162011-12-13  Xingnan Wang  <xingnan.wang@intel.com>
    217
  • trunk/Source/WebCore/dom/NamedNodeMap.cpp

    r102431 r102705  
    9494}
    9595
    96 PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* arg, ExceptionCode& ec)
    97 {
    98     if (!m_element || !arg) {
     96PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionCode& ec)
     97{
     98    if (!m_element || !node) {
    9999        ec = NOT_FOUND_ERR;
    100100        return 0;
     
    102102
    103103    // 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()) {
    105105        ec = HIERARCHY_REQUEST_ERR;
    106106        return 0;
    107107    }
    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 already
    114 
    115     // INUSE_ATTRIBUTE_ERR: Raised if arg is 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.
    116116    // The DOM user must explicitly clone Attr nodes to re-use them in other elements.
    117117    if (attr->ownerElement()) {
     
    121121
    122122    if (attr->isId())
    123         m_element->updateId(old ? old->value() : nullAtom, a->value());
     123        m_element->updateId(oldAttribute ? oldAttribute->value() : nullAtom, attribute->value());
    124124
    125125    // ### 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();
    134134}
    135135
     
    144144PassRefPtr<Node> NamedNodeMap::removeNamedItem(const QualifiedName& name, ExceptionCode& ec)
    145145{
    146     Attribute* a = getAttributeItem(name);
    147     if (!a) {
     146    Attribute* attribute = getAttributeItem(name);
     147    if (!attribute) {
    148148        ec = NOT_FOUND_ERR;
    149149        return 0;
    150150    }
    151151
    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);
    156156
    157157    removeAttribute(name);
    158     return r.release();
     158    return attr.release();
    159159}
    160160
Note: See TracChangeset for help on using the changeset viewer.