Commit ec9d27ca authored by Michael Gratton's avatar Michael Gratton 🤞 Committed by Michael Gratton

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
parent 1387fb64
......@@ -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
......
......@@ -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 = (
......
/*
* 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);
}
}
......@@ -257,6 +257,7 @@ public class GearyController : Geary.BaseObject {
ConversationWebView.load_resources(
this.application.get_user_config_directory()
);
Accounts.SignatureWebView.load_resources();
} catch (Error err) {
error("Error loading web resources: %s", err.message);
}
......
......@@ -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. */
......
......@@ -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',
......
......@@ -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;
}
......
......@@ -177,5 +177,3 @@ PageState.prototype = {
}
}
};
var geary = new PageState();
......@@ -37,6 +37,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>
......
/*
* 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();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment