WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-139443-20150119102056.patch (text/plain), 15.65 KB, created by
Tomas Popela
on 2015-01-19 01:20:50 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tomas Popela
Created:
2015-01-19 01:20:50 PST
Size:
15.65 KB
patch
obsolete
>Subversion Revision: 178641 >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 98ab9df61a27a1bbfcb68b06d27fa8f27178b5fc..07aa4f70a76b04d53cbcbc2beb1adab8f463ffef 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,22 @@ >+2015-01-19 Tomas Popela <tpopela@redhat.com> >+ >+ [GTK] Add API to set the web view editable into WebKit2 GTK+ API >+ https://bugs.webkit.org/show_bug.cgi?id=139443 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Provide a way to set the web view editable, without accessing the DOM >+ and setting the contenteditable attribute to elements. >+ >+ * UIProcess/API/gtk/WebKitWebView.cpp: >+ (webkitWebViewSetProperty): >+ (webkitWebViewGetProperty): >+ (webkit_web_view_class_init): >+ (webkit_web_view_is_editable): >+ (webkit_web_view_set_editable): >+ * UIProcess/API/gtk/WebKitWebView.h: >+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: >+ > 2015-01-18 Daniel Bates <dabates@apple.com> > > Attempt to fix the iOS build after <http://trac.webkit.org/changeset/178631> >diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp >index 13bd338b088429c91fc8275e542fb02ba8586a72..b5b893009b5ee7a4e498808690c88b6d16e0963c 100644 >--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp >+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp >@@ -149,7 +149,8 @@ enum { > PROP_URI, > PROP_ZOOM_LEVEL, > PROP_IS_LOADING, >- PROP_IS_PLAYING_AUDIO >+ PROP_IS_PLAYING_AUDIO, >+ PROP_EDITABLE > }; > > typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap; >@@ -688,6 +689,9 @@ static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue > case PROP_ZOOM_LEVEL: > webkit_web_view_set_zoom_level(webView, g_value_get_double(value)); > break; >+ case PROP_EDITABLE: >+ webkit_web_view_set_editable(webView, g_value_get_boolean(value)); >+ break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); > } >@@ -728,6 +732,9 @@ static void webkitWebViewGetProperty(GObject* object, guint propId, GValue* valu > case PROP_IS_PLAYING_AUDIO: > g_value_set_boolean(value, webkit_web_view_is_playing_audio(webView)); > break; >+ case PROP_EDITABLE: >+ g_value_set_boolean(value, webkit_web_view_is_editable(webView)); >+ break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); > } >@@ -959,6 +966,24 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) > WEBKIT_PARAM_READABLE)); > > /** >+ * WebKitWebView:editable: >+ * >+ * Whether the pages loaded inside #WebKitWebView are editable. For more >+ * information see webkit_web_view_set_editable(). >+ * >+ * Since: 2.8 >+ */ >+ g_object_class_install_property( >+ gObjectClass, >+ PROP_EDITABLE, >+ g_param_spec_boolean( >+ "editable", >+ _("Editable"), >+ _("Whether the content can be modified by the user."), >+ FALSE, >+ WEBKIT_PARAM_READWRITE)); >+ >+ /** > * WebKitWebView::load-changed: > * @web_view: the #WebKitWebView on which the signal is emitted > * @load_event: the #WebKitLoadEvent >@@ -3504,3 +3529,54 @@ void webkitWebViewWebProcessCrashed(WebKitWebView* webView) > g_signal_emit(webView, signals[WEB_PROCESS_CRASHED], 0, &returnValue); > } > >+/** >+ * webkit_web_view_is_editable: >+ * @web_view: a #WebKitWebView >+ * >+ * Returns whether the user is allowed to edit the document. >+ * >+ * Returns %TRUE if @web_view allows the user to edit the HTML document, %FALSE if >+ * it doesn't. If %TRUE, @web_view allows the user to edit the document. If %FALSE, >+ * an element in @web_view's document can only be edited if the CONTENTEDITABLE >+ * attribute has been set on the element or one of its parent elements. By default >+ * a #WebKitWebView is not editable. >+ * >+ * Since: 2.8 >+ */ >+gboolean webkit_web_view_is_editable(WebKitWebView* webView) >+{ >+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); >+ >+ return getPage(webView)->isEditable(); >+} >+ >+/** >+ * webkit_web_view_set_editable: >+ * @web_view: a #WebKitWebView >+ * @editable: a #gboolean indicating the editable state >+ * >+ * Sets whether @web_view allows the user to edit its HTML document. >+ * >+ * If @editable is %TRUE, @web_view allows the user to edit the document. If >+ * @editable is %FALSE, an element in @web_view's document can only be edited if the >+ * CONTENTEDITABLE attribute has been set on the element or one of its parent >+ * elements. By default a #WebKitWebView is not editable. >+ >+ * Normally, an HTML document is not editable unless the elements within the >+ * document are editable. This function provides a way to make the contents >+ * of a #WebKitWebView editable without altering the document or DOM structure. >+ * >+ * Since: 2.8 >+ */ >+void webkit_web_view_set_editable(WebKitWebView* webView, gboolean editable) >+{ >+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); >+ >+ if (editable == getPage(webView)->isEditable()) >+ return; >+ >+ getPage(webView)->setEditable(editable); >+ >+ g_object_notify(G_OBJECT(webView), "editable"); >+} >+ >diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h >index da3f165fdb6f034760158f7b7687f50a503c4f80..6965d7067d720713383c896519eedfdb285cfda6 100644 >--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h >+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h >@@ -474,6 +474,13 @@ webkit_web_view_get_snapshot_finish (WebKitWebView > WEBKIT_API WebKitUserContentManager * > webkit_web_view_get_user_content_manager (WebKitWebView *web_view); > >+WEBKIT_API gboolean >+webkit_web_view_is_editable (WebKitWebView *web_view); >+ >+WEBKIT_API void >+webkit_web_view_set_editable (WebKitWebView *web_view, >+ gboolean editable); >+ > G_END_DECLS > > #endif >diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt >index f366d0a0281436959ecf68db18d023b66978b2a7..4a9ddca2164e2e04356a7eaa5f1ba2e93f9c01f7 100644 >--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt >+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt >@@ -199,6 +199,8 @@ webkit_web_view_download_uri > webkit_web_view_get_tls_info > webkit_web_view_get_snapshot > webkit_web_view_get_snapshot_finish >+webkit_web_view_set_editable >+webkit_web_view_is_editable > > <SUBSECTION WebKitJavascriptResult> > WebKitJavascriptResult >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 2f2266273718f137a676aa6cf77a22641978077a..46b2baeeb814d949bb67a522f49b5444160af8a9 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,25 @@ >+2015-01-19 Tomas Popela <tpopela@redhat.com> >+ >+ [GTK] Add API to set the web view editable into WebKit2 GTK+ API >+ https://bugs.webkit.org/show_bug.cgi?id=139443 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Create the new test cases for setting the editable property on the web >+ view and on the contenteditable enabled document. Also rework the >+ current tests that are expecting that the web view is editable. >+ >+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp: >+ (testWebViewEditorCutCopyPasteEditable): >+ (testWebViewEditorSelectAllEditable): >+ (testWebViewEditorEditableNonEditable): >+ (testWebViewEditorEditableContentEditable): >+ (beforeAll): >+ * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp: >+ (WebViewTest::isEditable): >+ (WebViewTest::setEditable): >+ * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h: >+ > 2015-01-18 David Kilzer <ddkilzer@apple.com> > > iOS EWS queue name should be consistent >diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp b/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp >index 9e69bfa48e1a60e84efad940061eb7a38db5feb2..f3ccc021f1f73181a65383af042d4ca257f15645 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp >@@ -73,6 +73,16 @@ public: > g_main_loop_run(m_mainLoop); > } > >+ void cutClipboard() >+ { >+ webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_CUT); >+ // There's no way to know when the selection has been cut to >+ // the clipboard, so use a timeout source to query the clipboard. >+ m_triesCount = 0; >+ g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this); >+ g_main_loop_run(m_mainLoop); >+ } >+ > GtkClipboard* m_clipboard; > bool m_canExecuteEditingCommand; > size_t m_triesCount; >@@ -107,7 +117,7 @@ static void testWebViewEditorCutCopyPasteNonEditable(EditorTest* test, gconstpoi > > static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointer) > { >- static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">" >+ static const char* selectedSpanHTML = "<html><body>" > "<span id=\"mainspan\">All work and no play <span>make Jack a dull</span> boy.</span>" > "<script>document.getSelection().collapse();\n" > "document.getSelection().selectAllChildren(document.getElementById('mainspan'));\n" >@@ -118,6 +128,9 @@ static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointe > g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); > g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); > >+ g_assert(!test->isEditable()); >+ test->setEditable(true); >+ g_assert(test->isEditable()); > test->loadHtml(selectedSpanHTML, 0); > test->waitUntilLoadFinished(); > >@@ -162,7 +175,7 @@ static void testWebViewEditorSelectAllNonEditable(EditorTest* test, gconstpointe > > static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer) > { >- static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">" >+ static const char* selectedSpanHTML = "<html><body>" > "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>" > "<script>document.getSelection().collapse();\n" > "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n" >@@ -170,6 +183,9 @@ static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer) > > g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL)); > >+ g_assert(!test->isEditable()); >+ test->setEditable(true); >+ g_assert(test->isEditable()); > test->loadHtml(selectedSpanHTML, 0); > test->waitUntilLoadFinished(); > >@@ -189,8 +205,76 @@ static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer) > g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy."); > } > >+static void testWebViewEditorEditableNonEditable(EditorTest* test, gconstpointer) >+{ >+ static const char* selectedSpanHTML = "<html><body contentEditable=\"false\">" >+ "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>" >+ "<script>document.getSelection().collapse();\n" >+ "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n" >+ "</script></body></html>"; >+ >+ // View is not editable by default. >+ g_assert(!test->isEditable()); >+ >+ test->loadHtml(selectedSpanHTML, 0); >+ test->waitUntilLoadFinished(); >+ >+ g_assert(!test->isEditable()); >+ test->setEditable(true); >+ g_assert(test->isEditable()); >+ >+ // Cut and paste commands can be used only in editable view. >+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); >+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); >+ >+ // Cut the selection to the clipboard to see if the view is indeed editable. >+ test->cutClipboard(); >+ GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); >+ g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); >+ >+ g_assert(test->isEditable()); >+ test->setEditable(false); >+ g_assert(!test->isEditable()); >+} >+ >+static void testWebViewEditorEditableContentEditable(EditorTest* test, gconstpointer) >+{ >+ static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">" >+ "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>" >+ "<script>document.getSelection().collapse();\n" >+ "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n" >+ "</script></body></html>"; >+ >+ // View is not editable by default. >+ g_assert(!test->isEditable()); >+ >+ test->loadHtml(selectedSpanHTML, 0); >+ test->waitUntilLoadFinished(); >+ >+ // Even when the contenteditable attribute is set on the body the view's editable >+ // property will still be false. >+ g_assert(!test->isEditable()); >+ test->setEditable(true); >+ g_assert(test->isEditable()); >+ >+ // Cut and paste commands can be used only in editable view. >+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); >+ g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); >+ >+ // Cut the selection to the clipboard to see if the view is indeed editable. >+ test->cutClipboard(); >+ GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); >+ g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); >+ >+ g_assert(test->isEditable()); >+ test->setEditable(false); >+ g_assert(!test->isEditable()); >+} >+ > void beforeAll() > { >+ EditorTest::add("WebKitWebView", "editable/non-editable", testWebViewEditorEditableNonEditable); >+ EditorTest::add("WebKitWebView", "editable/content-editable", testWebViewEditorEditableContentEditable); > EditorTest::add("WebKitWebView", "cut-copy-paste/non-editable", testWebViewEditorCutCopyPasteNonEditable); > EditorTest::add("WebKitWebView", "cut-copy-paste/editable", testWebViewEditorCutCopyPasteEditable); > EditorTest::add("WebKitWebView", "select-all/non-editable", testWebViewEditorSelectAllNonEditable); >diff --git a/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp b/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp >index ea8b6b3feb052e8766037e617c231673f0c1c3a3..76ff7a5dc0647d74310cc19b3144f372ad42aef3 100644 >--- a/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp >+++ b/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp >@@ -260,6 +260,16 @@ void WebViewTest::selectAll() > webkit_web_view_execute_editing_command(m_webView, "SelectAll"); > } > >+bool WebViewTest::isEditable() >+{ >+ webkit_web_view_is_editable(m_webView); >+} >+ >+void WebViewTest::setEditable(bool editable) >+{ >+ webkit_web_view_set_editable(m_webView, editable); >+} >+ > static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData) > { > size_t dataSize; >diff --git a/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h b/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h >index 2c3692a562e57480b90b7fffef7563982db26a3a..ad39ef60be8fa573ca2d75c62e943f3d6511ea1e 100644 >--- a/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h >+++ b/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h >@@ -53,6 +53,9 @@ public: > void selectAll(); > const char* mainResourceData(size_t& mainResourceDataSize); > >+ bool isEditable(); >+ void setEditable(bool); >+ > void mouseMoveTo(int x, int y, unsigned mouseModifiers = 0); > void clickMouseButton(int x, int y, unsigned button = 1, unsigned mouseModifiers = 0); > void keyStroke(unsigned keyVal, unsigned keyModifiers = 0);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 139443
:
242912
|
242930
|
242933
|
244754
|
244882
|
244972
|
244976
|
244977