[geary/wip/728002-webkit2: 79/105] Remove ConversationWebView ::is_height_valid property.



commit 5fa89aa3c43066f860aeb7f9d817d2061d78e906
Author: Michael James Gratton <mike vee net>
Date:   Sun Nov 27 17:12:03 2016 +1100

    Remove ConversationWebView ::is_height_valid property.
    
    WK2 seems to be reporting valid hight values now, so we don't need this
    any more. With an additional small tweak, this also fixes auto-marking
    messages as read under WK2.
    
    * src/client/conversation-viewer/conversation-web-view.vala
      (ConversationWebView): Remove ::is_height_valid property. Update call
      sites to use ClientWebView::is_loaded instead.
    
    * src/client/conversation-viewer/conversation-list-box.vala
      (ConversationListBox::check_mark_read): Also check that the web view
      has been allocated a positive size before auto-marking as read.

 .../conversation-viewer/conversation-list-box.vala |   16 +++++++++-------
 .../conversation-viewer/conversation-message.vala  |    5 ++---
 .../conversation-viewer/conversation-web-view.vala |    3 ---
 3 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-list-box.vala 
b/src/client/conversation-viewer/conversation-list-box.vala
index e42ab95..67869be 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_height_valid) {
+                    if (!view.web_view.is_loaded) {
                         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_height_valid) {
+            if (view.primary_message.web_view.is_loaded) {
                 // 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.
@@ -348,7 +348,7 @@ public class ConversationListBox : Gtk.ListBox {
 
         this.key_press_event.connect(on_key_press);
         this.realize.connect(() => {
-                adjustment.value_changed.connect(check_mark_read);
+                adjustment.value_changed.connect(() => { check_mark_read(); });
             });
         this.row_activated.connect(on_row_activated);
         this.size_allocate.connect(() => { check_mark_read(); });
@@ -530,7 +530,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_height_valid &&
+                conversation_message.web_view.is_loaded &&
                 !email_view.is_manually_read) {
                  int body_top = 0;
                  int body_left = 0;
@@ -540,11 +540,13 @@ public class ConversationListBox : Gtk.ListBox {
                      0, 0,
                      out body_left, out body_top
                  );
-                 int body_bottom =
-                     body_top + web_view.get_allocated_height();
+
+                 int body_height = web_view.get_allocated_height();
+                 int body_bottom = body_top + body_height;
 
                  // Only mark the email as read if it's actually visible
-                 if (body_bottom > top_bound &&
+                 if (body_height > 0 &&
+                     body_bottom > top_bound &&
                      body_top + TEXT_PADDING < bottom_bound) {
                      email_ids.add(email_view.email.id);
 
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index df82441..7c567d4 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -453,7 +453,7 @@ public class ConversationMessage : Gtk.Grid {
 
         load_cancelled.cancelled.connect(() => { web_view.stop_loading(); });
         // XXX Hook up unset_controllable_quotes() to size_allocate
-        // and check is_height_valid since we need to accurately know
+        // and check if loaded since we need to accurately know
         // what the sizes of the quote and its container is to
         // determine if it should be unhidden. However this means that
         // when the user expands a hidden quote, this handler gets
@@ -463,8 +463,7 @@ public class ConversationMessage : Gtk.Grid {
         // user could collapse the quote again the space wouldn't be
         // reclaimed, which is worse than this.
         this.web_view.size_allocate.connect(() => {
-                if (this.web_view.is_loaded &&
-                    this.web_view.is_height_valid) {
+                if (this.web_view.is_loaded) {
                     this.web_view.unset_controllable_quotes();
                 }
             });
diff --git a/src/client/conversation-viewer/conversation-web-view.vala 
b/src/client/conversation-viewer/conversation-web-view.vala
index f8ebf6f..f112444 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -22,9 +22,6 @@ public class ConversationWebView : ClientWebView {
     }
 
 
-    public bool is_height_valid { get; private set; default = false; }
-
-
     public ConversationWebView() {
         WebKit.UserContentManager manager = new WebKit.UserContentManager();
         manager.add_style_sheet(ConversationWebView.app_stylesheet);


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