Expose a getMediaType method in WebKit
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2013 21:39:33 +0000 (21:39 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2013 21:39:33 +0000 (21:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117667

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-06-18
Reviewed by Brady Eidson.

Source/WebCore:

* WebCore.exp.in: Updated to add a symbol for
HitTestResult::mediaIsVideo method
and alphabetize the list of exposed methods.

Source/WebKit2:

* GNUmakefile.list.am:
* Target.pri:
Updated to include the added header file InjectedBundleHitTestResultMediaType.h

* UIProcess/API/C/WKAPICast.h:
(WebKit::toBundleHitTestResultMediaType):
(WebKit::toAPI):
Added methods to convert between BundleHitTestResultMediaType
and WKBundleHitTestResultMediaType.

* WebKit2.xcodeproj/project.pbxproj: Updated to include
InjectedBundleHitTestResultMediaType.h in the WebKit2 project.

* WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp:
(WKBundleHitTestResultGetMediaType): Exposes the method getMediaType and
hooks into InjectedBundleHitTestResult::getMediaType.

* WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:

* WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
(WebKit::InjectedBundleHitTestResult::getMediaType): Added to return
what type, if any, a media element is.

* WebProcess/InjectedBundle/InjectedBundleHitTestResult.h:

* WebProcess/InjectedBundle/InjectedBundleHitTestResultMediaType.h: Added
to contain new BundleHitTestResultMediaType enums.

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResultMediaType.h [new file with mode: 0644]

index 93540ea..778b7af 100644 (file)
@@ -1,3 +1,14 @@
+2013-06-18  Ruth Fong  <ruth_fong@apple.com>
+
+        Expose a getMediaType method in WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=117667
+
+        Reviewed by Brady Eidson.
+
+        * WebCore.exp.in: Updated to add a symbol for 
+        HitTestResult::mediaIsVideo method
+        and alphabetize the list of exposed methods.
+
 2013-06-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Remove unused bool argument from ReplacementFragment's constructor
index 6a1a94a..e0deba5 100644 (file)
@@ -1370,16 +1370,17 @@ __ZNK7WebCore13HitTestResult10isSelectedEv
 __ZNK7WebCore13HitTestResult11targetFrameEv
 __ZNK7WebCore13HitTestResult11textContentEv
 __ZNK7WebCore13HitTestResult12innerElementEv
+__ZNK7WebCore13HitTestResult12mediaIsVideoEv
 __ZNK7WebCore13HitTestResult14absolutePDFURLEv
 __ZNK7WebCore13HitTestResult14innerNodeFrameEv
 __ZNK7WebCore13HitTestResult15absoluteLinkURLEv
 __ZNK7WebCore13HitTestResult15spellingToolTipERNS_13TextDirectionE
 __ZNK7WebCore13HitTestResult16absoluteImageURLEv
 __ZNK7WebCore13HitTestResult16absoluteMediaURLEv
-__ZNK7WebCore13HitTestResult19mediaIsInFullscreenEv
 __ZNK7WebCore13HitTestResult16altDisplayStringEv
 __ZNK7WebCore13HitTestResult17isContentEditableEv
 __ZNK7WebCore13HitTestResult18titleDisplayStringEv
+__ZNK7WebCore13HitTestResult19mediaIsInFullscreenEv
 __ZNK7WebCore13HitTestResult19rectBasedTestResultEv
 __ZNK7WebCore13HitTestResult5imageEv
 __ZNK7WebCore13HitTestResult5titleERNS_13TextDirectionE
index 11a9bf5..de924cd 100644 (file)
@@ -1,3 +1,38 @@
+2013-06-18  Ruth Fong  <ruth_fong@apple.com>
+
+        Expose a getMediaType method in WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=117667
+
+        Reviewed by Brady Eidson.
+
+        * GNUmakefile.list.am:
+        * Target.pri:
+        Updated to include the added header file InjectedBundleHitTestResultMediaType.h
+        
+        * UIProcess/API/C/WKAPICast.h:
+        (WebKit::toBundleHitTestResultMediaType):
+        (WebKit::toAPI):
+        Added methods to convert between BundleHitTestResultMediaType
+        and WKBundleHitTestResultMediaType.
+
+        * WebKit2.xcodeproj/project.pbxproj: Updated to include
+        InjectedBundleHitTestResultMediaType.h in the WebKit2 project.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp:
+        (WKBundleHitTestResultGetMediaType): Exposes the method getMediaType and
+        hooks into InjectedBundleHitTestResult::getMediaType.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
+
+        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
+        (WebKit::InjectedBundleHitTestResult::getMediaType): Added to return 
+        what type, if any, a media element is.
+
+        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.h:
+
+        * WebProcess/InjectedBundle/InjectedBundleHitTestResultMediaType.h: Added
+        to contain new BundleHitTestResultMediaType enums.
+
 2013-06-18  Roger Fong  <roger_fong@apple.com>
 
         Re-implement WebFrameNetworkingContext.
index 72a8ec6..b15017f 100644 (file)
@@ -1073,6 +1073,7 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \
+       Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResultMediaType.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp \
index 58a64ac..fe6336a 100644 (file)
@@ -310,6 +310,7 @@ HEADERS += \
     WebProcess/InjectedBundle/InjectedBundleClient.h \
     WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \
     WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \
+    WebProcess/InjectedBundle/InjectedBundleHitTestResultMediaType.h \
     WebProcess/InjectedBundle/InjectedBundleNavigationAction.h \
     WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h \
     WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.h \
index 408656c..64c8d1a 100644 (file)
 #include "CacheModel.h"
 #include "FontSmoothingLevel.h"
 #include "HTTPCookieAcceptPolicy.h"
+#include "InjectedBundleHitTestResultMediaType.h"
 #include "PluginModuleInfo.h"
 #include "ProcessModel.h"
 #include "ResourceCachesToClear.h"
+#include "WKBundleHitTestResult.h"
 #include "WKContext.h"
 #include "WKCookieManager.h"
 #include "WKCredentialTypes.h"
@@ -103,6 +105,7 @@ WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
 WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
 WK_ADD_API_MAPPING(WKBatteryManagerRef, WebBatteryManagerProxy)
 WK_ADD_API_MAPPING(WKBatteryStatusRef, WebBatteryStatus)
+WK_ADD_API_MAPPING(WKBundleHitTestResultMediaType, BundleHitTestResultMediaType)
 WK_ADD_API_MAPPING(WKResourceCacheManagerRef, WebResourceCacheManagerProxy)
 WK_ADD_API_MAPPING(WKColorPickerResultListenerRef, WebColorPickerResultListenerProxy)
 WK_ADD_API_MAPPING(WKContextRef, WebContext)
@@ -144,6 +147,36 @@ WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
 
 /* Enum conversions */
 
+inline BundleHitTestResultMediaType toBundleHitTestResultMediaType(WKBundleHitTestResultMediaType wkMediaType)
+{
+    switch (wkMediaType) {
+    case kWKBundleHitTestResultMediaTypeNone:
+        return BundleHitTestResultMediaTypeNone;
+    case kWKBundleHitTestResultMediaTypeAudio:
+        return BundleHitTestResultMediaTypeAudio;
+    case kWKBundleHitTestResultMediaTypeVideo:
+        return BundleHitTestResultMediaTypeVideo;
+    }
+    
+    ASSERT_NOT_REACHED();
+    return BundleHitTestResultMediaTypeNone;
+}
+    
+inline WKBundleHitTestResultMediaType toAPI(BundleHitTestResultMediaType mediaType)
+{
+    switch (mediaType) {
+    case BundleHitTestResultMediaTypeNone:
+        return kWKBundleHitTestResultMediaTypeNone;
+    case BundleHitTestResultMediaTypeAudio:
+        return kWKBundleHitTestResultMediaTypeAudio;
+    case BundleHitTestResultMediaTypeVideo:
+        return kWKBundleHitTestResultMediaTypeVideo;
+    }
+    
+    ASSERT_NOT_REACHED();
+    return kWKBundleHitTestResultMediaTypeNone;
+}
+
 inline CacheModel toCacheModel(WKCacheModel wkCacheModel)
 {
     switch (wkCacheModel) {
index 6ae6db7..adab0a9 100644 (file)
                7CF47FFB17275C57008ACB91 /* PageBanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CF47FF917275C57008ACB91 /* PageBanner.h */; };
                7CF47FFE17276AE3008ACB91 /* WKBundlePageBannerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CF47FFC17276AE3008ACB91 /* WKBundlePageBannerMac.mm */; };
                7CF47FFF17276AE3008ACB91 /* WKBundlePageBannerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               84477853176FCC0800CDC7BB /* InjectedBundleHitTestResultMediaType.h in Headers */ = {isa = PBXBuildFile; fileRef = 84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */; };
                8CFECE941490F140002AAA32 /* EditorState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CFECE931490F140002AAA32 /* EditorState.cpp */; };
                8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
                909854EC12BC4E17000AD080 /* WebMemorySampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 905620E812BC248B000799B6 /* WebMemorySampler.cpp */; };
                7CF47FF917275C57008ACB91 /* PageBanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageBanner.h; sourceTree = "<group>"; };
                7CF47FFC17276AE3008ACB91 /* WKBundlePageBannerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBundlePageBannerMac.mm; sourceTree = "<group>"; };
                7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePageBannerMac.h; sourceTree = "<group>"; };
+               84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleHitTestResultMediaType.h; sourceTree = "<group>"; };
                8CFECE931490F140002AAA32 /* EditorState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditorState.cpp; sourceTree = "<group>"; };
                8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
                8DC2EF5B0486A6940098B216 /* WebKit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                                BC14DF76120B5B7900826C0C /* InjectedBundleScriptWorld.cpp */,
                                BC14DF75120B5B7900826C0C /* InjectedBundleScriptWorld.h */,
                                BCB0B0DD12305A8C00B1341E /* InjectedBundleUserMessageCoders.h */,
+                               84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */,
                        );
                        path = InjectedBundle;
                        sourceTree = "<group>";
                                E14A954A16E016A40068DE82 /* NetworkProcessPlatformStrategies.h in Headers */,
                                E1798C7A16E6818800240139 /* NetworkBlobRegistry.h in Headers */,
                                E152551B17011819003D7ADB /* NetworkResourceLoaderMessages.h in Headers */,
+                               84477853176FCC0800CDC7BB /* InjectedBundleHitTestResultMediaType.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 727efd2..e1c73d4 100644 (file)
@@ -79,6 +79,11 @@ bool WKBundleHitTestResultMediaIsInFullscreen(WKBundleHitTestResultRef hitTestRe
     return toImpl(hitTestResultRef)->mediaIsInFullscreen();
 }
 
+WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResultRef)
+{
+    return toAPI(toImpl(hitTestResultRef)->getMediaType());
+}
+
 WKRect WKBundleHitTestResultGetImageRect(WKBundleHitTestResultRef hitTestResultRef)
 {
     return toAPI(toImpl(hitTestResultRef)->imageRect());
index 1de6d58..dfeb1e2 100644 (file)
 extern "C" {
 #endif
 
+enum {
+    kWKBundleHitTestResultMediaTypeNone,
+    kWKBundleHitTestResultMediaTypeAudio,
+    kWKBundleHitTestResultMediaTypeVideo
+};
+typedef uint32_t WKBundleHitTestResultMediaType;
+
 WK_EXPORT WKTypeID WKBundleHitTestResultGetTypeID();
 
 WK_EXPORT WKBundleNodeHandleRef WKBundleHitTestResultCopyNodeHandle(WKBundleHitTestResultRef hitTestResult);
@@ -45,6 +52,7 @@ WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsolutePDFURL(WKBundleHitTestResult
 WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteLinkURL(WKBundleHitTestResultRef hitTestResult);
 WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteMediaURL(WKBundleHitTestResultRef hitTestResult);
 WK_EXPORT bool WKBundleHitTestResultMediaIsInFullscreen(WKBundleHitTestResultRef hitTestResult);
+WK_EXPORT WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResult);
 
 WK_EXPORT WKRect WKBundleHitTestResultGetImageRect(WKBundleHitTestResultRef hitTestResult);
 WK_EXPORT bool WKBundleHitTestResultGetIsSelected(WKBundleHitTestResultRef hitTestResult);
index ddc38cb..1f46041 100644 (file)
@@ -30,6 +30,7 @@
 #include "WebFrame.h"
 #include "WebFrameLoaderClient.h"
 #include <WebCore/Document.h>
+#include <WebCore/Element.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameLoader.h>
 #include <WebCore/FrameView.h>
@@ -103,6 +104,18 @@ bool InjectedBundleHitTestResult::mediaIsInFullscreen() const
     return m_hitTestResult.mediaIsInFullscreen();
 }
 
+BundleHitTestResultMediaType InjectedBundleHitTestResult::getMediaType() const
+{
+    WebCore::Node* node = m_hitTestResult.innerNonSharedNode();
+    if (!node->isElementNode())
+        return BundleHitTestResultMediaTypeNone;
+    
+    if (!toElement(node)->isMediaElement())
+        return BundleHitTestResultMediaTypeNone;
+    
+    return m_hitTestResult.mediaIsVideo() ? BundleHitTestResultMediaTypeVideo : BundleHitTestResultMediaTypeAudio;    
+}
+
 String InjectedBundleHitTestResult::linkLabel() const
 {
     return m_hitTestResult.textContent();
index 6537595..eeb0f41 100644 (file)
@@ -27,6 +27,7 @@
 #define InjectedBundleHitTestResult_h
 
 #include "APIObject.h"
+#include "InjectedBundleHitTestResultMediaType.h"
 #include <WebCore/HitTestResult.h>
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
@@ -52,6 +53,7 @@ public:
     String absoluteLinkURL() const;
     String absoluteMediaURL() const;
     bool mediaIsInFullscreen() const;
+    BundleHitTestResultMediaType getMediaType() const;
 
     String linkLabel() const;
     String linkTitle() const;
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResultMediaType.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResultMediaType.h
new file mode 100644 (file)
index 0000000..ffc21d9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+#ifndef InjectedBundleHitTestResultMediaType_h
+#define InjectedBundleHitTestResultMediaType_h
+
+namespace WebKit {
+
+enum BundleHitTestResultMediaType {
+    BundleHitTestResultMediaTypeNone,
+    BundleHitTestResultMediaTypeAudio,
+    BundleHitTestResultMediaTypeVideo
+};
+
+} // namespace WebKit
+
+#endif // InjectedBundleHitTestResultMediaType_h