[iOS] Inspector View Indication Support
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 21:52:20 +0000 (21:52 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 21:52:20 +0000 (21:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130709

Reviewed by Simon Fraser.

Source/WebCore:

* inspector/InspectorClient.h:
(WebCore::InspectorClient::showInspectorIndication):
(WebCore::InspectorClient::hideInspectorIndication):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::setIndicating):
Rename indicate/hideIndication to show/hide names.

Source/WebKit/ios:

* WebCoreSupport/WebInspectorClientIOS.mm:
(WebInspectorClient::showInspectorIndication):
(WebInspectorClient::hideInspectorIndication):
Renamed methods.

Source/WebKit/mac:

* WebCoreSupport/WebInspectorClient.h:
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorClient::didSetSearchingForNode): Deleted.
(WebInspectorClient::releaseFrontend): Deleted.
* WebView/WebView.mm:
(-[WebView setShowingInspectorIndication:]):
* WebView/WebViewPrivate.h:
Renamed methods.

Source/WebKit2:

* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKInspectorIndicationView initWithFrame:]):
(-[WKContentView isShowingInspectorIndication]):
(-[WKContentView setShowingInspectorIndication:]):
(-[WKContentView _didCommitLayerTree:WebKit::]):
When indicating include a simple tinted UIView over the content.

* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _showInspectorIndication]):
(-[WKWebView _hideInspectorIndication]):
Have the content view show or hide an indication.

* UIProcess/PageClient.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::showInspectorIndication):
(WebKit::PageClientImpl::hideInspectorIndication):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::showInspectorIndication):
(WebKit::WebPageProxy::hideInspectorIndication):
Pass WebProcess indication message up to the WKWebView.

* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::indicate):
(WebKit::WebInspectorClient::hideIndication):
* WebProcess/WebCoreSupport/WebInspectorClient.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::indicate):
(WebKit::WebPage::hideIndication):
Pass WebCore / remote inspector indication message up to UIProcess.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166257 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorClient.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/WebCoreSupport/WebInspectorClientIOS.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewPrivate.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WKContentView.h
Source/WebKit2/UIProcess/ios/WKContentView.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index d131c03..e7a53fe 100644 (file)
@@ -1,3 +1,17 @@
+2014-03-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [iOS] Inspector View Indication Support
+        https://bugs.webkit.org/show_bug.cgi?id=130709
+
+        Reviewed by Simon Fraser.
+
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::showInspectorIndication):
+        (WebCore::InspectorClient::hideInspectorIndication):
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::setIndicating):
+        Rename indicate/hideIndication to show/hide names.
+
 2014-03-25  Brent Fulgham  <bfulgham@apple.com>
 
         Unreviewed build fix. Typo on checkin.
index c39c0c0..636f096 100644 (file)
@@ -56,8 +56,8 @@ public:
     virtual void highlight() = 0;
     virtual void hideHighlight() = 0;
 
-    virtual void indicate() { }
-    virtual void hideIndication() { }
+    virtual void showInspectorIndication() { }
+    virtual void hideInspectorIndication() { }
 
     virtual bool canClearBrowserCache() { return false; }
     virtual void clearBrowserCache() { }
index eeb7d2f..595ca4c 100644 (file)
@@ -374,9 +374,9 @@ void InspectorController::setIndicating(bool indicating)
     m_overlay->setIndicating(indicating);
 #else
     if (indicating)
-        m_inspectorClient->indicate();
+        m_inspectorClient->showInspectorIndication();
     else
-        m_inspectorClient->hideIndication();
+        m_inspectorClient->hideInspectorIndication();
 #endif
 }
 
index f24e038..04116e0 100644 (file)
@@ -1,3 +1,15 @@
+2014-03-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [iOS] Inspector View Indication Support
+        https://bugs.webkit.org/show_bug.cgi?id=130709
+
+        Reviewed by Simon Fraser.
+
+        * WebCoreSupport/WebInspectorClientIOS.mm:
+        (WebInspectorClient::showInspectorIndication):
+        (WebInspectorClient::hideInspectorIndication):
+        Renamed methods.
+
 2014-03-22  Darin Adler  <darin@apple.com>
 
         Remove String::deprecatedCharacters
index 9bc34c5..a37fef3 100644 (file)
@@ -87,14 +87,14 @@ void WebInspectorClient::hideHighlight()
     [m_highlighter.get() hideHighlight];
 }
 
-void WebInspectorClient::indicate()
+void WebInspectorClient::showInspectorIndication()
 {
-    [m_webView setIndicatingForRemoteInspector:YES];
+    [m_webView setShowingInspectorIndication:YES];
 }
 
-void WebInspectorClient::hideIndication()
+void WebInspectorClient::hideInspectorIndication()
 {
-    [m_webView setIndicatingForRemoteInspector:NO];
+    [m_webView setShowingInspectorIndication:NO];
 }
 
 void WebInspectorClient::didSetSearchingForNode(bool enabled)
index 33b3e62..597c9a4 100644 (file)
@@ -1,3 +1,19 @@
+2014-03-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [iOS] Inspector View Indication Support
+        https://bugs.webkit.org/show_bug.cgi?id=130709
+
+        Reviewed by Simon Fraser.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorClient::didSetSearchingForNode): Deleted.
+        (WebInspectorClient::releaseFrontend): Deleted.
+        * WebView/WebView.mm:
+        (-[WebView setShowingInspectorIndication:]):
+        * WebView/WebViewPrivate.h:
+        Renamed methods.
+
 2014-03-24  Brent Fulgham  <bfulgham@apple.com>
 
         Activate WebVTT Tests Once Merging is Complete
index 322dd36..346f680 100644 (file)
@@ -73,8 +73,10 @@ public:
     virtual void highlight() override;
     virtual void hideHighlight() override;
 
-    virtual void indicate() override;
-    virtual void hideIndication() override;
+#if PLATFORM(IOS)
+    virtual void showInspectorIndication() override;
+    virtual void hideInspectorIndication() override;
+#endif
 
     virtual void didSetSearchingForNode(bool) override;
 
index bb40acf..2094aef 100644 (file)
@@ -181,20 +181,6 @@ void WebInspectorClient::hideHighlight()
     [m_highlighter.get() hideHighlight];
 }
 
-void WebInspectorClient::indicate()
-{
-#if ENABLE(REMOTE_INSPECTOR)
-    [m_webView setIndicatingForRemoteInspector:YES];
-#endif
-}
-
-void WebInspectorClient::hideIndication()
-{
-#if ENABLE(REMOTE_INSPECTOR)
-    [m_webView setIndicatingForRemoteInspector:NO];
-#endif
-}
-
 void WebInspectorClient::didSetSearchingForNode(bool enabled)
 {
     WebInspector *inspector = [m_webView inspector];
index db045b1..87f82c9 100644 (file)
@@ -1893,12 +1893,12 @@ static bool fastDocumentTeardownEnabled()
     _private->page->setRemoteInspectionAllowed(allow);
 }
 
-- (void)setIndicatingForRemoteInspector:(BOOL)enabled
+- (void)setShowingInspectorIndication:(BOOL)showing
 {
 #if PLATFORM(IOS)
     ASSERT(WebThreadIsLocked());
 
-    if (enabled) {
+    if (showing) {
         if (!_private->indicateLayer) {
             _private->indicateLayer = [[WebIndicateLayer alloc] initWithWebView:self];
             [_private->indicateLayer setNeedsLayout];
@@ -1910,7 +1910,7 @@ static bool fastDocumentTeardownEnabled()
         _private->indicateLayer = nil;
     }
 #else
-    // FIXME: Needs implementation or put an implementation in WebCore::InspectorOverlay.
+    // Implemented in WebCore::InspectorOverlay.
 #endif
 }
 
index d75cd5e..99eee89 100644 (file)
@@ -319,11 +319,11 @@ typedef enum {
 - (void)setAllowsRemoteInspection:(BOOL)allow;
 
 /*!
-    @method setIndicatingForRemoteInspector
+    @method setShowingInspectorIndication
     @param enabled Show the indication when true, hide when false.
     @abstract indicate this WebView on screen for a remote inspector.
 */
-- (void)setIndicatingForRemoteInspector:(BOOL)enabled;
+- (void)setShowingInspectorIndication:(BOOL)enabled;
 
 #if TARGET_OS_IPHONE
 /*!
index 34cb4bd..3cc5686 100644 (file)
@@ -1,3 +1,46 @@
+2014-03-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [iOS] Inspector View Indication Support
+        https://bugs.webkit.org/show_bug.cgi?id=130709
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/ios/WKContentView.h:
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKInspectorIndicationView initWithFrame:]):
+        (-[WKContentView isShowingInspectorIndication]):
+        (-[WKContentView setShowingInspectorIndication:]):
+        (-[WKContentView _didCommitLayerTree:WebKit::]):
+        When indicating include a simple tinted UIView over the content.
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _showInspectorIndication]):
+        (-[WKWebView _hideInspectorIndication]):
+        Have the content view show or hide an indication.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::showInspectorIndication):
+        (WebKit::PageClientImpl::hideInspectorIndication):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::showInspectorIndication):
+        (WebKit::WebPageProxy::hideInspectorIndication):
+        Pass WebProcess indication message up to the WKWebView.
+
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::indicate):
+        (WebKit::WebInspectorClient::hideIndication):
+        * WebProcess/WebCoreSupport/WebInspectorClient.h:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::indicate):
+        (WebKit::WebPage::hideIndication):
+        Pass WebCore / remote inspector indication message up to UIProcess.
+
 2014-03-25  Anders Carlsson  <andersca@apple.com>
 
         Add more properties to WKWindowFeatures
index 11b7391..dec22d7 100644 (file)
@@ -69,7 +69,6 @@
 @interface UIPeripheralHost(UIKitInternal)
 - (CGFloat)getVerticalOverlapForView:(UIView *)view usingKeyboardInfo:(NSDictionary *)info;
 @end
-
 #endif
 
 #if PLATFORM(MAC)
@@ -1110,6 +1109,16 @@ static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEve
     [self _updateVisibleContentRects];
 }
 
+- (void)_showInspectorIndication
+{
+    [_contentView setShowingInspectorIndication:YES];
+}
+
+- (void)_hideInspectorIndication
+{
+    [_contentView setShowingInspectorIndication:NO];
+}
+
 - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler
 {
     CGRect snapshotRectInContentCoordinates = [self convertRect:rectInViewCoordinates toView:_contentView.get()];
index f528c1f..7ed04d0 100644 (file)
@@ -90,6 +90,9 @@ typedef NS_ENUM(NSInteger, _WKPaginationMode) {
 - (void)_beginInteractiveObscuredInsetsChange;
 - (void)_endInteractiveObscuredInsetsChange;
 
+- (void)_showInspectorIndication;
+- (void)_hideInspectorIndication;
+
 - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler;
 #else
 @property (readonly) NSColor *_pageExtendedBackgroundColor;
index 9ffbc31..331aa48 100644 (file)
@@ -249,6 +249,11 @@ public:
     virtual void positionInformationDidChange(const InteractionInformationAtPosition&) = 0;
     virtual void saveImageToLibrary(PassRefPtr<WebCore::SharedBuffer>) = 0;
     virtual void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold) = 0;
+
+#if ENABLE(INSPECTOR)
+    virtual void showInspectorIndication() = 0;
+    virtual void hideInspectorIndication() = 0;
+#endif
 #endif
 
     // Auxiliary Client Creation
index 1ce9510..a233c74 100644 (file)
@@ -1325,6 +1325,12 @@ private:
 
     void startAssistingNode(const AssistedNodeInformation&);
     void stopAssistingNode();
+
+#if ENABLE(INSPECTOR)
+    void showInspectorIndication();
+    void hideInspectorIndication();
+#endif
+
     void notifyRevealedSelection();
 #endif // PLATFORM(IOS)
 
index ab2327f..515754c 100644 (file)
@@ -319,6 +319,11 @@ messages -> WebPageProxy {
     StartAssistingNode(WebKit::AssistedNodeInformation information)
     StopAssistingNode()
     NotifyRevealedSelection()
+
+#if ENABLE(INSPECTOR)
+    ShowInspectorIndication()
+    HideInspectorIndication()
+#endif
 #endif
 
     # Search popup menus
index 28998aa..cacaae8 100644 (file)
@@ -114,6 +114,11 @@ private:
     virtual void saveImageToLibrary(PassRefPtr<WebCore::SharedBuffer>);
     virtual void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold);
 
+#if ENABLE(INSPECTOR)
+    virtual void showInspectorIndication() override;
+    virtual void hideInspectorIndication() override;
+#endif
+
     // Auxiliary Client Creation
 #if ENABLE(FULLSCREEN_API)
     virual WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
index 3b5cd22..0975600 100644 (file)
@@ -363,6 +363,18 @@ void PageClientImpl::didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t f
     [m_contentView _didUpdateBlockSelectionWithTouch:(WKSelectionTouch)touch withFlags:(WKSelectionFlags)flags growThreshold:growThreshold shrinkThreshold:shrinkThreshold];
 }
 
+#if ENABLE(INSPECTOR)
+void PageClientImpl::showInspectorIndication()
+{
+    [m_webView _showInspectorIndication];
+}
+
+void PageClientImpl::hideInspectorIndication()
+{
+    [m_webView _hideInspectorIndication];
+}
+#endif
+
 #if ENABLE(FULLSCREEN_API)
 
 WebFullScreenManagerProxyClient& PageClientImpl::fullScreenManagerProxyClient()
index 7e7b167..b041016 100644 (file)
@@ -53,6 +53,7 @@ struct WebPageConfiguration;
 
 @property (nonatomic, readonly) WebKit::WebPageProxy* page;
 @property (nonatomic, readonly) BOOL isAssistingNode;
+@property (nonatomic, getter=isShowingInspectorIndication) BOOL showingInspectorIndication;
 
 - (instancetype)initWithFrame:(CGRect)frame context:(WebKit::WebContext&)context configuration:(WebKit::WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView;
 
index 99acce9..ab11e43 100644 (file)
@@ -130,11 +130,28 @@ private:
 };
 } // namespace WebKit
 
+@interface WKInspectorIndicationView : UIView
+@end
+
+@implementation WKInspectorIndicationView
+
+- (instancetype)initWithFrame:(CGRect)frame
+{
+    if (!(self = [super initWithFrame:frame]))
+        return nil;
+    self.userInteractionEnabled = NO;
+    self.backgroundColor = [UIColor colorWithRed:(111.0 / 255.0) green:(168.0 / 255.0) blue:(220.0 / 255.0) alpha:0.66f];
+    return self;
+}
+
+@end
+
 @implementation WKContentView {
     std::unique_ptr<PageClientImpl> _pageClient;
     RetainPtr<WKBrowsingContextController> _browsingContextController;
 
     RetainPtr<UIView> _rootContentView;
+    RetainPtr<WKInspectorIndicationView> _inspectorIndicationView;
 
     WKWebView *_webView;
 
@@ -235,6 +252,26 @@ private:
     return [self isEditable];
 }
 
+- (BOOL)isShowingInspectorIndication
+{
+    return !!_inspectorIndicationView;
+}
+
+- (void)setShowingInspectorIndication:(BOOL)show
+{
+    if (show) {
+        if (!_inspectorIndicationView) {
+            _inspectorIndicationView = adoptNS([[WKInspectorIndicationView alloc] initWithFrame:[self bounds]]);
+            [self insertSubview:_inspectorIndicationView.get() aboveSubview:_rootContentView.get()];
+        }
+    } else {
+        if (_inspectorIndicationView) {
+            [_inspectorIndicationView removeFromSuperview];
+            _inspectorIndicationView = nil;
+        }
+    }
+}
+
 static inline FloatRect fixedPositionRectFromExposedRect(CGRect unobscuredRect, CGSize documentSize, CGFloat scale)
 {
     return FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(unobscuredRect), roundedLayoutSize(FloatSize(documentSize)), scale, false, StickToViewportBounds);
@@ -370,6 +407,7 @@ static inline FloatRect fixedPositionRectFromExposedRect(CGRect unobscuredRect,
 
     [self setBounds:{CGPointZero, contentsSize}];
     [_rootContentView setFrame:CGRectMake(0, 0, contentsSize.width, contentsSize.height)];
+    [_inspectorIndicationView setFrame:[self bounds]];
 
     [_webView _didCommitLayerTree:layerTreeTransaction];
     [self _updateChangedSelection];
index 8a353ff..51f1a1b 100644 (file)
@@ -477,6 +477,18 @@ void WebPageProxy::stopAssistingNode()
     m_pageClient.stopAssistingNode();
 }
 
+#if ENABLE(INSPECTOR)
+void WebPageProxy::showInspectorIndication()
+{
+    m_pageClient.showInspectorIndication();
+}
+
+void WebPageProxy::hideInspectorIndication()
+{
+    m_pageClient.hideInspectorIndication();
+}
+#endif
+
 void WebPageProxy::focusNextAssistedNode(bool isForward)
 {
     process().send(Messages::WebPage::FocusNextAssistedNode(isForward), m_pageID);
index bf7c307..b47953e 100644 (file)
@@ -97,6 +97,18 @@ void WebInspectorClient::hideHighlight()
         m_page->uninstallPageOverlay(m_highlightOverlay, true);
 }
 
+#if PLATFORM(IOS)
+void WebInspectorClient::showInspectorIndication()
+{
+    m_page->showInspectorIndication();
+}
+
+void WebInspectorClient::hideInspectorIndication()
+{
+    m_page->hideInspectorIndication();
+}
+#endif
+
 bool WebInspectorClient::sendMessageToFrontend(const String& message)
 {
     WebInspector* inspector = m_page->inspector();
index a086b7b..d7a2512 100644 (file)
@@ -65,6 +65,11 @@ private:
     virtual void highlight() override;
     virtual void hideHighlight() override;
 
+#if PLATFORM(IOS)
+    virtual void showInspectorIndication() override;
+    virtual void hideInspectorIndication() override;
+#endif
+
     virtual bool sendMessageToFrontend(const String&) override;
 
     virtual bool supportsFrameInstrumentation();
index 083a30f..b392e36 100644 (file)
@@ -468,6 +468,11 @@ public:
     void setAssistedNodeValue(const String&);
     void setAssistedNodeValueAsNumber(double);
     void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection);
+
+#if ENABLE(INSPECTOR)
+    void showInspectorIndication();
+    void hideInspectorIndication();
+#endif
 #endif
 
     NotificationPermissionRequestManager* notificationPermissionRequestManager();
index c84cc19..b11ac03 100644 (file)
@@ -370,6 +370,18 @@ void WebPage::setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSel
     select->optionSelectedByUser(index, true, allowMultipleSelection);
 }
 
+#if ENABLE(INSPECTOR)
+void WebPage::showInspectorIndication()
+{
+    send(Messages::WebPageProxy::ShowInspectorIndication());
+}
+
+void WebPage::hideInspectorIndication()
+{
+    send(Messages::WebPageProxy::HideInspectorIndication());
+}
+#endif
+
 static FloatQuad innerFrameQuad(Frame* frame, Node* assistedNode)
 {
     frame->document()->updateLayoutIgnorePendingStylesheets();