diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 000000000..14f8beafb --- /dev/null +++ b/Package.swift @@ -0,0 +1,38 @@ +// swift-tools-version: 6.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let headersSearchPath: [CSetting] = [ + .headerSearchPath("."), + .headerSearchPath("Base"), + .headerSearchPath("Debug"), + .headerSearchPath("Details"), + .headerSearchPath("Details/Transactions"), + .headerSearchPath("Layout"), + .headerSearchPath("Private"), + .headerSearchPath("Private/Layout"), + .headerSearchPath("TextExperiment/Component"), + .headerSearchPath("TextExperiment/String"), + .headerSearchPath("TextExperiment/Utility"), + .headerSearchPath("TextKit"), + .headerSearchPath("tvOS"), +] + +let package = Package( + name: "Texture", + products: [ + .library( + name: "Texture", + targets: ["Texture"] + ), + ], + targets: [ + .target( + name: "Texture", + path: "Source", + publicHeadersPath: ".", + cSettings: headersSearchPath + ) + ] +) diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 000000000..b2492c546 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,20 @@ +PODS: + - iOSSnapshotTestCase/Core (8.0.0) + - OCMock (3.9.4) + +DEPENDENCIES: + - iOSSnapshotTestCase/Core (~> 8.0) + - OCMock (~> 3.9) + +SPEC REPOS: + trunk: + - iOSSnapshotTestCase + - OCMock + +SPEC CHECKSUMS: + iOSSnapshotTestCase: a670511f9ee3829c2b9c23e6e68f315fd7b6790f + OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74 + +PODFILE CHECKSUM: 3b874fa5a23281754f91a64090a82ef01ee76cc7 + +COCOAPODS: 1.15.2 diff --git a/Source/Details/_ASDisplayViewAccessiblity.mm b/Source/Details/_ASDisplayViewAccessiblity.mm index 23b1f89db..d100982ed 100644 --- a/Source/Details/_ASDisplayViewAccessiblity.mm +++ b/Source/Details/_ASDisplayViewAccessiblity.mm @@ -220,6 +220,11 @@ static BOOL nodeIsHiddenFromAcessibility(ASDisplayNode *node) { return node.isHidden || node.alpha == 0.0 || node.accessibilityElementsHidden; } +/// returns YES if this view should be considered "hidden" from the screen reader. +static BOOL viewIsHiddenFromAcessibility(UIView *view) { + return view.isHidden || view.alpha == 0.0 || view.accessibilityElementsHidden; +} + /// Collect all accessibliity elements for a given view and view node static void CollectAccessibilityElements(ASDisplayNode *node, NSMutableArray *elements) { @@ -302,6 +307,36 @@ static void CollectAccessibilityElements(ASDisplayNode *node, NSMutableArray *el [elements addObject:subnode.view]; } } + + if (modalSubnode) { + return; + } + + NSArray *subviews = view.subviews; + for (UIView *subview in subviews) { + // If a view is is already added then skip it + if ([elements containsObject:subview]) { + continue; + } + + // If a view is hidden or has an alpha of 0.0 we should not include it + if (viewIsHiddenFromAcessibility(subview)) { + continue; + } + + // If a subview is outside of the view's window, exclude it UNLESS it is a subview of an UIScrollView. + // In this case UIKit will return the element even if it is outside of the window or the scrollView's visible rect (contentOffset + contentSize) + CGRect viewInWindowCoords = [node convertRect:subview.frame toNode:nil]; + if (!CGRectIntersectsRect(view.window.frame, viewInWindowCoords) && !recusivelyCheckSuperviewsForScrollView(view)) { + continue; + } + + if (subview.isAccessibilityElement) { + [elements addObject:subview]; + } else if (subview.accessibilityElementCount > 0) { + [elements addObject:subview]; + } + } } @implementation _ASDisplayView (UIAccessibilityContainer)