Source/WebKit2: Added WKHitTestResult API's.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 22:00:06 +0000 (22:00 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 22:00:06 +0000 (22:00 +0000)
WKHitTestResult API's are added. These API's can be used to
get the hover'ed link/image/media URL as well as link lable and
title.
https://bugs.webkit.org/show_bug.cgi?id=68426

Patch by Nayan Kumar K <nayankk@motorola.com> on 2011-09-26
Reviewed by Anders Carlsson.

* CMakeLists.txt:
* GNUmakefile.am:
* UIProcess/API/C/WKHitTestResult.cpp: Added.
(WKHitTestResultGetTypeID):
(WKHitTestResultCopyAbsoluteImageURL):
(WKHitTestResultCopyAbsoluteLinkURL):
(WKHitTestResultCopyAbsoluteMediaURL):
(WKHitTestResultCopyLinkLabel):
(WKHitTestResultCopyLinkTitle):
* UIProcess/API/C/WKHitTestResult.h: Added.
* UIProcess/API/C/WebKit2.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebKit2API.pri:
* win/WebKit2.vcproj:
* win/WebKit2Generated.make:

Tools: Get hover'ed element URL from HitTest.

mouseDidMoveOverElement now gets the hover'ed element link using
WKHitTestResult API's.
https://bugs.webkit.org/show_bug.cgi?id=68426

Patch by Nayan Kumar K <nayankk@motorola.com> on 2011-09-26
Reviewed by Anders Carlsson.

* MiniBrowser/gtk/BrowserWindow.c:
(mouseDidMoveOverElement):

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

12 files changed:
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKHitTestResult.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WebKit2.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebKit2API.pri
Source/WebKit2/win/WebKit2.vcproj
Source/WebKit2/win/WebKit2Generated.make
Tools/ChangeLog
Tools/MiniBrowser/gtk/BrowserWindow.c

index dcbf796..54b4d83 100644 (file)
@@ -191,6 +191,7 @@ SET(WebKit2_SOURCES
     UIProcess/API/C/WKFormSubmissionListener.cpp
     UIProcess/API/C/WKFrame.cpp
     UIProcess/API/C/WKFramePolicyListener.cpp
+    UIProcess/API/C/WKHitTestResult.cpp
     UIProcess/API/C/WKIconDatabase.cpp
     UIProcess/API/C/WKInspector.cpp
     UIProcess/API/C/WKKeyValueStorageManager.cpp
index caf3b1f..3e07c45 100644 (file)
@@ -1,3 +1,30 @@
+2011-09-26  Nayan Kumar K  <nayankk@motorola.com>
+
+        Added WKHitTestResult API's.
+
+        WKHitTestResult API's are added. These API's can be used to
+        get the hover'ed link/image/media URL as well as link lable and
+        title.
+        https://bugs.webkit.org/show_bug.cgi?id=68426
+
+        Reviewed by Anders Carlsson.
+
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * UIProcess/API/C/WKHitTestResult.cpp: Added.
+        (WKHitTestResultGetTypeID):
+        (WKHitTestResultCopyAbsoluteImageURL):
+        (WKHitTestResultCopyAbsoluteLinkURL):
+        (WKHitTestResultCopyAbsoluteMediaURL):
+        (WKHitTestResultCopyLinkLabel):
+        (WKHitTestResultCopyLinkTitle):
+        * UIProcess/API/C/WKHitTestResult.h: Added.
+        * UIProcess/API/C/WebKit2.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebKit2API.pri:
+        * win/WebKit2.vcproj:
+        * win/WebKit2Generated.make:
+
 2011-09-26  Csaba Osztrogonác  <ossy@webkit.org>
 
         [Qt][WK2]Unreviewed speculative buildfix after r95968.
index 02591b0..c6018fb 100644 (file)
@@ -48,6 +48,7 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_HEA
        $(WebKit2)/UIProcess/API/C/WKFormSubmissionListener.h \
        $(WebKit2)/UIProcess/API/C/WKFrame.h \
        $(WebKit2)/UIProcess/API/C/WKFramePolicyListener.h \
+       $(WebKit2)/UIProcess/API/C/WKHitTestResult.h \
        $(WebKit2)/UIProcess/API/C/WKInspector.h \
        $(WebKit2)/UIProcess/API/C/WKKeyValueStorageManager.h \
        $(WebKit2)/UIProcess/API/C/WKMediaCacheManager.h \
@@ -413,6 +414,8 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
        Source/WebKit2/UIProcess/API/C/WKFrame.h \
        Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp \
        Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h \
+       Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp \
+       Source/WebKit2/UIProcess/API/C/WKHitTestResult.h \
        Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp \
        Source/WebKit2/UIProcess/API/C/WKIconDatabase.h \
        Source/WebKit2/UIProcess/API/C/WKInspector.cpp \
diff --git a/Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp b/Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp
new file mode 100644 (file)
index 0000000..b222d41
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, 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.
+ */
+
+#include "config.h"
+#include "WKHitTestResult.h"
+
+#include "WKAPICast.h"
+#include "WebHitTestResult.h"
+
+using namespace WebKit;
+
+WKTypeID WKHitTestResultGetTypeID()
+{
+    return toAPI(WebHitTestResult::APIType);
+}
+
+WKURLRef WKHitTestResultCopyAbsoluteImageURL(WKHitTestResultRef hitTestResultRef)
+{
+    return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteImageURL());
+}
+
+WKURLRef WKHitTestResultCopyAbsoluteLinkURL(WKHitTestResultRef hitTestResultRef)
+{
+    return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteLinkURL());
+}
+
+WKURLRef WKHitTestResultCopyAbsoluteMediaURL(WKHitTestResultRef hitTestResultRef)
+{
+    return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteMediaURL());
+}
+
+WKStringRef WKHitTestResultCopyLinkLabel(WKHitTestResultRef hitTestResultRef)
+{
+    return toCopiedAPI(toImpl(hitTestResultRef)->linkLabel());
+}
+
+WKStringRef WKHitTestResultCopyLinkTitle(WKHitTestResultRef hitTestResultRef)
+{
+    return toCopiedAPI(toImpl(hitTestResultRef)->linkTitle());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKHitTestResult.h b/Source/WebKit2/UIProcess/API/C/WKHitTestResult.h
new file mode 100644 (file)
index 0000000..aa6e64f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, 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 WKHitTestResult_h
+#define WKHitTestResult_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKHitTestResultGetTypeID();
+
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteImageURL(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteLinkURL(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteMediaURL(WKHitTestResultRef hitTestResult);
+
+WK_EXPORT WKStringRef WKHitTestResultCopyLinkLabel(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKStringRef WKHitTestResultCopyLinkTitle(WKHitTestResultRef hitTestResult);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKHitTestResult_h */
index 47d7c7b..ae1135a 100644 (file)
@@ -43,6 +43,7 @@
 #include <WebKit2/WKGeolocationPermissionRequest.h>
 #include <WebKit2/WKGeolocationPosition.h>
 #include <WebKit2/WKGraphicsContext.h>
+#include <WebKit2/WKHitTestResult.h>
 #include <WebKit2/WKMutableArray.h>
 #include <WebKit2/WKMutableDictionary.h>
 #include <WebKit2/WKNavigationData.h>
index 207d536..5615695 100644 (file)
                93FC67BE12D3CCF200A60610 /* DecoderAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FC679E12D3CC7400A60610 /* DecoderAdapter.h */; };
                93FC67BF12D3CCF200A60610 /* EncoderAdapter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93FC679F12D3CC7400A60610 /* EncoderAdapter.cpp */; };
                93FC67C012D3CCF200A60610 /* EncoderAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FC67A012D3CC7400A60610 /* EncoderAdapter.h */; };
+               B62E7310143047A60069EC35 /* WKHitTestResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B62E730F143047A60069EC35 /* WKHitTestResult.cpp */; };
+               B62E7312143047B00069EC35 /* WKHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B62E7311143047B00069EC35 /* WKHitTestResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
                B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = B878B613133428DC006888E9 /* CorrectionPanel.h */; };
                B878B616133428DC006888E9 /* CorrectionPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = B878B614133428DC006888E9 /* CorrectionPanel.mm */; };
                BC0092F7115837A300E0AE2A /* RunLoopMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0092F5115837A300E0AE2A /* RunLoopMac.mm */; };
                93FC67A012D3CC7400A60610 /* EncoderAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EncoderAdapter.h; sourceTree = "<group>"; };
                A72D5D7F1236CBA800A88B15 /* WebSerializedScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSerializedScriptValue.h; sourceTree = "<group>"; };
                B396EA5512E0ED2D00F4FEB7 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
+               B62E730F143047A60069EC35 /* WKHitTestResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKHitTestResult.cpp; sourceTree = "<group>"; };
+               B62E7311143047B00069EC35 /* WKHitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHitTestResult.h; sourceTree = "<group>"; };
                B878B613133428DC006888E9 /* CorrectionPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorrectionPanel.h; sourceTree = "<group>"; };
                B878B614133428DC006888E9 /* CorrectionPanel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CorrectionPanel.mm; sourceTree = "<group>"; };
                BC0092F5115837A300E0AE2A /* RunLoopMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RunLoopMac.mm; sourceTree = "<group>"; };
                BC0C376610F807660076D7CB /* C */ = {
                        isa = PBXGroup;
                        children = (
+                               B62E7311143047B00069EC35 /* WKHitTestResult.h */,
+                               B62E730F143047A60069EC35 /* WKHitTestResult.cpp */,
                                5123CF18133D25E60056F800 /* cg */,
                                6EE849C41368D9040038D481 /* mac */,
                                BCB63477116BF10600603215 /* WebKit2.h */,
                                1A2BB6D114117B4D000F35D4 /* PluginProcessConnectionMessages.h in Headers */,
                                7801C09A142290C400FAF9AF /* WebHitTestResult.h in Headers */,
                                0F174AA3142A4CB70039250F /* WebGeometry.h in Headers */,
+                               B62E7312143047B00069EC35 /* WKHitTestResult.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1A2BB6D014117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp in Sources */,
                                7801C099142290C400FAF9AF /* WebHitTestResult.cpp in Sources */,
                                0F174AA7142AAC610039250F /* WKGeometry.cpp in Sources */,
+                               B62E7310143047A60069EC35 /* WKHitTestResult.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 0dc1d39..0b2aaff 100644 (file)
@@ -34,6 +34,7 @@ WEBKIT2_API_SOURCES = \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp \
+    $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKHitTestResult.cpp \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKIconDatabase.cpp \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKInspector.cpp \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp \
@@ -108,6 +109,7 @@ WEBKIT2_API_HEADERS += \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKGeolocationManager.h \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKGeolocationPosition.h \
+    $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKHitTestResult.h \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKIconDatabase.h \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKInspector.h \
     $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h \
index 1f78ab3..4d91818 100755 (executable)
                                                >
                                        </File>
                                        <File
+                                               RelativePath="..\UIProcess\API\C\WKHitTestResult.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\UIProcess\API\C\WKHitTestResult.h"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\UIProcess\API\C\WKIconDatabase.cpp"
                                                >
                                        </File>
index 12cc120..830bb18 100644 (file)
@@ -63,6 +63,7 @@ all:
     xcopy /y /d "..\UIProcess\API\C\WKGeolocationManager.h" "%ConfigurationBuildDir%\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKGeolocationPermissionRequest.h" "%ConfigurationBuildDir%\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKGeolocationPosition.h" "%ConfigurationBuildDir%\include\WebKit2"
+    xcopy /y /d "..\UIProcess\API\C\WKHitTestResult.h" "%ConfigurationBuildDir%\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKInspector.h" "%ConfigurationBuildDir%\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKIconDatabase.h" "%ConfigurationBuildDir%\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKKeyValueStorageManager.h" "%ConfigurationBuildDir%\include\WebKit2"
index 54eaadb..f2ce5f7 100644 (file)
@@ -1,3 +1,16 @@
+2011-09-26  Nayan Kumar K  <nayankk@motorola.com>
+
+        Get hover'ed element URL from HitTest.
+
+        mouseDidMoveOverElement now gets the hover'ed element link using
+        WKHitTestResult API's.
+        https://bugs.webkit.org/show_bug.cgi?id=68426 
+
+        Reviewed by Anders Carlsson.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (mouseDidMoveOverElement):
+
 2011-09-26  David Levin  <levin@chromium.org>
 
         Add skeleton parsing for a WatchList.
index d5d41f0..991e445 100644 (file)
@@ -592,18 +592,17 @@ static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKSt
     return returnValue;
 }
 
-static void mouseDidMoveOverElement(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo)
+static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo)
 {
     BrowserWindow *window = BROWSER_WINDOW(clientInfo);
     gtk_statusbar_pop(GTK_STATUSBAR(window->statusBar), window->statusBarContextId);
 
-    if (!userData)
+    WKURLRef linkUrlRef = WKHitTestResultCopyAbsoluteLinkURL(hitTestResult);
+    if (!linkUrlRef)
         return;
 
-    if (WKGetTypeID(userData) != WKURLGetTypeID())
-        return;
-
-    gchar *link = WKURLGetCString((WKURLRef)userData);
+    gchar *link = WKURLGetCString(linkUrlRef);
+    WKRelease(linkUrlRef);
     gtk_statusbar_push(GTK_STATUSBAR(window->statusBar), window->statusBarContextId, link);
     g_free(link);
 }