[geary/wip/jsc-migration: 1/5] Move WebKitUtil namespace to Util.WebKit
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/jsc-migration: 1/5] Move WebKitUtil namespace to Util.WebKit
- Date: Sun, 21 Jul 2019 00:06:39 +0000 (UTC)
commit f14b16fe7a817e01afc304cad25a373ad006b24e
Author: Michael Gratton <mike vee net>
Date: Sat Jul 20 09:13:43 2019 +1000
Move WebKitUtil namespace to Util.WebKit
src/client/components/client-web-view.vala | 8 ++--
src/client/composer/composer-web-view.vala | 8 ++--
.../conversation-viewer/conversation-web-view.vala | 8 ++--
src/client/util/util-webkit.vala | 14 +++---
test/js/composer-page-state-test.vala | 54 +++++++++++-----------
test/js/conversation-page-state-test.vala | 10 ++--
6 files changed, 51 insertions(+), 51 deletions(-)
---
diff --git a/src/client/components/client-web-view.vala b/src/client/components/client-web-view.vala
index fe312fbb..b47ead01 100644
--- a/src/client/components/client-web-view.vala
+++ b/src/client/components/client-web-view.vala
@@ -392,7 +392,7 @@ public abstract class ClientWebView : WebKit.WebView, Geary.BaseInterface {
* Returns the view's content as an HTML string.
*/
public async string? get_html() throws Error {
- return WebKitUtil.to_string(
+ return Util.WebKit.to_string(
yield call(Geary.JS.callable("geary.getHtml"), null)
);
}
@@ -617,7 +617,7 @@ public abstract class ClientWebView : WebKit.WebView, Geary.BaseInterface {
private void on_preferred_height_changed(WebKit.JavascriptResult result) {
double height = this.webkit_reported_height;
try {
- height = WebKitUtil.to_number(result);
+ height = Util.WebKit.to_number(result);
} catch (Geary.JS.Error err) {
debug("Could not get preferred height: %s", err.message);
}
@@ -630,7 +630,7 @@ public abstract class ClientWebView : WebKit.WebView, Geary.BaseInterface {
private void on_command_stack_changed(WebKit.JavascriptResult result) {
try {
- string[] values = WebKitUtil.to_string(result).split(",");
+ string[] values = Util.WebKit.to_string(result).split(",");
command_stack_changed(values[0] == "true", values[1] == "true");
} catch (Geary.JS.Error err) {
debug("Could not get command stack state: %s", err.message);
@@ -652,7 +652,7 @@ public abstract class ClientWebView : WebKit.WebView, Geary.BaseInterface {
private void on_selection_changed(WebKit.JavascriptResult result) {
try {
- bool has_selection = WebKitUtil.to_bool(result);
+ bool has_selection = Util.WebKit.to_bool(result);
// Avoid firing multiple notifies if the value hasn't
// changed
if (this.has_selection != has_selection) {
diff --git a/src/client/composer/composer-web-view.vala b/src/client/composer/composer-web-view.vala
index 2e7f8147..37840874 100644
--- a/src/client/composer/composer-web-view.vala
+++ b/src/client/composer/composer-web-view.vala
@@ -216,7 +216,7 @@ public class ComposerWebView : ClientWebView {
* subsequent calls.
*/
public async string save_selection() throws Error {
- return WebKitUtil.to_string(
+ return Util.WebKit.to_string(
yield call(Geary.JS.callable("geary.saveSelection"), null)
);
}
@@ -391,7 +391,7 @@ public class ComposerWebView : ClientWebView {
*/
public async bool contains_attachment_keywords(string keyword_spec, string subject) {
try {
- return WebKitUtil.to_bool(
+ return Util.WebKit.to_bool(
yield call(
Geary.JS.callable("geary.containsAttachmentKeyword")
.string(keyword_spec)
@@ -421,7 +421,7 @@ public class ComposerWebView : ClientWebView {
const int MAX_BREAKABLE_LEN = 72; // F=F recommended line limit
const int MAX_UNBREAKABLE_LEN = 998; // SMTP line limit
- string body_text = WebKitUtil.to_string(
+ string body_text = Util.WebKit.to_string(
yield call(Geary.JS.callable("geary.getText"), null)
);
string[] lines = body_text.split("\n");
@@ -497,7 +497,7 @@ public class ComposerWebView : ClientWebView {
private void on_cursor_context_changed(WebKit.JavascriptResult result) {
try {
- cursor_context_changed(new EditContext(WebKitUtil.to_string(result)));
+ cursor_context_changed(new EditContext(Util.WebKit.to_string(result)));
} catch (Geary.JS.Error err) {
debug("Could not get text cursor style: %s", err.message);
}
diff --git a/src/client/conversation-viewer/conversation-web-view.vala
b/src/client/conversation-viewer/conversation-web-view.vala
index 2a9f98ba..6f456278 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -75,7 +75,7 @@ public class ConversationWebView : ClientWebView {
WebKit.JavascriptResult result = yield call(
Geary.JS.callable("geary.getSelectionForFind"), null
);
- return WebKitUtil.to_string(result);
+ return Util.WebKit.to_string(result);
}
/**
@@ -85,7 +85,7 @@ public class ConversationWebView : ClientWebView {
WebKit.JavascriptResult result = yield call(
Geary.JS.callable("geary.getSelectionForQuoting"), null
);
- return WebKitUtil.to_string(result);
+ return Util.WebKit.to_string(result);
}
/**
@@ -97,7 +97,7 @@ public class ConversationWebView : ClientWebView {
Geary.JS.callable("geary.getAnchorTargetY")
.string(anchor_body), null
);
- return (int) WebKitUtil.to_number(result);
+ return (int) Util.WebKit.to_number(result);
}
/**
@@ -199,7 +199,7 @@ public class ConversationWebView : ClientWebView {
private void on_deceptive_link_clicked(WebKit.JavascriptResult result) {
try {
unowned JS.GlobalContext context = result.get_global_context();
- JS.Object details = WebKitUtil.to_object(result);
+ JS.Object details = Util.WebKit.to_object(result);
uint reason = (uint) Geary.JS.to_number(
context,
diff --git a/src/client/util/util-webkit.vala b/src/client/util/util-webkit.vala
index 45a27c44..718048b5 100644
--- a/src/client/util/util-webkit.vala
+++ b/src/client/util/util-webkit.vala
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Michael James Gratton <mike vee net>
+ * Copyright 2017-2019 Michael James Gratton <mike vee net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@@ -8,7 +8,7 @@
/**
* Utility functions for WebKit objects.
*/
-namespace WebKitUtil {
+namespace Util.WebKit {
/**
* Returns a WebKit {@link WebKit.JavascriptResult} as a `bool`.
@@ -16,7 +16,7 @@ namespace WebKitUtil {
* This will raise a {@link Geary.JS.Error.TYPE} error if the
* result is not a JavaScript `Boolean`.
*/
- public bool to_bool(WebKit.JavascriptResult result)
+ public bool to_bool(global::WebKit.JavascriptResult result)
throws Geary.JS.Error {
unowned JS.GlobalContext context = result.get_global_context();
unowned JS.Value value = result.get_value();
@@ -32,7 +32,7 @@ namespace WebKitUtil {
* This will raise a {@link Geary.JS.Error.TYPE} error if the
* result is not a JavaScript `Number`.
*/
- public inline double to_number(WebKit.JavascriptResult result)
+ public inline double to_number(global::WebKit.JavascriptResult result)
throws Geary.JS.Error {
return Geary.JS.to_number(result.get_global_context(),
result.get_value());
@@ -44,7 +44,7 @@ namespace WebKitUtil {
* This will raise a {@link Geary.JS.Error.TYPE} error if the
* result is not a JavaScript `String`.
*/
- public inline string to_string(WebKit.JavascriptResult result)
+ public inline string to_string(global::WebKit.JavascriptResult result)
throws Geary.JS.Error {
return Geary.JS.to_string(result.get_global_context(),
result.get_value());
@@ -57,7 +57,7 @@ namespace WebKitUtil {
* result to a string, effectively by calling the JavaScript
* `toString()` method on it, and returning that value.
*/
- public string as_string(WebKit.JavascriptResult result)
+ public string as_string(global::WebKit.JavascriptResult result)
throws Geary.JS.Error {
unowned JS.GlobalContext context = result.get_global_context();
unowned JS.Value js_str_value = result.get_value();
@@ -76,7 +76,7 @@ namespace WebKitUtil {
* Return type is nullable as a workaround for Bug 778046, it will
* never actually be null.
*/
- public JS.Object? to_object(WebKit.JavascriptResult result)
+ public JS.Object? to_object(global::WebKit.JavascriptResult result)
throws Geary.JS.Error {
return Geary.JS.to_object(result.get_global_context(),
result.get_value());
diff --git a/test/js/composer-page-state-test.vala b/test/js/composer-page-state-test.vala
index 52afd678..ec88f8ff 100644
--- a/test/js/composer-page-state-test.vala
+++ b/test/js/composer-page-state-test.vala
@@ -38,7 +38,7 @@ class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
load_body_fixture(html);
try {
- assert(WebKitUtil.to_string(run_javascript(@"new
EditContext(document.getElementById('test')).encode()"))
+ assert(Util.WebKit.to_string(run_javascript(@"new
EditContext(document.getElementById('test')).encode()"))
.has_prefix("1,url,"));
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
@@ -54,7 +54,7 @@ class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
load_body_fixture(html);
try {
- assert(WebKitUtil.to_string(run_javascript(@"new
EditContext(document.getElementById('test')).encode()")) ==
+ assert(Util.WebKit.to_string(run_javascript(@"new
EditContext(document.getElementById('test')).encode()")) ==
"0,,Comic Sans,144");
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
@@ -70,8 +70,8 @@ class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
try {
run_javascript(@"SelectionUtil.selectNode(document.getElementById('test'))");
run_javascript(@"geary.indentLine()");
-
assert(WebKitUtil.to_number(run_javascript(@"document.querySelectorAll('blockquote[type=cite]').length")) ==
1);
-
assert(WebKitUtil.to_string(run_javascript(@"document.querySelectorAll('blockquote[type=cite]').item(0).innerText"))
==
+
assert(Util.WebKit.to_number(run_javascript(@"document.querySelectorAll('blockquote[type=cite]').length")) ==
1);
+
assert(Util.WebKit.to_string(run_javascript(@"document.querySelectorAll('blockquote[type=cite]').item(0).innerText"))
==
"some text");
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
@@ -94,16 +94,16 @@ some text
true
);
try {
- assert(WebKitUtil.to_bool(run_javascript(
+ assert(Util.WebKit.to_bool(run_javascript(
@"geary.containsAttachmentKeyword(\"some\", \"subject text\");"
)));
- assert(WebKitUtil.to_bool(run_javascript(
+ assert(Util.WebKit.to_bool(run_javascript(
@"geary.containsAttachmentKeyword(\"subject\", \"subject text\");"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"geary.containsAttachmentKeyword(\"innerquote\", \"subject text\");"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"geary.containsAttachmentKeyword(\"outerquote\", \"subject text\");"
)));
} catch (Geary.JS.Error err) {
@@ -143,7 +143,7 @@ unknown://example6.com
try {
run_javascript("geary.cleanContent();");
- assert(WebKitUtil.to_string(run_javascript("geary.bodyPart.innerHTML;")) ==
+ assert(Util.WebKit.to_string(run_javascript("geary.bodyPart.innerHTML;")) ==
CLEAN_BODY_TEMPLATE.printf(expected));
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
@@ -158,7 +158,7 @@ unknown://example6.com
string html = "<p>para</p>";
load_body_fixture(html);
try {
- assert(WebKitUtil.to_string(run_javascript(@"window.geary.getHtml();")) ==
+ assert(Util.WebKit.to_string(run_javascript(@"window.geary.getHtml();")) ==
COMPLETE_BODY_TEMPLATE.printf(html));
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
@@ -172,7 +172,7 @@ unknown://example6.com
public void get_text() throws Error {
load_body_fixture("<p>para</p>");
try {
- assert(WebKitUtil.to_string(run_javascript(@"window.geary.getText();")) ==
+ assert(Util.WebKit.to_string(run_javascript(@"window.geary.getText();")) ==
"para\n\n\n\n");
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
@@ -187,7 +187,7 @@ unknown://example6.com
unichar q_marker = Geary.RFC822.Utils.QUOTE_MARKER;
load_body_fixture("<p>pre</p> <blockquote><p>quote</p></blockquote> <p>post</p>");
try {
- assert(WebKitUtil.to_string(run_javascript(@"window.geary.getText();")) ==
+ assert(Util.WebKit.to_string(run_javascript(@"window.geary.getText();")) ==
@"pre\n\n$(q_marker)quote\n$(q_marker)\npost\n\n\n\n");
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s", err.message);
@@ -202,7 +202,7 @@ unknown://example6.com
unichar q_marker = Geary.RFC822.Utils.QUOTE_MARKER;
load_body_fixture("<p>pre</p> <blockquote><p>quote1</p>
<blockquote><p>quote2</p></blockquote></blockquote> <p>post</p>");
try {
- assert(WebKitUtil.to_string(run_javascript(@"window.geary.getText();")) ==
+ assert(Util.WebKit.to_string(run_javascript(@"window.geary.getText();")) ==
@"pre\n\n$(q_marker)quote1\n$(q_marker)\n$(q_marker)$(q_marker)quote2\n$(q_marker)$(q_marker)\npost\n\n\n\n");
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
@@ -219,42 +219,42 @@ unknown://example6.com
string suffix_keys = """new Set(["sf1", "sf2"])""";
try {
// Doesn't contain
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('notcontained', $complete_keys, $suffix_keys);"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('not contained', $complete_keys, $suffix_keys);"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('not\tcontained', $complete_keys, $suffix_keys);"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('http://www.keyword1.com', $complete_keys,
$suffix_keys);"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('http://www.something.com/something.sf1',
$complete_keys, $suffix_keys);"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('sf1', $complete_keys, $suffix_keys);"
)));
- assert(!WebKitUtil.to_bool(run_javascript(
+ assert(!Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('.sf1', $complete_keys, $suffix_keys);"
)));
// Does contain
- assert(WebKitUtil.to_bool(run_javascript(
+ assert(Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('keyword1', $complete_keys, $suffix_keys);"
)));
- assert(WebKitUtil.to_bool(run_javascript(
+ assert(Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('keyword2 contained', $complete_keys, $suffix_keys);"
)));
- assert(WebKitUtil.to_bool(run_javascript(
+ assert(Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('keyword2\tcontained', $complete_keys, $suffix_keys);"
)));
- assert(WebKitUtil.to_bool(run_javascript(
+ assert(Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('something.sf1', $complete_keys, $suffix_keys);"
)));
- assert(WebKitUtil.to_bool(run_javascript(
+ assert(Util.WebKit.to_bool(run_javascript(
@"ComposerPageState.containsKeywords('something.something.sf2', $complete_keys,
$suffix_keys);"
)));
} catch (Geary.JS.Error err) {
@@ -271,9 +271,9 @@ unknown://example6.com
string single_nbsp = "a b";
string multiple_nbsp = "a b c";
try {
-
assert(WebKitUtil.to_string(run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(single_nbsp)');"))
==
+
assert(Util.WebKit.to_string(run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(single_nbsp)');"))
==
"a b");
-
assert(WebKitUtil.to_string(run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(multiple_nbsp)');"))
==
+
assert(Util.WebKit.to_string(run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(multiple_nbsp)');"))
==
"a b c");
} catch (Geary.JS.Error err) {
print("Geary.JS.Error: %s\n", err.message);
diff --git a/test/js/conversation-page-state-test.vala b/test/js/conversation-page-state-test.vala
index 5b09364f..84131535 100644
--- a/test/js/conversation-page-state-test.vala
+++ b/test/js/conversation-page-state-test.vala
@@ -103,7 +103,7 @@ class ConversationPageStateTest : ClientWebViewTestCase<ConversationWebView> {
public void is_descendant_of() throws GLib.Error {
load_body_fixture("<blockquote><div id='test'>ohhai</div></blockquote>");
assert(
- WebKitUtil.to_bool(
+ Util.WebKit.to_bool(
run_javascript("""
ConversationPageState.isDescendantOf(
document.getElementById('test'), "BLOCKQUOTE"
@@ -116,7 +116,7 @@ class ConversationPageStateTest : ClientWebViewTestCase<ConversationWebView> {
public void is_descendant_of_with_class() throws GLib.Error {
load_body_fixture("<blockquote class='test-class'><div id='test'>ohhai</div></blockquote>");
assert(
- WebKitUtil.to_bool(
+ Util.WebKit.to_bool(
run_javascript("""
ConversationPageState.isDescendantOf(
document.getElementById('test'), "BLOCKQUOTE", "test-class"
@@ -129,7 +129,7 @@ class ConversationPageStateTest : ClientWebViewTestCase<ConversationWebView> {
public void is_descendant_of_no_match() throws GLib.Error {
load_body_fixture("<blockquote class='test-class'><div id='test'>ohhai</div></blockquote>");
assert(
- WebKitUtil.to_bool(
+ Util.WebKit.to_bool(
run_javascript("""
ConversationPageState.isDescendantOf(
document.getElementById('test'), "DIV"
@@ -142,7 +142,7 @@ class ConversationPageStateTest : ClientWebViewTestCase<ConversationWebView> {
public void is_descendant_of_lax() throws GLib.Error {
load_body_fixture("<blockquote class='test-class'><div id='test'>ohhai</div></blockquote>");
assert(
- WebKitUtil.to_bool(
+ Util.WebKit.to_bool(
run_javascript("""
ConversationPageState.isDescendantOf(
document.getElementById('test'), "DIV", null, false
@@ -159,7 +159,7 @@ class ConversationPageStateTest : ClientWebViewTestCase<ConversationWebView> {
private uint exec_is_deceptive_text(string text, string href) {
try {
- return (uint) WebKitUtil.to_number(
+ return (uint) Util.WebKit.to_number(
run_javascript(@"ConversationPageState.isDeceptiveText(\"$text\", \"$href\")")
);
} catch (Geary.JS.Error err) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]