Diff
Modified: trunk/Source/WebCore/ChangeLog (268584 => 268585)
--- trunk/Source/WebCore/ChangeLog 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/ChangeLog 2020-10-16 13:03:49 UTC (rev 268585)
@@ -1,3 +1,37 @@
+2020-10-16 Andres Gonzalez <[email protected]>
+
+ Refactor [WebAccessibilityObjectWrapper convertRectToSpace] so that the platform-specific code is in their corresponding AX object platform implementations.
+ https://bugs.webkit.org/show_bug.cgi?id=217785
+
+ Reviewed by Chris Fleizach.
+
+ No change in functionality, code refactor and cleanup.
+
+ [WebAccessibilityObjectWrapperBase convertRectToSpace] had two different
+ code paths for Mac and iOS, defeating the purpose of a base class.
+ This re-factoring Simplifies the wrapper code by moving the platform-
+ specific implementations to their corresponding AX object implementations
+ of convertRectToPlatformSpace.
+ Some code cleanup.
+
+ * accessibility/AccessibilityObject.h:
+ * accessibility/AccessibilityObjectInterface.h:
+ * accessibility/ios/AccessibilityObjectIOS.mm:
+ (WebCore::AccessibilityObject::topDocumentFrameView const):
+ (WebCore::AccessibilityObject::convertRectToPlatformSpace const):
+ * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+ (-[WebAccessibilityObjectWrapper _accessibilityWebDocumentView]):
+ * accessibility/isolatedtree/AXIsolatedObject.cpp:
+ (WebCore::AXIsolatedObject::convertRectToPlatformSpace const):
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/mac/AccessibilityObjectMac.mm:
+ (WebCore::AccessibilityObject::topDocumentFrameView const):
+ (WebCore::AccessibilityObject::convertRectToPlatformSpace const):
+ * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+ (-[WebAccessibilityObjectWrapperBase convertRectToSpace:space:]):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper position]):
+
2020-10-16 Philippe Normand <[email protected]>
[GStreamer] Audio worklet support
Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (268584 => 268585)
--- trunk/Source/WebCore/accessibility/AccessibilityObject.h 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h 2020-10-16 13:03:49 UTC (rev 268585)
@@ -440,6 +440,8 @@
PlatformWidget platformWidget() const override { return nullptr; }
#if PLATFORM(COCOA)
RemoteAXObjectRef remoteParentObject() const override;
+ FloatRect convertRectToPlatformSpace(const FloatRect&, AccessibilityConversionSpace) const override;
+ NSView *topDocumentFrameView() const override;
#endif
Widget* widgetForAttachmentView() const override { return nullptr; }
Page* page() const override;
@@ -729,7 +731,7 @@
bool hasApplePDFAnnotationAttribute() const override { return hasAttribute(HTMLNames::x_apple_pdf_annotationAttr); }
#endif
-#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
+#if PLATFORM(MAC)
bool caretBrowsingEnabled() const override;
void setCaretBrowsingEnabled(bool) override;
#endif
Modified: trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h (268584 => 268585)
--- trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2020-10-16 13:03:49 UTC (rev 268585)
@@ -1180,6 +1180,8 @@
virtual PlatformWidget platformWidget() const = 0;
#if PLATFORM(COCOA)
virtual RemoteAXObjectRef remoteParentObject() const = 0;
+ virtual FloatRect convertRectToPlatformSpace(const FloatRect&, AccessibilityConversionSpace) const = 0;
+ virtual NSView *topDocumentFrameView() const = 0;
#endif
virtual Widget* widgetForAttachmentView() const = 0;
virtual Page* page() const = 0;
@@ -1467,7 +1469,7 @@
virtual bool hasApplePDFAnnotationAttribute() const = 0;
#endif
-#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
+#if PLATFORM(MAC)
virtual bool caretBrowsingEnabled() const = 0;
virtual void setCaretBrowsingEnabled(bool) = 0;
#endif
Modified: trunk/Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm (268584 => 268585)
--- trunk/Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm 2020-10-16 13:03:49 UTC (rev 268585)
@@ -30,6 +30,7 @@
#import "AccessibilityRenderObject.h"
#import "EventNames.h"
+#import "FrameView.h"
#import "HTMLInputElement.h"
#import "RenderObject.h"
#import "WAKView.h"
@@ -46,6 +47,55 @@
{
}
+NSView *AccessibilityObject::topDocumentFrameView() const
+{
+ // This method performs the crucial task of connecting to the UIWebDocumentView.
+ // This is needed to correctly calculate the screen position of the AX object.
+ static Class webViewClass = nil;
+ if (!webViewClass)
+ webViewClass = NSClassFromString(@"WebView");
+ if (!webViewClass)
+ return nil;
+
+ auto* frameView = documentFrameView();
+ if (!frameView)
+ return nil;
+
+ // If this is the top level frame, the UIWebDocumentView should be returned.
+ NSView *parentView = frameView->documentView();
+ while (parentView && ![parentView isKindOfClass:webViewClass])
+ parentView = [parentView superview];
+
+ // The parentView should have an accessibilityContainer, if the UIKit accessibility bundle was loaded.
+ // The exception is DRT, which tests accessibility without the entire system turning accessibility on. Hence,
+ // this check should be valid for everything except DRT.
+ ASSERT([parentView accessibilityContainer] || IOSApplication::isDumpRenderTree());
+
+ return parentView;
+}
+
+FloatRect AccessibilityObject::convertRectToPlatformSpace(const FloatRect& rect, AccessibilityConversionSpace space) const
+{
+ auto* frameView = documentFrameView();
+ WAKView *documentView = frameView ? frameView->documentView() : nullptr;
+ if (documentView) {
+ CGPoint point = CGPointMake(rect.x(), rect.y());
+ CGSize size = CGSizeMake(rect.size().width(), rect.size().height());
+ CGRect cgRect = CGRectMake(point.x, point.y, size.width, size.height);
+
+ cgRect = [documentView convertRect:cgRect toView:nil];
+
+ // we need the web document view to give us our final screen coordinates
+ // because that can take account of the scroller
+ NSView *webDocument = topDocumentFrameView();
+ if (webDocument)
+ cgRect = [webDocument convertRect:cgRect toView:nil];
+ return cgRect;
+ }
+
+ return convertFrameToSpace(rect, space);
+}
+
// On iOS, we don't have to return the value in the title. We can return the actual title, given the API.
bool AccessibilityObject::fileUploadButtonReturnsValueInTitle() const
{
Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (268584 => 268585)
--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm 2020-10-16 13:03:49 UTC (rev 268585)
@@ -37,9 +37,7 @@
#import "Chrome.h"
#import "ChromeClient.h"
#import "FontCascade.h"
-#import "Frame.h"
#import "FrameSelection.h"
-#import "FrameView.h"
#import "HitTestResult.h"
#import "HTMLFrameOwnerElement.h"
#import "HTMLInputElement.h"
@@ -1741,31 +1739,7 @@
if (![self _prepareAccessibilityCall])
return nil;
- // This method performs the crucial task of connecting to the UIWebDocumentView.
- // This is needed to correctly calculate the screen position of the AX object.
- static Class webViewClass = nil;
- if (!webViewClass)
- webViewClass = NSClassFromString(@"WebView");
-
- if (!webViewClass)
- return nil;
-
- FrameView* frameView = self.axBackingObject->documentFrameView();
-
- if (!frameView)
- return nil;
-
- // If this is the top level frame, the UIWebDocumentView should be returned.
- id parentView = frameView->documentView();
- while (parentView && ![parentView isKindOfClass:webViewClass])
- parentView = [parentView superview];
-
- // The parentView should have an accessibilityContainer, if the UIKit accessibility bundle was loaded.
- // The exception is DRT, which tests accessibility without the entire system turning accessibility on. Hence,
- // this check should be valid for everything except DRT.
- ASSERT([parentView accessibilityContainer] || IOSApplication::isDumpRenderTree());
-
- return [parentView accessibilityContainer];
+ return [(id)self.axBackingObject->topDocumentFrameView() accessibilityContainer];
}
- (NSArray *)_accessibilityNextElementsWithCount:(UInt32)count
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (268584 => 268585)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2020-10-16 13:03:49 UTC (rev 268585)
@@ -965,6 +965,15 @@
});
}
+FloatRect AXIsolatedObject::convertRectToPlatformSpace(const FloatRect& rect, AccessibilityConversionSpace space) const
+{
+ return Accessibility::retrieveValueFromMainThread<FloatRect>([&rect, &space, this] () -> FloatRect {
+ if (auto* axObject = associatedAXObject())
+ return axObject->convertRectToPlatformSpace(rect, space);
+ return { };
+ });
+}
+
bool AXIsolatedObject::replaceTextInRange(const String& replacementText, const PlainTextRange& textRange)
{
return Accessibility::retrieveValueFromMainThread<bool>([&replacementText, &textRange, this] () -> bool {
@@ -1139,6 +1148,7 @@
Optional<SimpleRange> AXIsolatedObject::elementRange() const
{
+ ASSERT(isMainThread());
auto* axObject = associatedAXObject();
return axObject ? axObject->elementRange() : WTF::nullopt;
}
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (268584 => 268585)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2020-10-16 13:03:49 UTC (rev 268585)
@@ -334,7 +334,7 @@
String descriptionAttributeValue() const override { return stringAttributeValue(AXPropertyName::Description); }
String helpTextAttributeValue() const override { return stringAttributeValue(AXPropertyName::HelpText); }
String titleAttributeValue() const override { return stringAttributeValue(AXPropertyName::TitleAttributeValue); }
-#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
+#if PLATFORM(MAC)
bool caretBrowsingEnabled() const override { return boolAttributeValue(AXPropertyName::CaretBrowsingEnabled); }
#endif
AXCoreObject* focusableAncestor() override { return objectAttributeValue(AXPropertyName::FocusableAncestor); }
@@ -443,7 +443,7 @@
void setSelectedText(const String&) override;
void setSelectedTextRange(const PlainTextRange&) override;
bool setValue(const String&) override;
-#if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY)
+#if PLATFORM(MAC)
void setCaretBrowsingEnabled(bool) override;
#endif
void setPreventKeyboardDOMEventDispatch(bool) override;
@@ -579,6 +579,8 @@
HashMap<String, AXEditingStyleValueVariant> resolvedEditingStyles() const override;
#if PLATFORM(COCOA)
RemoteAXObjectRef remoteParentObject() const override;
+ FloatRect convertRectToPlatformSpace(const FloatRect&, AccessibilityConversionSpace) const override;
+ NSView *topDocumentFrameView() const override { return nil; } // FIXME: implement, currently only used on iOS.
#endif
Widget* widgetForAttachmentView() const override;
Page* page() const override;
Modified: trunk/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm (268584 => 268585)
--- trunk/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm 2020-10-16 13:03:49 UTC (rev 268585)
@@ -28,6 +28,7 @@
#import "AccessibilityLabel.h"
#import "AccessibilityList.h"
#import "ElementAncestorIterator.h"
+#import "FrameView.h"
#import "HTMLFieldSetElement.h"
#import "HTMLInputElement.h"
#import "LocalizedStrings.h"
@@ -69,6 +70,32 @@
ALLOW_DEPRECATED_DECLARATIONS_END
}
+NSView *AccessibilityObject::topDocumentFrameView() const
+{
+ // FIXME: implement, currently only used on iOS.
+ return nil;
+}
+
+FloatRect AccessibilityObject::convertRectToPlatformSpace(const FloatRect& rect, AccessibilityConversionSpace space) const
+{
+ // WebKit1 code path... platformWidget() exists.
+ auto* frameView = documentFrameView();
+ if (frameView && frameView->platformWidget()) {
+ CGPoint point = CGPointMake(rect.x(), rect.y());
+ CGSize size = CGSizeMake(rect.size().width(), rect.size().height());
+ CGRect cgRect = CGRectMake(point.x, point.y, size.width, size.height);
+
+ NSRect nsRect = NSRectFromCGRect(cgRect);
+ NSView *view = frameView->documentView();
+ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+ nsRect = [[view window] convertRectToScreen:[view convertRect:nsRect toView:nil]];
+ ALLOW_DEPRECATED_DECLARATIONS_END
+ return NSRectToCGRect(nsRect);
+ }
+
+ return convertFrameToSpace(rect, space);
+}
+
// On iOS, we don't have to return the value in the title. We can return the actual title, given the API.
bool AccessibilityObject::fileUploadButtonReturnsValueInTitle() const
{
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm (268584 => 268585)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm 2020-10-16 13:03:49 UTC (rev 268585)
@@ -50,8 +50,6 @@
#import "Editing.h"
#import "Font.h"
#import "FontCascade.h"
-#import "Frame.h"
-#import "FrameLoaderClient.h"
#import "FrameSelection.h"
#import "HTMLNames.h"
#import "LayoutRect.h"
@@ -63,15 +61,11 @@
#import "ScrollView.h"
#import "TextCheckerClient.h"
#import "VisibleUnits.h"
-#import "WebCoreFrameView.h"
#import <wtf/cocoa/VectorCocoa.h>
#if PLATFORM(MAC)
#import "WebAccessibilityObjectWrapperMac.h"
-#import <pal/spi/mac/HIServicesSPI.h>
#else
-#import "WAKView.h"
-#import "WAKWindow.h"
#import "WebAccessibilityObjectWrapperIOS.h"
#endif
@@ -463,40 +457,11 @@
- (CGRect)convertRectToSpace:(const WebCore::FloatRect&)rect space:(AccessibilityConversionSpace)space
{
- if (!self.axBackingObject)
+ auto* backingObject = self.axBackingObject;
+ if (!backingObject)
return CGRectZero;
-
- CGSize size = CGSizeMake(rect.size().width(), rect.size().height());
- CGPoint point = CGPointMake(rect.x(), rect.y());
-
- CGRect cgRect = CGRectMake(point.x, point.y, size.width, size.height);
- // WebKit1 code path... platformWidget() exists.
- FrameView* frameView = self.axBackingObject->documentFrameView();
-#if PLATFORM(IOS_FAMILY)
- WAKView* documentView = frameView ? frameView->documentView() : nullptr;
- if (documentView) {
- cgRect = [documentView convertRect:cgRect toView:nil];
-
- // we need the web document view to give us our final screen coordinates
- // because that can take account of the scroller
- id webDocument = [self _accessibilityWebDocumentView];
- if (webDocument)
- cgRect = [webDocument convertRect:cgRect toView:nil];
- return cgRect;
- }
-#else
- if (frameView && frameView->platformWidget()) {
- NSRect nsRect = NSRectFromCGRect(cgRect);
- NSView* view = frameView->documentView();
- ALLOW_DEPRECATED_DECLARATIONS_BEGIN
- nsRect = [[view window] convertRectToScreen:[view convertRect:nsRect toView:nil]];
- ALLOW_DEPRECATED_DECLARATIONS_END
- return NSRectToCGRect(nsRect);
- }
-#endif
- else
- return static_cast<CGRect>(self.axBackingObject->convertFrameToSpace(rect, space));
+ return backingObject->convertRectToPlatformSpace(rect, space);
}
- (NSString *)ariaLandmarkRoleDescription
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (268584 => 268585)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-10-16 12:53:35 UTC (rev 268584)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-10-16 13:03:49 UTC (rev 268585)
@@ -1975,11 +1975,12 @@
auto rect = snappedIntRect(backingObject->elementRect());
// The Cocoa accessibility API wants the lower-left corner.
- auto floatPoint = FloatPoint(rect.x(), rect.maxY());
+ FloatPoint floatPoint(rect.x(), rect.maxY());
- auto floatRect = FloatRect(floatPoint, FloatSize());
- CGPoint cgPoint = [self convertRectToSpace:floatRect space:AccessibilityConversionSpace::Screen].origin;
- return [NSValue valueWithPoint:NSPointFromCGPoint(cgPoint)];
+ // FIXME: add a function to convert a point, no need to convert a rect when you only need a point.
+ FloatRect floatRect(floatPoint, FloatSize());
+ CGRect cgRect(backingObject->convertRectToPlatformSpace(floatRect, AccessibilityConversionSpace::Screen));
+ return @(cgRect.origin);
}
- (NSString*)role