Title: [260448] trunk/Source/WebCore
Revision
260448
Author
andresg...@apple.com
Date
2020-04-21 13:21:04 -0700 (Tue, 21 Apr 2020)

Log Message

Fix for remoteParentObject and platformWidget not being stored properly in the AXIsolatedObject attributes variant.
https://bugs.webkit.org/show_bug.cgi?id=210809

Reviewed by Chris Fleizach.

Adding these properties to the AXIsolatedObject attributes variant as
WeakPtr<void*> fails. So they are now cached as member variables.

* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
(WebCore::AXIsolatedObject::platformWidget const):
* accessibility/isolatedtree/AXIsolatedObject.h:
(WebCore::AXIsolatedObject::propertyValue const): Deleted.
* accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
(WebCore::AXIsolatedObject::initializePlatformProperties):
(WebCore::AXIsolatedObject::remoteParentObject const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (260447 => 260448)


--- trunk/Source/WebCore/ChangeLog	2020-04-21 19:18:36 UTC (rev 260447)
+++ trunk/Source/WebCore/ChangeLog	2020-04-21 20:21:04 UTC (rev 260448)
@@ -1,3 +1,22 @@
+2020-04-21  Andres Gonzalez  <andresg...@apple.com>
+
+        Fix for remoteParentObject and platformWidget not being stored properly in the AXIsolatedObject attributes variant.
+        https://bugs.webkit.org/show_bug.cgi?id=210809
+
+        Reviewed by Chris Fleizach.
+
+        Adding these properties to the AXIsolatedObject attributes variant as
+        WeakPtr<void*> fails. So they are now cached as member variables.
+
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData):
+        (WebCore::AXIsolatedObject::platformWidget const):
+        * accessibility/isolatedtree/AXIsolatedObject.h:
+        (WebCore::AXIsolatedObject::propertyValue const): Deleted.
+        * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+        (WebCore::AXIsolatedObject::initializePlatformProperties):
+        (WebCore::AXIsolatedObject::remoteParentObject const):
+
 2020-04-20  Simon Fraser  <simon.fra...@apple.com>
 
         Horizontal overflow overlay scrollbar is misplaced in RTL

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (260447 => 260448)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2020-04-21 19:18:36 UTC (rev 260447)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2020-04-21 20:21:04 UTC (rev 260448)
@@ -374,15 +374,6 @@
         setMathscripts(AXPropertyName::MathPostscripts, object);
     }
 
-    if (object.isScrollView()) {
-#if PLATFORM(COCOA)
-        setProperty(AXPropertyName::PlatformWidget, object.platformWidget());
-        setProperty(AXPropertyName::RemoteParentObject, object.remoteParentObject());
-#else
-        setProperty(AXPropertyName::PlatformWidget, object.platformWidget());
-#endif
-    }
-
     if (isRoot) {
         setObjectProperty(AXPropertyName::WebArea, object.webAreaObject());
         setProperty(AXPropertyName::PreventKeyboardDOMEventDispatch, object.preventKeyboardDOMEventDispatch());
@@ -391,6 +382,8 @@
         setProperty(AXPropertyName::DocumentEncoding, object.documentEncoding());
         setObjectVectorProperty(AXPropertyName::DocumentLinks, object.documentLinks());
     }
+
+    initializePlatformProperties(object);
 }
 
 void AXIsolatedObject::setMathscripts(AXPropertyName propertyName, AXCoreObject& object)
@@ -1571,6 +1564,15 @@
     return nullptr;
 }
 
+PlatformWidget AXIsolatedObject::platformWidget() const
+{
+#if PLATFORM(COCOA)
+    return m_platformWidget.get();
+#else
+    return m_platformWidget;
+#endif
+}
+
 Widget* AXIsolatedObject::widgetForAttachmentView() const
 {
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (260447 => 260448)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h	2020-04-21 19:18:36 UTC (rev 260447)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h	2020-04-21 20:21:04 UTC (rev 260448)
@@ -73,6 +73,7 @@
     AXIsolatedObject(AXCoreObject&, AXIsolatedTreeID, AXID parentID);
     bool isAXIsolatedObjectInstance() const override { return true; }
     void initializeAttributeData(AXCoreObject&, bool isRoot);
+    void initializePlatformProperties(const AXCoreObject&);
     AXCoreObject* associatedAXObject() const
     {
         ASSERT(isMainThread());
@@ -276,15 +277,11 @@
         MinValueForRange,
         Orientation,
         PlaceholderValue,
-        PlatformWidget,
         PressedIsPresent,
         PopupValue,
         PosInSet,
         PreventKeyboardDOMEventDispatch,
         ReadOnlyValue,
-#if PLATFORM(COCOA)
-        RemoteParentObject,
-#endif
         RoleValue,
         RolePlatformString,
         RoleDescription,
@@ -341,13 +338,7 @@
         AccessibilityTextSource textSource;
     };
 
-    using AttributeValueVariant = Variant<std::nullptr_t, String, bool, int, unsigned, double, float, uint64_t, Color, URL, LayoutRect, FloatRect, AXID, IntPoint, OptionSet<SpeakAs>, std::pair<unsigned, unsigned>, Vector<AccessibilityIsolatedTreeText>, Vector<AXID>, Vector<AccessibilityIsolatedTreeMathMultiscriptPair>, Vector<String>,
-#if PLATFORM(COCOA)
-        WeakPtr<void*> // To hold an ObjectiveC object, e.g., NSView* or id.
-#else
-        PlatformWidget
-#endif
-    >;
+    using AttributeValueVariant = Variant<std::nullptr_t, String, bool, int, unsigned, double, float, uint64_t, Color, URL, LayoutRect, FloatRect, AXID, IntPoint, OptionSet<SpeakAs>, std::pair<unsigned, unsigned>, Vector<AccessibilityIsolatedTreeText>, Vector<AXID>, Vector<AccessibilityIsolatedTreeMathMultiscriptPair>, Vector<String>>;
     void setProperty(AXPropertyName, AttributeValueVariant&&, bool shouldRemove = false);
     void setObjectProperty(AXPropertyName, AXCoreObject*);
     void setObjectVectorProperty(AXPropertyName, const AccessibilityChildrenVector&);
@@ -831,7 +822,7 @@
     bool supportsPath() const override { return boolAttributeValue(AXPropertyName::SupportsPath); }
     TextIteratorBehavior textIteratorBehaviorForTextRange() const override;
     Widget* widget() const override;
-    PlatformWidget platformWidget() const override { return propertyValue<PlatformWidget>(AXPropertyName::PlatformWidget); }
+    PlatformWidget platformWidget() const override;
 #if PLATFORM(COCOA)
     RemoteAXObjectRef remoteParentObject() const override;
 #endif
@@ -910,18 +901,14 @@
     Vector<RefPtr<AXCoreObject>> m_children;
 
     HashMap<AXPropertyName, AttributeValueVariant, WTF::IntHash<AXPropertyName>, WTF::StrongEnumHashTraits<AXPropertyName>> m_attributeMap;
+#if PLATFORM(COCOA)
+    RetainPtr<NSView> m_platformWidget;
+    RetainPtr<RemoteAXObjectRef> m_remoteParent;
+#else
+    PlatformWidget m_platformWidget;
+#endif
 };
 
-template<typename T>
-inline T AXIsolatedObject::propertyValue(AXPropertyName propertyName) const
-{
-    auto value = m_attributeMap.get(propertyName);
-    return WTF::switchOn(value,
-        [] (WeakPtr<T>& typedValue) { return typedValue; },
-        [] (auto&) { return nullptr; }
-    );
-}
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AXIsolatedObject, isAXIsolatedObjectInstance())

Modified: trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm (260447 => 260448)


--- trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm	2020-04-21 19:18:36 UTC (rev 260447)
+++ trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm	2020-04-21 20:21:04 UTC (rev 260448)
@@ -32,12 +32,20 @@
 
 namespace WebCore {
 
+void AXIsolatedObject::initializePlatformProperties(const AXCoreObject& object)
+{
+    if (object.isScrollView()) {
+        m_platformWidget = object.platformWidget();
+        m_remoteParent = object.remoteParentObject();
+    }
+}
+
 RemoteAXObjectRef AXIsolatedObject::remoteParentObject() const
 {
     auto* scrollView = Accessibility::findAncestor<AXCoreObject>(*this, true, [] (const AXCoreObject& object) {
         return object.isScrollView();
     });
-    return is<AXIsolatedObject>(scrollView) ? downcast<AXIsolatedObject>(scrollView)->propertyValue<RemoteAXObjectRef>(AXPropertyName::RemoteParentObject) : nil;
+    return is<AXIsolatedObject>(scrollView) ? downcast<AXIsolatedObject>(scrollView)->m_remoteParent.get() : nil;
 }
 
 void AXIsolatedObject::attachPlatformWrapper(AccessibilityObjectWrapper* wrapper)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to