Add support for AirPlay picker for iOS.
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Mar 2014 16:18:01 +0000 (16:18 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Mar 2014 16:18:01 +0000 (16:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130876
<rdar://problem/15349859>

Reviewed by Benjamin Poulain.

Adds support for the AirPlay picker for WebKit.
The actual picker is implemented in UIKit.

* DefaultDelegates/WebDefaultUIKitDelegate.m:
(-[WebDefaultUIKitDelegate interactionLocation]):
(-[WebDefaultUIKitDelegate showPlaybackTargetPicker:fromRect:]):
* WebCoreSupport/WebChromeClientIOS.mm:
(WebChromeClientIOS::showPlaybackTargetPicker):
* WebCoreSupport/WebFrameIOS.h:
* WebCoreSupport/WebFrameIOS.mm:
(-[WebFrame elementRectAtPoint:]):
* WebView/WebUIKitDelegate.h:

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

Source/WebKit/ios/ChangeLog
Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.m
Source/WebKit/ios/WebCoreSupport/WebChromeClientIOS.mm
Source/WebKit/ios/WebCoreSupport/WebFrameIOS.h
Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm
Source/WebKit/ios/WebView/WebUIKitDelegate.h

index d67a17279ab987288522a0a086898a6869e66fc2..b50a944ffbdea9d788c7aedad015a990bc21250c 100644 (file)
@@ -1,3 +1,24 @@
+2014-03-27  Enrica Casucci  <enrica@apple.com>
+
+        Add support for AirPlay picker for iOS.
+        https://bugs.webkit.org/show_bug.cgi?id=130876
+        <rdar://problem/15349859>
+
+        Reviewed by Benjamin Poulain.
+
+        Adds support for the AirPlay picker for WebKit.
+        The actual picker is implemented in UIKit.
+
+        * DefaultDelegates/WebDefaultUIKitDelegate.m:
+        (-[WebDefaultUIKitDelegate interactionLocation]):
+        (-[WebDefaultUIKitDelegate showPlaybackTargetPicker:fromRect:]):
+        * WebCoreSupport/WebChromeClientIOS.mm:
+        (WebChromeClientIOS::showPlaybackTargetPicker):
+        * WebCoreSupport/WebFrameIOS.h:
+        * WebCoreSupport/WebFrameIOS.mm:
+        (-[WebFrame elementRectAtPoint:]):
+        * WebView/WebUIKitDelegate.h:
+
 2014-03-27  Enrica Casucci  <enrica@apple.com>
 
         Add support for AirPlay picker in WK2 for iOS.
index 9aaa5f0052e79cd5ce70317057a1272396b03149..f173dbabeab1a05359bd249c3814c58587a8f6ef 100644 (file)
@@ -236,6 +236,15 @@ static WebDefaultUIKitDelegate *sharedDelegate = nil;
     return nil; 
 } 
 
+- (CGPoint)interactionLocation
+{
+    return CGPointZero;
+}
+
+- (void)showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(CGRect)elementRect
+{
+}
+
 - (BOOL)hasRichlyEditableSelection
 {
     return NO;
index 5794e6a07336a12d41d7ec61dabdbfa4afe87a3b..410f4c692104cc77295162bb21e659c99edce257 100644 (file)
@@ -316,6 +316,9 @@ void WebChromeClientIOS::focusedElementChanged(Element* element)
 
 void WebChromeClientIOS::showPlaybackTargetPicker(bool hasVideo)
 {
+    CGPoint point = [[webView() _UIKitDelegateForwarder] interactionLocation];
+    CGRect elementRect = [[webView() mainFrame] elementRectAtPoint:point];
+    [[webView() _UIKitDelegateForwarder] showPlaybackTargetPicker:hasVideo fromRect:elementRect];
 }
 
 #endif // PLATFORM(IOS)
index 46fe90cabb91c0a639e791d34847504e16c218be..2a15182c9cffe6e1c4716d71d04b34bfb789ca61 100644 (file)
@@ -93,6 +93,7 @@ typedef enum {
 - (WebVisiblePosition *)previousUnperturbedDictationResultBoundaryFromPosition:(WebVisiblePosition *)position;
 - (WebVisiblePosition *)nextUnperturbedDictationResultBoundaryFromPosition:(WebVisiblePosition *)position;
 
+- (CGRect)elementRectAtPoint:(CGPoint)point;
 @end
 
 #endif // TARGET_OS_IPHONE
index ff934120532957dc97a571005b4d160104842515..1d5ba944989f63e43f4086bf7f9102a2f663fcef 100644 (file)
@@ -943,6 +943,17 @@ static VisiblePosition SimpleSmartExtendEnd(const VisiblePosition& start, const
     return position;
 }
 
+- (CGRect)elementRectAtPoint:(CGPoint)point
+{
+    Frame *frame = [self coreFrame];
+    IntPoint adjustedPoint = frame->view()->windowToContents(roundedIntPoint(point));
+    HitTestResult result = frame->eventHandler().hitTestResultAtPoint(adjustedPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowChildFrameContent);
+    Node* hitNode = result.innerNode();
+    if (!hitNode || !hitNode->renderer())
+        return IntRect();
+    return result.innerNodeFrame()->view()->contentsToWindow(hitNode->renderer()->absoluteBoundingBoxRect(true));
+}
+
 @end
 
 #endif  // PLATFORM(IOS)
index 8991d84f3de61c3b310033c7d9edbb176fc14f8e..2339dfa2dcd8a88e28c561a14b27d9bd0e5b5709 100644 (file)
 - (BOOL)hasRichlyEditableSelection;
 - (BOOL)performsTwoStepPaste:(DOMDocumentFragment*)fragment;
 - (NSInteger)getPasteboardChangeCount;
+- (CGPoint)interactionLocation;
+- (void)showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(CGRect)elementRect;
 
 - (BOOL)isUnperturbedDictationResultMarker:(id)metadataForMarker;
 - (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message withSource:(NSString *)source;