pub struct Tab { /* private fields */ }Expand description
Tab はブラウザで開かれた 1 つのページを表す構造体です。
主な責務:
- 現在表示しているページのタイトルの保持
- ページ内容を扱う WebView の保持
WebView が「ページそのもの」の状態を管理するのに対し、 Tab は UI 上のタブとしてのメタ情報(タイトルなど)を管理します。
Implementations§
Source§impl Tab
impl Tab
pub fn new(system_color_scheme: ColorScheme, js_policy: JsPolicy) -> Self
Sourcepub fn tick(&mut self) -> Vec<TabTask>
pub fn tick(&mut self) -> Vec<TabTask>
Tab 内の状態を 1 ステップ進める
- WebView.tick() を呼び出す
- 発生した Task を BrowserApp に返す
Sourcepub fn on_css_fetched(&mut self, css: String)
pub fn on_css_fetched(&mut self, css: String)
BrowserApp から CSS fetch 完了を通知
Sourcepub fn on_fetch_succeeded_html(&mut self, html: String)
pub fn on_fetch_succeeded_html(&mut self, html: String)
BrowserApp からの HTML fetch 完了を通知
pub fn on_fetch_succeeded_css(&mut self, css: String)
pub fn on_fetch_succeeded_css_from(&mut self, css: String, stylesheet_url: &Url)
Sourcepub fn on_fetch_succeeded_image(&mut self, source: String, bytes: &[u8])
pub fn on_fetch_succeeded_image(&mut self, source: String, bytes: &[u8])
Delivers encoded image bytes to the page that requested them.
Sourcepub fn on_fetch_succeeded_audio(&mut self, source: String, bytes: &[u8])
pub fn on_fetch_succeeded_audio(&mut self, source: String, bytes: &[u8])
Delivers encoded audio bytes to the page that requested them.
Sourcepub fn on_fetch_succeeded_script(&mut self, index: usize, source: String)
pub fn on_fetch_succeeded_script(&mut self, index: usize, source: String)
Delivers a fetched external classic script in document order.
Sourcepub fn on_fetch_failed_script(&mut self, index: usize)
pub fn on_fetch_failed_script(&mut self, index: usize)
Skips a failed external classic script without replacing the page.
pub fn on_fetch_succeeded_dynamic_script( &mut self, node_id: u64, source: String, )
pub fn on_fetch_failed_dynamic_script(&mut self, node_id: u64)
pub fn on_fetch_succeeded_dynamic_style(&mut self, node_id: u64, source: String)
pub fn on_fetch_failed_dynamic_style(&mut self, node_id: u64)
Sourcepub fn on_fetch_succeeded_iframe(&mut self, dom_id: u64, html: String)
pub fn on_fetch_succeeded_iframe(&mut self, dom_id: u64, html: String)
Installs fetched HTML as an <iframe> element’s contentDocument.
Sourcepub fn on_fetch_failed_iframe(&mut self, dom_id: u64)
pub fn on_fetch_failed_iframe(&mut self, dom_id: u64)
Marks an iframe load as failed so later contentDocument accesses do
not keep re-queuing a fetch.
Sourcepub fn on_fetch_succeeded_js(
&mut self,
request_id: u64,
response: BrowserResponse,
redirected: bool,
)
pub fn on_fetch_succeeded_js( &mut self, request_id: u64, response: BrowserResponse, redirected: bool, )
Delivers a completed JavaScript fetch() response.
Sourcepub fn on_fetch_failed_js(&mut self, request_id: u64, reason: String)
pub fn on_fetch_failed_js(&mut self, request_id: u64, reason: String)
Delivers a JavaScript fetch() network failure without navigating away.
Sourcepub fn inspect(&mut self, method: &str, params: &str) -> Result<Value, String>
pub fn inspect(&mut self, method: &str, params: &str) -> Result<Value, String>
Answers a DevTools inspection query against this tab’s page.
pub fn draw(&mut self, cmd_buf: &mut Vec<DrawCommand>, width: f32, height: f32)
pub fn handle_mouse_input( &mut self, px: f32, py: f32, state: ElementState, ) -> (bool, bool)
Sourcepub fn handle_pointer_move(&mut self, px: f32, py: f32) -> (bool, bool)
pub fn handle_pointer_move(&mut self, px: f32, py: f32) -> (bool, bool)
Dispatches a pointer move and updates hover state without touching
click bookkeeping. Unlike Tab::handle_mouse_input it never
synthesizes press/release events, so it is safe to call on every
cursor movement.
Sourcepub fn dispatch_text_input(&self, event: InputTextEvent) -> bool
pub fn dispatch_text_input(&self, event: InputTextEvent) -> bool
Sends a text-input event (key, insert, composition) to the focused text input, if one exists.
Sourcepub fn defocus_text_input(&self) -> bool
pub fn defocus_text_input(&self) -> bool
Defocuses any focused text input.
Sourcepub fn link_at(&self, px: f32, py: f32) -> Option<String>
pub fn link_at(&self, px: f32, py: f32) -> Option<String>
Returns the href of the link under the given page coordinates, if any.
Sourcepub fn scroll_at(
&mut self,
px: f32,
py: f32,
dx: f32,
dy: f32,
viewport: (f32, f32),
)
pub fn scroll_at( &mut self, px: f32, py: f32, dx: f32, dy: f32, viewport: (f32, f32), )
Scrolls the scrollable container under the cursor.
Sourcepub fn has_layout(&self) -> bool
pub fn has_layout(&self) -> bool
Whether this tab has a layout tree ready for drawing or hit-testing.
Sourcepub fn is_text_input_composing(&self) -> bool
pub fn is_text_input_composing(&self) -> bool
Whether the currently focused text input is in the middle of a composition (e.g. IME preedit).
Sourcepub fn on_devtools_response(&mut self, id: u64, result: String)
pub fn on_devtools_response(&mut self, id: u64, result: String)
Settles a DevTools inspection request with its JSON envelope.
Sourcepub fn on_fetch_failed(&mut self, err: BrowserNetworkError, failed_url: Url)
pub fn on_fetch_failed(&mut self, err: BrowserNetworkError, failed_url: Url)
Display error page on fetch failure
Sourcepub fn go_back(&mut self) -> bool
pub fn go_back(&mut self) -> bool
Navigates to the previous URL in the history, if any.
Returns false when there is no history to go back to.
Sourcepub fn can_go_back(&self) -> bool
pub fn can_go_back(&self) -> bool
Returns whether the back button can navigate to a previous page.
pub fn move_to(&mut self, href: &str)
pub fn relayout(&mut self, viewport: (f32, f32))
Sourcepub fn on_js_click(&mut self, dom_id: u32) -> bool
pub fn on_js_click(&mut self, dom_id: u32) -> bool
Dispatches a click on a DOM node to the page’s JS onclick handler.
Returns whether the click mutated the DOM and needs a redraw.
pub fn set_system_color_scheme(&mut self, scheme: ColorScheme)
Sourcepub fn document_url(&self) -> Option<Url>
pub fn document_url(&self) -> Option<Url>
Returns document url
pub fn needs_redraw(&self) -> bool
pub fn clear_redraw_flag(&mut self)
pub fn set_js_policy(&mut self, policy: JsPolicy)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Tab
impl !RefUnwindSafe for Tab
impl !Send for Tab
impl !Sync for Tab
impl !UnwindSafe for Tab
impl Unpin for Tab
impl UnsafeUnpin for Tab
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().