mirror of
https://github.com/servo/servo.git
synced 2025-10-04 10:39:16 +01:00
* winit: add minibrowser feature that depends on egui{,-winit} * winit: carve out some space at the top of headed windows * winit: minimal toolbar and egui/winit integration (but no painting) * winit: try to paint with egui_glow (doesn’t work yet) * winit: add comment about toolbar size * Add framebuffer object, set it as glow's target * compositing: clear only the viewport, not the whole framebuffer * plumb the actual size of the egui toolbar to webrender * fix formatting * winit: fix crash when fbo is zero * winit: don’t bother binding the framebuffer object * winit: remove unsafe and get toolbar_height * winit: location field should reflect the current top-level url * [NFC] winit: move Minibrowser out of App::run * winit: clean up toolbar height code * winit: make App own the Minibrowser if any * winit: make the go button work * winit:make the location field reflect the current top-level url * winit: allow enabling minibrowser from command line * winit: tell compositor to repaint WR and flush when we repaint * winit: fix bug where location field edits would get overridden * winit: borrow the minibrowser once in App::handle_events * winit: address todo about viewport origin coordinates * winit: fix some minor problems with comments and errors * winit: update location field once per HistoryChanged event * winit: rename Window::set_toolbar_size to set_toolbar_height * winit: take toolbar height into account in hit testing * winit: pass egui only relevant CursorMoved events * winit: scratch that, coalesce minibrowser updates instead * ensure both minibrowser and WR are repainted on every frame * compositing: only skip framebuffer clear in external present mode * winit: destroy egui glow Painter when shutting down * winit: clean up and fix license lint * fix duplicate versions lint by downgrading bytemuck_derive was egui_glow ^0.22.0 (0.22.0) → egui/bytemuck ^0.22.0 (0.22.0) → epaint/bytemuck ^0.22.0 (0.22.0) → bytemuck ^1.7.2 (1.13.1) → bytemuck_derive ^1.4 (1.4.1) → syn ^2.0.1 (2.0.28) now lock has bytemuck_derive 1.4.0 → syn ^1.0.99 (1.0.103) * fix duplicate versions lint by disabling egui-winit/links (we don’t need support for hyperlinks in our use of egui) * squelch duplicate versions lint by excluding clipboard-win * winit: fix compile warnings * winit: make gleam an optional dependency under /minibrowser * winit: remove cargo feature, since it’s not really optional * winit: extract Minibrowser and related code to separate module * winit: remove unnecessary trailing comma * winit: simplify the ServoUrl serialisation optimisation --------- Co-authored-by: atbrakhi <atbrakhi@igalia.com>
151 lines
6.2 KiB
Rust
151 lines
6.2 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
#![deny(unsafe_code)]
|
|
|
|
#[macro_use]
|
|
extern crate log;
|
|
|
|
pub use crate::compositor::CompositingReason;
|
|
pub use crate::compositor::IOCompositor;
|
|
pub use crate::compositor::ShutdownState;
|
|
pub use crate::compositor_thread::CompositorProxy;
|
|
use embedder_traits::Cursor;
|
|
use gfx_traits::Epoch;
|
|
use ipc_channel::ipc::IpcSender;
|
|
use keyboard_types::KeyboardEvent;
|
|
use msg::constellation_msg::PipelineId;
|
|
use msg::constellation_msg::TopLevelBrowsingContextId;
|
|
use msg::constellation_msg::{BrowsingContextId, TraversalDirection};
|
|
use script_traits::{
|
|
AnimationTickType, LogEntry, WebDriverCommandMsg, WindowSizeData, WindowSizeType,
|
|
};
|
|
use script_traits::{
|
|
CompositorEvent, ConstellationControlMsg, LayoutControlMsg, MediaSessionActionType,
|
|
};
|
|
use servo_url::ServoUrl;
|
|
use std::collections::HashMap;
|
|
use std::fmt;
|
|
use std::time::Duration;
|
|
|
|
mod compositor;
|
|
pub mod compositor_thread;
|
|
#[cfg(feature = "gl")]
|
|
mod gl;
|
|
mod touch;
|
|
pub mod windowing;
|
|
|
|
pub struct SendableFrameTree {
|
|
pub pipeline: CompositionPipeline,
|
|
pub children: Vec<SendableFrameTree>,
|
|
}
|
|
|
|
/// The subset of the pipeline that is needed for layer composition.
|
|
#[derive(Clone)]
|
|
pub struct CompositionPipeline {
|
|
pub id: PipelineId,
|
|
pub top_level_browsing_context_id: TopLevelBrowsingContextId,
|
|
pub script_chan: IpcSender<ConstellationControlMsg>,
|
|
pub layout_chan: IpcSender<LayoutControlMsg>,
|
|
}
|
|
|
|
/// Messages to the constellation.
|
|
pub enum ConstellationMsg {
|
|
/// Exit the constellation.
|
|
Exit,
|
|
/// Request that the constellation send the BrowsingContextId corresponding to the document
|
|
/// with the provided pipeline id
|
|
GetBrowsingContext(PipelineId, IpcSender<Option<BrowsingContextId>>),
|
|
/// Request that the constellation send the current pipeline id for the provided
|
|
/// browsing context id, over a provided channel.
|
|
GetPipeline(BrowsingContextId, IpcSender<Option<PipelineId>>),
|
|
/// Request that the constellation send the current focused top-level browsing context id,
|
|
/// over a provided channel.
|
|
GetFocusTopLevelBrowsingContext(IpcSender<Option<TopLevelBrowsingContextId>>),
|
|
/// Query the constellation to see if the current compositor output is stable
|
|
IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
|
|
/// Inform the constellation of a key event.
|
|
Keyboard(KeyboardEvent),
|
|
/// Whether to allow script to navigate.
|
|
AllowNavigationResponse(PipelineId, bool),
|
|
/// Request to load a page.
|
|
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
|
|
/// Clear the network cache.
|
|
ClearCache,
|
|
/// Request to traverse the joint session history of the provided browsing context.
|
|
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
|
|
/// Inform the constellation of a window being resized.
|
|
WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
|
|
/// Requests that the constellation instruct layout to begin a new tick of the animation.
|
|
TickAnimation(PipelineId, AnimationTickType),
|
|
/// Dispatch a webdriver command
|
|
WebDriverCommand(WebDriverCommandMsg),
|
|
/// Reload a top-level browsing context.
|
|
Reload(TopLevelBrowsingContextId),
|
|
/// A log entry, with the top-level browsing context id and thread name
|
|
LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry),
|
|
/// Create a new top level browsing context.
|
|
NewBrowser(ServoUrl, TopLevelBrowsingContextId),
|
|
/// Close a top level browsing context.
|
|
CloseBrowser(TopLevelBrowsingContextId),
|
|
/// Panic a top level browsing context.
|
|
SendError(Option<TopLevelBrowsingContextId>, String),
|
|
/// Make browser visible.
|
|
SelectBrowser(TopLevelBrowsingContextId),
|
|
/// Forward an event to the script task of the given pipeline.
|
|
ForwardEvent(PipelineId, CompositorEvent),
|
|
/// Requesting a change to the onscreen cursor.
|
|
SetCursor(Cursor),
|
|
/// Enable the sampling profiler, with a given sampling rate and max total sampling duration.
|
|
EnableProfiler(Duration, Duration),
|
|
/// Disable the sampling profiler.
|
|
DisableProfiler,
|
|
/// Request to exit from fullscreen mode
|
|
ExitFullScreen(TopLevelBrowsingContextId),
|
|
/// Media session action.
|
|
MediaSessionAction(MediaSessionActionType),
|
|
/// Toggle browser visibility.
|
|
ChangeBrowserVisibility(TopLevelBrowsingContextId, bool),
|
|
/// Virtual keyboard was dismissed
|
|
IMEDismissed,
|
|
/// Compositing done, but external code needs to present.
|
|
ReadyToPresent(TopLevelBrowsingContextId),
|
|
}
|
|
|
|
impl fmt::Debug for ConstellationMsg {
|
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
use self::ConstellationMsg::*;
|
|
let variant = match *self {
|
|
Exit => "Exit",
|
|
GetBrowsingContext(..) => "GetBrowsingContext",
|
|
GetPipeline(..) => "GetPipeline",
|
|
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
|
|
IsReadyToSaveImage(..) => "IsReadyToSaveImage",
|
|
Keyboard(..) => "Keyboard",
|
|
AllowNavigationResponse(..) => "AllowNavigationResponse",
|
|
LoadUrl(..) => "LoadUrl",
|
|
TraverseHistory(..) => "TraverseHistory",
|
|
WindowSize(..) => "WindowSize",
|
|
TickAnimation(..) => "TickAnimation",
|
|
WebDriverCommand(..) => "WebDriverCommand",
|
|
Reload(..) => "Reload",
|
|
LogEntry(..) => "LogEntry",
|
|
NewBrowser(..) => "NewBrowser",
|
|
CloseBrowser(..) => "CloseBrowser",
|
|
SendError(..) => "SendError",
|
|
SelectBrowser(..) => "SelectBrowser",
|
|
ForwardEvent(..) => "ForwardEvent",
|
|
SetCursor(..) => "SetCursor",
|
|
EnableProfiler(..) => "EnableProfiler",
|
|
DisableProfiler => "DisableProfiler",
|
|
ExitFullScreen(..) => "ExitFullScreen",
|
|
MediaSessionAction(..) => "MediaSessionAction",
|
|
ChangeBrowserVisibility(..) => "ChangeBrowserVisibility",
|
|
IMEDismissed => "IMEDismissed",
|
|
ClearCache => "ClearCache",
|
|
ReadyToPresent(..) => "ReadyToPresent",
|
|
};
|
|
write!(formatter, "ConstellationMsg::{}", variant)
|
|
}
|
|
}
|