Changeset 252012 in webkit


Ignore:
Timestamp:
Nov 4, 2019 1:49:37 PM (4 years ago)
Author:
Wenson Hsieh
Message:

Consolidate forEachViewInHierarchy and findAllViewsInHierarchyOfType into common helper file
https://bugs.webkit.org/show_bug.cgi?id=203777

Reviewed by Tim Horton.

  • TestRunnerShared/cocoa/PlatformViewHelpers.h: Added.
  • TestRunnerShared/cocoa/PlatformViewHelpers.mm: Added.

Add a new Cocoa helper file, PlatformViewHelpers, to make it easier to traverse platform view hierarchies
(NSView and UIView) for testing purposes. This is minor refactoring, before I try to create some new testing
primitives to make webkit.org/b/203116 testable.

(forEachViewInHierarchy):

  • WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
  • WebKitTestRunner/ios/UIScriptControllerIOS.h:
  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptControllerIOS::findEditableImageCanvas const):
(WTR::forEachViewInHierarchy): Deleted.
(WTR::findEditableImageCanvas): Deleted.

Location:
trunk/Tools
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r251996 r252012  
     12019-11-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Consolidate forEachViewInHierarchy and findAllViewsInHierarchyOfType into common helper file
     4        https://bugs.webkit.org/show_bug.cgi?id=203777
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestRunnerShared/cocoa/PlatformViewHelpers.h: Added.
     9        * TestRunnerShared/cocoa/PlatformViewHelpers.mm: Added.
     10
     11        Add a new Cocoa helper file, PlatformViewHelpers, to make it easier to traverse platform view hierarchies
     12        (NSView and UIView) for testing purposes. This is minor refactoring, before I try to create some new testing
     13        primitives to make webkit.org/b/203116 testable.
     14
     15        (forEachViewInHierarchy):
     16        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
     17        * WebKitTestRunner/ios/UIScriptControllerIOS.h:
     18        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     19        (WTR::UIScriptControllerIOS::findEditableImageCanvas const):
     20        (WTR::forEachViewInHierarchy): Deleted.
     21        (WTR::findEditableImageCanvas): Deleted.
     22
    1232019-11-04  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj

    r251279 r252012  
    8686                2DFA98481D7F70CF00AFF2C9 /* SharedEventStreamsMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DFA98461D7F70CF00AFF2C9 /* SharedEventStreamsMac.h */; };
    8787                2DFA98491D7F70CF00AFF2C9 /* SharedEventStreamsMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DFA98471D7F70CF00AFF2C9 /* SharedEventStreamsMac.mm */; };
     88                2E2A765D2370C8D1008F9FFE /* PlatformViewHelpers.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E2A765C2370C8A0008F9FFE /* PlatformViewHelpers.mm */; };
    8889                2E34C90018B68808000067BB /* WebKitTestRunnerInjectedBundle.bundle in Copy Plug-Ins */ = {isa = PBXBuildFile; fileRef = BC25186211D15D54002EBC01 /* WebKitTestRunnerInjectedBundle.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
    8990                2E63ED8A1891AD7E002A7AFC /* AccessibilityControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED751891ACE9002A7AFC /* AccessibilityControllerIOS.mm */; };
     
    286287                2DFA98461D7F70CF00AFF2C9 /* SharedEventStreamsMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharedEventStreamsMac.h; path = mac/SharedEventStreamsMac.h; sourceTree = "<group>"; };
    287288                2DFA98471D7F70CF00AFF2C9 /* SharedEventStreamsMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SharedEventStreamsMac.mm; path = mac/SharedEventStreamsMac.mm; sourceTree = "<group>"; };
     289                2E2A765B2370C8A0008F9FFE /* PlatformViewHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformViewHelpers.h; path = ../TestRunnerShared/cocoa/PlatformViewHelpers.h; sourceTree = "<group>"; };
     290                2E2A765C2370C8A0008F9FFE /* PlatformViewHelpers.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PlatformViewHelpers.mm; path = ../TestRunnerShared/cocoa/PlatformViewHelpers.mm; sourceTree = "<group>"; };
    288291                2E63ED751891ACE9002A7AFC /* AccessibilityControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityControllerIOS.mm; sourceTree = "<group>"; };
    289292                2E63ED761891ACE9002A7AFC /* AccessibilityNotificationHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityNotificationHandler.h; sourceTree = "<group>"; };
     
    891894                                F4C3578B20E8444000FA0748 /* LayoutTestSpellChecker.h */,
    892895                                F4C3578A20E8444000FA0748 /* LayoutTestSpellChecker.mm */,
     896                                2E2A765B2370C8A0008F9FFE /* PlatformViewHelpers.h */,
     897                                2E2A765C2370C8A0008F9FFE /* PlatformViewHelpers.mm */,
    893898                        );
    894899                        name = cocoa;
     
    11821187                                A185103C1B9AE0FE00744AEB /* Options.cpp in Sources */,
    11831188                                A18510401B9AE13100744AEB /* PixelDumpSupport.cpp in Sources */,
     1189                                2E2A765D2370C8D1008F9FFE /* PlatformViewHelpers.mm in Sources */,
    11841190                                2DFA98491D7F70CF00AFF2C9 /* SharedEventStreamsMac.mm in Sources */,
    11851191                                A18510411B9AE13800744AEB /* TestController.cpp in Sources */,
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h

    r251522 r252012  
    3030
    3131#if PLATFORM(IOS_FAMILY)
     32
     33#if HAVE(PENCILKIT)
     34@class PKCanvasView;
     35#endif
    3236
    3337namespace WebCore {
     
    154158    WebCore::FloatRect rectForMenuAction(CFStringRef) const;
    155159    void singleTapAtPointWithModifiers(WebCore::FloatPoint location, Vector<String>&& modifierFlags, BlockPtr<void()>&&);
     160#if HAVE(PENCILKIT)
     161    PKCanvasView *findEditableImageCanvas() const;
     162#endif
    156163};
    157164
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r251522 r252012  
    3131#import "HIDEventGenerator.h"
    3232#import "PencilKitTestSPI.h"
     33#import "PlatformViewHelpers.h"
    3334#import "PlatformWebView.h"
    3435#import "StringFunctions.h"
     
    106107}
    107108
    108 static BOOL forEachViewInHierarchy(UIView *view, void(^mapFunction)(UIView *subview, BOOL *stop))
    109 {
    110     BOOL stop = NO;
    111     mapFunction(view, &stop);
    112     if (stop)
    113         return YES;
    114 
    115     for (UIView *subview in view.subviews) {
    116         stop = forEachViewInHierarchy(subview, mapFunction);
    117         if (stop)
    118             break;
    119     }
    120     return stop;
    121 }
    122 
    123 static NSArray<UIView *> *findAllViewsInHierarchyOfType(UIView *view, Class viewClass)
    124 {
    125     __block RetainPtr<NSMutableArray> views = adoptNS([[NSMutableArray alloc] init]);
    126     forEachViewInHierarchy(view, ^(UIView *subview, BOOL *stop) {
    127         if ([subview isKindOfClass:viewClass])
    128             [views addObject:subview];
    129     });
    130     return views.autorelease();
    131 }
    132 
    133109Ref<UIScriptController> UIScriptController::create(UIScriptContext& context)
    134110{
     
    10821058
    10831059#if HAVE(PENCILKIT)
    1084 static PKCanvasView *findEditableImageCanvas()
     1060
     1061PKCanvasView *UIScriptControllerIOS::findEditableImageCanvas() const
    10851062{
    10861063    Class pkCanvasViewClass = NSClassFromString(@"PKCanvasView");
     
    10951072    return canvasView;
    10961073}
    1097 #endif
     1074
     1075#endif // HAVE(PENCILKIT)
    10981076
    10991077void UIScriptControllerIOS::drawSquareInEditableImage()
Note: See TracChangeset for help on using the changeset viewer.