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.
This commit is contained in:
Michael James Gratton 2016-11-27 17:12:03 +11:00
parent 766d55e75d
commit 7c5e5ae2cd
3 changed files with 11 additions and 13 deletions

View file

@ -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);

View file

@ -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();
}
});

View file

@ -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);