[geary/wip/728002-webkit2: 73/105] Inject ClientWebView script at document start.



commit 13e196d8f65f8b94eac84b745eec56f5e7cb492d
Author: Michael James Gratton <mike vee net>
Date:   Thu Nov 24 23:42:28 2016 +1100

    Inject ClientWebView script at document start.
    
    * src/client/components/client-web-view.vala
      (ClientWebView::load_app_script): Set script injection time to the
      start of the document load.
    
    * ui/client-web-view.js: Set an onload handler to report back the
      preferred height.

 src/client/components/client-web-view.vala |    4 ++--
 ui/client-web-view.js                      |   16 +++++++++++++---
 2 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/client/components/client-web-view.vala b/src/client/components/client-web-view.vala
index 46aed75..ba67d2b 100644
--- a/src/client/components/client-web-view.vala
+++ b/src/client/components/client-web-view.vala
@@ -68,7 +68,7 @@ public class ClientWebView : WebKit.WebView {
         return new WebKit.UserScript(
             app.read_resource(name),
             WebKit.UserContentInjectedFrames.TOP_FRAME,
-            WebKit.UserScriptInjectionTime.END,
+            WebKit.UserScriptInjectionTime.START,
             null,
             null
         );
@@ -152,7 +152,7 @@ public class ClientWebView : WebKit.WebView {
         setts.enable_html5_database = false;
         setts.enable_html5_local_storage = false;
         setts.enable_java = false;
-        setts.enable_javascript = false;
+        setts.enable_javascript = true;
         setts.enable_media_stream = false;
         setts.enable_offline_web_application_cache = false;
         setts.enable_page_cache = false;
diff --git a/ui/client-web-view.js b/ui/client-web-view.js
index a49b113..b80554e 100644
--- a/ui/client-web-view.js
+++ b/ui/client-web-view.js
@@ -5,6 +5,16 @@
  * (version 2.1 or later). See the COPYING file in this distribution.
  */
 
-window.webkit.messageHandlers.preferredHeightChanged.postMessage(
-    window.document.documentElement.offsetHeight
-);
+/**
+ * Application logic for ClientWebView and subclasses.
+ */
+
+function emitPreferredHeightChanged() {
+    window.webkit.messageHandlers.preferredHeightChanged.postMessage(
+        window.document.documentElement.offsetHeight
+    );
+}
+
+window.onload = function() {
+    emitPreferredHeightChanged();
+};


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]