Commit 2266a5b0 authored by xan@webkit.org's avatar xan@webkit.org

2009-09-14 Xan Lopez <xlopez@igalia.com>

        Reviewed by Gustavo Noronha and Jan Alonzo.

        [GTK] context menu overriding API is very limited
        https://bugs.webkit.org/show_bug.cgi?id=27546

        Add WebKitHitTestResult to the build.

        * GNUmakefile.am:

WebKit/gtk:

2009-09-18  Xan Lopez  <xlopez@igalia.com>

        Reviewed by Gustavo Noronha and Jan Alonzo.

        [GTK] context menu overriding API is very limited
        https://bugs.webkit.org/show_bug.cgi?id=27546

        Add WebKitHitTestResult, a wrapper over HitTestResult. It contains
        context information about a point in the web page.

        * webkit/webkit.h:
        * webkit/webkitdefines.h:
        * webkit/webkithittestresult.cpp: Added.
        (webkit_hit_test_result_finalize):
        (webkit_hit_test_result_get_property):
        (webkit_hit_test_result_set_property):
        (webkit_hit_test_result_class_init):
        (webkit_hit_test_result_init):
        * webkit/webkithittestresult.h: Added.
        * webkit/webkitprivate.cpp:
        (WebKit::kit):
        * webkit/webkitprivate.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9a2d46fb
2009-09-14 Xan Lopez <xlopez@igalia.com>
Reviewed by Gustavo Noronha and Jan Alonzo.
[GTK] context menu overriding API is very limited
https://bugs.webkit.org/show_bug.cgi?id=27546
Add WebKitHitTestResult to the build.
* GNUmakefile.am:
2009-09-10 Laszlo Gombos <laszlo.1.gombos@nokia.com>
Reviewed by Ariya Hidayat.
......
......@@ -318,6 +318,7 @@ webkitgtk_h_api += \
$(srcdir)/WebKit/gtk/webkit/webkitdefines.h \
$(srcdir)/WebKit/gtk/webkit/webkitdownload.h \
$(srcdir)/WebKit/gtk/webkit/webkiterror.h \
$(srcdir)/WebKit/gtk/webkit/webkithittestresult.h \
$(srcdir)/WebKit/gtk/webkit/webkitnetworkrequest.h \
$(srcdir)/WebKit/gtk/webkit/webkitnetworkresponse.h \
$(srcdir)/WebKit/gtk/webkit/webkitsoupauthdialog.h \
......@@ -362,6 +363,7 @@ webkitgtk_sources += \
WebKit/gtk/webkit/webkitapplicationcache.cpp \
WebKit/gtk/webkit/webkitdownload.cpp \
WebKit/gtk/webkit/webkiterror.cpp \
WebKit/gtk/webkit/webkithittestresult.cpp \
WebKit/gtk/webkit/webkitnetworkrequest.cpp \
WebKit/gtk/webkit/webkitnetworkresponse.cpp \
WebKit/gtk/webkit/webkitprivate.cpp \
......
2009-09-18 Xan Lopez <xlopez@igalia.com>
Reviewed by Gustavo Noronha and Jan Alonzo.
[GTK] context menu overriding API is very limited
https://bugs.webkit.org/show_bug.cgi?id=27546
Add WebKitHitTestResult, a wrapper over HitTestResult. It contains
context information about a point in the web page.
* webkit/webkit.h:
* webkit/webkitdefines.h:
* webkit/webkithittestresult.cpp: Added.
(webkit_hit_test_result_finalize):
(webkit_hit_test_result_get_property):
(webkit_hit_test_result_set_property):
(webkit_hit_test_result_class_init):
(webkit_hit_test_result_init):
* webkit/webkithittestresult.h: Added.
* webkit/webkitprivate.cpp:
(WebKit::kit):
* webkit/webkitprivate.h:
2009-09-14 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Reviewed by Xan Lopez and Jan Alonzo.
......
......@@ -24,6 +24,7 @@
#include <webkit/webkitversion.h>
#include <webkit/webkitdefines.h>
#include <webkit/webkitdownload.h>
#include <webkit/webkithittestresult.h>
#include <webkit/webkitnetworkrequest.h>
#include <webkit/webkitnetworkresponse.h>
#include <webkit/webkitsoupauthdialog.h>
......
......@@ -86,6 +86,9 @@ typedef struct _WebKitWebDatabaseClass WebKitWebDatabaseClass;
typedef struct _WebKitSecurityOrigin WebKitSecurityOrigin;
typedef struct _WebKitSecurityOriginClass WebKitSecurityOriginClass;
typedef struct _WebKitHitTestResult WebKitHitTestResult;
typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass;
G_END_DECLS
#endif
/*
* Copyright (C) 2009 Collabora Ltd.
* Copyright (C) 2009 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "webkithittestresult.h"
#include "CString.h"
#include "GOwnPtr.h"
#include "webkitenumtypes.h"
#include "webkitprivate.h"
#include <glib/gi18n-lib.h>
/**
* SECTION:webkitwebhittestresult
* @short_description: The target of a mouse or keyboard event
*
* #WebKitHitTestResult
*/
G_DEFINE_TYPE(WebKitHitTestResult, webkit_hit_test_result, G_TYPE_OBJECT)
struct _WebKitHitTestResultPrivate {
guint context;
char* linkURI;
char* imageURI;
char* mediaURI;
};
#define WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultPrivate))
enum {
PROP_0,
PROP_CONTEXT,
PROP_LINK_URI,
PROP_IMAGE_URI,
PROP_MEDIA_URI
};
static void webkit_hit_test_result_finalize(GObject* object)
{
WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
g_free(priv->linkURI);
g_free(priv->imageURI);
g_free(priv->mediaURI);
G_OBJECT_CLASS(webkit_hit_test_result_parent_class)->finalize(object);
}
static void webkit_hit_test_result_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* pspec)
{
WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
switch(propertyID) {
case PROP_CONTEXT:
g_value_set_flags(value, priv->context);
break;
case PROP_LINK_URI:
g_value_set_string(value, priv->linkURI);
break;
case PROP_IMAGE_URI:
g_value_set_string(value, priv->imageURI);
break;
case PROP_MEDIA_URI:
g_value_set_string(value, priv->mediaURI);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
}
}
static void webkit_hit_test_result_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* pspec)
{
WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
switch(propertyID) {
case PROP_CONTEXT:
priv->context = g_value_get_flags(value);
break;
case PROP_LINK_URI:
g_free (priv->linkURI);
priv->linkURI = g_value_dup_string(value);
break;
case PROP_IMAGE_URI:
g_free (priv->imageURI);
priv->imageURI = g_value_dup_string(value);
break;
case PROP_MEDIA_URI:
g_free (priv->mediaURI);
priv->mediaURI = g_value_dup_string(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
}
}
static void webkit_hit_test_result_class_init(WebKitHitTestResultClass* webHitTestResultClass)
{
GObjectClass* objectClass = G_OBJECT_CLASS(webHitTestResultClass);
objectClass->finalize = webkit_hit_test_result_finalize;
objectClass->get_property = webkit_hit_test_result_get_property;
objectClass->set_property = webkit_hit_test_result_set_property;
webkit_init();
/**
* WebKitHitTestResult:context:
*
* Flags indicating the kind of target that received the event.
*
* Since: 1.1.15
*/
g_object_class_install_property(objectClass, PROP_CONTEXT,
g_param_spec_flags("context",
_("Context"),
_("Flags indicating the kind of target that received the event."),
WEBKIT_TYPE_HIT_TEST_RESULT_CONTEXT,
WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
static_cast<GParamFlags>((WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY))));
/**
* WebKitHitTestResult:link-uri:
*
* The URI to which the target that received the event points, if any.
*
* Since: 1.1.15
*/
g_object_class_install_property(objectClass, PROP_LINK_URI,
g_param_spec_string("link-uri",
_("Link URI"),
_("The URI to which the target that received the event points, if any."),
NULL,
static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
/**
* WebKitHitTestResult:image-uri:
*
* The URI of the image that is part of the target that received the event, if any.
*
* Since: 1.1.15
*/
g_object_class_install_property(objectClass, PROP_IMAGE_URI,
g_param_spec_string("image-uri",
_("Image URI"),
_("The URI of the image that is part of the target that received the event, if any."),
NULL,
static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
/**
* WebKitHitTestResult:media-uri:
*
* The URI of the media that is part of the target that received the event, if any.
*
* Since: 1.1.15
*/
g_object_class_install_property(objectClass, PROP_MEDIA_URI,
g_param_spec_string("media-uri",
_("Media URI"),
_("The URI of the media that is part of the target that received the event, if any."),
NULL,
static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
g_type_class_add_private(webHitTestResultClass, sizeof(WebKitHitTestResultPrivate));
}
static void webkit_hit_test_result_init(WebKitHitTestResult* web_hit_test_result)
{
web_hit_test_result->priv = WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(web_hit_test_result);
}
/*
* Copyright (C) 2009 Collabora Ltd.
* Copyright (C) 2009 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef WEBKIT_HIT_TEST_RESULT_H
#define WEBKIT_HIT_TEST_RESULT_H
#include <glib-object.h>
#include <webkit/webkitdefines.h>
G_BEGIN_DECLS
#define WEBKIT_TYPE_HIT_TEST_RESULT (webkit_hit_test_result_get_type())
#define WEBKIT_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResult))
#define WEBKIT_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultClass))
#define WEBKIT_IS_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_HIT_TEST_RESULT))
#define WEBKIT_IS_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_HIT_TEST_RESULT))
#define WEBKIT_HIT_TEST_RESULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_HIT_TEST_RESULT, WebKitHitTestResultClass))
typedef struct _WebKitHitTestResultPrivate WebKitHitTestResultPrivate;
struct _WebKitHitTestResult {
GObject parent_instance;
/*< private >*/
WebKitHitTestResultPrivate *priv;
};
struct _WebKitHitTestResultClass {
GObjectClass parent_class;
/* Padding for future expansion */
void (*_webkit_reserved0) (void);
void (*_webkit_reserved1) (void);
void (*_webkit_reserved2) (void);
void (*_webkit_reserved3) (void);
};
/**
* WebKitHitTestResultContext
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT: anywhere in the document.
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK: a hyperlink element.
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE: an image element.
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA: a video or audio element.
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION: the area is selected by
* the user.
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE: the area is
* editable by the user.
*/
typedef enum
{
WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT = 1 << 1,
WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK = 1 << 2,
WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE = 1 << 3,
WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4,
WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION = 1 << 5,
WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 6,
} WebKitHitTestResultContext;
WEBKIT_API GType
webkit_hit_test_result_get_type (void);
G_END_DECLS
#endif
......@@ -27,6 +27,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClientGtk.h"
#include "HitTestResult.h"
#include <libintl.h>
#include "Logging.h"
#include "PageCache.h"
......@@ -116,6 +117,42 @@ WebCore::EditingBehavior core(WebKitEditingBehavior type)
return (WebCore::EditingBehavior)type;
}
WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
{
guint context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
GOwnPtr<char> linkURI(0);
GOwnPtr<char> imageURI(0);
GOwnPtr<char> mediaURI(0);
if (!result.absoluteLinkURL().isEmpty()) {
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
linkURI.set(g_strdup(result.absoluteLinkURL().string().utf8().data()));
}
if (!result.absoluteImageURL().isEmpty()) {
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
imageURI.set(g_strdup(result.absoluteImageURL().string().utf8().data()));
}
if (!result.absoluteMediaURL().isEmpty()) {
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
mediaURI.set(g_strdup(result.absoluteMediaURL().string().utf8().data()));
}
if (result.isSelected())
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION;
if (result.isContentEditable())
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
"link-uri", linkURI.get(),
"image-uri", imageURI.get(),
"media-uri", mediaURI.get(),
"context", context,
NULL));
}
} /** end namespace WebKit */
namespace WTF {
......
......@@ -30,6 +30,7 @@
#include <webkit/webkitdefines.h>
#include <webkit/webkitdownload.h>
#include <webkit/webkithittestresult.h>
#include <webkit/webkitnetworkrequest.h>
#include <webkit/webkitwebview.h>
#include <webkit/webkitwebdatasource.h>
......@@ -94,6 +95,8 @@ namespace WebKit {
WebKitSecurityOrigin* kit(WebCore::SecurityOrigin*);
WebCore::SecurityOrigin* core(WebKitSecurityOrigin*);
WebKitHitTestResult* kit(const WebCore::HitTestResult&);
}
typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment