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
+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.
if (!node)
return false;
- if (node->hasTagName(imgTag))
+ if (isHTMLImageElement(node))
return true;
if (node->hasTagName(appletTag) || node->hasTagName(embedTag) || node->hasTagName(objectTag))
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();
// 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)
// 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);
}
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);
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));
}
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;
#include "FrameView.h"
#include "HTMLElement.h"
#include "HTMLFrameOwnerElement.h"
+#include "HTMLImageElement.h"
#include "HTMLNames.h"
#include "HTMLStyleElement.h"
#include "InsertionPoint.h"
// 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;
}
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
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;
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
{
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;
#include "Element.h"
#include "HTMLDocument.h"
#include "HTMLFormElement.h"
+#include "HTMLImageElement.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
#include "NodeRareData.h"
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);
}
{
// 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)
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;
}
#include "FrameSelection.h"
#include "FrameView.h"
#include "HTMLAnchorElement.h"
+#include "HTMLImageElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLPlugInElement.h"
}
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);
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);
#include "DocumentFragment.h"
#include "Editor.h"
#include "Frame.h"
+#include "HTMLImageElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
{
// 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))
#import "Font.h"
#import "Frame.h"
#import "FrameLoader.h"
+#import "HTMLImageElement.h"
#import "HTMLNames.h"
#import "HTMLParserIdioms.h"
#import "LoaderNSURLExtras.h"
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]];
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());
}
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)
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());
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;
}
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()
#include "GraphicsContext.h"
#include "HTMLAnchorElement.h"
#include "HTMLElement.h"
+#include "HTMLImageElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "LogicalSelectionOffsetCaches.h"
// 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
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)) {
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();
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);
// 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();
+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
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)