From d1e77fff25e5a65b15d975f76278db31c0af418f Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 7 Aug 2003 21:53:39 +0000 Subject: Clamp the values to 0/100, mozilla sometimes report more done requests 2003-08-07 Marco Pesenti Gritti * src/ephy-tab.c: (build_load_percent): Clamp the values to 0/100, mozilla sometimes report more done requests than total requests, but their progress widget clamp them. --- src/ephy-tab.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ephy-tab.c b/src/ephy-tab.c index a84c0ce4f..e9643c56f 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -597,16 +597,24 @@ ephy_tab_title_cb (EphyEmbed *embed, EphyTab *tab) } static int -build_load_percent (int bytes_loaded, int max_bytes_loaded) +build_load_percent (int requests_done, int requests_total) { - if (max_bytes_loaded > 0) + int percent; + + if (requests_total > 0) { - return (bytes_loaded * 100) / max_bytes_loaded; + percent = (requests_done * 100) / requests_total; + + /* Mozilla sometimes report more done requests than + total requests. Their progress widget clamp the value */ + percent = CLAMP (percent, 0, 100); } else { - return -1; + percent = -1; } + + return percent; } static char * -- cgit v1.2.3