diff options
Diffstat (limited to 'WebCore/bindings/gobject')
-rw-r--r-- | WebCore/bindings/gobject/ConvertToUTF8String.cpp | 39 | ||||
-rw-r--r-- | WebCore/bindings/gobject/ConvertToUTF8String.h | 34 | ||||
-rw-r--r-- | WebCore/bindings/gobject/WebKitDOMBinding.cpp | 90 | ||||
-rw-r--r-- | WebCore/bindings/gobject/WebKitDOMBinding.h | 44 | ||||
-rw-r--r-- | WebCore/bindings/gobject/WebKitDOMObject.cpp | 23 | ||||
-rw-r--r-- | WebCore/bindings/gobject/WebKitDOMObject.h | 58 |
6 files changed, 288 insertions, 0 deletions
diff --git a/WebCore/bindings/gobject/ConvertToUTF8String.cpp b/WebCore/bindings/gobject/ConvertToUTF8String.cpp new file mode 100644 index 0000000..57010fa --- /dev/null +++ b/WebCore/bindings/gobject/ConvertToUTF8String.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + * Copyright (C) 2010 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 "ConvertToUTF8String.h" + +#include "KURL.h" +#include "PlatformString.h" +#include <wtf/text/CString.h> + +#include <glib.h> + +gchar* convertToUTF8String(WebCore::String const& s) +{ + return g_strdup(s.utf8().data()); +} + +gchar* convertToUTF8String(WebCore::KURL const& s) +{ + return g_strdup(s.string().utf8().data()); +} + diff --git a/WebCore/bindings/gobject/ConvertToUTF8String.h b/WebCore/bindings/gobject/ConvertToUTF8String.h new file mode 100644 index 0000000..02b6416 --- /dev/null +++ b/WebCore/bindings/gobject/ConvertToUTF8String.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + * Copyright (C) 2010 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 ConvertToUTF8String_h +#define ConvertToUTF8String_h + +namespace WebCore { +class String; +class KURL; +} + +typedef char gchar; + +gchar* convertToUTF8String(WebCore::String const& s); +gchar* convertToUTF8String(WebCore::KURL const& s); + +#endif /* ConvertToUTF8String_h */ diff --git a/WebCore/bindings/gobject/WebKitDOMBinding.cpp b/WebCore/bindings/gobject/WebKitDOMBinding.cpp new file mode 100644 index 0000000..1f900c3 --- /dev/null +++ b/WebCore/bindings/gobject/WebKitDOMBinding.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Samuel Weinig <sam@webkit.org> + * Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + * Copyright (C) 2008 Martin Soto <soto@freedesktop.org> + * Copyright (C) 2009, 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "WebKitDOMBinding.h" + +#include "Event.h" +#include "EventException.h" +#include "HTMLNames.h" +#include "WebKitDOMNode.h" +#include "WebKitDOMNodePrivate.h" + +namespace WebKit { + +using namespace WebCore; +using namespace WebCore::HTMLNames; + +// DOMObjectCache + +typedef HashMap<void*, gpointer> DOMObjectMap; + +static DOMObjectMap& domObjects() +{ + static DOMObjectMap staticDOMObjects; + return staticDOMObjects; +} + +gpointer DOMObjectCache::get(void* objectHandle) +{ + return domObjects().get(objectHandle); +} + +gpointer DOMObjectCache::put(void* objectHandle, gpointer wrapper) +{ + domObjects().set(objectHandle, wrapper); + return wrapper; +} + +void DOMObjectCache::forget(void* objectHandle) +{ + domObjects().take(objectHandle); +} + +// kit methods + +static gpointer createWrapper(Node* node) +{ + ASSERT(node); + + gpointer wrappedNode = 0; + + if (node->nodeType()) + wrappedNode = wrapNode(node); + + return DOMObjectCache::put(node, wrappedNode); +} + +gpointer kit(Node* node) +{ + if (!node) + return 0; + + gpointer kitNode = DOMObjectCache::get(node); + if (kitNode) + return kitNode; + + return createWrapper(node); +} + +} // namespace WebKit diff --git a/WebCore/bindings/gobject/WebKitDOMBinding.h b/WebCore/bindings/gobject/WebKitDOMBinding.h new file mode 100644 index 0000000..f6efa46 --- /dev/null +++ b/WebCore/bindings/gobject/WebKitDOMBinding.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Samuel Weinig <sam@webkit.org> + * Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + * Copyright (C) 2008 Martin Soto <soto@freedesktop.org> + * Copyright (C) 2009-2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef WebKitDOMBinding_h +#define WebKitDOMBinding_h + +#include <glib.h> + +namespace WebCore { +class Node; +} // namespace WebCore + +namespace WebKit { +gpointer kit(WebCore::Node* node); + +class DOMObjectCache { +public: + static gpointer get(void* objectHandle); + static gpointer put(void* objectHandle, gpointer wrapper); + static void forget(void* objectHandle); +}; +} // namespace WebKit + +#endif // WebKitDOMBinding_h diff --git a/WebCore/bindings/gobject/WebKitDOMObject.cpp b/WebCore/bindings/gobject/WebKitDOMObject.cpp new file mode 100644 index 0000000..fc8a874 --- /dev/null +++ b/WebCore/bindings/gobject/WebKitDOMObject.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + * Copyright (C) 2008 Martin Soto <soto@freedesktop.org> + * Copyright (C) 2008 Alp Toker <alp@atoker.com> + * Copyright (C) 2008 Apple Inc. + * Copyright (C) 2009 Igalia S.L. + */ +#include "config.h" +#include "WebKitDOMObject.h" + +#include "glib-object.h" +#include "WebKitDOMBinding.h" + +G_DEFINE_TYPE(WebKitDOMObject, webkit_dom_object, G_TYPE_OBJECT); + +static void webkit_dom_object_init(WebKitDOMObject* object) +{ +} + +static void webkit_dom_object_class_init(WebKitDOMObjectClass* klass) +{ +} + diff --git a/WebCore/bindings/gobject/WebKitDOMObject.h b/WebCore/bindings/gobject/WebKitDOMObject.h new file mode 100644 index 0000000..b99c57c --- /dev/null +++ b/WebCore/bindings/gobject/WebKitDOMObject.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + * Copyright (C) 2008 Martin Soto <soto@freedesktop.org> + * Copyright (C) 2008 Alp Toker <alp@atoker.com> + * Copyright (C) 2008 Apple Inc. + * 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 WebKitDOMObject_h +#define WebKitDOMObject_h + +#include "glib-object.h" +#include "webkit/webkitdomdefines.h" +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_DOM_OBJECT (webkit_dom_object_get_type()) +#define WEBKIT_DOM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_OBJECT, WebKitDOMObject)) +#define WEBKIT_DOM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_OBJECT, WebKitDOMObjectClass)) +#define WEBKIT_IS_DOM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_OBJECT)) +#define WEBKIT_IS_DOM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_OBJECT)) +#define WEBKIT_DOM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_OBJECT, WebKitDOMObjectClass)) + +typedef struct _WebKitDOMObjectPrivate WebKitDOMObjectPrivate; + +struct _WebKitDOMObject { + GObject parentInstance; + + gpointer coreObject; +}; + +struct _WebKitDOMObjectClass { + GObjectClass parentClass; +}; + +WEBKIT_API GType +webkit_dom_object_get_type(void); + +G_END_DECLS + +#endif /* WebKitDOMObject_h */ |