[geary/wip/283-message-body-height-re-reux: 1/2] Remove default instance of ClientWebView's PageState JS object
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/283-message-body-height-re-reux: 1/2] Remove default instance of ClientWebView's PageState JS object
- Date: Wed, 6 Mar 2019 09:19:27 +0000 (UTC)
commit 9ed81ed7593dba1f586fd166cb72c4d53a836248
Author: Michael Gratton <mike vee net>
Date: Wed Mar 6 20:11:33 2019 +1100
Remove default instance of ClientWebView's PageState JS object
This default instance was causing double the number of preferred height
events, which was likely creating a race for ConversationWebView. This
might (should?) fix plain text email with quotes sometimes showing up
with a vastly incorrect height.
To ensure that a PageState is constructed properly, make ClientWebView
abstract and use replace the one direct use of the class in the accounts
editor for the signature with a new subclass.
See #283
po/POTFILES.in | 1 +
src/client/accounts/accounts-editor-edit-pane.vala | 4 +--
.../accounts/accounts-signature-web-view.vala | 29 ++++++++++++++++++++++
src/client/application/geary-controller.vala | 1 +
src/client/components/client-web-view.vala | 2 +-
src/client/meson.build | 1 +
test/js/client-page-state-test.vala | 11 +++++++-
ui/client-web-view.js | 2 --
ui/org.gnome.Geary.gresource.xml | 1 +
ui/signature-web-view.js | 12 +++++++++
10 files changed, 58 insertions(+), 6 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 92f7e71e..e68a30aa 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,6 +14,7 @@ src/client/accounts/accounts-editor-remove-pane.vala
src/client/accounts/accounts-editor-row.vala
src/client/accounts/accounts-editor-servers-pane.vala
src/client/accounts/accounts-manager.vala
+src/client/accounts/accounts-signature-web-view.vala
src/client/application/application-avatar-store.vala
src/client/application/application-certificate-manager.vala
src/client/application/application-command.vala
diff --git a/src/client/accounts/accounts-editor-edit-pane.vala
b/src/client/accounts/accounts-editor-edit-pane.vala
index 3576a53d..5cfcfdbb 100644
--- a/src/client/accounts/accounts-editor-edit-pane.vala
+++ b/src/client/accounts/accounts-editor-edit-pane.vala
@@ -55,7 +55,7 @@ internal class Accounts.EditorEditPane :
[GtkChild]
private Gtk.Frame signature_frame;
- private ClientWebView signature_preview;
+ private SignatureWebView signature_preview;
private bool signature_changed = false;
[GtkChild]
@@ -86,7 +86,7 @@ internal class Accounts.EditorEditPane :
}
this.senders_list.add(new AddMailboxRow());
- this.signature_preview = new ClientWebView(
+ this.signature_preview = new SignatureWebView(
((GearyApplication) editor.application).config
);
this.signature_preview.events = (
diff --git a/src/client/accounts/accounts-signature-web-view.vala
b/src/client/accounts/accounts-signature-web-view.vala
new file mode 100644
index 00000000..4a7b5fbb
--- /dev/null
+++ b/src/client/accounts/accounts-signature-web-view.vala
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2019 Michael 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.
+ */
+
+/**
+ * A class for editing signatures in the accounts editor.
+ */
+public class Accounts.SignatureWebView : ClientWebView {
+
+
+ private static WebKit.UserScript? app_script = null;
+
+ public static new void load_resources()
+ throws GLib.Error {
+ SignatureWebView.app_script = ClientWebView.load_app_script(
+ "signature-web-view.js"
+ );
+ }
+
+
+ public SignatureWebView(Configuration config) {
+ base(config);
+ this.user_content_manager.add_script(SignatureWebView.app_script);
+ }
+
+}
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index a4fee38b..8220ed4d 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -255,6 +255,7 @@ public class GearyController : Geary.BaseObject {
);
ComposerWebView.load_resources();
ConversationWebView.load_resources();
+ Accounts.SignatureWebView.load_resources();
} catch (Error err) {
error("Error loading web resources: %s", err.message);
}
diff --git a/src/client/components/client-web-view.vala b/src/client/components/client-web-view.vala
index 3db73259..65d96f46 100644
--- a/src/client/components/client-web-view.vala
+++ b/src/client/components/client-web-view.vala
@@ -14,7 +14,7 @@
* integration, Inspector support, and remote and inline image
* handling.
*/
-public class ClientWebView : WebKit.WebView, Geary.BaseInterface {
+public abstract class ClientWebView : WebKit.WebView, Geary.BaseInterface {
/** URI Scheme and delimiter for internal resource loads. */
diff --git a/src/client/meson.build b/src/client/meson.build
index 3d6b9fb9..8ba7d8e7 100644
--- a/src/client/meson.build
+++ b/src/client/meson.build
@@ -18,6 +18,7 @@ geary_client_vala_sources = files(
'accounts/accounts-editor-remove-pane.vala',
'accounts/accounts-editor-row.vala',
'accounts/accounts-editor-servers-pane.vala',
+ 'accounts/accounts-signature-web-view.vala',
'accounts/accounts-manager.vala',
'components/client-web-view.vala',
diff --git a/test/js/client-page-state-test.vala b/test/js/client-page-state-test.vala
index 8616746e..01145916 100644
--- a/test/js/client-page-state-test.vala
+++ b/test/js/client-page-state-test.vala
@@ -8,6 +8,15 @@
class ClientPageStateTest : ClientWebViewTestCase<ClientWebView> {
+ private class TestClientWebView : ClientWebView {
+
+ public TestClientWebView(Configuration config) {
+ base(config);
+ }
+
+ }
+
+
public ClientPageStateTest() {
base("ClientPageStateTest");
add_test("content_loaded", content_loaded);
@@ -46,7 +55,7 @@ class ClientPageStateTest : ClientWebViewTestCase<ClientWebView> {
null
);
- ClientWebView view = new ClientWebView(this.config);
+ ClientWebView view = new TestClientWebView(this.config);
view.get_user_content_manager().add_script(test_script);
return view;
}
diff --git a/ui/client-web-view.js b/ui/client-web-view.js
index ac2abe9e..7b70093e 100644
--- a/ui/client-web-view.js
+++ b/ui/client-web-view.js
@@ -177,5 +177,3 @@ PageState.prototype = {
}
}
};
-
-var geary = new PageState();
diff --git a/ui/org.gnome.Geary.gresource.xml b/ui/org.gnome.Geary.gresource.xml
index 7d950892..45c0e4f6 100644
--- a/ui/org.gnome.Geary.gresource.xml
+++ b/ui/org.gnome.Geary.gresource.xml
@@ -36,6 +36,7 @@
<file compressed="true" preprocess="xml-stripblanks">password-dialog.glade</file>
<file compressed="true" preprocess="xml-stripblanks">preferences-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">problem-details-dialog.ui</file>
+ <file compressed="true">signature-web-view.js</file>
<file compressed="true" preprocess="xml-stripblanks">upgrade_dialog.glade</file>
<file compressed="true">geary.css</file>
</gresource>
diff --git a/ui/signature-web-view.js b/ui/signature-web-view.js
new file mode 100644
index 00000000..aae44fab
--- /dev/null
+++ b/ui/signature-web-view.js
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2019 Michael 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.
+ */
+
+/**
+ * Application logic for SignatureWebView.
+ */
+
+var geary = new PageState();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]