IsolatedObject support for ProgressIndicator and Meter.
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Feb 2020 16:28:51 +0000 (16:28 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Feb 2020 16:28:51 +0000 (16:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208175

Reviewed by Chris Fleizach.

- Eliminated the need to downcast to an AccessibilityProgressIndicator
by including gaugeRegionValueDescription in the valueDescription
method.
- Separated isAccessibilityProgressIndicatorInstance from
isProgressIndicator, so that the latter now works for both
AccessibilityObjects and AXIsolatedObjects.
- Completed implementation of isMeter in AXIsolatedObject.

* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityObjectInterface.h:
* accessibility/AccessibilityProgressIndicator.cpp:
(WebCore::AccessibilityProgressIndicator::valueDescription const):
* accessibility/AccessibilityProgressIndicator.h:
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData): Sets the isMeter property.
(WebCore::AXIsolatedObject::isAccessibilityProgressIndicatorInstance const):
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
(-[WebAccessibilityObjectWrapper valueDescriptionForMeter]): Deleted, no needed any longer.

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityObjectInterface.h
Source/WebCore/accessibility/AccessibilityProgressIndicator.cpp
Source/WebCore/accessibility/AccessibilityProgressIndicator.h
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index f646852..ae7cb1e 100644 (file)
@@ -1,3 +1,31 @@
+2020-02-25  Andres Gonzalez  <andresg_22@apple.com>
+
+        IsolatedObject support for ProgressIndicator and Meter.
+        https://bugs.webkit.org/show_bug.cgi?id=208175
+
+        Reviewed by Chris Fleizach.
+
+        - Eliminated the need to downcast to an AccessibilityProgressIndicator
+        by including gaugeRegionValueDescription in the valueDescription
+        method.
+        - Separated isAccessibilityProgressIndicatorInstance from
+        isProgressIndicator, so that the latter now works for both
+        AccessibilityObjects and AXIsolatedObjects.
+        - Completed implementation of isMeter in AXIsolatedObject.
+
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityObjectInterface.h:
+        * accessibility/AccessibilityProgressIndicator.cpp:
+        (WebCore::AccessibilityProgressIndicator::valueDescription const):
+        * accessibility/AccessibilityProgressIndicator.h:
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData): Sets the isMeter property.
+        (WebCore::AXIsolatedObject::isAccessibilityProgressIndicatorInstance const):
+        * accessibility/isolatedtree/AXIsolatedObject.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        (-[WebAccessibilityObjectWrapper valueDescriptionForMeter]): Deleted, no needed any longer.
+
 2020-02-25  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] Invalidate layout states on style mutation
index 94ca59d..dd04a07 100644 (file)
@@ -114,6 +114,7 @@ public:
     bool isAccessibilitySVGRoot() const override { return false; }
     bool isAccessibilitySVGElement() const override { return false; }
     bool isAccessibilityTableInstance() const override { return false; }
+    bool isAccessibilityProgressIndicatorInstance() const override { return false; }
 
     bool isAttachmentElement() const override { return false; }
     bool isHeading() const override { return false; }
index 8df7d2f..3a79a10 100644 (file)
@@ -489,6 +489,7 @@ public:
     virtual bool isAccessibilitySVGRoot() const = 0;
     virtual bool isAccessibilitySVGElement() const = 0;
     virtual bool isAccessibilityTableInstance() const = 0;
+    virtual bool isAccessibilityProgressIndicatorInstance() const = 0;
 
     virtual bool isAttachmentElement() const = 0;
     virtual bool isHeading() const = 0;
index f81069c..1da9a85 100644 (file)
@@ -71,25 +71,27 @@ String AccessibilityProgressIndicator::valueDescription() const
 
 #if ENABLE(METER_ELEMENT)
     if (!m_renderer->isMeter())
-        return String();
+        return description;
 
     HTMLMeterElement* meter = meterElement();
     if (!meter)
-        return String();
+        return description;
 
     // The HTML spec encourages authors to include a textual representation of the meter's state in
     // the element's contents. We'll fall back on that if there is not a more accessible alternative.
     AccessibilityObject* axMeter = axObjectCache()->getOrCreate(meter);
-    if (is<AccessibilityNodeObject>(axMeter)) {
+    if (is<AccessibilityNodeObject>(axMeter))
         description = downcast<AccessibilityNodeObject>(axMeter)->accessibilityDescriptionForChildren();
-        if (!description.isEmpty())
-            return description;
-    }
 
-    return meter->textContent();
+    if (description.isEmpty())
+        description = meter->textContent();
+
+    String gaugeRegionValue = gaugeRegionValueDescription();
+    if (!gaugeRegionValue.isEmpty())
+        description = description.isEmpty() ? gaugeRegionValue : description + ", " + gaugeRegionValue;
 #endif
 
-    return String();
+    return description;
 }
 
 float AccessibilityProgressIndicator::valueForRange() const
index 7bb0360..d15e0c8 100644 (file)
@@ -37,16 +37,20 @@ public:
     static Ref<AccessibilityProgressIndicator> create(RenderProgress*);
 #if ENABLE(METER_ELEMENT)
     static Ref<AccessibilityProgressIndicator> create(RenderMeter*);
-    String gaugeRegionValueDescription() const;
 #endif
     Element* element() const override;
 
 private:
     AccessibilityRole roleValue() const override;
-
     bool isProgressIndicator() const override { return true; }
 
+    // Used in type checking function is<AccessibilityProgressIndicator>.
+    bool isAccessibilityProgressIndicatorInstance() const final { return true; }
+
     String valueDescription() const override;
+#if ENABLE(METER_ELEMENT)
+    String gaugeRegionValueDescription() const;
+#endif
     float valueForRange() const override;
     float maxValueForRange() const override;
     float minValueForRange() const override;
@@ -64,4 +68,4 @@ private:
 
 } // namespace WebCore
 
-SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityProgressIndicator, isProgressIndicator())
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityProgressIndicator, isAccessibilityProgressIndicatorInstance())
index c04b046..1d53925 100644 (file)
@@ -97,6 +97,7 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
     setProperty(AXPropertyName::IsMenuListOption, object.isMenuListOption());
     setProperty(AXPropertyName::IsMenuListPopup, object.isMenuListPopup());
     setProperty(AXPropertyName::IsMenuRelated, object.isMenuRelated());
+    setProperty(AXPropertyName::IsMeter, object.isMeter());
     setProperty(AXPropertyName::IsMultiSelectable, object.isMultiSelectable());
     setProperty(AXPropertyName::IsOffScreen, object.isOffScreen());
     setProperty(AXPropertyName::IsOnScreen, object.isOnScreen());
@@ -936,6 +937,12 @@ bool AXIsolatedObject::isAccessibilityTableInstance() const
     return false;
 }
 
+bool AXIsolatedObject::isAccessibilityProgressIndicatorInstance() const
+{
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 bool AXIsolatedObject::isAttachmentElement() const
 {
     ASSERT_NOT_REACHED();
index a12ef1d..db0dd11 100644 (file)
@@ -689,6 +689,7 @@ private:
     bool isAccessibilitySVGRoot() const override;
     bool isAccessibilitySVGElement() const override;
     bool isAccessibilityTableInstance() const override;
+    bool isAccessibilityProgressIndicatorInstance() const override;
     bool isAttachmentElement() const override;
     bool isNativeImage() const override;
     bool isImageButton() const override;
index bec487a..562ab7b 100644 (file)
@@ -2325,29 +2325,6 @@ ALLOW_DEPRECATED_DECLARATIONS_END
     });
 }
 
-- (NSString *)valueDescriptionForMeter
-{
-    if (!self.axBackingObject)
-        return nil;
-    
-    String valueDescription = self.axBackingObject->valueDescription();
-#if ENABLE(METER_ELEMENT)
-    if (!is<AccessibilityProgressIndicator>(self.axBackingObject))
-        return valueDescription;
-    auto &meter = downcast<AccessibilityProgressIndicator>(*self.axBackingObject);
-    String gaugeRegionValue = meter.gaugeRegionValueDescription();
-    if (!gaugeRegionValue.isEmpty()) {
-        StringBuilder builder;
-        builder.append(valueDescription);
-        if (builder.length())
-            builder.appendLiteral(", ");
-        builder.append(gaugeRegionValue);
-        return builder.toString();
-    }
-#endif
-    return valueDescription;
-}
-
 - (id)windowElement:(NSString*)attributeName
 {
     return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([attributeName, protectedSelf = RetainPtr<WebAccessibilityObjectWrapper>(self)] () -> RetainPtr<id> {
@@ -2943,11 +2920,8 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         return nil;
     }
 
-    if ([attributeName isEqualToString:NSAccessibilityValueDescriptionAttribute]) {
-        if (backingObject->isMeter())
-            return [self valueDescriptionForMeter];
+    if ([attributeName isEqualToString:NSAccessibilityValueDescriptionAttribute])
         return backingObject->valueDescription();
-    }
 
     if ([attributeName isEqualToString:NSAccessibilityOrientationAttribute]) {
         AccessibilityOrientation elementOrientation = backingObject->orientation();