Adopt is/toHTMLImageElement for code cleanup
authorkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Jun 2013 02:41:54 +0000 (02:41 +0000)
committerkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Jun 2013 02:41:54 +0000 (02:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118182

Reviewed by Andreas Kling.

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

Source/WebCore:

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isNativeImage):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::url):
* bindings/js/JSNodeCustom.cpp:
(WebCore::isReachableFromDOM):
* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::assignToHTMLImageElement):
(JSC::Bindings::QtPixmapRuntime::toQt):
* dom/Clipboard.cpp:
(WebCore::Clipboard::setDragImage):
* dom/Node.cpp:
(WebCore::Node::enclosingLinkEventParentOrSelf):
* editing/Editor.cpp:
(WebCore::imageElementFromImageDocument):
* html/HTMLAnchorElement.cpp:
(WebCore::appendServerMapMousePosition):
* html/HTMLImageElement.h:
(WebCore::isHTMLImageElement):
(WebCore::toHTMLImageElement):
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::imageElement):
* html/HTMLNameCollection.cpp:
(WebCore::WindowNameCollection::nodeMatchesIfNameAttributeMatch):
(WebCore::DocumentNameCollection::nodeMatchesIfIdAttributeMatch):
(WebCore::DocumentNameCollection::nodeMatchesIfNameAttributeMatch):
(WebCore::DocumentNameCollection::nodeMatches):
* page/DragController.cpp:
(WebCore::DragController::draggableElement):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::serializeFrame):
* platform/gtk/PasteboardGtk.cpp:
(WebCore::getURLForImageNode):
* platform/mac/HTMLConverter.mm:
(+[WebHTMLConverter editingAttributedStringFromRange:]):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::altDisplayString):
(WebCore::HitTestResult::absoluteImageURL):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintIntoRect):
(WebCore::RenderImage::imageMap):
(WebCore::RenderImage::updateAltText):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldRespectImageOrientation):

Source/WebKit/blackberry:

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):
(BlackBerry::WebKit::WebPagePrivate::blockZoomRectForNode):
(BlackBerry::WebKit::WebPage::blockZoom):
* WebKitSupport/FatFingers.cpp:
(BlackBerry::WebKit::FatFingers::isElementClickable):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152203 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/bindings/js/JSNodeCustom.cpp
Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
Source/WebCore/dom/Clipboard.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/html/HTMLMapElement.cpp
Source/WebCore/html/HTMLNameCollection.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/platform/gtk/PasteboardGtk.cpp
Source/WebCore/platform/mac/HTMLConverter.mm
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/FatFingers.cpp

index bfcb7e2..9fa0a82 100644 (file)
@@ -1,3 +1,58 @@
+2013-06-28  Kangil Han  <kangil.han@samsung.com>
+
+        Adopt is/toHTMLImageElement for code cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=118182
+
+        Reviewed by Andreas Kling.
+
+        To enhance readability, this patch adopts is/toHTMLImageElement.
+        This also helps out to reduce duplicated use of static_cast.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::isNativeImage):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::url):
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::isReachableFromDOM):
+        * bridge/qt/qt_pixmapruntime.cpp:
+        (JSC::Bindings::assignToHTMLImageElement):
+        (JSC::Bindings::QtPixmapRuntime::toQt):
+        * dom/Clipboard.cpp:
+        (WebCore::Clipboard::setDragImage):
+        * dom/Node.cpp:
+        (WebCore::Node::enclosingLinkEventParentOrSelf):
+        * editing/Editor.cpp:
+        (WebCore::imageElementFromImageDocument):
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::appendServerMapMousePosition):
+        * html/HTMLImageElement.h:
+        (WebCore::isHTMLImageElement):
+        (WebCore::toHTMLImageElement):
+        * html/HTMLMapElement.cpp:
+        (WebCore::HTMLMapElement::imageElement):
+        * html/HTMLNameCollection.cpp:
+        (WebCore::WindowNameCollection::nodeMatchesIfNameAttributeMatch):
+        (WebCore::DocumentNameCollection::nodeMatchesIfIdAttributeMatch):
+        (WebCore::DocumentNameCollection::nodeMatchesIfNameAttributeMatch):
+        (WebCore::DocumentNameCollection::nodeMatches):
+        * page/DragController.cpp:
+        (WebCore::DragController::draggableElement):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::serializeFrame):
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::getURLForImageNode):
+        * platform/mac/HTMLConverter.mm:
+        (+[WebHTMLConverter editingAttributedStringFromRange:]):
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::altDisplayString):
+        (WebCore::HitTestResult::absoluteImageURL):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::paintIntoRect):
+        (WebCore::RenderImage::imageMap):
+        (WebCore::RenderImage::updateAltText):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::shouldRespectImageOrientation):
+
 2013-06-28  Gavin Barraclough  <barraclough@apple.com>
 
         PageThrottler::shouldThrottleTimers is wrong.
index 1c71156..c2b24d8 100644 (file)
@@ -488,7 +488,7 @@ bool AccessibilityNodeObject::isNativeImage() const
     if (!node)
         return false;
 
-    if (node->hasTagName(imgTag))
+    if (isHTMLImageElement(node))
         return true;
 
     if (node->hasTagName(appletTag) || node->hasTagName(embedTag) || node->hasTagName(objectTag))
index f9d8a09..366cf60 100644 (file)
@@ -1467,8 +1467,8 @@ KURL AccessibilityRenderObject::url() const
     if (isWebArea())
         return m_renderer->document()->url();
     
-    if (isImage() && m_renderer->node() && m_renderer->node()->hasTagName(imgTag))
-        return static_cast<HTMLImageElement*>(m_renderer->node())->src();
+    if (isImage() && m_renderer->node() && isHTMLImageElement(m_renderer->node()))
+        return toHTMLImageElement(m_renderer->node())->src();
     
     if (isInputImage())
         return toHTMLInputElement(m_renderer->node())->src();
index 11c6219..0d3c20f 100644 (file)
@@ -105,8 +105,8 @@ static inline bool isReachableFromDOM(JSNode* jsNode, Node* node, SlotVisitor& v
         // because it is the only thing keeping the image element alive, and if
         // the element is destroyed, its load event will not fire.
         // FIXME: The DOM should manage this issue without the help of JavaScript wrappers.
-        if (node->hasTagName(imgTag)) {
-            if (static_cast<HTMLImageElement*>(node)->hasPendingActivity())
+        if (isHTMLImageElement(node)) {
+            if (toHTMLImageElement(node)->hasPendingActivity())
                 return true;
         }
     #if ENABLE(VIDEO)
index 1ddf4fd..8689307 100644 (file)
@@ -137,7 +137,7 @@ static JSValueRef assignToHTMLImageElement(JSContextRef context, JSObjectRef fun
 
     // We now know that we have a valid <img> element as the argument, we can attach the pixmap to it.
     RefPtr<StillImage> stillImage = WebCore::StillImage::create(toPixmap(data));
-    HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(static_cast<JSHTMLImageElement*>(jsObject)->impl());
+    HTMLImageElement* imageElement = toHTMLImageElement(static_cast<JSHTMLImageElement*>(jsObject)->impl());
     imageElement->setCachedImage(new CachedImage(stillImage.get()));
     return JSValueMakeUndefined(context);
 }
@@ -218,7 +218,7 @@ QVariant QtPixmapRuntime::toQt(JSContextRef context, JSObjectRef obj, QMetaType:
         return emptyVariantForHint(hint);
 
     JSHTMLImageElement* elementJSWrapper = static_cast<JSHTMLImageElement*>(jsObject);
-    HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(elementJSWrapper->impl());
+    HTMLImageElement* imageElement = toHTMLImageElement(elementJSWrapper->impl());
 
     if (!imageElement)
         return emptyVariantForHint(hint);
index c3e6f15..73f519b 100644 (file)
@@ -285,8 +285,8 @@ void Clipboard::setDragImage(Element* element, int x, int y)
     if (!canSetDragImage())
         return;
 
-    if (element && element->hasTagName(HTMLNames::imgTag) && !element->inDocument())
-        setDragImage(static_cast<HTMLImageElement*>(element)->cachedImage(), IntPoint(x, y));
+    if (element && isHTMLImageElement(element) && !element->inDocument())
+        setDragImage(toHTMLImageElement(element)->cachedImage(), IntPoint(x, y));
     else
         setDragImageElement(element, IntPoint(x, y));
 }
@@ -385,8 +385,8 @@ void Clipboard::setDragImage(Element* element, int x, int y)
         return;
 
     CachedImage* image;
-    if (element && element->hasTagName(HTMLNames::imgTag) && !element->inDocument())
-        image = static_cast<HTMLImageElement*>(element)->cachedImage();
+    if (element && isHTMLImageElement(element) && !element->inDocument())
+        image = toHTMLImageElement(element)->cachedImage();
     else
         image = 0;
 
index f3e653b..5be5d96 100644 (file)
@@ -64,6 +64,7 @@
 #include "FrameView.h"
 #include "HTMLElement.h"
 #include "HTMLFrameOwnerElement.h"
+#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "HTMLStyleElement.h"
 #include "InsertionPoint.h"
@@ -1949,7 +1950,7 @@ Node* Node::enclosingLinkEventParentOrSelf()
         // For imagemaps, the enclosing link node is the associated area element not the image itself.
         // So we don't let images be the enclosingLinkNode, even though isLink sometimes returns true
         // for them.
-        if (node->isLink() && !node->hasTagName(imgTag))
+        if (node->isLink() && !isHTMLImageElement(node))
             return node;
     }
 
index e68968a..de0605d 100644 (file)
@@ -288,10 +288,10 @@ static HTMLImageElement* imageElementFromImageDocument(Document* document)
     
     Node* node = body->firstChild();
     if (!node)
-        return 0;    
-    if (!node->hasTagName(imgTag))
         return 0;
-    return static_cast<HTMLImageElement*>(node);
+    if (!isHTMLImageElement(node))
+        return 0;
+    return toHTMLImageElement(node);
 }
 
 bool Editor::canCopy() const
index 617fa4b..c3b067e 100644 (file)
@@ -156,10 +156,10 @@ static void appendServerMapMousePosition(StringBuilder& url, Event* event)
     ASSERT(event->target());
     Node* target = event->target()->toNode();
     ASSERT(target);
-    if (!target->hasTagName(imgTag))
+    if (!isHTMLImageElement(target))
         return;
 
-    HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(event->target()->toNode());
+    HTMLImageElement* imageElement = toHTMLImageElement(target);
     if (!imageElement || !imageElement->isServerMap())
         return;
 
index a63de2c..4ad71bb 100644 (file)
@@ -112,6 +112,17 @@ private:
     CompositeOperator m_compositeOperator;
 };
 
+inline bool isHTMLImageElement(Node* node)
+{
+    return node->hasTagName(HTMLNames::imgTag);
+}
+
+inline HTMLImageElement* toHTMLImageElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLImageElement(node));
+    return static_cast<HTMLImageElement*>(node);
+}
+
 } //namespace
 
 #endif
index a362f54..66fd73e 100644 (file)
@@ -85,12 +85,12 @@ HTMLImageElement* HTMLMapElement::imageElement()
 {
     RefPtr<HTMLCollection> images = document()->images();
     for (unsigned i = 0; Node* curr = images->item(i); i++) {
-        if (!curr->hasTagName(imgTag))
+        if (!isHTMLImageElement(curr))
             continue;
         
         // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning,
         // which has to be stripped off.
-        HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(curr);
+        HTMLImageElement* imageElement = toHTMLImageElement(curr);
         String useMapName = imageElement->getAttribute(usemapAttr).string().substring(1);
         if (equalIgnoringCase(useMapName, m_name))
             return imageElement;
index 9f4f135..6192d8a 100644 (file)
@@ -26,6 +26,7 @@
 #include "Element.h"
 #include "HTMLDocument.h"
 #include "HTMLFormElement.h"
+#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
 #include "NodeRareData.h"
@@ -52,7 +53,7 @@ HTMLNameCollection::~HTMLNameCollection()
 
 bool WindowNameCollection::nodeMatchesIfNameAttributeMatch(Element* element)
 {
-    return element->hasTagName(imgTag) || isHTMLFormElement(element) || element->hasTagName(appletTag)
+    return isHTMLImageElement(element) || isHTMLFormElement(element) || element->hasTagName(appletTag)
         || element->hasTagName(embedTag) || element->hasTagName(objectTag);
 }
 
@@ -68,14 +69,14 @@ bool DocumentNameCollection::nodeMatchesIfIdAttributeMatch(Element* element)
 {
     // FIXME: we need to fix HTMLImageElement to update the hash map for us when name attribute has been removed.
     return element->hasTagName(appletTag) || (element->hasTagName(objectTag) && toHTMLObjectElement(element)->isDocNamedItem())
-        || (element->hasTagName(imgTag) && element->hasName());
+        || (isHTMLImageElement(element) && element->hasName());
 }
 
 bool DocumentNameCollection::nodeMatchesIfNameAttributeMatch(Element* element)
 {
     return isHTMLFormElement(element) || element->hasTagName(embedTag) || element->hasTagName(iframeTag)
         || element->hasTagName(appletTag) || (element->hasTagName(objectTag) && toHTMLObjectElement(element)->isDocNamedItem())
-        || element->hasTagName(imgTag);
+        || isHTMLImageElement(element);
 }
 
 bool DocumentNameCollection::nodeMatches(Element* element, const AtomicString& name)
@@ -88,7 +89,7 @@ bool DocumentNameCollection::nodeMatches(Element* element, const AtomicString& n
         return element->getNameAttribute() == name || element->getIdAttribute() == name;
     if (element->hasTagName(objectTag))
         return (element->getNameAttribute() == name || element->getIdAttribute() == name) && toHTMLObjectElement(element)->isDocNamedItem();
-    if (element->hasTagName(imgTag))
+    if (isHTMLImageElement(element))
         return element->getNameAttribute() == name || (element->getIdAttribute() == name && element->hasName());
     return false;
 }
index 54446a7..d41eb31 100644 (file)
@@ -51,6 +51,7 @@
 #include "FrameSelection.h"
 #include "FrameView.h"
 #include "HTMLAnchorElement.h"
+#include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLPlugInElement.h"
@@ -659,7 +660,7 @@ Element* DragController::draggableElement(const Frame* sourceFrame, Element* sta
             }
             if (dragMode == DRAG_AUTO) {
                 if ((m_dragSourceAction & DragSourceActionImage)
-                    && node->hasTagName(HTMLNames::imgTag)
+                    && isHTMLImageElement(node)
                     && sourceFrame->settings()
                     && sourceFrame->settings()->loadsImagesAutomatically()) {
                     state.type = static_cast<DragSourceAction>(state.type | DragSourceActionImage);
index 5377f7d..32facf6 100644 (file)
@@ -231,8 +231,8 @@ void PageSerializer::serializeFrame(Frame* frame)
         if (element->isStyledElement())
             retrieveResourcesForProperties(static_cast<StyledElement*>(element)->inlineStyle(), document);
 
-        if (element->hasTagName(HTMLNames::imgTag)) {
-            HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(element);
+        if (isHTMLImageElement(element)) {
+            HTMLImageElement* imageElement = toHTMLImageElement(element);
             KURL url = document->completeURL(imageElement->getAttribute(HTMLNames::srcAttr));
             CachedImage* cachedImage = imageElement->cachedImage();
             addImageToResources(cachedImage, imageElement->renderer(), url);
index a8ab912..8e2e499 100644 (file)
@@ -25,6 +25,7 @@
 #include "DocumentFragment.h"
 #include "Editor.h"
 #include "Frame.h"
+#include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
@@ -199,7 +200,7 @@ static KURL getURLForImageNode(Node* node)
 {
     // FIXME: Later this code should be shared with Chromium somehow. Chances are all platforms want it.
     AtomicString urlString;
-    if (node->hasTagName(HTMLNames::imgTag) || isHTMLInputElement(node))
+    if (isHTMLImageElement(node) || isHTMLInputElement(node))
         urlString = toElement(node)->getAttribute(HTMLNames::srcAttr);
 #if ENABLE(SVG)
     else if (node->hasTagName(SVGNames::imageTag))
index 1068333..d4c0291 100644 (file)
@@ -40,6 +40,7 @@
 #import "Font.h"
 #import "Frame.h"
 #import "FrameLoader.h"
+#import "HTMLImageElement.h"
 #import "HTMLNames.h"
 #import "HTMLParserIdioms.h"
 #import "LoaderNSURLExtras.h"
@@ -1675,7 +1676,7 @@ static NSInteger _colCompare(id block1, id block2, void *)
         
         if (startContainer == endContainer && (startOffset == endOffset - 1)) {
             Node* node = startContainer->childNode(startOffset);
-            if (node && node->hasTagName(imgTag)) {
+            if (node && isHTMLImageElement(node)) {
                 NSFileWrapper* fileWrapper = fileWrapperForElement(toElement(node));
                 NSTextAttachment* attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
                 [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
index 2418119..b551733 100644 (file)
@@ -271,8 +271,8 @@ String HitTestResult::altDisplayString() const
     if (!m_innerNonSharedNode)
         return String();
     
-    if (m_innerNonSharedNode->hasTagName(imgTag)) {
-        HTMLImageElement* image = static_cast<HTMLImageElement*>(m_innerNonSharedNode.get());
+    if (isHTMLImageElement(m_innerNonSharedNode.get())) {
+        HTMLImageElement* image = toHTMLImageElement(m_innerNonSharedNode.get());
         return displayString(image->getAttribute(altAttr), m_innerNonSharedNode.get());
     }
     
@@ -316,7 +316,7 @@ KURL HitTestResult::absoluteImageURL() const
 
     AtomicString urlString;
     if (m_innerNonSharedNode->hasTagName(embedTag)
-        || m_innerNonSharedNode->hasTagName(imgTag)
+        || isHTMLImageElement(m_innerNonSharedNode.get())
         || isHTMLInputElement(m_innerNonSharedNode.get())
         || m_innerNonSharedNode->hasTagName(objectTag)
 #if ENABLE(SVG)
index ce18e78..698894b 100644 (file)
@@ -471,7 +471,7 @@ void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect
     if (!img || img->isNull())
         return;
 
-    HTMLImageElement* imageElt = (node() && node()->hasTagName(imgTag)) ? static_cast<HTMLImageElement*>(node()) : 0;
+    HTMLImageElement* imageElt = (node() && isHTMLImageElement(node())) ? toHTMLImageElement(node()) : 0;
     CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver;
     Image* image = m_imageResource->image().get();
     bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size());
@@ -524,7 +524,7 @@ LayoutUnit RenderImage::minimumReplacedHeight() const
 
 HTMLMapElement* RenderImage::imageMap() const
 {
-    HTMLImageElement* i = node() && node()->hasTagName(imgTag) ? static_cast<HTMLImageElement*>(node()) : 0;
+    HTMLImageElement* i = node() && isHTMLImageElement(node()) ? toHTMLImageElement(node()) : 0;
     return i ? i->treeScope()->getImageMap(i->fastGetAttribute(usemapAttr)) : 0;
 }
 
@@ -559,8 +559,8 @@ void RenderImage::updateAltText()
 
     if (isHTMLInputElement(node()))
         m_altText = toHTMLInputElement(node())->altText();
-    else if (node()->hasTagName(imgTag))
-        m_altText = static_cast<HTMLImageElement*>(node())->altText();
+    else if (isHTMLImageElement(node()))
+        m_altText = toHTMLImageElement(node())->altText();
 }
 
 void RenderImage::layout()
index 6d8dbb6..88fd712 100644 (file)
@@ -40,6 +40,7 @@
 #include "GraphicsContext.h"
 #include "HTMLAnchorElement.h"
 #include "HTMLElement.h"
+#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
 #include "LogicalSelectionOffsetCaches.h"
@@ -2328,7 +2329,7 @@ RespectImageOrientationEnum RenderObject::shouldRespectImageOrientation() const
         // This can only be enabled for ports which honor the orientation flag in their drawing code.
         document()->isImageDocument() ||
 #endif
-        (document()->settings() && document()->settings()->shouldRespectImageOrientation() && node() && node()->hasTagName(HTMLNames::imgTag)) ? RespectImageOrientation : DoNotRespectImageOrientation;
+        (document()->settings() && document()->settings()->shouldRespectImageOrientation() && node() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotRespectImageOrientation;
 }
 
 bool RenderObject::hasOutlineAnnotation() const
index 844ff27..211a60e 100644 (file)
@@ -2133,7 +2133,7 @@ Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy
     layoutIfNeeded();
 
     bool nodeAllowSelectionOverride = false;
-    bool nodeIsImage = node->isHTMLElement() && node->hasTagName(HTMLNames::imgTag);
+    bool nodeIsImage = node->isHTMLElement() && isHTMLImageElement(node);
     Node* linkNode = node->enclosingLinkEventParentOrSelf();
     // Set link url only when the node is linked image, or text inside anchor. Prevent CCM popup when long press non-link element(eg. button) inside an anchor.
     if (linkNode && (node == linkNode || node->isTextNode() || nodeIsImage)) {
@@ -2161,8 +2161,8 @@ Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy
         HTMLImageElement* imageElement = 0;
         HTMLMediaElement* mediaElement = 0;
 
-        if (node->hasTagName(HTMLNames::imgTag))
-            imageElement = static_cast<HTMLImageElement*>(node.get());
+        if (isHTMLImageElement(node))
+            imageElement = toHTMLImageElement(node.get());
         else if (isHTMLAreaElement(node))
             imageElement = toHTMLAreaElement(node.get())->imageElement();
 
@@ -2831,7 +2831,7 @@ IntRect WebPagePrivate::blockZoomRectForNode(Node* node)
     double blockToPageRatio = static_cast<double>(pageArea - originalArea) / pageArea;
     double blockExpansionRatio = 5.0 * blockToPageRatio * blockToPageRatio;
 
-    if (!tnode->hasTagName(HTMLNames::imgTag) && !isHTMLInputElement(tnode) && !tnode->hasTagName(HTMLNames::textareaTag)) {
+    if (!isHTMLImageElement(tnode) && !isHTMLInputElement(tnode) && !tnode->hasTagName(HTMLNames::textareaTag)) {
         while ((tnode = tnode->parentNode())) {
             ASSERT(tnode);
             IntRect tRect = rectForNode(tnode);
@@ -4499,7 +4499,7 @@ bool WebPage::blockZoom(const Platform::IntPoint& documentTargetPoint)
 
         // Don't use a block if it is too close to the size of the actual contents.
         // We allow this for images only so that they can be zoomed tight to the screen.
-        if (!node->hasTagName(HTMLNames::imgTag)) {
+        if (!isHTMLImageElement(node)) {
             const IntRect tRect = viewportAccessor->roundToDocumentFromPixelContents(WebCore::FloatRect(blockRect));
             int blockArea = tRect.width() * tRect.height();
             int pageArea = d->contentsSize().width() * d->contentsSize().height();
index 5043f3d..0535d11 100644 (file)
@@ -1,3 +1,20 @@
+2013-06-28  Kangil Han  <kangil.han@samsung.com>
+
+        Adopt is/toHTMLImageElement for code cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=118182
+
+        Reviewed by Andreas Kling.
+
+        To enhance readability, this patch adopts is/toHTMLImageElement.
+        This also helps out to reduce duplicated use of static_cast.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::webContext):
+        (BlackBerry::WebKit::WebPagePrivate::blockZoomRectForNode):
+        (BlackBerry::WebKit::WebPage::blockZoom):
+        * WebKitSupport/FatFingers.cpp:
+        (BlackBerry::WebKit::FatFingers::isElementClickable):
+
 2013-06-27  Kangil Han  <kangil.han@samsung.com>
 
         Adopt is/toHTMLInputElement for code cleanup
index 52b1ab3..389c1c3 100644 (file)
@@ -93,7 +93,7 @@ bool FatFingers::isElementClickable(Element* element) const
     if (element->webkitMatchesSelector("a[href],*:link,*:visited,*[role=button],button,input,select,label[for],area[href],textarea,embed,object", ec)
         || element->isMediaControlElement()
         || element->isContentEditable()
-        || (element->hasTagName(HTMLNames::imgTag) && element->parentNode() && isHTMLAnchorElement(element->parentNode())))
+        || (isHTMLImageElement(element) && element->parentNode() && isHTMLAnchorElement(element->parentNode())))
         return true;
 
     return hasMousePressListener(element)