Skip to content

Commit

Permalink
[GTK][WPE] Deprecate WebKitDOMDocument
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=248520

Reviewed by Žan Doberšek.

All methods and properties are deprecated and the js value can be obtained with JSC API.

* Source/WebKit/WebProcess/InjectedBundle/API/glib/DOM/WebKitDOMDocument.cpp:
* Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebEditor.cpp:
* Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp:
* Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebPage.h.in:
* Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.h:
* Source/WebKit/WebProcess/InjectedBundle/API/wpe/DOM/WebKitDOMDocument.h:
* Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp:
(WebKitFrameTest::testJavaScriptValues):
* Tools/TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:
(documentLoadedCallback):
(methodCallCallback):
* Tools/TestWebKitAPI/Tests/WebKitGtk/AutocleanupsTest.cpp:
(AutocleanupsTest::testWebProcessAutocleanups):

Canonical link: https://commits.webkit.org/257225@main
  • Loading branch information
carlosgcampos committed Dec 1, 2022
1 parent 4ef0417 commit decc637
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 10 deletions.
Expand Up @@ -29,6 +29,8 @@
#include "WebKitDOMEventTarget.h"
#endif

G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

namespace WebKit {

WebKitDOMDocument* kit(WebCore::Document* obj)
Expand Down Expand Up @@ -56,9 +58,7 @@ WebKitDOMDocument* wrapDocument(WebCore::Document* coreObject)
} // namespace WebKit

#if PLATFORM(GTK)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
G_DEFINE_TYPE_WITH_CODE(WebKitDOMDocument, webkit_dom_document, WEBKIT_DOM_TYPE_NODE, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_EVENT_TARGET, webkitDOMDocumentDOMEventTargetInit))
G_GNUC_END_IGNORE_DEPRECATIONS;
#else
G_DEFINE_TYPE(WebKitDOMDocument, webkit_dom_document, WEBKIT_DOM_TYPE_NODE)
#endif
Expand All @@ -74,3 +74,5 @@ static void webkit_dom_document_class_init(WebKitDOMDocumentClass* documentClass
static void webkit_dom_document_init(WebKitDOMDocument*)
{
}

G_GNUC_END_IGNORE_DEPRECATIONS;
Expand Up @@ -102,8 +102,7 @@ WebKitWebEditor* webkitWebEditorCreate(WebKitWebPage* webPage)
* webkit_web_editor_get_page:
* @editor: a #WebKitWebEditor
*
* Gets the #WebKitWebPage that is associated with the #WebKitWebEditor that can
* be used to access the #WebKitDOMDocument currently loaded into it.
* Gets the #WebKitWebPage that is associated with the #WebKitWebEditor.
*
* Returns: (transfer none): the associated #WebKitWebPage
*
Expand Down
Expand Up @@ -658,6 +658,8 @@ void webkitWebPageDidReceiveUserMessage(WebKitWebPage* webPage, UserMessage&& me
*
* Returns: (transfer none): the #WebKitDOMDocument currently loaded, or %NULL
* if no document is currently loaded.
*
* Deprecated: 2.40. Use JavaScriptCore API instead.
*/
WebKitDOMDocument* webkit_web_page_get_dom_document(WebKitWebPage* webPage)
{
Expand Down
Expand Up @@ -81,7 +81,7 @@ struct _WebKitWebPageClass {
WEBKIT_API GType
webkit_web_page_get_type (void);

WEBKIT_API WebKitDOMDocument *
WEBKIT_DEPRECATED WebKitDOMDocument *
webkit_web_page_get_dom_document (WebKitWebPage *web_page);

WEBKIT_API guint64
Expand Down
Expand Up @@ -45,7 +45,7 @@ struct _WebKitDOMDocumentClass {
WebKitDOMNodeClass parent_class;
};

WEBKIT_API GType
WEBKIT_DEPRECATED GType
webkit_dom_document_get_type(void);

/**
Expand Down
Expand Up @@ -48,7 +48,7 @@ struct _WebKitDOMDocumentClass {
WebKitDOMNodeClass parent_class;
};

WEBKIT_API GType
WEBKIT_DEPRECATED GType
webkit_dom_document_get_type(void);

G_END_DECLS
Expand Down
2 changes: 2 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp
Expand Up @@ -72,9 +72,11 @@ class WebKitFrameTest : public WebProcessTest {
g_assert_true(JSC_IS_CONTEXT(jsContext.get()));
assertObjectIsDeletedWhenTestFinishes(G_OBJECT(jsContext.get()));

G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
g_assert_true(WEBKIT_DOM_IS_DOCUMENT(document));
assertObjectIsDeletedWhenTestFinishes(G_OBJECT(document));
G_GNUC_END_IGNORE_DEPRECATIONS;

GRefPtr<JSCValue> jsDocument = adoptGRef(webkit_frame_get_js_value_for_dom_object(frame, WEBKIT_DOM_OBJECT(document)));
g_assert_true(JSC_IS_VALUE(jsDocument.get()));
Expand Down
5 changes: 2 additions & 3 deletions Tools/TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp
Expand Up @@ -160,8 +160,8 @@ static void emitDocumentLoaded(GDBusConnection* connection)
static void documentLoadedCallback(WebKitWebPage* webPage, WebKitWebExtension* extension)
{
#if PLATFORM(GTK)
WebKitDOMDocument* document = webkit_web_page_get_dom_document(webPage);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
WebKitDOMDocument* document = webkit_web_page_get_dom_document(webPage);
GRefPtr<WebKitDOMDOMWindow> window = adoptGRef(webkit_dom_document_get_default_view(document));
webkit_dom_dom_window_webkit_message_handlers_post_message(window.get(), "dom", "DocumentLoaded");
G_GNUC_END_IGNORE_DEPRECATIONS;
Expand Down Expand Up @@ -593,10 +593,9 @@ static void methodCallCallback(GDBusConnection* connection, const char* sender,
if (!page)
return;

WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
WebKitFrame* frame = webkit_web_page_get_main_frame(page);
GRefPtr<JSCContext> jsContext = adoptGRef(webkit_frame_get_js_context(frame));
GRefPtr<JSCValue> jsDocument = adoptGRef(webkit_frame_get_js_value_for_dom_object(frame, WEBKIT_DOM_OBJECT(document)));
GRefPtr<JSCValue> jsDocument = adoptGRef(jsc_context_get_value(jsContext.get(), "document"));
GRefPtr<JSCValue> jsInputElement = adoptGRef(jsc_value_object_invoke_method(jsDocument.get(), "getElementById", G_TYPE_STRING, elementID, G_TYPE_NONE));
WebKitDOMNode* node = webkit_dom_node_for_js_value(jsInputElement.get());
gboolean isUserEdited = webkit_dom_element_html_input_element_is_user_edited(WEBKIT_DOM_ELEMENT(node));
Expand Down
2 changes: 2 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitGtk/AutocleanupsTest.cpp
Expand Up @@ -42,8 +42,10 @@ class AutocleanupsTest : public WebProcessTest {
assertObjectIsDeletedWhenTestFinishes(G_OBJECT(page));

// Transfer none
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_autoptr(WebKitDOMDocument) document = WEBKIT_DOM_DOCUMENT(g_object_ref(G_OBJECT(webkit_web_page_get_dom_document(page))));
g_assert_true(WEBKIT_DOM_IS_DOCUMENT(document));
G_GNUC_END_IGNORE_DEPRECATIONS;
assertObjectIsDeletedWhenTestFinishes(G_OBJECT(document));

// Transfer full
Expand Down

0 comments on commit decc637

Please sign in to comment.