1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// from webkit2gtk-gir-files
// DO NOT EDIT
use crate::DOMObject;
use crate::ScriptWorld;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
/// A web page frame.
///
/// Each `WebKitWebPage` has at least one main frame, and can have any number
/// of subframes.
///
/// # Implements
///
/// [`FrameExt`][trait@crate::prelude::FrameExt]
#[doc(alias = "WebKitFrame")]
pub struct Frame(Object<ffi::WebKitFrame, ffi::WebKitFrameClass>);
match fn {
type_ => || ffi::webkit_frame_get_type(),
}
}
impl Frame {
pub const NONE: Option<&'static Frame> = None;
}
/// Trait containing all [`struct@Frame`] methods.
///
/// # Implementors
///
/// [`Frame`][struct@crate::Frame]
pub trait FrameExt: 'static {
/// Gets the process-unique identifier of this [`Frame`][crate::Frame]. No other
/// frame in the same web process will have the same ID; however, frames
/// in other web processes may.
///
/// # Returns
///
/// the identifier of `self`
#[doc(alias = "webkit_frame_get_id")]
#[doc(alias = "get_id")]
fn id(&self) -> u64;
//#[cfg_attr(feature = "v2_22", deprecated = "Since 2.22")]
//#[doc(alias = "webkit_frame_get_javascript_context_for_script_world")]
//#[doc(alias = "get_javascript_context_for_script_world")]
//fn javascript_context_for_script_world(&self, world: &impl IsA<ScriptWorld>) -> /*Ignored*/Option<javascriptcore::GlobalContextRef>;
//#[cfg_attr(feature = "v2_22", deprecated = "Since 2.22")]
//#[doc(alias = "webkit_frame_get_javascript_global_context")]
//#[doc(alias = "get_javascript_global_context")]
//fn javascript_global_context(&self) -> /*Ignored*/Option<javascriptcore::GlobalContextRef>;
/// Get the JavaScript execution context of `self`. Use this function to bridge
/// between the WebKit and JavaScriptCore APIs.
///
/// # Returns
///
/// the [`javascriptcore::Context`][crate::javascriptcore::Context] for the JavaScript execution context of `self`.
#[doc(alias = "webkit_frame_get_js_context")]
#[doc(alias = "get_js_context")]
fn js_context(&self) -> Option<javascriptcore::Context>;
/// Get the JavaScript execution context of `self` for the given [`ScriptWorld`][crate::ScriptWorld].
/// ## `world`
/// a [`ScriptWorld`][crate::ScriptWorld]
///
/// # Returns
///
/// the [`javascriptcore::Context`][crate::javascriptcore::Context] for the JavaScript execution context of `self` for `world`.
#[doc(alias = "webkit_frame_get_js_context_for_script_world")]
#[doc(alias = "get_js_context_for_script_world")]
fn js_context_for_script_world(
&self,
world: &impl IsA<ScriptWorld>,
) -> Option<javascriptcore::Context>;
/// Get a [`javascriptcore::Value`][crate::javascriptcore::Value] referencing the given DOM object. The value is created in the JavaScript execution
/// context of `self`.
/// ## `dom_object`
/// a [`DOMObject`][crate::DOMObject]
///
/// # Returns
///
/// the [`javascriptcore::Value`][crate::javascriptcore::Value] referencing `dom_object`.
#[doc(alias = "webkit_frame_get_js_value_for_dom_object")]
#[doc(alias = "get_js_value_for_dom_object")]
fn js_value_for_dom_object(
&self,
dom_object: &impl IsA<DOMObject>,
) -> Option<javascriptcore::Value>;
/// Get a [`javascriptcore::Value`][crate::javascriptcore::Value] referencing the given DOM object. The value is created in the JavaScript execution
/// context of `self` for the given [`ScriptWorld`][crate::ScriptWorld].
/// ## `dom_object`
/// a [`DOMObject`][crate::DOMObject]
/// ## `world`
/// a [`ScriptWorld`][crate::ScriptWorld]
///
/// # Returns
///
/// the [`javascriptcore::Value`][crate::javascriptcore::Value] referencing `dom_object`
#[doc(alias = "webkit_frame_get_js_value_for_dom_object_in_script_world")]
#[doc(alias = "get_js_value_for_dom_object_in_script_world")]
fn js_value_for_dom_object_in_script_world(
&self,
dom_object: &impl IsA<DOMObject>,
world: &impl IsA<ScriptWorld>,
) -> Option<javascriptcore::Value>;
/// Gets the current active URI of `self`.
///
/// # Returns
///
/// the current active URI of `self` or [`None`] if nothing has been
/// loaded yet.
#[doc(alias = "webkit_frame_get_uri")]
#[doc(alias = "get_uri")]
fn uri(&self) -> Option<glib::GString>;
/// Gets whether `self` is the main frame of a [`WebPage`][crate::WebPage]
///
/// # Returns
///
/// [`true`] if `self` is a main frame or [`false`] otherwise
#[doc(alias = "webkit_frame_is_main_frame")]
fn is_main_frame(&self) -> bool;
}
impl<O: IsA<Frame>> FrameExt for O {
fn id(&self) -> u64 {
unsafe { ffi::webkit_frame_get_id(self.as_ref().to_glib_none().0) }
}
//fn javascript_context_for_script_world(&self, world: &impl IsA<ScriptWorld>) -> /*Ignored*/Option<javascriptcore::GlobalContextRef> {
// unsafe { TODO: call ffi:webkit_frame_get_javascript_context_for_script_world() }
//}
//fn javascript_global_context(&self) -> /*Ignored*/Option<javascriptcore::GlobalContextRef> {
// unsafe { TODO: call ffi:webkit_frame_get_javascript_global_context() }
//}
fn js_context(&self) -> Option<javascriptcore::Context> {
unsafe {
from_glib_full(ffi::webkit_frame_get_js_context(
self.as_ref().to_glib_none().0,
))
}
}
fn js_context_for_script_world(
&self,
world: &impl IsA<ScriptWorld>,
) -> Option<javascriptcore::Context> {
unsafe {
from_glib_full(ffi::webkit_frame_get_js_context_for_script_world(
self.as_ref().to_glib_none().0,
world.as_ref().to_glib_none().0,
))
}
}
fn js_value_for_dom_object(
&self,
dom_object: &impl IsA<DOMObject>,
) -> Option<javascriptcore::Value> {
unsafe {
from_glib_full(ffi::webkit_frame_get_js_value_for_dom_object(
self.as_ref().to_glib_none().0,
dom_object.as_ref().to_glib_none().0,
))
}
}
fn js_value_for_dom_object_in_script_world(
&self,
dom_object: &impl IsA<DOMObject>,
world: &impl IsA<ScriptWorld>,
) -> Option<javascriptcore::Value> {
unsafe {
from_glib_full(
ffi::webkit_frame_get_js_value_for_dom_object_in_script_world(
self.as_ref().to_glib_none().0,
dom_object.as_ref().to_glib_none().0,
world.as_ref().to_glib_none().0,
),
)
}
}
fn uri(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::webkit_frame_get_uri(self.as_ref().to_glib_none().0)) }
}
fn is_main_frame(&self) -> bool {
unsafe {
from_glib(ffi::webkit_frame_is_main_frame(
self.as_ref().to_glib_none().0,
))
}
}
}
impl fmt::Display for Frame {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Frame")
}
}