mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #20071 - paulrouget:typedsize, r=glennw
Use typed coordinates more Requires https://github.com/servo/servo/pull/19895 We use Size2D and Point2D across compositing, constellation and script, loosing the type of pixels we use (DevicePixel, DeviceIndepententPixel or CSSPixel) along the way, which might lead to bugs like `window.outerHeight` not taking into account the page zoom (using DeviceIndepententPixel instead of CSSPixel). This should make the situation a bit better. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because we can't zoom in a test <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20071) <!-- Reviewable:end -->
This commit is contained in:
commit
fc90e613d8
13 changed files with 151 additions and 133 deletions
|
@ -5,26 +5,25 @@
|
|||
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
|
||||
|
||||
use compositor_thread::EventLoopWaker;
|
||||
use euclid::{Point2D, Size2D};
|
||||
use euclid::{TypedScale, TypedPoint2D, TypedSize2D};
|
||||
use euclid::TypedScale;
|
||||
use gleam::gl;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, TopLevelBrowsingContextId, TraversalDirection};
|
||||
use net_traits::net_error_list::NetError;
|
||||
use script_traits::{LoadData, MouseButton, TouchEventType, TouchId};
|
||||
use servo_geometry::DeviceIndependentPixel;
|
||||
use servo_geometry::{DeviceIndependentPixel, DeviceUintLength};
|
||||
use servo_url::ServoUrl;
|
||||
use std::fmt::{Debug, Error, Formatter};
|
||||
use std::rc::Rc;
|
||||
use style_traits::DevicePixel;
|
||||
use style_traits::cursor::CursorKind;
|
||||
use webrender_api::{DeviceUintSize, DeviceUintRect, ScrollLocation};
|
||||
use webrender_api::{DeviceIntPoint, DevicePoint, DeviceUintSize, DeviceUintRect, ScrollLocation};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum MouseWindowEvent {
|
||||
Click(MouseButton, TypedPoint2D<f32, DevicePixel>),
|
||||
MouseDown(MouseButton, TypedPoint2D<f32, DevicePixel>),
|
||||
MouseUp(MouseButton, TypedPoint2D<f32, DevicePixel>),
|
||||
Click(MouseButton, DevicePoint),
|
||||
MouseDown(MouseButton, DevicePoint),
|
||||
MouseUp(MouseButton, DevicePoint),
|
||||
}
|
||||
|
||||
/// Various debug and profiling flags that WebRender supports.
|
||||
|
@ -55,12 +54,12 @@ pub enum WindowEvent {
|
|||
/// Sent when a mouse hit test is to be performed.
|
||||
MouseWindowEventClass(MouseWindowEvent),
|
||||
/// Sent when a mouse move.
|
||||
MouseWindowMoveEventClass(TypedPoint2D<f32, DevicePixel>),
|
||||
MouseWindowMoveEventClass(DevicePoint),
|
||||
/// Touch event: type, identifier, point
|
||||
Touch(TouchEventType, TouchId, TypedPoint2D<f32, DevicePixel>),
|
||||
Touch(TouchEventType, TouchId, DevicePoint),
|
||||
/// Sent when the user scrolls. The first point is the delta and the second point is the
|
||||
/// origin.
|
||||
Scroll(ScrollLocation, TypedPoint2D<i32, DevicePixel>, TouchEventType),
|
||||
Scroll(ScrollLocation, DeviceIntPoint, TouchEventType),
|
||||
/// Sent when the user zooms.
|
||||
Zoom(f32),
|
||||
/// Simulated "pinch zoom" gesture for non-touch platforms (e.g. ctrl-scrollwheel).
|
||||
|
@ -126,21 +125,19 @@ pub trait WindowMethods {
|
|||
fn framebuffer_size(&self) -> DeviceUintSize;
|
||||
/// Returns the position and size of the window within the rendering area.
|
||||
fn window_rect(&self) -> DeviceUintRect;
|
||||
/// Returns the size of the window in density-independent "px" units.
|
||||
fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel>;
|
||||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
fn present(&self);
|
||||
|
||||
/// Return the size of the window with head and borders and position of the window values
|
||||
fn client_window(&self, ctx: TopLevelBrowsingContextId) -> (Size2D<u32>, Point2D<i32>);
|
||||
/// Return the size of the screen (pixel)
|
||||
fn screen_size(&self, ctx: TopLevelBrowsingContextId) -> Size2D<u32>;
|
||||
/// Return the available size of the screen (pixel)
|
||||
fn screen_avail_size(&self, ctx: TopLevelBrowsingContextId) -> Size2D<u32>;
|
||||
fn client_window(&self, ctx: TopLevelBrowsingContextId) -> (DeviceUintSize, DeviceIntPoint);
|
||||
/// Return the size of the screen.
|
||||
fn screen_size(&self, ctx: TopLevelBrowsingContextId) -> DeviceUintSize;
|
||||
/// Return the available size of the screen.
|
||||
fn screen_avail_size(&self, ctx: TopLevelBrowsingContextId) -> DeviceUintSize;
|
||||
/// Set the size inside of borders and head
|
||||
fn set_inner_size(&self, ctx: TopLevelBrowsingContextId, size: Size2D<u32>);
|
||||
fn set_inner_size(&self, ctx: TopLevelBrowsingContextId, size: DeviceUintSize);
|
||||
/// Set the window position
|
||||
fn set_position(&self, ctx: TopLevelBrowsingContextId, point: Point2D<i32>);
|
||||
fn set_position(&self, ctx: TopLevelBrowsingContextId, point: DeviceIntPoint);
|
||||
/// Set fullscreen state
|
||||
fn set_fullscreen_state(&self, ctx: TopLevelBrowsingContextId, state: bool);
|
||||
|
||||
|
@ -170,7 +167,7 @@ pub trait WindowMethods {
|
|||
/// Requests that the window system prepare a composite. Typically this will involve making
|
||||
/// some type of platform-specific graphics context current. Returns true if the composite may
|
||||
/// proceed and false if it should not.
|
||||
fn prepare_for_composite(&self, width: usize, height: usize) -> bool;
|
||||
fn prepare_for_composite(&self, width: DeviceUintLength, height: DeviceUintLength) -> bool;
|
||||
|
||||
/// Sets the cursor to be used in the window.
|
||||
fn set_cursor(&self, cursor: CursorKind);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue