From 2d160b5a492082e73aa307a7fa885f6536aabfda Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 28 Sep 2024 14:18:13 +0300 Subject: [PATCH] implement progress fraction update --- src/browser/main/tab/page.rs | 12 ++++++++++-- src/browser/main/tab/page/navigation.rs | 4 ++-- src/browser/main/tab/page/navigation/request.rs | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/browser/main/tab/page.rs b/src/browser/main/tab/page.rs index 10609e64..fba480d7 100644 --- a/src/browser/main/tab/page.rs +++ b/src/browser/main/tab/page.rs @@ -388,8 +388,16 @@ impl Page { pub fn update(&self) { // Interpret status to progress fraction - // @TODO - self.navigation.update(); + let progress_fraction = match self.meta.borrow().status { + Some(Status::Prepare) => 0.25, + Some(Status::Connect) => 0.50, + Some(Status::Request) => 0.75, + Some(Status::Response) => 1.0, + _ => 0.0, + }; + + // Update components + self.navigation.update(progress_fraction); // @TODO self.content.update(); } diff --git a/src/browser/main/tab/page/navigation.rs b/src/browser/main/tab/page/navigation.rs index 029c81fd..6b59bdfe 100644 --- a/src/browser/main/tab/page/navigation.rs +++ b/src/browser/main/tab/page/navigation.rs @@ -71,11 +71,11 @@ impl Navigation { } // Actions - pub fn update(&self) { + pub fn update(&self, progress_fraction: f64) { self.base.update(self.request.uri()); self.history.update(); self.reload.update(!self.request.is_empty()); - self.request.update(); + self.request.update(progress_fraction); self.bookmark.update(); } diff --git a/src/browser/main/tab/page/navigation/request.rs b/src/browser/main/tab/page/navigation/request.rs index 3835b573..80eb631f 100644 --- a/src/browser/main/tab/page/navigation/request.rs +++ b/src/browser/main/tab/page/navigation/request.rs @@ -41,7 +41,8 @@ impl Request { } // Actions - pub fn update(&self) { + pub fn update(&self, progress_fraction: f64) { + self.widget.set_progress_fraction(progress_fraction); // @TODO animate progress fraction }