Title: [152387] trunk/Source/WebCore
- Revision
- 152387
- Author
- [email protected]
- Date
- 2013-07-03 21:31:30 -0700 (Wed, 03 Jul 2013)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (152386 => 152387)
--- trunk/Source/WebCore/ChangeLog 2013-07-04 00:47:04 UTC (rev 152386)
+++ trunk/Source/WebCore/ChangeLog 2013-07-04 04:31:30 UTC (rev 152387)
@@ -1,3 +1,27 @@
+2013-07-03 Kangil Han <[email protected]>
+
+ 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):
+
2013-07-03 Brent Fulgham <[email protected]>
[Windows] Unreviewed build correction after r15283.
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (152386 => 152387)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2013-07-04 00:47:04 UTC (rev 152386)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2013-07-04 04:31:30 UTC (rev 152387)
@@ -1735,11 +1735,12 @@
result.append(axobj);
} else {
Node* parent = curr->parentNode();
- if (parent && isHTMLAreaElement(curr) && parent->hasTagName(mapTag)) {
+ if (parent && isHTMLAreaElement(curr) && isHTMLMapElement(parent)) {
AccessibilityImageMapLink* areaObject = static_cast<AccessibilityImageMapLink*>(axObjectCache()->getOrCreate(ImageMapLinkRole));
+ HTMLMapElement* map = toHTMLMapElement(parent);
areaObject->setHTMLAreaElement(toHTMLAreaElement(curr));
- areaObject->setHTMLMapElement(static_cast<HTMLMapElement*>(parent));
- areaObject->setParent(accessibilityParentForImageMap(static_cast<HTMLMapElement*>(parent)));
+ areaObject->setHTMLMapElement(map);
+ areaObject->setParent(accessibilityParentForImageMap(map));
result.append(areaObject);
}
@@ -2154,8 +2155,8 @@
AccessibilityObject* parent = 0;
for (Element* mapParent = area->parentElement(); mapParent; mapParent = mapParent->parentElement()) {
- if (mapParent->hasTagName(mapTag)) {
- parent = accessibilityParentForImageMap(static_cast<HTMLMapElement*>(mapParent));
+ if (isHTMLMapElement(mapParent)) {
+ parent = accessibilityParentForImageMap(toHTMLMapElement(mapParent));
break;
}
}
Modified: trunk/Source/WebCore/dom/DocumentOrderedMap.cpp (152386 => 152387)
--- trunk/Source/WebCore/dom/DocumentOrderedMap.cpp 2013-07-04 00:47:04 UTC (rev 152386)
+++ trunk/Source/WebCore/dom/DocumentOrderedMap.cpp 2013-07-04 04:31:30 UTC (rev 152387)
@@ -55,12 +55,12 @@
inline bool keyMatchesMapName(AtomicStringImpl* key, Element* element)
{
- return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().impl() == key;
+ return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().impl() == key;
}
inline bool keyMatchesLowercasedMapName(AtomicStringImpl* key, Element* element)
{
- return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().lower().impl() == key;
+ return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().lower().impl() == key;
}
inline bool keyMatchesLabelForAttribute(AtomicStringImpl* key, Element* element)
Modified: trunk/Source/WebCore/dom/TreeScope.cpp (152386 => 152387)
--- trunk/Source/WebCore/dom/TreeScope.cpp 2013-07-04 00:47:04 UTC (rev 152386)
+++ trunk/Source/WebCore/dom/TreeScope.cpp 2013-07-04 04:31:30 UTC (rev 152387)
@@ -238,8 +238,8 @@
size_t hashPos = url.find('#');
String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl();
if (rootNode()->document()->isHTMLDocument())
- return static_cast<HTMLMapElement*>(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
- return static_cast<HTMLMapElement*>(m_imageMapsByName->getElementByMapName(AtomicString(name).impl(), this));
+ return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
+ return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(name).impl(), this));
}
Node* nodeFromPoint(Document* document, int x, int y, LayoutPoint* localPoint)
Modified: trunk/Source/WebCore/html/HTMLAreaElement.cpp (152386 => 152387)
--- trunk/Source/WebCore/html/HTMLAreaElement.cpp 2013-07-04 00:47:04 UTC (rev 152386)
+++ trunk/Source/WebCore/html/HTMLAreaElement.cpp 2013-07-04 04:31:30 UTC (rev 152387)
@@ -184,10 +184,10 @@
HTMLImageElement* HTMLAreaElement::imageElement() const
{
Node* mapElement = parentNode();
- if (!mapElement || !mapElement->hasTagName(mapTag))
+ if (!mapElement || !isHTMLMapElement(mapElement))
return 0;
- return static_cast<HTMLMapElement*>(mapElement)->imageElement();
+ return toHTMLMapElement(mapElement)->imageElement();
}
bool HTMLAreaElement::isKeyboardFocusable(KeyboardEvent*) const
Modified: trunk/Source/WebCore/html/HTMLMapElement.h (152386 => 152387)
--- trunk/Source/WebCore/html/HTMLMapElement.h 2013-07-04 00:47:04 UTC (rev 152386)
+++ trunk/Source/WebCore/html/HTMLMapElement.h 2013-07-04 04:31:30 UTC (rev 152387)
@@ -54,6 +54,22 @@
AtomicString m_name;
};
+inline bool isHTMLMapElement(Node* node)
+{
+ return node->hasTagName(HTMLNames::mapTag);
+}
+
+inline bool isHTMLMapElement(Element* element)
+{
+ return element->hasTagName(HTMLNames::mapTag);
+}
+
+inline HTMLMapElement* toHTMLMapElement(Node* node)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLMapElement(node));
+ return static_cast<HTMLMapElement*>(node);
+}
+
} //namespace
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes