<rdar://problem/4867889> REGRESSION: "Choose File.." buttons are exposed as AXGroup...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2008 16:35:48 +0000 (16:35 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2008 16:35:48 +0000 (16:35 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32958 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/AccessibilityObject.h
WebCore/page/AccessibilityRenderObject.cpp
WebCore/page/AccessibilityRenderObject.h
WebCore/rendering/RenderFileUploadControl.cpp
WebCore/rendering/RenderFileUploadControl.h

index b7e9f5f..130b9da 100644 (file)
@@ -1,3 +1,23 @@
+2008-05-07  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Alice Liu
+
+        <rdar://problem/4867889> REGRESSION: "Choose File.." buttons are exposed as AXGroup instead of AXButton
+
+        * page/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::isFileUploadButton):
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isFileUploadButton):
+        (WebCore::AccessibilityRenderObject::actionElement):
+        (WebCore::AccessibilityRenderObject::textUnderElement):
+        (WebCore::AccessibilityRenderObject::stringValue):
+        (WebCore::AccessibilityRenderObject::roleValue):
+        * page/AccessibilityRenderObject.h:
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::buttonValue):
+        (WebCore::RenderFileUploadControl::fileTextValue):
+        * rendering/RenderFileUploadControl.h:
+
 2008-05-07  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Reviewed by Eric.
index 46ed61b..f3ed3b3 100644 (file)
@@ -198,7 +198,8 @@ public:
     virtual bool isWebArea() const { return false; };
     virtual bool isCheckboxOrRadio() const { return false; };
     virtual bool isListBox() const { return false; };
-
+    virtual bool isFileUploadButton() const { return false; };
+    
     virtual bool isChecked() const { return false; };
     virtual bool isEnabled() const { return false; };
     virtual bool isSelected() const { return false; };
index 6f7c3e1..e1cbf2e 100644 (file)
@@ -54,6 +54,7 @@
 #include "NodeList.h"
 #include "NotImplemented.h"
 #include "Page.h"
+#include "RenderFileUploadControl.h"
 #include "RenderImage.h"
 #include "RenderListBox.h"
 #include "RenderListMarker.h"
@@ -226,6 +227,16 @@ bool AccessibilityRenderObject::isCheckboxOrRadio() const
     return role == RadioButtonRole || role == CheckBoxRole;
 }    
     
+bool AccessibilityRenderObject::isFileUploadButton() const
+{
+    if (m_renderer && m_renderer->element() && m_renderer->element()->hasTagName(inputTag)) {
+        HTMLInputElement* input = static_cast<HTMLInputElement*>(m_renderer->element());
+        return input->inputType() == HTMLInputElement::FILE;
+    }
+    
+    return false;
+}
+    
 bool AccessibilityRenderObject::isPressed() const
 {
     ASSERT(m_renderer);
@@ -359,7 +370,10 @@ Element* AccessibilityRenderObject::actionElement() const
         if (!input->disabled() && (isCheckboxOrRadio() || input->isTextButton()))
             return input;
     }
-    
+            
+    if (isFileUploadButton())
+        return static_cast<Element*>(m_renderer->element());
+            
     if (AccessibilityObject::isARIAInput(ariaRoleAttribute()))
         return static_cast<Element*>(m_renderer->element());
 
@@ -425,6 +439,11 @@ String AccessibilityRenderObject::textUnderElement() const
     if (!m_renderer)
         return String();
     
+    if (isFileUploadButton()) {
+        RenderFileUploadControl* uploadControl = static_cast<RenderFileUploadControl*>(m_renderer);
+        return uploadControl->buttonValue();
+    }
+    
     Node* node = m_renderer->element();
     if (node) {
         if (Frame* frame = node->document()->frame()) {
@@ -496,6 +515,11 @@ String AccessibilityRenderObject::stringValue() const
     if (isTextControl())
         return text();
     
+    if (isFileUploadButton()) {
+        RenderFileUploadControl* uploadControl = static_cast<RenderFileUploadControl*>(m_renderer);
+        return uploadControl->fileTextValue();
+    }
+    
     // FIXME: We might need to implement a value here for more types
     // FIXME: It would be better not to advertise a value at all for the types for which we don't implement one;
     // this would require subclassing or making accessibilityAttributeNames do something other than return a
@@ -1585,6 +1609,9 @@ AccessibilityRole AccessibilityRenderObject::roleValue() const
     if (node && node->hasTagName(buttonTag))
         return ButtonRole;
 
+    if (isFileUploadButton())
+        return ButtonRole;
+    
     if (m_renderer->isMenuList())
         return PopUpButtonRole;
     
index 1e2f631..f52deb4 100644 (file)
@@ -73,6 +73,7 @@ public:
     virtual bool isNativeTextControl() const;
     virtual bool isWebArea() const;
     virtual bool isCheckboxOrRadio() const;
+    virtual bool isFileUploadButton() const;
     
     virtual bool isEnabled() const;
     virtual bool isSelected() const;
index fea7565..ddd887e 100644 (file)
@@ -262,6 +262,19 @@ void RenderFileUploadControl::receiveDroppedFile(const String& filename)
     m_fileChooser->chooseFile(filename);
 }
 
+String RenderFileUploadControl::buttonValue()
+{
+    if (!m_button)
+        return String();
+    
+    return m_button->value();
+}
+
+String RenderFileUploadControl::fileTextValue()
+{
+    return m_fileChooser->basenameForWidth(style()->font(), maxFilenameWidth());
+}
+    
 HTMLFileUploadInnerButtonElement::HTMLFileUploadInnerButtonElement(Document* doc, Node* shadowParent)
     : HTMLInputElement(doc)
     , m_shadowParent(shadowParent)
index e94b787..e0289da 100644 (file)
@@ -50,6 +50,9 @@ public:
     
     void receiveDroppedFile(const String&);
 
+    String buttonValue();
+    String fileTextValue();
+    
 private:
     int maxFilenameWidth() const;
     RenderStyle* createButtonStyle(RenderStyle* parentStyle) const;