IsolatedObject implementation of property setters.
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Dec 2019 01:03:13 +0000 (01:03 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Dec 2019 01:03:13 +0000 (01:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205566

Reviewed by Chris Fleizach.

- Implementation of setters that need to be executed in the main
thread.
- Sanity check of the associatedAXObject() before calling corresponding
method on main thread.

* accessibility/isolatedtree/AXIsolatedTreeNode.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
(WebCore::AXIsolatedObject::performFunctionOnMainThread):
(WebCore::AXIsolatedObject::setARIAGrabbed):
(WebCore::AXIsolatedObject::setIsExpanded):
(WebCore::AXIsolatedObject::setValue):
(WebCore::AXIsolatedObject::setSelected):
(WebCore::AXIsolatedObject::setSelectedRows):
(WebCore::AXIsolatedObject::setFocused):
(WebCore::AXIsolatedObject::setSelectedText):
(WebCore::AXIsolatedObject::setSelectedTextRange):
(WebCore::AXIsolatedObject::setCaretBrowsingEnabled):
(WebCore::AXIsolatedObject::setPreventKeyboardDOMEventDispatch):
(WebCore::AXIsolatedObject::findTextRanges const):
(WebCore::AXIsolatedObject::performTextOperation):
(WebCore::AXIsolatedObject::widget const):
(WebCore::AXIsolatedObject::document const):
(WebCore::AXIsolatedObject::documentFrameView const):
* accessibility/isolatedtree/AXIsolatedTreeNode.h:

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/isolatedtree/AXIsolatedTreeNode.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedTreeNode.h

index 2552c7d..b705411 100644 (file)
@@ -1,3 +1,35 @@
+2019-12-23  Andres Gonzalez  <andresg_22@apple.com>
+
+        IsolatedObject implementation of property setters.
+        https://bugs.webkit.org/show_bug.cgi?id=205566
+
+        Reviewed by Chris Fleizach.
+
+        - Implementation of setters that need to be executed in the main
+        thread.
+        - Sanity check of the associatedAXObject() before calling corresponding
+        method on main thread.
+
+        * accessibility/isolatedtree/AXIsolatedTreeNode.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData):
+        (WebCore::AXIsolatedObject::performFunctionOnMainThread):
+        (WebCore::AXIsolatedObject::setARIAGrabbed):
+        (WebCore::AXIsolatedObject::setIsExpanded):
+        (WebCore::AXIsolatedObject::setValue):
+        (WebCore::AXIsolatedObject::setSelected):
+        (WebCore::AXIsolatedObject::setSelectedRows):
+        (WebCore::AXIsolatedObject::setFocused):
+        (WebCore::AXIsolatedObject::setSelectedText):
+        (WebCore::AXIsolatedObject::setSelectedTextRange):
+        (WebCore::AXIsolatedObject::setCaretBrowsingEnabled):
+        (WebCore::AXIsolatedObject::setPreventKeyboardDOMEventDispatch):
+        (WebCore::AXIsolatedObject::findTextRanges const):
+        (WebCore::AXIsolatedObject::performTextOperation):
+        (WebCore::AXIsolatedObject::widget const):
+        (WebCore::AXIsolatedObject::document const):
+        (WebCore::AXIsolatedObject::documentFrameView const):
+        * accessibility/isolatedtree/AXIsolatedTreeNode.h:
+
 2019-12-23  Daniel Bates  <dabates@apple.com>
 
         REGRESSION (r212693): getClientRects(), getBoundingClientRect() for range that spans multi-lines differs depending on whether text is selected
 2019-12-23  Daniel Bates  <dabates@apple.com>
 
         REGRESSION (r212693): getClientRects(), getBoundingClientRect() for range that spans multi-lines differs depending on whether text is selected
index a5493cc..62c3da2 100644 (file)
@@ -185,7 +185,9 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
     setProperty(AXPropertyName::ReadOnlyValue, object.readOnlyValue());
     setProperty(AXPropertyName::AutoCompleteValue, object.autoCompleteValue());
     setProperty(AXPropertyName::SpeakAs, object.speakAsProperty());
     setProperty(AXPropertyName::ReadOnlyValue, object.readOnlyValue());
     setProperty(AXPropertyName::AutoCompleteValue, object.autoCompleteValue());
     setProperty(AXPropertyName::SpeakAs, object.speakAsProperty());
+#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
     setProperty(AXPropertyName::CaretBrowsingEnabled, object.caretBrowsingEnabled());
     setProperty(AXPropertyName::CaretBrowsingEnabled, object.caretBrowsingEnabled());
+#endif
     setObjectProperty(AXPropertyName::FocusableAncestor, object.focusableAncestor());
     setObjectProperty(AXPropertyName::EditableAncestor, object.editableAncestor());
     setObjectProperty(AXPropertyName::HighestEditableAncestor, object.highestEditableAncestor());
     setObjectProperty(AXPropertyName::FocusableAncestor, object.focusableAncestor());
     setObjectProperty(AXPropertyName::EditableAncestor, object.editableAncestor());
     setObjectProperty(AXPropertyName::HighestEditableAncestor, object.highestEditableAncestor());
@@ -518,6 +520,92 @@ AXCoreObject* AXIsolatedObject::scrollBar(AccessibilityOrientation orientation)
     return objectAttributeValue(orientation == AccessibilityOrientation::Vertical ? AXPropertyName::VerticalScrollBar : AXPropertyName::HorizontalScrollBar);
 }
 
     return objectAttributeValue(orientation == AccessibilityOrientation::Vertical ? AXPropertyName::VerticalScrollBar : AXPropertyName::HorizontalScrollBar);
 }
 
+template<typename U>
+void AXIsolatedObject::performFunctionOnMainThread(U&& lambda)
+{
+    Accessibility::performFunctionOnMainThread([&lambda, this] () {
+        if (auto object = associatedAXObject())
+            lambda(object);
+    });
+}
+
+void AXIsolatedObject::setARIAGrabbed(bool value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setARIAGrabbed(value);
+    });
+}
+
+void AXIsolatedObject::setIsExpanded(bool value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setIsExpanded(value);
+    });
+}
+void AXIsolatedObject::setValue(float value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setValue(value);
+    });
+}
+
+void AXIsolatedObject::setSelected(bool value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setSelected(value);
+    });
+}
+void AXIsolatedObject::setSelectedRows(AccessibilityChildrenVector& value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setSelectedRows(value);
+    });
+}
+
+void AXIsolatedObject::setFocused(bool value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setFocused(value);
+    });
+}
+
+void AXIsolatedObject::setSelectedText(const String& value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setSelectedText(value);
+    });
+}
+
+void AXIsolatedObject::setSelectedTextRange(const PlainTextRange& value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setSelectedTextRange(value);
+    });
+}
+
+void AXIsolatedObject::setValue(const String& value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setValue(value);
+    });
+}
+
+#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
+void AXIsolatedObject::setCaretBrowsingEnabled(bool value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setCaretBrowsingEnabled(value);
+    });
+}
+#endif
+
+void AXIsolatedObject::setPreventKeyboardDOMEventDispatch(bool value)
+{
+    performFunctionOnMainThread([&value](AXCoreObject* object) {
+        object->setPreventKeyboardDOMEventDispatch(value);
+    });
+}
+
 void AXIsolatedObject::colorValue(int& r, int& g, int& b) const
 {
     auto color = colorAttributeValue(AXPropertyName::ColorValue);
 void AXIsolatedObject::colorValue(int& r, int& g, int& b) const
 {
     auto color = colorAttributeValue(AXPropertyName::ColorValue);
@@ -699,14 +787,18 @@ void AXIsolatedObject::updateBackingStore()
 Vector<RefPtr<Range>> AXIsolatedObject::findTextRanges(AccessibilitySearchTextCriteria const& criteria) const
 {
     return Accessibility::retrieveValueFromMainThread<Vector<RefPtr<Range>>>([&criteria, this] () -> Vector<RefPtr<Range>> {
 Vector<RefPtr<Range>> AXIsolatedObject::findTextRanges(AccessibilitySearchTextCriteria const& criteria) const
 {
     return Accessibility::retrieveValueFromMainThread<Vector<RefPtr<Range>>>([&criteria, this] () -> Vector<RefPtr<Range>> {
-        return associatedAXObject()->findTextRanges(criteria);
+        if (auto object = associatedAXObject())
+            return object->findTextRanges(criteria);
+        return Vector<RefPtr<Range>>();
     });
 }
 
 Vector<String> AXIsolatedObject::performTextOperation(AccessibilityTextOperation const& textOperation)
 {
     return Accessibility::retrieveValueFromMainThread<Vector<String>>([&textOperation, this] () -> Vector<String> {
     });
 }
 
 Vector<String> AXIsolatedObject::performTextOperation(AccessibilityTextOperation const& textOperation)
 {
     return Accessibility::retrieveValueFromMainThread<Vector<String>>([&textOperation, this] () -> Vector<String> {
-        return associatedAXObject()->performTextOperation(textOperation);
+        if (auto object = associatedAXObject())
+            return object->performTextOperation(textOperation);
+        return Vector<String>();
     });
 }
 
     });
 }
 
@@ -1384,7 +1476,9 @@ TextIteratorBehavior AXIsolatedObject::textIteratorBehaviorForTextRange() const
 
 Widget* AXIsolatedObject::widget() const
 {
 
 Widget* AXIsolatedObject::widget() const
 {
-    return associatedAXObject()->widget();
+    if (auto object = associatedAXObject())
+        return object->widget();
+    return nullptr;
 }
 
 Widget* AXIsolatedObject::widgetForAttachmentView() const
 }
 
 Widget* AXIsolatedObject::widgetForAttachmentView() const
@@ -1401,12 +1495,16 @@ Page* AXIsolatedObject::page() const
 
 Document* AXIsolatedObject::document() const
 {
 
 Document* AXIsolatedObject::document() const
 {
-    return associatedAXObject()->document();
+    if (auto object = associatedAXObject())
+        return object->document();
+    return nullptr;
 }
 
 FrameView* AXIsolatedObject::documentFrameView() const
 {
 }
 
 FrameView* AXIsolatedObject::documentFrameView() const
 {
-    return associatedAXObject()->documentFrameView();
+    if (auto object = associatedAXObject())
+        return object->documentFrameView();
+    return nullptr;
 }
 
 Frame* AXIsolatedObject::frame() const
 }
 
 Frame* AXIsolatedObject::frame() const
index 8573b04..553ba88 100644 (file)
@@ -104,7 +104,9 @@ private:
         CanSetTextRangeAttributes,
         CanSetValueAttribute,
         CanvasHasFallbackContent,
         CanSetTextRangeAttributes,
         CanSetValueAttribute,
         CanvasHasFallbackContent,
+#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
         CaretBrowsingEnabled,
         CaretBrowsingEnabled,
+#endif
         ClassList,
         ClickPoint,
         ColorValue,
         ClassList,
         ClickPoint,
         ColorValue,
@@ -325,7 +327,8 @@ private:
     void fillChildrenVectorForProperty(AXPropertyName, AccessibilityChildrenVector&) const;
     void setMathscripts(AXPropertyName, AXCoreObject&);
     void insertMathPairs(Vector<AccessibilityIsolatedTreeMathMultiscriptPair>&, AccessibilityMathMultiscriptPairs&);
     void fillChildrenVectorForProperty(AXPropertyName, AccessibilityChildrenVector&) const;
     void setMathscripts(AXPropertyName, AXCoreObject&);
     void insertMathPairs(Vector<AccessibilityIsolatedTreeMathMultiscriptPair>&, AccessibilityMathMultiscriptPairs&);
-    
+    template<typename U> void performFunctionOnMainThread(U&&);
+
     // Attribute retrieval overrides.
     bool isHeading() const override { return boolAttributeValue(AXPropertyName::IsHeading); }
     bool isLink() const override { return boolAttributeValue(AXPropertyName::IsLink); }
     // Attribute retrieval overrides.
     bool isHeading() const override { return boolAttributeValue(AXPropertyName::IsHeading); }
     bool isLink() const override { return boolAttributeValue(AXPropertyName::IsLink); }
@@ -502,7 +505,9 @@ private:
     String descriptionAttributeValue() const override { return stringAttributeValue(AXPropertyName::Description); }
     String helpTextAttributeValue() const override { return stringAttributeValue(AXPropertyName::HelpText); }
     String titleAttributeValue() const override { return stringAttributeValue(AXPropertyName::Title); }
     String descriptionAttributeValue() const override { return stringAttributeValue(AXPropertyName::Description); }
     String helpTextAttributeValue() const override { return stringAttributeValue(AXPropertyName::HelpText); }
     String titleAttributeValue() const override { return stringAttributeValue(AXPropertyName::Title); }
+#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
     bool caretBrowsingEnabled() const override { return boolAttributeValue(AXPropertyName::CaretBrowsingEnabled); }
     bool caretBrowsingEnabled() const override { return boolAttributeValue(AXPropertyName::CaretBrowsingEnabled); }
+#endif
     AXCoreObject* focusableAncestor() override { return objectAttributeValue(AXPropertyName::FocusableAncestor); }
     AXCoreObject* editableAncestor() override { return objectAttributeValue(AXPropertyName::EditableAncestor); }
     AXCoreObject* highestEditableAncestor() override { return objectAttributeValue(AXPropertyName::HighestEditableAncestor); }
     AXCoreObject* focusableAncestor() override { return objectAttributeValue(AXPropertyName::FocusableAncestor); }
     AXCoreObject* editableAncestor() override { return objectAttributeValue(AXPropertyName::EditableAncestor); }
     AXCoreObject* highestEditableAncestor() override { return objectAttributeValue(AXPropertyName::HighestEditableAncestor); }
@@ -595,18 +600,20 @@ private:
     IntRect doAXBoundsForRangeUsingCharacterOffset(const PlainTextRange&) const override { return IntRect(); }
     unsigned doAXLineForIndex(unsigned) override { return 0; }
 
     IntRect doAXBoundsForRangeUsingCharacterOffset(const PlainTextRange&) const override { return IntRect(); }
     unsigned doAXLineForIndex(unsigned) override { return 0; }
 
-    // TODO: Attribute setters.
-    void setARIAGrabbed(bool) override { }
-    void setIsExpanded(bool) override { }
-    void setValue(float) override { }
-    void setSelected(bool) override { }
-    void setSelectedRows(AccessibilityChildrenVector&) override { }
-    void setFocused(bool) override { }
-    void setSelectedText(const String&) override { }
-    void setSelectedTextRange(const PlainTextRange&) override { }
-    void setValue(const String&) override { }
-    void setCaretBrowsingEnabled(bool) override { }
-    void setPreventKeyboardDOMEventDispatch(bool) override { }
+    // Attribute setters.
+    void setARIAGrabbed(bool) override;
+    void setIsExpanded(bool) override;
+    void setValue(float) override;
+    void setSelected(bool) override;
+    void setSelectedRows(AccessibilityChildrenVector&) override;
+    void setFocused(bool) override;
+    void setSelectedText(const String&) override;
+    void setSelectedTextRange(const PlainTextRange&) override;
+    void setValue(const String&) override;
+#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
+    void setCaretBrowsingEnabled(bool) override;
+#endif
+    void setPreventKeyboardDOMEventDispatch(bool) override;
 
     // TODO: Functions
     String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) const override { return String(); }
 
     // TODO: Functions
     String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) const override { return String(); }