[iOS]: WK2 Inspector Node Search
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jun 2014 23:13:24 +0000 (23:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jun 2014 23:13:24 +0000 (23:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134279

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2014-06-25
Reviewed by Benjamin Poulain.

Source/WebCore:
* WebCore.exp.in:
Export Node::inspect for WebKit2.

Source/WebKit2:
* UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.h: Added.
* UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.mm: Added.
(-[WKInspectorNodeSearchGestureRecognizer locationInView:]):
(-[WKInspectorNodeSearchGestureRecognizer _processTouches:state:]):
(-[WKInspectorNodeSearchGestureRecognizer touchesBegan:withEvent:]):
(-[WKInspectorNodeSearchGestureRecognizer touchesMoved:withEvent:]):
(-[WKInspectorNodeSearchGestureRecognizer touchesEnded:withEvent:]):
(-[WKInspectorNodeSearchGestureRecognizer touchesCancelled:withEvent:]):
(-[WKInspectorNodeSearchGestureRecognizer reset]):
Gesture recognizer that tracks a single touch, updates as that touch
moves, and ends when that touch is cancelled or ends. The location
of the gesture recognizer is the location of the touch it was tracking.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanupInteraction]):
Handle the inspector node search gesture recognizer if needed.

(-[WKContentView _removeDefaultGestureRecognizers]):
(-[WKContentView _addDefaultGestureRecognizers]):
Helpers to add and remove the default gestures.

(-[WKContentView _enableInspectorNodeSearch]):
(-[WKContentView _disableInspectorNodeSearch]):
When node search is enabled, remove all gesture recognizers and
replace with a single inspector node search gesture recognizer.
Likewise, inverse that when disabled.

(-[WKContentView _inspectorNodeSearchRecognized:]):
Notify the WebProcess of new touch positions during node search.

(-[WKContentView hasSelectablePositionAtPoint:]):
When inspector node search is enabled, disable selection.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::inspectorNodeSearchMovedToPosition):
Send a mouse move to the new location. WebCore will update the highlight.

(WebKit::WebPage::inspectorNodeSearchEndedAtPosition):
Inspect the node at the location.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _enableInspectorNodeSearch]):
(-[WKWebView _disableInspectorNodeSearch]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::enableInspectorNodeSearch):
(WebKit::PageClientImpl::disableInspectorNodeSearch):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::inspectorNodeSearchMovedToPosition):
(WebKit::WebPageProxy::inspectorNodeSearchEndedAtPosition):
(WebKit::WebPageProxy::enableInspectorNodeSearch):
(WebKit::WebPageProxy::disableInspectorNodeSearch):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::didSetSearchingForNode):
* WebProcess/WebCoreSupport/WebInspectorClient.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::enableInspectorNodeSearch):
(WebKit::WebPage::disableInspectorNodeSearch):
Pass the inspector node search state up from the WebProcess
to the WKContentView in the UIProcess. Likewise some messages
in the reverse direction.

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

23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
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.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.h [new file with mode: 0644]
Source/WebKit2/UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index 0f3a91b..918dc4b 100644 (file)
@@ -1,3 +1,13 @@
+2014-06-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [iOS]: WK2 Inspector Node Search
+        https://bugs.webkit.org/show_bug.cgi?id=134279
+
+        Reviewed by Benjamin Poulain.
+
+        * WebCore.exp.in:
+        Export Node::inspect for WebKit2.
+
 2014-06-25  Dana Burkart  <dburkart@apple.com>
 
         Add support for 5-tuple versioning.
index 50f5415..18ebe4d 100644 (file)
@@ -3152,6 +3152,7 @@ __ZNK7WebCore9DOMWindow8documentEv
 
 #if ENABLE(INSPECTOR) && PLATFORM(IOS)
 __ZN7WebCore16findIntersectionERKNS_10FloatPointES2_S2_S2_RS0_
+__ZN7WebCore4Node7inspectEv
 __ZNK7WebCore9FloatQuad12containsQuadERKS0_
 __ZNK7WebCore9FloatQuad13containsPointERKNS_10FloatPointE
 #endif
index 2001372..247d3b1 100644 (file)
@@ -1,3 +1,80 @@
+2014-06-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        [iOS]: WK2 Inspector Node Search
+        https://bugs.webkit.org/show_bug.cgi?id=134279
+
+        Reviewed by Benjamin Poulain.
+
+        * UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.h: Added.
+        * UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.mm: Added.
+        (-[WKInspectorNodeSearchGestureRecognizer locationInView:]):
+        (-[WKInspectorNodeSearchGestureRecognizer _processTouches:state:]):
+        (-[WKInspectorNodeSearchGestureRecognizer touchesBegan:withEvent:]):
+        (-[WKInspectorNodeSearchGestureRecognizer touchesMoved:withEvent:]):
+        (-[WKInspectorNodeSearchGestureRecognizer touchesEnded:withEvent:]):
+        (-[WKInspectorNodeSearchGestureRecognizer touchesCancelled:withEvent:]):
+        (-[WKInspectorNodeSearchGestureRecognizer reset]):
+        Gesture recognizer that tracks a single touch, updates as that touch
+        moves, and ends when that touch is cancelled or ends. The location
+        of the gesture recognizer is the location of the touch it was tracking.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanupInteraction]):
+        Handle the inspector node search gesture recognizer if needed.
+
+        (-[WKContentView _removeDefaultGestureRecognizers]):
+        (-[WKContentView _addDefaultGestureRecognizers]):
+        Helpers to add and remove the default gestures.
+
+        (-[WKContentView _enableInspectorNodeSearch]):
+        (-[WKContentView _disableInspectorNodeSearch]):
+        When node search is enabled, remove all gesture recognizers and
+        replace with a single inspector node search gesture recognizer.
+        Likewise, inverse that when disabled.
+
+        (-[WKContentView _inspectorNodeSearchRecognized:]):
+        Notify the WebProcess of new touch positions during node search.
+
+        (-[WKContentView hasSelectablePositionAtPoint:]):
+        When inspector node search is enabled, disable selection.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::inspectorNodeSearchMovedToPosition):
+        Send a mouse move to the new location. WebCore will update the highlight.
+
+        (WebKit::WebPage::inspectorNodeSearchEndedAtPosition):
+        Inspect the node at the location.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _enableInspectorNodeSearch]):
+        (-[WKWebView _disableInspectorNodeSearch]):
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::enableInspectorNodeSearch):
+        (WebKit::PageClientImpl::disableInspectorNodeSearch):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::inspectorNodeSearchMovedToPosition):
+        (WebKit::WebPageProxy::inspectorNodeSearchEndedAtPosition):
+        (WebKit::WebPageProxy::enableInspectorNodeSearch):
+        (WebKit::WebPageProxy::disableInspectorNodeSearch):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::didSetSearchingForNode):
+        * WebProcess/WebCoreSupport/WebInspectorClient.h:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::enableInspectorNodeSearch):
+        (WebKit::WebPage::disableInspectorNodeSearch):
+        Pass the inspector node search state up from the WebProcess
+        to the WKContentView in the UIProcess. Likewise some messages
+        in the reverse direction.
+
 2014-06-25  Dana Burkart  <dburkart@apple.com>
 
         Add support for 5-tuple versioning.
index 60a189c..a74315a 100644 (file)
@@ -640,16 +640,6 @@ static CGSize roundScrollViewContentSize(const WebKit::WebPageProxy& page, CGSiz
     }
 }
 
-- (void)_showInspectorHighlight:(const WebCore::Highlight&)highlight
-{
-    [_contentView _showInspectorHighlight:highlight];
-}
-
-- (void)_hideInspectorHighlight
-{
-    [_contentView _hideInspectorHighlight];
-}
-
 static CGFloat contentZoomScale(WKWebView* webView)
 {
     UIView *zoomView;
@@ -2147,16 +2137,6 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     [self _updateVisibleContentRects];
 }
 
-- (void)_showInspectorIndication
-{
-    [_contentView setShowingInspectorIndication:YES];
-}
-
-- (void)_hideInspectorIndication
-{
-    [_contentView setShowingInspectorIndication:NO];
-}
-
 - (void)_setOverlaidAccessoryViewsInset:(CGSize)inset
 {
     [_customContentView web_setOverlaidAccessoryViewsInset:inset];
index dc5bd0d..cf90a15 100644 (file)
@@ -93,13 +93,9 @@ struct ViewSnapshot;
 - (void)_willInvokeUIScrollViewDelegateCallback;
 - (void)_didInvokeUIScrollViewDelegateCallback;
 
-- (void)_showInspectorHighlight:(const WebCore::Highlight&)highlight;
-- (void)_hideInspectorHighlight;
-
 - (void)_updateVisibleContentRects;
 
 @property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
-
 #endif
 @end
 
index dfffc2f..4a86e4a 100644 (file)
@@ -131,9 +131,6 @@ typedef NS_OPTIONS(NSUInteger, _WKFindOptions) {
 - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock;
 - (void)_endAnimatedResize;
 
-- (void)_showInspectorIndication;
-- (void)_hideInspectorIndication;
-
 - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler;
 
 - (void)_overrideLayoutParametersWithMinimumLayoutSize:(CGSize)minimumLayoutSize minimumLayoutSizeForMinimalUI:(CGSize)minimumLayoutSizeForMinimalUI maximumUnobscuredSizeOverride:(CGSize)maximumUnobscuredSizeOverride;
index 4bff49f..e7b92d0 100644 (file)
@@ -276,6 +276,9 @@ public:
 
     virtual void showInspectorIndication() = 0;
     virtual void hideInspectorIndication() = 0;
+
+    virtual void enableInspectorNodeSearch() = 0;
+    virtual void disableInspectorNodeSearch() = 0;
 #endif
 #endif
 
index 4cf84a3..9979693 100644 (file)
@@ -845,6 +845,9 @@ public:
     void cancelPotentialTap();
     void tapHighlightAtPosition(const WebCore::FloatPoint&, uint64_t& requestID);
 
+    void inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint&);
+    void inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint&);
+
     void blurAssistedNode();
 #endif
 
@@ -1212,6 +1215,9 @@ private:
 
     void showInspectorIndication();
     void hideInspectorIndication();
+
+    void enableInspectorNodeSearch();
+    void disableInspectorNodeSearch();
 #endif
 
     void notifyRevealedSelection();
index 95e85f5..e8a1720 100644 (file)
@@ -347,6 +347,9 @@ messages -> WebPageProxy {
 
     ShowInspectorIndication()
     HideInspectorIndication()
+
+    EnableInspectorNodeSearch()
+    DisableInspectorNodeSearch()
 #endif
 #endif
 
index dddb4a4..59a2bc7 100644 (file)
@@ -137,6 +137,9 @@ private:
 
     virtual void showInspectorIndication() override;
     virtual void hideInspectorIndication() override;
+
+    virtual void enableInspectorNodeSearch() override;
+    virtual void disableInspectorNodeSearch() override;
 #endif
 
     virtual void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) override;
index 1bfcd11..a7ac571 100644 (file)
@@ -487,22 +487,32 @@ bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPa
 #if ENABLE(INSPECTOR)
 void PageClientImpl::showInspectorHighlight(const WebCore::Highlight& highlight)
 {
-    [m_webView _showInspectorHighlight:highlight];
+    [m_contentView _showInspectorHighlight:highlight];
 }
 
 void PageClientImpl::hideInspectorHighlight()
 {
-    [m_webView _hideInspectorHighlight];
+    [m_contentView _hideInspectorHighlight];
 }
 
 void PageClientImpl::showInspectorIndication()
 {
-    [m_webView _showInspectorIndication];
+    [m_contentView setShowingInspectorIndication:YES];
 }
 
 void PageClientImpl::hideInspectorIndication()
 {
-    [m_webView _hideInspectorIndication];
+    [m_contentView setShowingInspectorIndication:NO];
+}
+
+void PageClientImpl::enableInspectorNodeSearch()
+{
+    [m_contentView _enableInspectorNodeSearch];
+}
+
+void PageClientImpl::disableInspectorNodeSearch()
+{
+    [m_contentView _disableInspectorNodeSearch];
 }
 #endif
 
index d28636f..051b71a 100644 (file)
@@ -643,6 +643,9 @@ static void layerPath(CAShapeLayer *layer, const FloatQuad& outerQuad)
 - (void)_processDidExit
 {
     [self cleanupInteraction];
+
+    [self setShowingInspectorIndication:NO];
+    [self _hideInspectorHighlight];
 }
 
 - (void)_didRelaunchProcess
index 0277252..6dc513b 100644 (file)
@@ -62,6 +62,7 @@ class WebPageProxy;
 
 @class WKActionSheetAssistant;
 @class WKFormInputSession;
+@class WKInspectorNodeSearchGestureRecognizer;
 @class WebIOSEvent;
 @class _UIHighlightView;
 @class _UIWebHighlightLongPressGestureRecognizer;
@@ -92,6 +93,7 @@ struct WKAutoCorrectionData {
     RetainPtr<UILongPressGestureRecognizer> _longPressGestureRecognizer;
     RetainPtr<UITapGestureRecognizer> _doubleTapGestureRecognizer;
     RetainPtr<UITapGestureRecognizer> _twoFingerDoubleTapGestureRecognizer;
+    RetainPtr<WKInspectorNodeSearchGestureRecognizer> _inspectorNodeSearchGestureRecognizer;
 
     RetainPtr<UIWKTextInteractionAssistant> _textSelectionAssistant;
     RetainPtr<UIWKSelectionAssistant> _webSelectionAssistant;
@@ -136,6 +138,7 @@ struct WKAutoCorrectionData {
     BOOL _potentialTapInProgress;
     BOOL _selectionNeedsUpdate;
     BOOL _usingGestureForSelection;
+    BOOL _inspectorNodeSearchEnabled;
 }
 
 @end
@@ -176,6 +179,8 @@ struct WKAutoCorrectionData {
 - (void)_didHandleKeyEvent:(WebIOSEvent *)event;
 - (Vector<WebKit::OptionItem>&) assistedNodeSelectOptions;
 - (void)_updateUnscaledView;
+- (void)_enableInspectorNodeSearch;
+- (void)_disableInspectorNodeSearch;
 @end
 
 #endif // PLATFORM(IOS)
index 4e4ce39..b4ccddc 100644 (file)
@@ -35,6 +35,7 @@
 #import "WKActionSheetAssistant.h"
 #import "WKFormInputControl.h"
 #import "WKFormSelectControl.h"
+#import "WKInspectorNodeSearchGestureRecognizer.h"
 #import "WKWebViewPrivate.h"
 #import "WebEvent.h"
 #import "WebIOSEventFactory.h"
@@ -273,6 +274,13 @@ static const float tapAndHoldDelay  = 0.75;
     [_twoFingerDoubleTapGestureRecognizer setDelegate:nil];
     [self removeGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
 
+    _inspectorNodeSearchEnabled = NO;
+    if (_inspectorNodeSearchGestureRecognizer) {
+        [_inspectorNodeSearchGestureRecognizer setDelegate:nil];
+        [self removeGestureRecognizer:_inspectorNodeSearchGestureRecognizer.get()];
+        _inspectorNodeSearchGestureRecognizer = nil;
+    }
+
     if (_fileUploadPanel) {
         [_fileUploadPanel setDelegate:nil];
         [_fileUploadPanel dismiss];
@@ -280,6 +288,26 @@ static const float tapAndHoldDelay  = 0.75;
     }
 }
 
+- (void)_removeDefaultGestureRecognizers
+{
+    [self removeGestureRecognizer:_touchEventGestureRecognizer.get()];
+    [self removeGestureRecognizer:_singleTapGestureRecognizer.get()];
+    [self removeGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
+    [self removeGestureRecognizer:_longPressGestureRecognizer.get()];
+    [self removeGestureRecognizer:_doubleTapGestureRecognizer.get()];
+    [self removeGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
+}
+
+- (void)_addDefaultGestureRecognizers
+{
+    [self addGestureRecognizer:_touchEventGestureRecognizer.get()];
+    [self addGestureRecognizer:_singleTapGestureRecognizer.get()];
+    [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
+    [self addGestureRecognizer:_longPressGestureRecognizer.get()];
+    [self addGestureRecognizer:_doubleTapGestureRecognizer.get()];
+    [self addGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
+}
+
 - (UIView*)unscaledView
 {
     return _inverseScaleRootView.get();
@@ -298,6 +326,26 @@ static const float tapAndHoldDelay  = 0.75;
     [self _updateChangedSelection];
 }
 
+- (void)_enableInspectorNodeSearch
+{
+    _inspectorNodeSearchEnabled = YES;
+
+    [self _cancelInteraction];
+
+    [self _removeDefaultGestureRecognizers];
+    _inspectorNodeSearchGestureRecognizer = adoptNS([[WKInspectorNodeSearchGestureRecognizer alloc] initWithTarget:self action:@selector(_inspectorNodeSearchRecognized:)]);
+    [self addGestureRecognizer:_inspectorNodeSearchGestureRecognizer.get()];
+}
+
+- (void)_disableInspectorNodeSearch
+{
+    _inspectorNodeSearchEnabled = NO;
+
+    [self _addDefaultGestureRecognizers];
+    [self removeGestureRecognizer:_inspectorNodeSearchGestureRecognizer.get()];
+    _inspectorNodeSearchGestureRecognizer = nil;
+}
+
 - (UIView *)hitTest:(CGPoint)point withEvent:(::UIEvent *)event
 {
     for (UIView *subView in [_inverseScaleRootView.get() subviews]) {
@@ -370,6 +418,25 @@ static const float tapAndHoldDelay  = 0.75;
         _canSendTouchEventsAsynchronously = NO;
 }
 
+- (void)_inspectorNodeSearchRecognized:(UIGestureRecognizer *)gestureRecognizer
+{
+    ASSERT(_inspectorNodeSearchEnabled);
+
+    CGPoint point = [gestureRecognizer locationInView:self];
+
+    switch (gestureRecognizer.state) {
+    case UIGestureRecognizerStateBegan:
+    case UIGestureRecognizerStateChanged:
+        _page->inspectorNodeSearchMovedToPosition(point);
+        break;
+    case UIGestureRecognizerStateEnded:
+    case UIGestureRecognizerStateCancelled:
+    default: // To ensure we turn off node search.
+        _page->inspectorNodeSearchEndedAtPosition(point);
+        break;
+    }
+}
+
 static FloatQuad inflateQuad(const FloatQuad& quad, float inflateSize)
 {
     // We sort the output points like this (as expected by the highlight view):
@@ -734,6 +801,9 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI
 
 - (BOOL)hasSelectablePositionAtPoint:(CGPoint)point
 {
+    if (_inspectorNodeSearchEnabled)
+        return NO;
+
     [self ensurePositionInformationIsUpToDate:point];
     return _positionInformation.isSelectable;
 }
diff --git a/Source/WebKit2/UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.h b/Source/WebKit2/UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.h
new file mode 100644 (file)
index 0000000..0fef5e8
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <UIKit/UIGestureRecognizer.h>
+
+@interface WKInspectorNodeSearchGestureRecognizer : UIGestureRecognizer
+- (CGPoint)locationInView:(UIView *)view;
+@end
+
+#endif
diff --git a/Source/WebKit2/UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.mm b/Source/WebKit2/UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.mm
new file mode 100644 (file)
index 0000000..468b9bb
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKInspectorNodeSearchGestureRecognizer.h"
+
+#if PLATFORM(IOS)
+
+#import <UIKit/UIGestureRecognizerSubclass.h>
+#import <wtf/RetainPtr.h>
+
+@implementation WKInspectorNodeSearchGestureRecognizer {
+    RetainPtr<UITouch> _touch;
+}
+
+- (CGPoint)locationInView:(UIView *)view
+{
+    return [_touch locationInView:view];
+}
+
+- (void)_processTouches:(NSSet *)touches state:(UIGestureRecognizerState)newState
+{
+    ASSERT(_touch);
+    if ([touches containsObject:_touch.get()])
+        self.state = newState;
+}
+
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+{
+    if (self.state != UIGestureRecognizerStatePossible)
+        return;
+
+    ASSERT(!_touch);
+    _touch = [touches anyObject];
+
+    [self _processTouches:touches state:UIGestureRecognizerStateBegan];
+}
+
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
+{
+    [self _processTouches:touches state:UIGestureRecognizerStateChanged];
+}
+
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
+{
+    [self _processTouches:touches state:UIGestureRecognizerStateEnded];
+}
+
+- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
+{
+    [self _processTouches:touches state:UIGestureRecognizerStateCancelled];
+}
+
+- (void)reset
+{
+    _touch = nil;
+}
+
+@end
+
+#endif
index 13b1483..f8d2302 100644 (file)
@@ -587,6 +587,16 @@ void WebPageProxy::tapHighlightAtPosition(const WebCore::FloatPoint& position, u
     process().send(Messages::WebPage::TapHighlightAtPosition(requestID, position), m_pageID);
 }
 
+void WebPageProxy::inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint& position)
+{
+    process().send(Messages::WebPage::InspectorNodeSearchMovedToPosition(position), m_pageID);
+}
+
+void WebPageProxy::inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint& position)
+{
+    process().send(Messages::WebPage::InspectorNodeSearchEndedAtPosition(position), m_pageID);
+}
+
 void WebPageProxy::blurAssistedNode()
 {
     process().send(Messages::WebPage::BlurAssistedNode(), m_pageID);
@@ -665,6 +675,16 @@ void WebPageProxy::hideInspectorIndication()
 {
     m_pageClient.hideInspectorIndication();
 }
+
+void WebPageProxy::enableInspectorNodeSearch()
+{
+    m_pageClient.enableInspectorNodeSearch();
+}
+
+void WebPageProxy::disableInspectorNodeSearch()
+{
+    m_pageClient.disableInspectorNodeSearch();
+}
 #endif
 
 void WebPageProxy::focusNextAssistedNode(bool isForward)
index 47a66d3..6c95824 100644 (file)
                A1C512C9190656E500448914 /* WebQuickLookHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C512C7190656E500448914 /* WebQuickLookHandleClient.h */; };
                A1DF631218E0B7C8003A3E2A /* DownloadClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */; };
                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1DF631118E0B7C8003A3E2A /* DownloadClient.h */; };
+               A54293A4195A43DA002782C7 /* WKInspectorNodeSearchGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */; };
+               A54293A5195A43DD002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A54293A3195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm */; };
                A58B6F0818FCA733008CBA53 /* WKFileUploadPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */; };
                A58B6F0918FCA733008CBA53 /* WKFileUploadPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A58B6F0718FCA733008CBA53 /* WKFileUploadPanel.mm */; };
                A5EFD38C16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = A5EFD38B16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1EDD2DB1884B96400BBFE98 /* PluginProcessShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = PluginProcessShim.xcconfig; sourceTree = "<group>"; };
                A1EDD2DC1884B9B500BBFE98 /* SecItemShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SecItemShim.xcconfig; sourceTree = "<group>"; };
                A1EDD2DD1884B9E300BBFE98 /* WebProcessShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WebProcessShim.xcconfig; sourceTree = "<group>"; };
+               A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKInspectorNodeSearchGestureRecognizer.h; path = ios/WKInspectorNodeSearchGestureRecognizer.h; sourceTree = "<group>"; };
+               A54293A3195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKInspectorNodeSearchGestureRecognizer.mm; path = ios/WKInspectorNodeSearchGestureRecognizer.mm; sourceTree = "<group>"; };
                A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFileUploadPanel.h; path = ios/forms/WKFileUploadPanel.h; sourceTree = "<group>"; };
                A58B6F0718FCA733008CBA53 /* WKFileUploadPanel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFileUploadPanel.mm; path = ios/forms/WKFileUploadPanel.mm; sourceTree = "<group>"; };
                A5EFD38B16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageVisibilityTypes.h; sourceTree = "<group>"; };
                                0FCB4E3F18BBE044000FCFC9 /* WKGeolocationProviderIOS.h */,
                                0FCB4E4018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm */,
                                0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */,
+                               A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */,
+                               A54293A3195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm */,
                                0FCB4E4418BBE044000FCFC9 /* WKScrollView.h */,
                                0FCB4E4518BBE044000FCFC9 /* WKScrollView.mm */,
                                A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */,
                                33D3A3B61339600B00709BE4 /* WKMediaCacheManager.h in Headers */,
                                BC4075FE124FF0270068F20A /* WKMutableArray.h in Headers */,
                                BC407600124FF0270068F20A /* WKMutableDictionary.h in Headers */,
+                               A54293A4195A43DA002782C7 /* WKInspectorNodeSearchGestureRecognizer.h in Headers */,
                                C09AE5E9125257C20025825D /* WKNativeEvent.h in Headers */,
                                1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */,
                                BCF69FA91176D1CB00471A52 /* WKNavigationDataRef.h in Headers */,
                                BC111AE0112F5BC200337BAB /* WebErrorsMac.mm in Sources */,
                                1A7284481959F8040007BCE5 /* SessionStateConversion.cpp in Sources */,
                                1AFA3AC818E61C61003CCBAE /* WKUserContentController.mm in Sources */,
+                               A54293A5195A43DD002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm in Sources */,
                                C0337DAE127A24FE008FF4F4 /* WebEvent.cpp in Sources */,
                                BC032DBA10F4380F0058C15A /* WebEventConversion.cpp in Sources */,
                                2D140EAF18F37BE0005E75A0 /* PageOverlayController.cpp in Sources */,
index 6cfc918..e5b437c 100644 (file)
@@ -110,6 +110,14 @@ void WebInspectorClient::hideInspectorIndication()
 {
     m_page->hideInspectorIndication();
 }
+
+void WebInspectorClient::didSetSearchingForNode(bool enabled)
+{
+    if (enabled)
+        m_page->enableInspectorNodeSearch();
+    else
+        m_page->disableInspectorNodeSearch();
+}
 #endif
 
 bool WebInspectorClient::sendMessageToFrontend(const String& message)
index f697f63..b3ed8d2 100644 (file)
@@ -64,6 +64,8 @@ private:
 #if PLATFORM(IOS)
     virtual void showInspectorIndication() override;
     virtual void hideInspectorIndication() override;
+
+    virtual void didSetSearchingForNode(bool) override;
 #endif
 
     virtual bool sendMessageToFrontend(const String&) override;
index f9655fd..214ca14 100644 (file)
@@ -476,6 +476,9 @@ public:
     void cancelPotentialTap();
     void tapHighlightAtPosition(uint64_t requestID, const WebCore::FloatPoint&);
 
+    void inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint&);
+    void inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint&);
+
     void blurAssistedNode();
     void selectWithGesture(const WebCore::IntPoint&, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, uint64_t callbackID);
     void updateSelectionWithTouches(const WebCore::IntPoint& point, uint32_t touches, bool baseIsStart, uint64_t callbackID);
@@ -513,6 +516,9 @@ public:
 
     void showInspectorIndication();
     void hideInspectorIndication();
+
+    void enableInspectorNodeSearch();
+    void disableInspectorNodeSearch();
 #endif
 #endif
 
index 2d12274..c6b4e2e 100644 (file)
@@ -55,6 +55,8 @@ messages -> WebPage LegacyReceiver {
     CommitPotentialTap()
     CancelPotentialTap()
     TapHighlightAtPosition(uint64_t requestID, WebCore::FloatPoint point)
+    InspectorNodeSearchMovedToPosition(WebCore::FloatPoint point)
+    InspectorNodeSearchEndedAtPosition(WebCore::FloatPoint point)
     BlurAssistedNode()
     SelectWithGesture(WebCore::IntPoint point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, uint64_t callbackID)
     UpdateSelectionWithTouches(WebCore::IntPoint point, uint32_t touches, bool baseIsStart, uint64_t callbackID)
index 83f4b79..cd68a5e 100644 (file)
@@ -576,6 +576,21 @@ void WebPage::tapHighlightAtPosition(uint64_t requestID, const FloatPoint& posit
     sendTapHighlightForNodeIfNecessary(requestID, mainframe.nodeRespondingToClickEvents(position, adjustedPoint));
 }
 
+void WebPage::inspectorNodeSearchMovedToPosition(const FloatPoint& position)
+{
+    IntPoint adjustedPoint = roundedIntPoint(position);
+    Frame& mainframe = m_page->mainFrame();
+
+    mainframe.eventHandler().mouseMoved(PlatformMouseEvent(adjustedPoint, adjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, false, false, false, false, 0));
+    mainframe.document()->updateStyleIfNeeded();
+}
+
+void WebPage::inspectorNodeSearchEndedAtPosition(const FloatPoint& position)
+{
+    if (Node* node = m_page->mainFrame().deepestNodeAtLocation(position))
+        node->inspect();
+}
+
 void WebPage::blurAssistedNode()
 {
     if (m_assistedNode && m_assistedNode->isElementNode())
@@ -631,6 +646,16 @@ void WebPage::hideInspectorIndication()
 {
     send(Messages::WebPageProxy::HideInspectorIndication());
 }
+
+void WebPage::enableInspectorNodeSearch()
+{
+    send(Messages::WebPageProxy::EnableInspectorNodeSearch());
+}
+
+void WebPage::disableInspectorNodeSearch()
+{
+    send(Messages::WebPageProxy::DisableInspectorNodeSearch());
+}
 #endif
 
 static FloatQuad innerFrameQuad(Frame* frame, Node* assistedNode)