[geary/wip/728002-webkit2: 69/96] Fix being unable to scroll a message while remote images are loading.



commit a97acc8d34448a16af1346a18c332f7c04a42eab
Author: Michael James Gratton <mike vee net>
Date:   Tue Jan 3 21:48:02 2017 +1100

    Fix being unable to scroll a message while remote images are loading.
    
    * src/client/conversation-viewer/conversation-list-box.vala
      (EmailRow::on_size_allocate): Disable should-scroll when we have a
      valid height, not when loaded, so we stop pinning the scroll value and
      let users scroll, even when remote images loads are still running.
    
    * src/client/components/client-web-view.vala (WebView): Replace is_loaded
      with has_valid_height, so we can if the body has been parsed and some
      content is visible. This still isn't perfect, but better than using
      load-ended. Fix call sites.

 src/client/components/client-web-view.vala         |   12 +++++-------
 .../conversation-viewer/conversation-email.vala    |    2 +-
 .../conversation-viewer/conversation-list-box.vala |    6 +++---
 3 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/src/client/components/client-web-view.vala b/src/client/components/client-web-view.vala
index 60313ff..dabbc01 100644
--- a/src/client/components/client-web-view.vala
+++ b/src/client/components/client-web-view.vala
@@ -134,7 +134,7 @@ public class ClientWebView : WebKit.WebView {
     }
 
 
-    public bool is_loaded { get; private set; default = false; }
+    public bool has_valid_height = false;
 
     public string allow_prefix { get; private set; default = ""; }
 
@@ -215,11 +215,6 @@ public class ClientWebView : WebKit.WebView {
         // XXX get the allow prefix from the extension somehow
 
         this.decide_policy.connect(on_decide_policy);
-        this.load_changed.connect((web_view, event) => {
-                if (event == WebKit.LoadEvent.FINISHED) {
-                    this.is_loaded = true;
-                }
-            });
         this.web_process_crashed.connect(() => {
                 debug("Web process crashed");
                 return Gdk.EVENT_PROPAGATE;
@@ -229,7 +224,10 @@ public class ClientWebView : WebKit.WebView {
             (result) => {
                 try {
                     this.preferred_height = (int) WebKitUtil.to_number(result);
-                    queue_resize();
+                    if (this.preferred_height >= 1) {
+                        this.has_valid_height = true;
+                        queue_resize();
+                    }
                 } catch (Geary.JS.Error err) {
                     debug("Could not get preferred height: %s", err.message);
                 } finally {
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index 7ee1e71..2af0b4f 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -633,7 +633,7 @@ public class ConversationEmail : Gtk.Box {
         view.web_view.notify["load-status"].connect(() => {
                 bool all_loaded = true;
                 message_view_iterator().foreach((view) => {
-                        if (!view.web_view.is_loaded) {
+                        if (!view.web_view.has_valid_height) {
                             all_loaded = false;
                             return false;
                         }
diff --git a/src/client/conversation-viewer/conversation-list-box.vala 
b/src/client/conversation-viewer/conversation-list-box.vala
index 3ad1bfb..ca26792 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -190,7 +190,7 @@ public class ConversationListBox : Gtk.ListBox {
         public override void expand() {
             this.is_expanded = true;
             this.view.message_view_iterator().foreach((view) => {
-                    if (!view.web_view.is_loaded) {
+                    if (!view.web_view.has_valid_height) {
                         view.web_view.queue_resize();
                     }
                     return true;
@@ -209,7 +209,7 @@ public class ConversationListBox : Gtk.ListBox {
             // message has a non-trivial height, and then wait for it
             // to be reallocated, so that it picks up the web_view's
             // height.
-            if (view.primary_message.web_view.is_loaded) {
+            if (view.primary_message.web_view.has_valid_height) {
                 // Disable should_scroll after the message body has
                 // been loaded so we don't keep on scrolling later,
                 // like when the window has been resized.
@@ -535,7 +535,7 @@ public class ConversationListBox : Gtk.ListBox {
             // size of the body will be off, affecting the visibility
             // of emails further down the conversation.
             if (email_view.email.is_unread().is_certain() &&
-                conversation_message.web_view.is_loaded &&
+                conversation_message.web_view.has_valid_height &&
                 !email_view.is_manually_read) {
                  int body_top = 0;
                  int body_left = 0;


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