Changeset 152088 in webkit


Ignore:
Timestamp:
Jun 27, 2013 3:30:32 AM (11 years ago)
Author:
kangil.han@samsung.com
Message:

Adopt is/toHTMLLabelElement for code cleanup
https://bugs.webkit.org/show_bug.cgi?id=118113

Reviewed by Andreas Kling.

To enhance readability, this patch adopts is/toHTMLLabelElement.
This also helps out to reduce duplicated use of static_cast.

  • accessibility/AXObjectCache.cpp:

(WebCore::AXObjectCache::handleAttributeChanged):
(WebCore::AXObjectCache::labelChanged):

  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::AccessibilityNodeObject::determineAccessibilityRole):
(WebCore::AccessibilityNodeObject::labelForElement):

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::labelElementContainer):
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):

  • dom/DocumentOrderedMap.cpp:

(WebCore::keyMatchesLabelForAttribute):

  • dom/Element.cpp:

(WebCore::Element::updateLabel):

  • dom/TreeScope.cpp:

(WebCore::TreeScope::labelElementForId):

  • html/HTMLLabelElement.h:

(WebCore::isHTMLLabelElement):
(WebCore::toHTMLLabelElement):

  • html/LabelsNodeList.cpp:

(WebCore::LabelsNodeList::nodeMatches):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152087 r152088  
     12013-06-27  Kangil Han  <kangil.han@samsung.com>
     2
     3        Adopt is/toHTMLLabelElement for code cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=118113
     5
     6        Reviewed by Andreas Kling.
     7
     8        To enhance readability, this patch adopts is/toHTMLLabelElement.
     9        This also helps out to reduce duplicated use of static_cast.
     10
     11        * accessibility/AXObjectCache.cpp:
     12        (WebCore::AXObjectCache::handleAttributeChanged):
     13        (WebCore::AXObjectCache::labelChanged):
     14        * accessibility/AccessibilityNodeObject.cpp:
     15        (WebCore::AccessibilityNodeObject::determineAccessibilityRole):
     16        (WebCore::AccessibilityNodeObject::labelForElement):
     17        * accessibility/AccessibilityRenderObject.cpp:
     18        (WebCore::AccessibilityRenderObject::labelElementContainer):
     19        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
     20        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
     21        * dom/DocumentOrderedMap.cpp:
     22        (WebCore::keyMatchesLabelForAttribute):
     23        * dom/Element.cpp:
     24        (WebCore::Element::updateLabel):
     25        * dom/TreeScope.cpp:
     26        (WebCore::TreeScope::labelElementForId):
     27        * html/HTMLLabelElement.h:
     28        (WebCore::isHTMLLabelElement):
     29        (WebCore::toHTMLLabelElement):
     30        * html/LabelsNodeList.cpp:
     31        (WebCore::LabelsNodeList::nodeMatches):
     32
    1332013-06-27  Peter Gal  <galpeter@inf.u-szeged.hu>
    234
  • trunk/Source/WebCore/accessibility/AXObjectCache.cpp

    r151996 r152088  
    810810    else if (attrName == altAttr || attrName == titleAttr)
    811811        textChanged(element);
    812     else if (attrName == forAttr && element->hasTagName(labelTag))
     812    else if (attrName == forAttr && isHTMLLabelElement(element))
    813813        labelChanged(element);
    814814
     
    838838void AXObjectCache::labelChanged(Element* element)
    839839{
    840     ASSERT(element->hasTagName(labelTag));
    841     HTMLElement* correspondingControl = static_cast<HTMLLabelElement*>(element)->control();
     840    ASSERT(isHTMLLabelElement(element));
     841    HTMLElement* correspondingControl = toHTMLLabelElement(element)->control();
    842842    textChanged(correspondingControl);
    843843}
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r151990 r152088  
    314314    if (node()->hasTagName(pTag))
    315315        return ParagraphRole;
    316     if (node()->hasTagName(labelTag))
     316    if (isHTMLLabelElement(node()))
    317317        return LabelRole;
    318318    if (node()->isElementNode() && toElement(node())->isFocusable())
     
    11011101
    11021102    for (Element* parent = element->parentElement(); parent; parent = parent->parentElement()) {
    1103         if (parent->hasTagName(labelTag))
    1104             return static_cast<HTMLLabelElement*>(parent);
     1103        if (isHTMLLabelElement(parent))
     1104            return toHTMLLabelElement(parent);
    11051105    }
    11061106
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r151996 r152088  
    760760    // find if this has a parent that is a label
    761761    for (Node* parentNode = m_renderer->node(); parentNode; parentNode = parentNode->parentNode()) {
    762         if (parentNode->hasTagName(labelTag))
    763             return static_cast<HTMLLabelElement*>(parentNode);
     762        if (isHTMLLabelElement(parentNode))
     763            return toHTMLLabelElement(parentNode);
    764764    }
    765765   
     
    11991199    // don't ignore labels, because they serve as TitleUIElements
    12001200    Node* node = m_renderer->node();
    1201     if (node && node->hasTagName(labelTag))
     1201    if (node && isHTMLLabelElement(node))
    12021202        return false;
    12031203   
     
    25492549        return ParagraphRole;
    25502550
    2551     if (node && node->hasTagName(labelTag))
     2551    if (node && isHTMLLabelElement(node))
    25522552        return LabelRole;
    25532553
  • trunk/Source/WebCore/dom/DocumentOrderedMap.cpp

    r150187 r152088  
    3333
    3434#include "Element.h"
     35#include "HTMLLabelElement.h"
    3536#include "HTMLMapElement.h"
    3637#include "HTMLNameCollection.h"
     
    6566inline bool keyMatchesLabelForAttribute(AtomicStringImpl* key, Element* element)
    6667{
    67     return element->hasTagName(labelTag) && element->getAttribute(forAttr).impl() == key;
     68    return isHTMLLabelElement(element) && element->getAttribute(forAttr).impl() == key;
    6869}
    6970
  • trunk/Source/WebCore/dom/Element.cpp

    r151998 r152088  
    29872987
    29882988    if (!oldForAttributeValue.isEmpty())
    2989         scope->removeLabel(oldForAttributeValue, static_cast<HTMLLabelElement*>(this));
     2989        scope->removeLabel(oldForAttributeValue, toHTMLLabelElement(this));
    29902990    if (!newForAttributeValue.isEmpty())
    2991         scope->addLabel(newForAttributeValue, static_cast<HTMLLabelElement*>(this));
     2991        scope->addLabel(newForAttributeValue, toHTMLLabelElement(this));
    29922992}
    29932993
  • trunk/Source/WebCore/dom/TreeScope.cpp

    r151975 r152088  
    300300        m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap);
    301301        for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(element)) {
    302             if (element->hasTagName(labelTag)) {
    303                 HTMLLabelElement* label = static_cast<HTMLLabelElement*>(element);
     302            if (isHTMLLabelElement(element)) {
     303                HTMLLabelElement* label = toHTMLLabelElement(element);
    304304                const AtomicString& forValue = label->fastGetAttribute(forAttr);
    305305                if (!forValue.isEmpty())
     
    309309    }
    310310
    311     return static_cast<HTMLLabelElement*>(m_labelsByForAttribute->getElementByLabelForAttribute(forAttributeValue.impl(), this));
     311    return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttribute(forAttributeValue.impl(), this));
    312312}
    313313
  • trunk/Source/WebCore/html/HTMLLabelElement.h

    r150715 r152088  
    5656};
    5757
     58inline bool isHTMLLabelElement(Node* node)
     59{
     60    return node->hasTagName(HTMLNames::labelTag);
     61}
     62
     63inline HTMLLabelElement* toHTMLLabelElement(Node* node)
     64{
     65    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLLabelElement(node));
     66    return static_cast<HTMLLabelElement*>(node);
     67}
     68
    5869} //namespace
    5970
  • trunk/Source/WebCore/html/LabelsNodeList.cpp

    r135671 r152088  
    4646bool LabelsNodeList::nodeMatches(Element* testNode) const
    4747{
    48     return testNode->hasTagName(labelTag) && static_cast<HTMLLabelElement*>(testNode)->control() == ownerNode();
     48    return isHTMLLabelElement(testNode) && toHTMLLabelElement(testNode)->control() == ownerNode();
    4949}
    5050
Note: See TracChangeset for help on using the changeset viewer.