Changeset 152387 in webkit


Ignore:
Timestamp:
Jul 3, 2013 9:31:30 PM (11 years ago)
Author:
kangil.han@samsung.com
Message:

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

Reviewed by Andreas Kling.

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

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::getDocumentLinks):
(WebCore::AccessibilityRenderObject::accessibilityImageMapHitTest):

  • dom/DocumentOrderedMap.cpp:

(WebCore::keyMatchesMapName):
(WebCore::keyMatchesLowercasedMapName):

  • dom/TreeScope.cpp:

(WebCore::TreeScope::getImageMap):

  • html/HTMLAreaElement.cpp:

(WebCore::HTMLAreaElement::imageElement):

  • html/HTMLMapElement.h:

(WebCore::isHTMLMapElement):
(WebCore::toHTMLMapElement):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152386 r152387  
     12013-07-03  Kangil Han  <kangil.han@samsung.com>
     2
     3        Adopt is/toHTMLMapElement for code cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=118235
     5
     6        Reviewed by Andreas Kling.
     7
     8        To enhance readability, this patch adopts is/toHTMLMapElement.
     9        This also helps out to reduce duplicated use of static_cast.
     10
     11        * accessibility/AccessibilityRenderObject.cpp:
     12        (WebCore::AccessibilityRenderObject::getDocumentLinks):
     13        (WebCore::AccessibilityRenderObject::accessibilityImageMapHitTest):
     14        * dom/DocumentOrderedMap.cpp:
     15        (WebCore::keyMatchesMapName):
     16        (WebCore::keyMatchesLowercasedMapName):
     17        * dom/TreeScope.cpp:
     18        (WebCore::TreeScope::getImageMap):
     19        * html/HTMLAreaElement.cpp:
     20        (WebCore::HTMLAreaElement::imageElement):
     21        * html/HTMLMapElement.h:
     22        (WebCore::isHTMLMapElement):
     23        (WebCore::toHTMLMapElement):
     24
    1252013-07-03  Brent Fulgham  <bfulgham@apple.com>
    226
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r152218 r152387  
    17361736        } else {
    17371737            Node* parent = curr->parentNode();
    1738             if (parent && isHTMLAreaElement(curr) && parent->hasTagName(mapTag)) {
     1738            if (parent && isHTMLAreaElement(curr) && isHTMLMapElement(parent)) {
    17391739                AccessibilityImageMapLink* areaObject = static_cast<AccessibilityImageMapLink*>(axObjectCache()->getOrCreate(ImageMapLinkRole));
     1740                HTMLMapElement* map = toHTMLMapElement(parent);
    17401741                areaObject->setHTMLAreaElement(toHTMLAreaElement(curr));
    1741                 areaObject->setHTMLMapElement(static_cast<HTMLMapElement*>(parent));
    1742                 areaObject->setParent(accessibilityParentForImageMap(static_cast<HTMLMapElement*>(parent)));
     1742                areaObject->setHTMLMapElement(map);
     1743                areaObject->setParent(accessibilityParentForImageMap(map));
    17431744
    17441745                result.append(areaObject);
     
    21552156    AccessibilityObject* parent = 0;
    21562157    for (Element* mapParent = area->parentElement(); mapParent; mapParent = mapParent->parentElement()) {
    2157         if (mapParent->hasTagName(mapTag)) {
    2158             parent = accessibilityParentForImageMap(static_cast<HTMLMapElement*>(mapParent));
     2158        if (isHTMLMapElement(mapParent)) {
     2159            parent = accessibilityParentForImageMap(toHTMLMapElement(mapParent));
    21592160            break;
    21602161        }
  • trunk/Source/WebCore/dom/DocumentOrderedMap.cpp

    r152088 r152387  
    5656inline bool keyMatchesMapName(AtomicStringImpl* key, Element* element)
    5757{
    58     return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().impl() == key;
     58    return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().impl() == key;
    5959}
    6060
    6161inline bool keyMatchesLowercasedMapName(AtomicStringImpl* key, Element* element)
    6262{
    63     return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().lower().impl() == key;
     63    return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().lower().impl() == key;
    6464}
    6565
  • trunk/Source/WebCore/dom/TreeScope.cpp

    r152088 r152387  
    239239    String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl();
    240240    if (rootNode()->document()->isHTMLDocument())
    241         return static_cast<HTMLMapElement*>(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
    242     return static_cast<HTMLMapElement*>(m_imageMapsByName->getElementByMapName(AtomicString(name).impl(), this));
     241        return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
     242    return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(name).impl(), this));
    243243}
    244244
  • trunk/Source/WebCore/html/HTMLAreaElement.cpp

    r139037 r152387  
    185185{
    186186    Node* mapElement = parentNode();
    187     if (!mapElement || !mapElement->hasTagName(mapTag))
     187    if (!mapElement || !isHTMLMapElement(mapElement))
    188188        return 0;
    189189   
    190     return static_cast<HTMLMapElement*>(mapElement)->imageElement();
     190    return toHTMLMapElement(mapElement)->imageElement();
    191191}
    192192
  • trunk/Source/WebCore/html/HTMLMapElement.h

    r149960 r152387  
    5555};
    5656
     57inline bool isHTMLMapElement(Node* node)
     58{
     59    return node->hasTagName(HTMLNames::mapTag);
     60}
     61
     62inline bool isHTMLMapElement(Element* element)
     63{
     64    return element->hasTagName(HTMLNames::mapTag);
     65}
     66
     67inline HTMLMapElement* toHTMLMapElement(Node* node)
     68{
     69    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLMapElement(node));
     70    return static_cast<HTMLMapElement*>(node);
     71}
     72
    5773} //namespace
    5874
Note: See TracChangeset for help on using the changeset viewer.