Source/WebKit2: Added WKHitTestResult API's.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2011 20:16:58 +0000 (20:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2011 20:16:58 +0000 (20:16 +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-20
Reviewed by Anders Carlsson.

* GNUmakefile.am:
* Shared/API/c/WKHitTestResult.cpp: Copied from Source/WebKit2/UIProcess/API/C/WebKit2.h.
(WKHitTestResultGetTypeID):
(WKHitTestResultCopyAbsoluteImageURL):
(WKHitTestResultCopyAbsoluteLinkURL):
(WKHitTestResultCopyAbsoluteMediaURL):
(WKHitTestResultCopyLinkLabel):
(WKHitTestResultCopyLinkTitle):
* Shared/API/c/WKHitTestResult.h: Copied from Source/WebKit2/UIProcess/API/C/WebKit2.h.
* UIProcess/API/C/WebKit2.h:

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-20
Reviewed by Anders Carlsson.

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

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

Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/Shared/API/c/WKHitTestResult.cpp [new file with mode: 0644]
Source/WebKit2/Shared/API/c/WKHitTestResult.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WebKit2.h
Tools/ChangeLog
Tools/MiniBrowser/gtk/BrowserWindow.c

index f6010eb..15f6027 100644 (file)
@@ -1,3 +1,25 @@
+2011-09-20  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.
+
+        * GNUmakefile.am:
+        * Shared/API/c/WKHitTestResult.cpp: Copied from Source/WebKit2/UIProcess/API/C/WebKit2.h.
+        (WKHitTestResultGetTypeID):
+        (WKHitTestResultCopyAbsoluteImageURL):
+        (WKHitTestResultCopyAbsoluteLinkURL):
+        (WKHitTestResultCopyAbsoluteMediaURL):
+        (WKHitTestResultCopyLinkLabel):
+        (WKHitTestResultCopyLinkTitle):
+        * Shared/API/c/WKHitTestResult.h: Copied from Source/WebKit2/UIProcess/API/C/WebKit2.h.
+        * UIProcess/API/C/WebKit2.h:
+
 2011-09-20  Alexis Menard  <alexis.menard@openbossa.org>
 
         [Qt][WK2] Add stubs for FULLSCREEN_API on Qt.
index e9f7e2e..ff16658 100644 (file)
@@ -13,6 +13,7 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_HEA
        $(WebKit2)/Shared/API/c/WKFindOptions.h \
        $(WebKit2)/Shared/API/c/WKGeometry.h \
        $(WebKit2)/Shared/API/c/WKGraphicsContext.h \
+       $(WebKit2)/Shared/API/c/WKHitTestResult.h \
        $(WebKit2)/Shared/API/c/WKImage.h \
        $(WebKit2)/Shared/API/c/WKMutableArray.h \
        $(WebKit2)/Shared/API/c/WKMutableDictionary.h \
@@ -222,6 +223,8 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
        Source/WebKit2/Shared/API/c/WKGeometry.h \
        Source/WebKit2/Shared/API/c/WKGraphicsContext.cpp \
        Source/WebKit2/Shared/API/c/WKGraphicsContext.h \
+       Source/WebKit2/Shared/API/c/WKHitTestResult.cpp \
+       Source/WebKit2/Shared/API/c/WKHitTestResult.h \
        Source/WebKit2/Shared/API/c/WKImage.cpp \
        Source/WebKit2/Shared/API/c/WKImage.h \
        Source/WebKit2/Shared/API/c/WKMutableArray.cpp \
diff --git a/Source/WebKit2/Shared/API/c/WKHitTestResult.cpp b/Source/WebKit2/Shared/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/Shared/API/c/WKHitTestResult.h b/Source/WebKit2/Shared/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 2d471f5..cf1b3d1 100644 (file)
@@ -1,3 +1,16 @@
+2011-09-20  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-20  Leandro Pereira  <leandro@profusion.mobi>
 
         Changelog class should have a method to return all entries
index d5d41f0..437bede 100644 (file)
@@ -592,18 +592,16 @@ 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);
     gtk_statusbar_push(GTK_STATUSBAR(window->statusBar), window->statusBarContextId, link);
     g_free(link);
 }