Changeset 259512 in webkit


Ignore:
Timestamp:
Apr 3, 2020 1:55:39 PM (4 years ago)
Author:
timothy_horton@apple.com
Message:

Add a visual debug indicator for locating and identifying all kinds of WebViews
https://bugs.webkit.org/show_bug.cgi?id=209982
<rdar://problem/60339870>

Reviewed by Simon Fraser.

Source/WebCore:

Add a debug overlay that can be enabled with a single switch for all
*WebView variants, which indicates the type of *WebView in an unmissable,
gaudy fashion.

This is intended to address some shortcomings of existing mechanisms
that people use to answer the "what kind of web view is X app using?"
question. Specifically:

  • it will appear even if the Web Content process does not launch or crashes
  • it will appear even if a custom content view is being used (e.g. PDF)
  • it will appear even if compositing is not enabled (e.g. in a legacy WebView on macOS)
  • it explicitly states in written text the class name of the web view, with no need for interpreting colors
  • it covers the entire web view, so cannot be accidentally obscured

No new tests, just debugging UI.

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • testing/cocoa/WebViewVisualIdentificationOverlay.h: Added.
  • testing/cocoa/WebViewVisualIdentificationOverlay.mm: Added.

(+[WebViewVisualIdentificationOverlay shouldIdentifyWebViews]):
Use a single default across all kinds of WebViews, instead of using
WebPreferences and friends, in order to make it extremely easy to turn on,
and because it's intended to be set globally, and is not useful on a
per-view basis.

(+[WebViewVisualIdentificationOverlay installForWebViewIfNeeded:kind:deprecated:]):
(-[WebViewVisualIdentificationOverlay initWithWebView:kind:deprecated:]):
(-[WebViewVisualIdentificationOverlay dealloc]):
(-[WebViewVisualIdentificationOverlay observeValueForKeyPath:ofObject:change:context:]):
(-[WebViewVisualIdentificationOverlay drawLayer:inContext:]):
Draw a wash and the class name over the entire face of the web view.
The wash is blue for WKWebView and red for all of the deprecated web views (WKView, WebView, UIWebView).

Source/WebKit:

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):

  • UIProcess/API/mac/WKView.mm:

(-[WKView initWithFrame:processPool:configuration:]):
Adopt in WKWebView and WKView.

Source/WebKitLegacy/mac:

  • WebView/WebView.mm:

(-[WebView _commonInitializationWithFrameName:groupName:]):
Adopt for WebView on macOS (UIWebView will install it itself on iOS).

  • WebView/WebViewPrivate.h:

Expose _installVisualIdentificationOverlayForViewIfNeeded:kind: for UIWebView's use.
It is slightly unfortunate to expose SPI that uses UIView from a framework
underneath UIKit, but there is no other single place where this code can live
and not be a minor layering problem. Since it's debug UI, it seems passable.

Location:
trunk/Source
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259483 r259512  
     12020-04-03  Tim Horton  <timothy_horton@apple.com>
     2
     3        Add a visual debug indicator for locating and identifying all kinds of WebViews
     4        https://bugs.webkit.org/show_bug.cgi?id=209982
     5        <rdar://problem/60339870>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add a debug overlay that can be enabled with a single switch for all
     10        *WebView variants, which indicates the type of *WebView in an unmissable,
     11        gaudy fashion.
     12
     13        This is intended to address some shortcomings of existing mechanisms
     14        that people use to answer the "what kind of web view is X app using?"
     15        question. Specifically:
     16
     17        - it will appear even if the Web Content process does not launch or crashes
     18        - it will appear even if a custom content view is being used (e.g. PDF)
     19        - it will appear even if compositing is not enabled (e.g. in a legacy WebView on macOS)
     20        - it explicitly states in written text the class name of the web view, with no need for interpreting colors
     21        - it covers the entire web view, so cannot be accidentally obscured
     22
     23        No new tests, just debugging UI.
     24
     25        * SourcesCocoa.txt:
     26        * WebCore.xcodeproj/project.pbxproj:
     27        * testing/cocoa/WebViewVisualIdentificationOverlay.h: Added.
     28        * testing/cocoa/WebViewVisualIdentificationOverlay.mm: Added.
     29        (+[WebViewVisualIdentificationOverlay shouldIdentifyWebViews]):
     30        Use a single default across all kinds of WebViews, instead of using
     31        WebPreferences and friends, in order to make it extremely easy to turn on,
     32        and because it's intended to be set globally, and is not useful on a
     33        per-view basis.
     34
     35        (+[WebViewVisualIdentificationOverlay installForWebViewIfNeeded:kind:deprecated:]):
     36        (-[WebViewVisualIdentificationOverlay initWithWebView:kind:deprecated:]):
     37        (-[WebViewVisualIdentificationOverlay dealloc]):
     38        (-[WebViewVisualIdentificationOverlay observeValueForKeyPath:ofObject:change:context:]):
     39        (-[WebViewVisualIdentificationOverlay drawLayer:inContext:]):
     40        Draw a wash and the class name over the entire face of the web view.
     41        The wash is blue for WKWebView and red for all of the deprecated web views (WKView, WebView, UIWebView).
     42
    1432020-04-03  David Kilzer  <ddkilzer@apple.com>
    244
  • trunk/Source/WebCore/SourcesCocoa.txt

    r258966 r259512  
    579579platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp
    580580
     581testing/cocoa/WebViewVisualIdentificationOverlay.mm
     582
    581583// Derived Sources
    582584
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r259435 r259512  
    753753                2D70BA1318074DDF0001908A /* PlatformCALayerCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D70BA1218074DDF0001908A /* PlatformCALayerCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
    754754                2D76BB821945632400CFD29A /* RunLoopObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D76BB801945632400CFD29A /* RunLoopObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
     755                2D7DA0F22435EB1900F048D1 /* WebViewVisualIdentificationOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7DA0EF2435EB1700F048D1 /* WebViewVisualIdentificationOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; };
    755756                2D7ED0AB1BAE99170043B3E5 /* TimerEventBasedMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7ED0A91BAE99170043B3E5 /* TimerEventBasedMock.h */; };
    756757                2D81E1CF21A78CC200A32CF4 /* InsertEditableImageCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D81E1CD21A78CC200A32CF4 /* InsertEditableImageCommand.h */; };
     
    68606861                2D76BB801945632400CFD29A /* RunLoopObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoopObserver.h; sourceTree = "<group>"; };
    68616862                2D76BB8319456F8100CFD29A /* RunLoopObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopObserver.cpp; sourceTree = "<group>"; };
     6863                2D7DA0EF2435EB1700F048D1 /* WebViewVisualIdentificationOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewVisualIdentificationOverlay.h; sourceTree = "<group>"; };
     6864                2D7DA0F12435EB1800F048D1 /* WebViewVisualIdentificationOverlay.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewVisualIdentificationOverlay.mm; sourceTree = "<group>"; };
    68626865                2D7ED0A91BAE99170043B3E5 /* TimerEventBasedMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimerEventBasedMock.h; sourceTree = "<group>"; };
    68636866                2D81E1CB21A78CC100A32CF4 /* InsertEditableImageCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InsertEditableImageCommand.cpp; sourceTree = "<group>"; };
     
    2295622959                                A1763F3D1E205234001D58DE /* WebArchiveDumpSupport.h */,
    2295722960                                A1763F3C1E205234001D58DE /* WebArchiveDumpSupport.mm */,
     22961                                2D7DA0EF2435EB1700F048D1 /* WebViewVisualIdentificationOverlay.h */,
     22962                                2D7DA0F12435EB1800F048D1 /* WebViewVisualIdentificationOverlay.mm */,
    2295822963                        );
    2295922964                        path = cocoa;
     
    3343633441                                0F580FA31496939100FB5BD8 /* WebTiledBackingLayer.h in Headers */,
    3343733442                                3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */,
     33443                                2D7DA0F22435EB1900F048D1 /* WebViewVisualIdentificationOverlay.h in Headers */,
    3343833444                                F12171F616A8CF0B000053CA /* WebVTTElement.h in Headers */,
    3343933445                                5D21A80313ECE5DF00BB7064 /* WebVTTParser.h in Headers */,
  • trunk/Source/WebKit/ChangeLog

    r259507 r259512  
     12020-04-03  Tim Horton  <timothy_horton@apple.com>
     2
     3        Add a visual debug indicator for locating and identifying all kinds of WebViews
     4        https://bugs.webkit.org/show_bug.cgi?id=209982
     5        <rdar://problem/60339870>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * UIProcess/API/Cocoa/WKWebView.mm:
     10        (-[WKWebView _initializeWithConfiguration:]):
     11        * UIProcess/API/mac/WKView.mm:
     12        (-[WKView initWithFrame:processPool:configuration:]):
     13        Adopt in WKWebView and WKView.
     14
    1152020-04-03  Kate Cheney  <katherine_cheney@apple.com>
    216
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r259507 r259512  
    128128#import <WebCore/TextManipulationController.h>
    129129#import <WebCore/ViewportArguments.h>
     130#import <WebCore/WebViewVisualIdentificationOverlay.h>
    130131#import <WebCore/WritingMode.h>
    131132#import <wtf/BlockPtr.h>
     
    404405
    405406    pageToViewMap().add(_page.get(), self);
     407
     408    [WebViewVisualIdentificationOverlay installForWebViewIfNeeded:self kind:@"WKWebView" deprecated:NO];
    406409
    407410#if PLATFORM(IOS_FAMILY)
  • trunk/Source/WebKit/UIProcess/API/mac/WKView.mm

    r259399 r259512  
    4444#import "WebViewImpl.h"
    4545#import "_WKLinkIconParametersInternal.h"
     46#import <WebCore/WebViewVisualIdentificationOverlay.h>
    4647#import <WebKit/WKDragDestinationAction.h>
    4748#import <pal/spi/cocoa/AVKitSPI.h>
     
    964965
    965966    [self maybeInstallIconLoadingClient];
     967    [WebViewVisualIdentificationOverlay installForWebViewIfNeeded:self kind:@"WKView" deprecated:YES];
    966968
    967969    return self;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r259466 r259512  
     12020-04-03  Tim Horton  <timothy_horton@apple.com>
     2
     3        Add a visual debug indicator for locating and identifying all kinds of WebViews
     4        https://bugs.webkit.org/show_bug.cgi?id=209982
     5        <rdar://problem/60339870>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * WebView/WebView.mm:
     10        (-[WebView _commonInitializationWithFrameName:groupName:]):
     11        Adopt for WebView on macOS (UIWebView will install it itself on iOS).
     12
     13        * WebView/WebViewPrivate.h:
     14        Expose _installVisualIdentificationOverlayForViewIfNeeded:kind: for UIWebView's use.
     15        It is slightly unfortunate to expose SPI that uses UIView from a framework
     16        underneath UIKit, but there is no other single place where this code can live
     17        and not be a minor layering problem. Since it's debug UI, it seems passable.
     18
    1192020-04-03  David Kilzer  <ddkilzer@apple.com>
    220
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r259184 r259512  
    222222#import <WebCore/WebCoreObjCExtras.h>
    223223#import <WebCore/WebCoreView.h>
     224#import <WebCore/WebViewVisualIdentificationOverlay.h>
    224225#import <WebCore/Widget.h>
    225226#import <WebKitLegacy/DOM.h>
     
    16011602
    16021603    _private->page->settings().setContentDispositionAttachmentSandboxEnabled(true);
     1604
     1605#if PLATFORM(MAC)
     1606    [WebViewVisualIdentificationOverlay installForWebViewIfNeeded:self kind:@"WebView" deprecated:YES];
     1607#endif
    16031608}
    16041609
     
    1022110226}
    1022210227
     10228- (void)_installVisualIdentificationOverlayForViewIfNeeded:(id)view kind:(NSString *)kind
     10229{
     10230    [WebViewVisualIdentificationOverlay installForWebViewIfNeeded:static_cast<UIView *>(view) kind:kind deprecated:YES];
     10231}
     10232
    1022310233@end
    1022410234
  • trunk/Source/WebKitLegacy/mac/WebView/WebViewPrivate.h

    r257143 r259512  
    10891089- (NSArray<DOMElement *> *)_editableElementsInRect:(CGRect)rect;
    10901090- (void)revealCurrentSelection;
     1091
     1092// View must be a UIView.
     1093- (void)_installVisualIdentificationOverlayForViewIfNeeded:(id)view kind:(NSString *)kind;
    10911094@end
    10921095
Note: See TracChangeset for help on using the changeset viewer.