Skip to content

Commit

Permalink
gtk 0.18 upgrade with proper signing
Browse files Browse the repository at this point in the history
  • Loading branch information
dklassic committed Oct 19, 2023
1 parent b22a19e commit 2639314
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 36 deletions.
21 changes: 10 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ default = [ "file-drop", "objc-exception", "protocol", "tao" ]
objc-exception = [ "objc/exception" ]
file-drop = [ ]
protocol = [ ]
dox = [ "tao/dox", "webkit2gtk/dox", "soup3/dox" ]
devtools = [ ]
transparent = [ ]
fullscreen = [ ]
Expand All @@ -41,23 +40,23 @@ serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
thiserror = "1.0"
url = "2.4"
tao = { version = "0.22", default-features = false, features = [ "serde" ], optional = true }
tao = { version = "0.23", default-features = false, features = [ "serde" ], optional = true }
http = "0.2.9"

[dev-dependencies]
http-range = "0.1.5"
base64 = "0.21"

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
javascriptcore-rs = { version = "1.0", features = [ "v2_28" ] }
webkit2gtk = { version = "1.1", features = [ "v2_38" ] }
webkit2gtk-sys = "1.1"
gio = "0.16"
glib = "0.16"
gtk = "0.16"
gdk = "0.16"
soup3 = "0.3"
winit = { package = "winit-gtk", version = "0.28.1", features = [ "serde" ], optional = true }
javascriptcore-rs = { version = "=1.1", features = [ "v2_28" ] }
webkit2gtk = { version = "=2.0", features = [ "v2_38" ] }
webkit2gtk-sys = "=2.0"
gio = "0.18"
glib = "0.18"
gtk = "0.18"
gdk = "0.18"
soup3 = "0.5"
winit = { version = "0.29", package = "winit-gtk", features = [ "serde" ], optional = true }

[target."cfg(target_os = \"windows\")".dependencies]
webview2-com = "0.27"
Expand Down
9 changes: 7 additions & 2 deletions src/webview/webkitgtk/file_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ pub(crate) fn connect_drag_event(
// Called when a drag "fails" - we'll just emit a Cancelled event.
let listener_ref = listener.clone();
let w = window;
webview
.connect_drag_failed(move |_, _, _| gtk::Inhibit(listener_ref.0(&w, FileDropEvent::Cancelled)));
webview.connect_drag_failed(move |_, _, _| {
if listener_ref.0(&w, FileDropEvent::Cancelled) {
glib::Propagation::Stop
} else {
glib::Propagation::Proceed
}
});
}
12 changes: 7 additions & 5 deletions src/webview/webkitgtk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ use std::{
};
use url::Url;
use webkit2gtk::{
traits::*, AutoplayPolicy, LoadEvent, NavigationPolicyDecision, NetworkProxyMode,
NetworkProxySettings, PolicyDecisionType, SettingsExt, URIRequest, UserContentInjectedFrames,
UserScript, UserScriptInjectionTime, WebView, WebViewBuilder, WebsitePoliciesBuilder,
AutoplayPolicy, InputMethodContextExt, LoadEvent, NavigationPolicyDecision,
NavigationPolicyDecisionExt, NetworkProxyMode, NetworkProxySettings, PolicyDecisionType,
SettingsExt, URIRequest, URIRequestExt, UserContentInjectedFrames, UserContentManagerExt,
UserScript, UserScriptInjectionTime, WebInspectorExt, WebView, WebViewExt, WebsiteDataManagerExt,
WebsitePolicies,
};
use webkit2gtk_sys::{
webkit_get_major_version, webkit_get_micro_version, webkit_get_minor_version,
Expand Down Expand Up @@ -86,13 +88,13 @@ impl InnerWebView {
}
}
let webview = {
let mut webview = WebViewBuilder::new();
let mut webview = WebView::builder();
webview = webview.user_content_manager(web_context.manager());
webview = webview.web_context(web_context.context());
webview = webview.is_controlled_by_automation(web_context.allows_automation());
if attributes.autoplay {
webview = webview.website_policies(
&WebsitePoliciesBuilder::new()
&WebsitePolicies::builder()
.autoplay(AutoplayPolicy::Allow)
.build(),
);
Expand Down
12 changes: 10 additions & 2 deletions src/webview/webkitgtk/synthetic_mouse_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ pub fn setup(webview: &WebView) {
_ => {}
}

Inhibit(inhibit)
if inhibit {
glib::Propagation::Stop
} else {
glib::Propagation::Proceed
}
});

let bf_state_c = bf_state.clone();
Expand Down Expand Up @@ -63,7 +67,11 @@ pub fn setup(webview: &WebView) {
}
_ => {}
}
Inhibit(inhibit)
if inhibit {
glib::Propagation::Stop
} else {
glib::Propagation::Proceed
}
});
}

Expand Down
7 changes: 3 additions & 4 deletions src/webview/webkitgtk/undecorated_resizing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ pub fn setup(webview: &WebView) {
}
}
}
Inhibit(false)
glib::Propagation::Proceed
});
webview.connect_button_press_event(move |webview, event| {
let inhibit = false;
if event.button() == 1 {
let (cx, cy) = event.root();
// This one should be GtkBox
Expand All @@ -64,7 +63,7 @@ pub fn setup(webview: &WebView) {
}
}
}
Inhibit(inhibit)
glib::Propagation::Proceed
});
webview.connect_touch_event(|webview, event| {
// This one should be GtkBox
Expand Down Expand Up @@ -97,6 +96,6 @@ pub fn setup(webview: &WebView) {
}
}
}
Inhibit(false)
glib::Propagation::Proceed
});
}
25 changes: 13 additions & 12 deletions src/webview/webkitgtk/web_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use std::{
};
use url::Url;
use webkit2gtk::{
traits::*, ApplicationInfo, CookiePersistentStorage, LoadEvent, URIRequest, UserContentManager,
WebContext, WebContextBuilder, WebView, WebsiteDataManagerBuilder,
ApplicationInfo, CookiePersistentStorage, LoadEvent, URIRequest, URIRequestExt,
URISchemeResponseExt, UserContentManager, WebContext, WebView, WebViewExt,
};

#[derive(Debug)]
Expand All @@ -40,12 +40,13 @@ pub struct WebContextImpl {

impl WebContextImpl {
pub fn new(data: &WebContextData) -> Self {
let mut context_builder = WebContextBuilder::new();
use webkit2gtk::{CookieManagerExt, WebsiteDataManager, WebsiteDataManagerExt};
let mut context_builder = WebContext::builder();
if let Some(data_directory) = data.data_directory() {
let data_manager = WebsiteDataManagerBuilder::new()
.local_storage_directory(&data_directory.join("localstorage").to_string_lossy())
let data_manager = WebsiteDataManager::builder()
.local_storage_directory(data_directory.join("localstorage").to_string_lossy())
.indexeddb_directory(
&data_directory
data_directory
.join("databases")
.join("indexeddb")
.to_string_lossy(),
Expand All @@ -71,7 +72,7 @@ impl WebContextImpl {
}

pub fn create_context(context: WebContext) -> Self {
use webkit2gtk::traits::*;
use webkit2gtk::WebContextExt;
let automation = false;
context.set_automation_allowed(automation);

Expand Down Expand Up @@ -101,7 +102,7 @@ impl WebContextImpl {
}

pub fn set_allows_automation(&mut self, flag: bool) {
use webkit2gtk::traits::*;
use webkit2gtk::WebContextExt;
self.automation = flag;
self.context.set_automation_allowed(flag);
}
Expand Down Expand Up @@ -201,7 +202,7 @@ impl WebContextExt for super::WebContext {
}

fn register_automation(&mut self, webview: WebView) {
use webkit2gtk::traits::*;
use webkit2gtk::{AutomationSessionExt, WebContextExt};

if let (true, Some(app_info)) = (self.os.automation, self.os.app_info.take()) {
self.os.context.connect_automation_started(move |_, auto| {
Expand All @@ -225,7 +226,7 @@ impl WebContextExt for super::WebContext {
download_started_handler: Option<Box<dyn FnMut(String, &mut PathBuf) -> bool>>,
download_completed_handler: Option<Rc<dyn Fn(String, Option<PathBuf>, bool) + 'static>>,
) {
use webkit2gtk::traits::*;
use webkit2gtk::{DownloadExt, WebContextExt};
let context = &self.os.context;

let download_started_handler = RefCell::new(download_started_handler);
Expand Down Expand Up @@ -289,7 +290,7 @@ fn actually_register_uri_scheme<F>(
where
F: Fn(Request<Vec<u8>>, RequestAsyncResponder) + 'static,
{
use webkit2gtk::traits::*;
use webkit2gtk::{SecurityManagerExt, URISchemeRequestExt, WebContextExt};
let context = &context.os.context;
// Enable secure context
context
Expand Down Expand Up @@ -393,7 +394,7 @@ where
for (name, value) in http_response.headers().into_iter() {
headers.append(name.as_str(), value.to_str().unwrap_or(""));
}
response.set_http_headers(&headers);
response.set_http_headers(headers);
request_.finish_with_response(&response);
});

Expand Down

0 comments on commit 2639314

Please sign in to comment.