[geary/geary-0.12] Revert "Adjust conversation height dynamically when zooming"



commit 8af78213487fe9b26155b7735e167837308e8099
Author: Michael James Gratton <mike vee net>
Date:   Sun Oct 14 12:25:22 2018 +1100

    Revert "Adjust conversation height dynamically when zooming"
    
    This reverts commit 008ff892e5e9d1f3657fe7b6d31e1eca2fdadac0.

 src/client/components/client-web-view.vala         | 43 +++++++++-------------
 .../conversation-viewer/conversation-list-box.vala |  2 +-
 .../conversation-viewer/conversation-web-view.vala |  2 -
 3 files changed, 19 insertions(+), 28 deletions(-)
---
diff --git a/src/client/components/client-web-view.vala b/src/client/components/client-web-view.vala
index f5c98a85..44949aab 100644
--- a/src/client/components/client-web-view.vala
+++ b/src/client/components/client-web-view.vala
@@ -198,14 +198,8 @@ public class ClientWebView : WebKit.WebView, Geary.BaseInterface {
     /** Determines if the view has started rendering the HTML */
     public bool has_valid_height { get; private set; default = false; }
 
-    /** The HTML content's current preferred height in window pixels. */
-    public int preferred_height {
-        get {
-            return (int) GLib.Math.ceil(
-                this.webkit_reported_height * this.zoom_level
-            );
-        }
-    }
+    /** The HTML content's current preferred height. */
+    public int preferred_height { get; private set; default = 0; }
 
     public string document_font {
         get {
@@ -245,8 +239,6 @@ public class ClientWebView : WebKit.WebView, Geary.BaseInterface {
     private Gee.List<ulong> registered_message_handlers =
         new Gee.LinkedList<ulong>();
 
-    private double webkit_reported_height = 0;
-
 
     /**
      * Emitted when the view's content has finished loaded.
@@ -413,11 +405,8 @@ public class ClientWebView : WebKit.WebView, Geary.BaseInterface {
         execute_editing_command(WebKit.EDITING_COMMAND_COPY);
     }
 
-    public void zoom_reset() {
-        this.zoom_level = ZOOM_DEFAULT;
-        // Notify the preferred height has changed since it depends on
-        // the zoom level. Same for zoom in and out below.
-        notify_property("preferred-height");
+    public void reset_zoom() {
+        this.zoom_level == ZOOM_DEFAULT;
     }
 
     public void zoom_in() {
@@ -426,7 +415,6 @@ public class ClientWebView : WebKit.WebView, Geary.BaseInterface {
             new_zoom = ZOOM_MAX;
         }
         this.zoom_level = new_zoom;
-        notify_property("preferred-height");
     }
 
     public void zoom_out() {
@@ -435,7 +423,6 @@ public class ClientWebView : WebKit.WebView, Geary.BaseInterface {
             new_zoom = ZOOM_MIN;
         }
         this.zoom_level = new_zoom;
-        notify_property("preferred-height");
     }
 
     /**
@@ -563,18 +550,24 @@ public 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);
-            this.has_valid_height = true;
+            int height = (int) WebKitUtil.to_number(result);
+            // Avoid notifying if the values have not changed
+            if (this.preferred_height != height) {
+                // value has changed
+                this.preferred_height = height;
+                if (height >= 1) {
+                    // value is valid
+                    if (!this.has_valid_height) {
+                        // validity has changed
+                        this.has_valid_height = true;
+                    }
+                    queue_resize();
+                }
+            }
         } catch (Geary.JS.Error err) {
             debug("Could not get preferred height: %s", err.message);
         }
-
-        if (this.webkit_reported_height != height) {
-            this.webkit_reported_height = height;
-            notify_property("preferred-height");
-        }
     }
 
     private void on_remote_image_load_blocked(WebKit.JavascriptResult result) {
diff --git a/src/client/conversation-viewer/conversation-list-box.vala 
b/src/client/conversation-viewer/conversation-list-box.vala
index ec98087c..fcd8259f 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -855,7 +855,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
      */
     public void zoom_reset() {
         message_view_iterator().foreach((msg_view) => {
-                msg_view.web_view.zoom_reset();
+                msg_view.web_view.zoom_level = 1.0f;
                 return true;
             });
     }
diff --git a/src/client/conversation-viewer/conversation-web-view.vala 
b/src/client/conversation-viewer/conversation-web-view.vala
index cd849418..3d2ac5fb 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -72,8 +72,6 @@ public class ConversationWebView : ClientWebView {
         register_message_handler(
             DECEPTIVE_LINK_CLICKED, on_deceptive_link_clicked
         );
-
-        this.notify["preferred-height"].connect(() => queue_resize());
     }
 
     /**


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