1 | /* |
2 | * Copyright (C) 2018 Igalia S.L. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "config.h" |
21 | #include "WebKitDOMDocument.h" |
22 | |
23 | #include "DOMObjectCache.h" |
24 | #include "WebKitDOMDocumentPrivate.h" |
25 | #include "WebKitDOMNodePrivate.h" |
26 | #include "WebKitDOMPrivate.h" |
27 | |
28 | #if PLATFORM(GTK) |
29 | #include "WebKitDOMEventTarget.h" |
30 | #endif |
31 | |
32 | namespace WebKit { |
33 | |
34 | WebKitDOMDocument* kit(WebCore::Document* obj) |
35 | { |
36 | return WEBKIT_DOM_DOCUMENT(kit(static_cast<WebCore::Node*>(obj))); |
37 | } |
38 | |
39 | WebCore::Document* core(WebKitDOMDocument* document) |
40 | { |
41 | return document ? static_cast<WebCore::Document*>(webkitDOMNodeGetCoreObject(WEBKIT_DOM_NODE(document))) : nullptr; |
42 | } |
43 | |
44 | WebKitDOMDocument* wrapDocument(WebCore::Document* coreObject) |
45 | { |
46 | ASSERT(coreObject); |
47 | #if PLATFORM(GTK) |
48 | return WEBKIT_DOM_DOCUMENT(g_object_new(WEBKIT_DOM_TYPE_DOCUMENT, "core-object" , coreObject, nullptr)); |
49 | #else |
50 | auto* document = WEBKIT_DOM_DOCUMENT(g_object_new(WEBKIT_DOM_TYPE_DOCUMENT, nullptr)); |
51 | webkitDOMNodeSetCoreObject(WEBKIT_DOM_NODE(document), static_cast<WebCore::Node*>(coreObject)); |
52 | return document; |
53 | #endif |
54 | } |
55 | |
56 | } // namespace WebKit |
57 | |
58 | #if PLATFORM(GTK) |
59 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
60 | G_DEFINE_TYPE_WITH_CODE(WebKitDOMDocument, webkit_dom_document, WEBKIT_DOM_TYPE_NODE, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_EVENT_TARGET, webkitDOMDocumentDOMEventTargetInit)) |
61 | G_GNUC_END_IGNORE_DEPRECATIONS; |
62 | #else |
63 | G_DEFINE_TYPE(WebKitDOMDocument, webkit_dom_document, WEBKIT_DOM_TYPE_NODE) |
64 | #endif |
65 | |
66 | static void webkit_dom_document_class_init(WebKitDOMDocumentClass* documentClass) |
67 | { |
68 | #if PLATFORM(GTK) |
69 | GObjectClass* gobjectClass = G_OBJECT_CLASS(documentClass); |
70 | webkitDOMDocumentInstallProperties(gobjectClass); |
71 | #endif |
72 | } |
73 | |
74 | static void webkit_dom_document_init(WebKitDOMDocument*) |
75 | { |
76 | } |
77 | |