Skip to main content

Tab

Struct Tab 

Source
pub struct Tab { /* private fields */ }
Expand description

Tab はブラウザで開かれた 1 つのページを表す構造体です。

主な責務:

  • 現在表示しているページのタイトルの保持
  • ページ内容を扱う WebView の保持

WebView が「ページそのもの」の状態を管理するのに対し、 Tab は UI 上のタブとしてのメタ情報(タイトルなど)を管理します。

Implementations§

Source§

impl Tab

Source

pub fn new(system_color_scheme: ColorScheme, js_policy: JsPolicy) -> Self

Source

pub fn tick(&mut self) -> Vec<TabTask>

Tab 内の状態を 1 ステップ進める

  • WebView.tick() を呼び出す
  • 発生した Task を BrowserApp に返す
Source

pub fn on_css_fetched(&mut self, css: String)

BrowserApp から CSS fetch 完了を通知

Source

pub fn on_fetch_succeeded_html(&mut self, html: String)

BrowserApp からの HTML fetch 完了を通知

Source

pub fn on_fetch_succeeded_css(&mut self, css: String)

Source

pub fn on_fetch_succeeded_css_from(&mut self, css: String, stylesheet_url: &Url)

Source

pub fn on_fetch_succeeded_image(&mut self, source: String, bytes: &[u8])

Delivers encoded image bytes to the page that requested them.

Source

pub fn on_fetch_succeeded_audio(&mut self, source: String, bytes: &[u8])

Delivers encoded audio bytes to the page that requested them.

Source

pub fn on_fetch_succeeded_script(&mut self, index: usize, source: String)

Delivers a fetched external classic script in document order.

Source

pub fn on_fetch_failed_script(&mut self, index: usize)

Skips a failed external classic script without replacing the page.

Source

pub fn on_fetch_succeeded_dynamic_script( &mut self, node_id: u64, source: String, )

Source

pub fn on_fetch_failed_dynamic_script(&mut self, node_id: u64)

Source

pub fn on_fetch_succeeded_dynamic_style(&mut self, node_id: u64, source: String)

Source

pub fn on_fetch_failed_dynamic_style(&mut self, node_id: u64)

Source

pub fn on_fetch_succeeded_iframe(&mut self, dom_id: u64, html: String)

Installs fetched HTML as an <iframe> element’s contentDocument.

Source

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.

Source

pub fn on_fetch_succeeded_js( &mut self, request_id: u64, response: BrowserResponse, redirected: bool, )

Delivers a completed JavaScript fetch() response.

Source

pub fn on_fetch_failed_js(&mut self, request_id: u64, reason: String)

Delivers a JavaScript fetch() network failure without navigating away.

Source

pub fn inspect(&mut self, method: &str, params: &str) -> Result<Value, String>

Answers a DevTools inspection query against this tab’s page.

Source

pub fn draw(&mut self, cmd_buf: &mut Vec<DrawCommand>, width: f32, height: f32)

Source

pub fn handle_mouse_input( &mut self, px: f32, py: f32, state: ElementState, ) -> (bool, bool)

Source

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.

Source

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.

Source

pub fn defocus_text_input(&self) -> bool

Defocuses any focused text input.

Returns the href of the link under the given page coordinates, if any.

Source

pub fn scroll_at( &mut self, px: f32, py: f32, dx: f32, dy: f32, viewport: (f32, f32), )

Scrolls the scrollable container under the cursor.

Source

pub fn has_layout(&self) -> bool

Whether this tab has a layout tree ready for drawing or hit-testing.

Source

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).

Source

pub fn on_devtools_response(&mut self, id: u64, result: String)

Settles a DevTools inspection request with its JSON envelope.

Source

pub fn on_fetch_failed(&mut self, err: BrowserNetworkError, failed_url: Url)

Display error page on fetch failure

Source

pub fn navigate(&mut self, url: Url)

Source

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.

Source

pub fn reload(&mut self)

Reloads the current document, if one is loaded.

Source

pub fn can_go_back(&self) -> bool

Returns whether the back button can navigate to a previous page.

Source

pub fn move_to(&mut self, href: &str)

Source

pub fn relayout(&mut self, viewport: (f32, f32))

Source

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.

Source

pub fn set_system_color_scheme(&mut self, scheme: ColorScheme)

Source

pub fn title(&self) -> Option<String>

Returns title of the document

Source

pub fn document_url(&self) -> Option<Url>

Returns document url

Source

pub fn needs_redraw(&self) -> bool

Source

pub fn clear_redraw_flag(&mut self)

Source

pub fn set_js_policy(&mut self, policy: JsPolicy)

Trait Implementations§

Source§

impl Debug for Tab

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Tab

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more