[AX] Use toAccessibilityRenderObject() instead of using static_cast<>
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Nov 2013 12:29:10 +0000 (12:29 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Nov 2013 12:29:10 +0000 (12:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123986

Reviewed by Mario Sanchez Prada.

Though there is toAccessibilityRenderObject(), static_cast<> are being used by many places.
To use toAccessibilityRenderObject() is more helpful to find bad type cast.

No new tests, no behavior changes.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::notificationPostTimerFired):
* accessibility/AccessibilityImageMapLink.cpp:
(WebCore::AccessibilityImageMapLink::imageMapLinkRenderer):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole):
* accessibility/ios/AccessibilityObjectIOS.mm:
(WebCore::AccessibilityObject::accessibilityPasswordFieldLength):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetElement):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityImageMapLink.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebKit/win/AccessibleImage.cpp

index 703192d..59db616 100644 (file)
@@ -1,5 +1,30 @@
 2013-11-07  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
+        [AX] Use toAccessibilityRenderObject() instead of using static_cast<>
+        https://bugs.webkit.org/show_bug.cgi?id=123986
+
+        Reviewed by Mario Sanchez Prada.
+
+        Though there is toAccessibilityRenderObject(), static_cast<> are being used by many places.
+        To use toAccessibilityRenderObject() is more helpful to find bad type cast.
+
+        No new tests, no behavior changes.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::notificationPostTimerFired):
+        * accessibility/AccessibilityImageMapLink.cpp:
+        (WebCore::AccessibilityImageMapLink::imageMapLinkRenderer):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
+        (WebCore::AccessibilityRenderObject::inheritsPresentationalRole):
+        * accessibility/ios/AccessibilityObjectIOS.mm:
+        (WebCore::AccessibilityObject::accessibilityPasswordFieldLength):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetElement):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
+2013-11-07  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
         [AX] Use toAccessibilityTable() instead of using manual static_cast<>
         https://bugs.webkit.org/show_bug.cgi?id=123982
 
index 6b16db3..50f8485 100644 (file)
@@ -657,7 +657,7 @@ void AXObjectCache::notificationPostTimerFired(Timer<AXObjectCache>*)
         // Make sure none of the render views are in the process of being layed out.
         // Notifications should only be sent after the renderer has finished
         if (obj->isAccessibilityRenderObject()) {
-            AccessibilityRenderObject* renderObj = static_cast<AccessibilityRenderObject*>(obj);
+            AccessibilityRenderObject* renderObj = toAccessibilityRenderObject(obj);
             RenderObject* renderer = renderObj->renderer();
             if (renderer)
                 ASSERT(!renderer->view().layoutState());
index 5c32779..5f3f2fa 100644 (file)
@@ -141,7 +141,7 @@ RenderElement* AccessibilityImageMapLink::imageMapLinkRenderer() const
 
     RenderElement* renderer = nullptr;
     if (m_parent && m_parent->isAccessibilityRenderObject())
-        renderer = toRenderElement(static_cast<AccessibilityRenderObject*>(m_parent)->renderer());
+        renderer = toRenderElement(toAccessibilityRenderObject(m_parent)->renderer());
     else
         renderer = m_mapElement->renderer();
     
index bf47bfa..61350d6 100644 (file)
@@ -2310,10 +2310,9 @@ void AccessibilityRenderObject::handleActiveDescendantChanged()
     if (!element)
         return;
     if (!renderer()->frame().selection().isFocusedAndActive() || renderer()->document().focusedElement() != element)
-        return; 
-    AccessibilityRenderObject* activedescendant = static_cast<AccessibilityRenderObject*>(activeDescendant());
-    
-    if (activedescendant && shouldNotifyActiveDescendant())
+        return;
+
+    if (toAccessibilityRenderObject(activeDescendant()) && shouldNotifyActiveDescendant())
         renderer()->document().axObjectCache()->postNotification(m_renderer, AXObjectCache::AXActiveDescendantChanged);
 }
 
@@ -2625,7 +2624,7 @@ bool AccessibilityRenderObject::inheritsPresentationalRole() const
         if (!parent->isAccessibilityRenderObject())
             continue;
         
-        Node* elementNode = static_cast<AccessibilityRenderObject*>(parent)->node();
+        Node* elementNode = toAccessibilityRenderObject(parent)->node();
         if (!elementNode || !elementNode->isElementNode())
             continue;
         
index dcde88a..6892702 100644 (file)
@@ -62,7 +62,7 @@ int AccessibilityObject::accessibilityPasswordFieldLength()
 {
     if (!isPasswordField())
         return 0;
-    RenderObject* renderObject = static_cast<AccessibilityRenderObject*>(this)->renderer();
+    RenderObject* renderObject = toAccessibilityRenderObject(this)->renderer();
     
     if (!renderObject || !renderObject->node() || !renderObject->node()->isHTMLElement())
         return false;
index 7392df5..ab1caf6 100644 (file)
@@ -818,7 +818,7 @@ static void AXAttributeStringSetElement(NSMutableAttributedString* attrString, N
     if (object && object->isAccessibilityRenderObject()) {
         // make a serializable AX object
         
-        RenderObject* renderer = static_cast<AccessibilityRenderObject*>(object)->renderer();
+        RenderObject* renderer = toAccessibilityRenderObject(object)->renderer();
         if (!renderer)
             return;
         
@@ -2124,7 +2124,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if (m_object->isWebArea()) {
         if ([attributeName isEqualToString:@"AXLinkUIElements"]) {
             AccessibilityObject::AccessibilityChildrenVector links;
-            static_cast<AccessibilityRenderObject*>(m_object)->getDocumentLinks(links);
+            toAccessibilityRenderObject(m_object)->getDocumentLinks(links);
             return convertToNSArray(links);
         }
         if ([attributeName isEqualToString:@"AXLoaded"])
@@ -2545,7 +2545,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return [NSNumber numberWithBool:m_object->isSelected()];
     
     if ([attributeName isEqualToString: NSAccessibilityServesAsTitleForUIElementsAttribute] && m_object->isMenuButton()) {
-        AccessibilityObject* uiElement = static_cast<AccessibilityRenderObject*>(m_object)->menuForMenuButton();
+        AccessibilityObject* uiElement = toAccessibilityRenderObject(m_object)->menuForMenuButton();
         if (uiElement)
             return [NSArray arrayWithObject:uiElement->wrapper()];
     }
index 4a70cc8..fd5f5f6 100644 (file)
@@ -44,7 +44,7 @@ String AccessibleImage::name() const
     if (!m_object->isAccessibilityRenderObject())
         return AccessibleBase::name();
 
-    AccessibilityRenderObject* obj = static_cast<AccessibilityRenderObject*>(m_object);
+    AccessibilityRenderObject* obj = toAccessibilityRenderObject(m_object);
 
     String ariaLabel = obj->ariaLabeledByAttribute();
     if (!ariaLabel.isEmpty())