<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[187024] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/187024">187024</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-07-20 10:42:01 -0700 (Mon, 20 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Add selection-changed signal to the WebKit2 API
https://bugs.webkit.org/show_bug.cgi?id=137116
Patch by Tomas Popela <tpopela@redhat.com> on 2015-07-20
Reviewed by Carlos Garcia Campos.
Source/WebKit2:
Add a new object WebKitWebEditor where the editing capabilities of a
WebPage will be grouped and exposed. Add the selection-changed signal
there (we used the same name as in WK1 API).
* PlatformGTK.cmake:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp: Added.
(didChangeSelection):
(webkitWebEditorCreate):
(webkit_web_editor_get_page):
* WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h: Added.
* WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h: Added.
* WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
(webkitWebPageGetPage):
(webkit_web_page_get_editor):
* WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h:
* WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h:
* WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h:
Tools:
Add a new WebProcess test TestEditor that is testing the WebKitWebEditor
(namely the selection-changed signal).
* TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
* TestWebKitAPI/Tests/WebKit2Gtk/EditorTest.cpp: Added.
(WebKitWebEditorTest::create):
(WebKitWebEditorTest::selectionChangedCallback):
(WebKitWebEditorTest::testSelectionSelectAll):
(WebKitWebEditorTest::testSelectionCollapse):
(WebKitWebEditorTest::testSelectionModifyMove):
(WebKitWebEditorTest::testSelectionModifyExtend):
(WebKitWebEditorTest::testSelectionUnselect):
(registerTests):
* TestWebKitAPI/Tests/WebKit2Gtk/TestEditor.cpp: Added.
(testWebKitWebEditorSelectionChanged):
(beforeAll):
(afterAll):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebPagecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebPageh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebPagePrivateh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIgtkwebkitwebextensionh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebEditorcpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebEditorh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebEditorPrivateh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkEditorTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/EditorTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestEditorcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestEditor.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Source/WebKit2/ChangeLog        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2015-07-20 Tomas Popela <tpopela@redhat.com>
+
+ [GTK] Add selection-changed signal to the WebKit2 API
+ https://bugs.webkit.org/show_bug.cgi?id=137116
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add a new object WebKitWebEditor where the editing capabilities of a
+ WebPage will be grouped and exposed. Add the selection-changed signal
+ there (we used the same name as in WK1 API).
+
+ * PlatformGTK.cmake:
+ * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp: Added.
+ (didChangeSelection):
+ (webkitWebEditorCreate):
+ (webkit_web_editor_get_page):
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h: Added.
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h: Added.
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
+ (webkitWebPageGetPage):
+ (webkit_web_page_get_editor):
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h:
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h:
+ * WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h:
+
</ins><span class="cx"> 2015-07-16 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> WebsiteDataStore operations need to grab background assertions
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -314,6 +314,7 @@
</span><span class="cx">
</span><span class="cx"> WebProcess/InjectedBundle/API/gtk/WebKitFrame.cpp
</span><span class="cx"> WebProcess/InjectedBundle/API/gtk/WebKitScriptWorld.cpp
</span><ins>+ WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp
</ins><span class="cx"> WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp
</span><span class="cx"> WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.cpp
</span><span class="cx"> WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp
</span><span class="lines">@@ -418,6 +419,7 @@
</span><span class="cx"> set(WebKit2WebExtension_INSTALLED_HEADERS
</span><span class="cx"> ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h
</span><span class="cx"> ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk/WebKitScriptWorld.h
</span><ins>+ ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h
</ins><span class="cx"> ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h
</span><span class="cx"> ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.h
</span><span class="cx"> ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -1202,6 +1202,7 @@
</span><span class="cx"> webkit_web_page_get_id
</span><span class="cx"> webkit_web_page_get_uri
</span><span class="cx"> webkit_web_page_get_main_frame
</span><ins>+webkit_web_page_get_editor
</ins><span class="cx">
</span><span class="cx"> <SUBSECTION Standard>
</span><span class="cx"> WebKitWebPageClass
</span><span class="lines">@@ -1218,6 +1219,25 @@
</span><span class="cx"> </SECTION>
</span><span class="cx">
</span><span class="cx"> <SECTION>
</span><ins>+<FILE>WebKitWebEditor</FILE>
+WebKitWebEditor
+webkit_web_editor_get_page
+
+<SUBSECTION Standard>
+WebKitWebEditorClass
+WEBKIT_TYPE_WEB_EDITOR
+WEBKIT_WEB_EDITOR
+WEBKIT_IS_WEB_EDITOR
+WEBKIT_WEB_EDITOR_CLASS
+WEBKIT_IS_WEB_EDITOR_CLASS
+WEBKIT_WEB_EDITOR_GET_CLASS
+
+<SUBSECTION Private>
+WebKitWebEditorPrivate
+webkit_web_editor_get_type
+</SECTION>
+
+<SECTION>
</ins><span class="cx"> <FILE>WebKitFrame</FILE>
</span><span class="cx"> WebKitFrame
</span><span class="cx"> webkit_frame_is_main_frame
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebEditorcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp (0 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp         (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.cpp        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -0,0 +1,124 @@
</span><ins>+/*
+ * Copyright (C) 2015 Red Hat Inc.
+ *
+ * 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,1 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 "WebKitWebEditor.h"
+
+#include "WebKitPrivate.h"
+#include "WebKitWebEditorPrivate.h"
+#include "WebKitWebPagePrivate.h"
+#include "WKBundleAPICast.h"
+
+using namespace WebKit;
+using namespace WebCore;
+
+/**
+ * SECTION: WebKitWebEditor
+ * @Short_description: Access to editing capabilities of a #WebKitWebPage
+ * @Title: WebKitWebEditor
+ * @See_also: #WebKitWebPage
+ *
+ * The WebKitWebEditor provides access to various editing capabilities of
+ * a #WebKitWebPage such as a possibility to react to the current selection in
+ * #WebKitWebPage.
+ *
+ * Since: 2.10
+ */
+enum {
+ SELECTION_CHANGED,
+
+ LAST_SIGNAL
+};
+
+struct _WebKitWebEditorPrivate {
+ WebKitWebPage* webPage;
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+WEBKIT_DEFINE_TYPE(WebKitWebEditor, webkit_web_editor, G_TYPE_OBJECT)
+
+static void webkit_web_editor_class_init(WebKitWebEditorClass* klass)
+{
+ /**
+ * WebKitWebEditor::selection-changed:
+ * @editor: the #WebKitWebEditor on which the signal is emitted
+ *
+ * This signal is emitted for every selection change inside a #WebKitWebPage
+ * as well as for every caret position change as the caret is a collapsed
+ * selection.
+ *
+ * Since: 2.10
+ */
+ signals[SELECTION_CHANGED] = g_signal_new(
+ "selection-changed",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ 0, nullptr, nullptr,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+static void didChangeSelection(WKBundlePageRef, WKStringRef /* notificationName */, const void* clientInfo)
+{
+ g_signal_emit(WEBKIT_WEB_EDITOR(clientInfo), signals[SELECTION_CHANGED], 0);
+}
+
+WebKitWebEditor* webkitWebEditorCreate(WebKitWebPage* webPage)
+{
+ WebKitWebEditor* editor = WEBKIT_WEB_EDITOR(g_object_new(WEBKIT_TYPE_WEB_EDITOR, nullptr));
+ editor->priv->webPage = webPage;
+
+ WKBundlePageEditorClientV0 editorClient = {
+ {
+ 0, // version
+ editor, // clientInfo
+ },
+ nullptr, // shouldBeginEditing
+ nullptr, // shouldEndEditing
+ nullptr, // shouldInsertNode
+ nullptr, // shouldInsertText
+ nullptr, // shouldDeleteRange
+ nullptr, // shouldChangeSelectedRange
+ nullptr, // shouldApplyStyle
+ nullptr, // didBeginEditing
+ nullptr, // didEndEditing
+ nullptr, // didChange
+ didChangeSelection
+ };
+ WKBundlePageSetEditorClient(toAPI(webkitWebPageGetPage(webPage)), &editorClient.base);
+
+ return editor;
+}
+
+/**
+ * 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.
+ *
+ * Returns: (transfer none): the associated #WebKitWebPage
+ *
+ * Since: 2.10
+ */
+WebKitWebPage* webkit_web_editor_get_page(WebKitWebEditor* editor)
+{
+ return editor->priv->webPage;
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebEditorh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h (0 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h         (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditor.h        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+/*
+ * Copyright (C) 2015 Red Hat Inc.
+ *
+ * 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,1 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.
+ */
+
+#if !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit-web-extension.h> can be included directly."
+#endif
+
+#ifndef WebKitWebEditor_h
+#define WebKitWebEditor_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitWebPage.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_EDITOR (webkit_web_editor_get_type())
+#define WEBKIT_WEB_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_EDITOR, WebKitWebEditor))
+#define WEBKIT_IS_WEB_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_EDITOR))
+#define WEBKIT_WEB_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_EDITOR, WebKitWebEditorClass))
+#define WEBKIT_IS_WEB_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_EDITOR))
+#define WEBKIT_WEB_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_EDITOR, WebKitWebEditorClass))
+
+typedef struct _WebKitWebEditor WebKitWebEditor;
+typedef struct _WebKitWebEditorClass WebKitWebEditorClass;
+typedef struct _WebKitWebEditorPrivate WebKitWebEditorPrivate;
+
+/* Forward declarations */
+typedef struct _WebKitWebPage WebKitWebPage;
+
+struct _WebKitWebEditor {
+ GObject parent;
+
+ WebKitWebEditorPrivate *priv;
+};
+
+struct _WebKitWebEditorClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_web_editor_get_type (void);
+
+WEBKIT_API WebKitWebPage *
+webkit_web_editor_get_page (WebKitWebEditor *editor);
+
+G_END_DECLS
+
+#endif // WebKitWebEditor_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebEditorPrivatehfromrev187023trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebPagePrivateh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h (from rev 187023, trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h) (0 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h         (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebEditorPrivate.h        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+/*
+ * Copyright (C) 2015 Red Hat Inc.
+ *
+ * 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 WebKitWebEditorPrivate_h
+#define WebKitWebEditorPrivate_h
+
+#include "WebKitWebEditor.h"
+#include "WebKitWebPage.h"
+
+WebKitWebEditor* webkitWebEditorCreate(WebKitWebPage*);
+
+#endif // WebKitWebEditor_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include "WebKitScriptWorldPrivate.h"
</span><span class="cx"> #include "WebKitURIRequestPrivate.h"
</span><span class="cx"> #include "WebKitURIResponsePrivate.h"
</span><ins>+#include "WebKitWebEditorPrivate.h"
</ins><span class="cx"> #include "WebKitWebHitTestResultPrivate.h"
</span><span class="cx"> #include "WebKitWebPagePrivate.h"
</span><span class="cx"> #include "WebProcess.h"
</span><span class="lines">@@ -70,6 +71,8 @@
</span><span class="cx"> WebPage* webPage;
</span><span class="cx">
</span><span class="cx"> CString uri;
</span><ins>+
+ GRefPtr<WebKitWebEditor> webEditor;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static guint signals[LAST_SIGNAL] = { 0, };
</span><span class="lines">@@ -394,6 +397,11 @@
</span><span class="cx"> WEBKIT_TYPE_WEB_HIT_TEST_RESULT);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+WebPage* webkitWebPageGetPage(WebKitWebPage *webPage)
+{
+ return webPage->priv->webPage;
+}
+
</ins><span class="cx"> WebKitWebPage* webkitWebPageCreate(WebPage* webPage)
</span><span class="cx"> {
</span><span class="cx"> WebKitWebPage* page = WEBKIT_WEB_PAGE(g_object_new(WEBKIT_TYPE_WEB_PAGE, NULL));
</span><span class="lines">@@ -575,3 +583,23 @@
</span><span class="cx">
</span><span class="cx"> return webkitFrameGetOrCreate(webPage->priv->webPage->mainWebFrame());
</span><span class="cx"> }
</span><ins>+
+/**
+ * webkit_web_page_get_editor:
+ * @web_page: a #WebKitWebPage
+ *
+ * Gets the #WebKitWebEditor of a #WebKitWebPage.
+ *
+ * Returns: (transfer none): the #WebKitWebEditor
+ *
+ * Since: 2.10
+ */
+WebKitWebEditor* webkit_web_page_get_editor(WebKitWebPage* webPage)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_PAGE(webPage), nullptr);
+
+ if (!webPage->priv->webEditor)
+ webPage->priv->webEditor = adoptGRef(webkitWebEditorCreate(webPage));
+
+ return webPage->priv->webEditor.get();
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include <glib-object.h>
</span><span class="cx"> #include <webkit2/WebKitDefines.h>
</span><span class="cx"> #include <webkit2/WebKitFrame.h>
</span><ins>+#include <webkit2/WebKitWebEditor.h>
</ins><span class="cx"> #include <webkitdom/webkitdom.h>
</span><span class="cx">
</span><span class="cx"> G_BEGIN_DECLS
</span><span class="lines">@@ -42,6 +43,9 @@
</span><span class="cx"> typedef struct _WebKitWebPageClass WebKitWebPageClass;
</span><span class="cx"> typedef struct _WebKitWebPagePrivate WebKitWebPagePrivate;
</span><span class="cx">
</span><ins>+/* Forward declarations */
+typedef struct _WebKitWebEditor WebKitWebEditor;
+
</ins><span class="cx"> struct _WebKitWebPage {
</span><span class="cx"> GObject parent;
</span><span class="cx">
</span><span class="lines">@@ -67,6 +71,9 @@
</span><span class="cx"> WEBKIT_API WebKitFrame *
</span><span class="cx"> webkit_web_page_get_main_frame (WebKitWebPage *web_page);
</span><span class="cx">
</span><ins>+WEBKIT_API WebKitWebEditor *
+webkit_web_page_get_editor (WebKitWebPage *web_page);
+
</ins><span class="cx"> G_END_DECLS
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIgtkWebKitWebPagePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -26,5 +26,6 @@
</span><span class="cx">
</span><span class="cx"> WebKitWebPage* webkitWebPageCreate(WebKit::WebPage*);
</span><span class="cx"> void webkitWebPageDidReceiveMessage(WebKitWebPage*, const String& messageName, API::Dictionary& message);
</span><ins>+WebKit::WebPage* webkitWebPageGetPage(WebKitWebPage*);
</ins><span class="cx">
</span><span class="cx"> #endif // WebKitWebPagePrivate_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIgtkwebkitwebextensionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include <webkit2/WebKitURIRequest.h>
</span><span class="cx"> #include <webkit2/WebKitURIResponse.h>
</span><span class="cx"> #include <webkit2/WebKitVersion.h>
</span><ins>+#include <webkit2/WebKitWebEditor.h>
</ins><span class="cx"> #include <webkit2/WebKitWebExtension.h>
</span><span class="cx"> #include <webkit2/WebKitWebHitTestResult.h>
</span><span class="cx"> #include <webkit2/WebKitWebPage.h>
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Tools/ChangeLog        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-07-20 Tomas Popela <tpopela@redhat.com>
+
+ [GTK] Add selection-changed signal to the WebKit2 API
+ https://bugs.webkit.org/show_bug.cgi?id=137116
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add a new WebProcess test TestEditor that is testing the WebKitWebEditor
+ (namely the selection-changed signal).
+
+ * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
+ * TestWebKitAPI/Tests/WebKit2Gtk/EditorTest.cpp: Added.
+ (WebKitWebEditorTest::create):
+ (WebKitWebEditorTest::selectionChangedCallback):
+ (WebKitWebEditorTest::testSelectionSelectAll):
+ (WebKitWebEditorTest::testSelectionCollapse):
+ (WebKitWebEditorTest::testSelectionModifyMove):
+ (WebKitWebEditorTest::testSelectionModifyExtend):
+ (WebKitWebEditorTest::testSelectionUnselect):
+ (registerTests):
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestEditor.cpp: Added.
+ (testWebKitWebEditorSelectionChanged):
+ (beforeAll):
+ (afterAll):
+
</ins><span class="cx"> 2015-07-20 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Resurrect CMake build on Windows.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt (187023 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt        2015-07-20 17:08:10 UTC (rev 187023)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx"> endmacro()
</span><span class="cx">
</span><span class="cx"> ADD_WK2_TEST_WEB_EXTENSION(WebExtensionTest WebExtensionTest.cpp)
</span><del>-ADD_WK2_TEST_WEB_EXTENSION(WebProcessTest DOMNodeTest.cpp DOMNodeFilterTest.cpp DOMXPathNSResolverTest.cpp FrameTest.cpp WebProcessTest.cpp)
</del><ins>+ADD_WK2_TEST_WEB_EXTENSION(WebProcessTest DOMNodeTest.cpp DOMNodeFilterTest.cpp DOMXPathNSResolverTest.cpp FrameTest.cpp WebProcessTest.cpp EditorTest.cpp)
</ins><span class="cx">
</span><span class="cx"> ADD_WK2_TEST(InspectorTestServer InspectorTestServer.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestAuthentication TestAuthentication.cpp)
</span><span class="lines">@@ -119,6 +119,7 @@
</span><span class="cx"> ADD_WK2_TEST(TestWebKitWebContext TestWebKitWebContext.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestWebKitWebView TestWebKitWebView.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestWebKitUserContentManager TestWebKitUserContentManager.cpp)
</span><ins>+ADD_WK2_TEST(TestEditor TestEditor.cpp)
</ins><span class="cx">
</span><span class="cx"> if (ATSPI_FOUND)
</span><span class="cx"> ADD_WK2_TEST(AccessibilityTestServer AccessibilityTestServer.cpp)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkEditorTestcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/EditorTest.cpp (0 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/EditorTest.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/EditorTest.cpp        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -0,0 +1,131 @@
</span><ins>+/*
+ * Copyright (C) 2015 Red Hat Inc.
+ *
+ * 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 "WebProcessTest.h"
+#include <webkit2/webkit-web-extension.h>
+
+#define WEBKIT_DOM_USE_UNSTABLE_API
+#include <webkitdom/WebKitDOMDOMSelection.h>
+#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
+
+class WebKitWebEditorTest : public WebProcessTest {
+public:
+ static std::unique_ptr<WebProcessTest> create() { return std::unique_ptr<WebProcessTest>(new WebKitWebEditorTest()); }
+
+private:
+ static void selectionChangedCallback(bool* selectionChanged)
+ {
+ *selectionChanged = true;
+ }
+
+ void testSelectionSelectAll(WebKitWebPage* page)
+ {
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ webkit_dom_document_exec_command(document, "SelectAll", false, "");
+ }
+
+ void testSelectionCollapse(WebKitWebPage* page)
+ {
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+ GRefPtr<WebKitDOMDOMWindow> domWindow = adoptGRef(webkit_dom_document_get_default_view(document));
+ g_assert(WEBKIT_DOM_IS_DOM_WINDOW(domWindow.get()));
+ GRefPtr<WebKitDOMDOMSelection> domSelection = adoptGRef(webkit_dom_dom_window_get_selection(domWindow.get()));
+ g_assert(WEBKIT_DOM_IS_DOM_SELECTION(domSelection.get()));
+
+ webkit_dom_dom_selection_collapse_to_start(domSelection.get(), nullptr);
+ }
+
+ void testSelectionModifyMove(WebKitWebPage* page)
+ {
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+ GRefPtr<WebKitDOMDOMWindow> domWindow = adoptGRef(webkit_dom_document_get_default_view(document));
+ g_assert(WEBKIT_DOM_IS_DOM_WINDOW(domWindow.get()));
+ GRefPtr<WebKitDOMDOMSelection> domSelection = adoptGRef(webkit_dom_dom_window_get_selection(domWindow.get()));
+ g_assert(WEBKIT_DOM_IS_DOM_SELECTION(domSelection.get()));
+
+ webkit_dom_dom_selection_modify(domSelection.get(), "move", "forward", "character");
+ }
+
+ void testSelectionModifyExtend(WebKitWebPage* page)
+ {
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+ GRefPtr<WebKitDOMDOMWindow> domWindow = adoptGRef(webkit_dom_document_get_default_view(document));
+ g_assert(WEBKIT_DOM_IS_DOM_WINDOW(domWindow.get()));
+ GRefPtr<WebKitDOMDOMSelection> domSelection = adoptGRef(webkit_dom_dom_window_get_selection(domWindow.get()));
+ g_assert(WEBKIT_DOM_IS_DOM_SELECTION(domSelection.get()));
+
+ webkit_dom_dom_selection_modify(domSelection.get(), "extend", "forward", "word");
+ }
+
+ void testSelectionUnselect(WebKitWebPage* page)
+ {
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ webkit_dom_document_exec_command(document, "Unselect", false, "");
+ }
+
+ bool runTest(const char* testName, WebKitWebPage* page) override
+ {
+ if (!strcmp(testName, "selection-changed")) {
+ bool selectionChanged = false;
+
+ WebKitWebEditor* editor = webkit_web_page_get_editor(page);
+ g_assert(WEBKIT_IS_WEB_EDITOR(editor));
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(editor));
+ g_signal_connect_swapped(editor, "selection-changed", G_CALLBACK(selectionChangedCallback), &selectionChanged);
+
+ testSelectionSelectAll(page);
+ g_assert(selectionChanged);
+
+ selectionChanged = false;
+ testSelectionCollapse(page);
+ g_assert(selectionChanged);
+
+ selectionChanged = false;
+ testSelectionModifyMove(page);
+ g_assert(selectionChanged);
+
+ selectionChanged = false;
+ testSelectionModifyExtend(page);
+ g_assert(selectionChanged);
+
+ selectionChanged = false;
+ testSelectionUnselect(page);
+ g_assert(selectionChanged);
+
+ return true;
+ }
+
+ g_assert_not_reached();
+ return false;
+ }
+};
+
+static void __attribute__((constructor)) registerTests()
+{
+ REGISTER_TEST(WebKitWebEditorTest, "WebKitWebEditor/selection-changed");
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestEditorcppfromrev187023trunkSourceWebKit2WebProcessInjectedBundleAPIgtkwebkitwebextensionh"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestEditor.cpp (from rev 187023, trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h) (0 => 187024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestEditor.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestEditor.cpp        2015-07-20 17:42:01 UTC (rev 187024)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * Copyright (C) 2015 Red Hat Inc.
+ *
+ * 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,1 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 "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static void testWebKitWebEditorSelectionChanged(WebViewTest* test, gconstpointer)
+{
+ static const gchar* testHTML = "<html><body>All work and no play make Jack a dull boy.</body></html>";
+ test->loadHtml(testHTML, nullptr);
+ test->waitUntilLoadFinished();
+
+ g_assert(test->runWebProcessTest("WebKitWebEditor", "selection-changed"));
+}
+
+void beforeAll()
+{
+ WebViewTest::add("WebKitWebEditor", "selection-changed", testWebKitWebEditorSelectionChanged);
+}
+
+void afterAll()
+{
+}
</ins></span></pre>
</div>
</div>
</body>
</html>