Use webrender_api::units::DevicePixel rather than style_traits::DevicePixel unless interfacing with Stylo (#34353)

* Use webrender_api::units::DevicePixel rather than style_traits::DevicePixel unless interfacing with Stylo

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix OpenHarmony build

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
Nico Burns 2024-11-26 12:42:04 +13:00 committed by GitHub
parent 97154d9cf8
commit 63793ccbb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 52 additions and 46 deletions

25
Cargo.lock generated
View file

@ -1617,7 +1617,7 @@ dependencies = [
[[package]]
name = "dom"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"bitflags 2.6.0",
"malloc_size_of",
@ -4246,7 +4246,7 @@ dependencies = [
[[package]]
name = "malloc_size_of"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"app_units",
"cssparser",
@ -6196,7 +6196,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.26.0"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"bitflags 2.6.0",
"cssparser",
@ -6484,7 +6484,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.4.0"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"serde",
"stable_deref_trait",
@ -6493,7 +6493,7 @@ dependencies = [
[[package]]
name = "servo_atoms"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"string_cache",
"string_cache_codegen",
@ -6866,7 +6866,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "static_prefs"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
[[package]]
name = "strck"
@ -6925,7 +6925,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "style"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"app_units",
"arrayvec",
@ -6983,7 +6983,7 @@ dependencies = [
[[package]]
name = "style_config"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"lazy_static",
]
@ -6991,7 +6991,7 @@ dependencies = [
[[package]]
name = "style_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"darling",
"proc-macro2",
@ -7021,7 +7021,7 @@ dependencies = [
[[package]]
name = "style_traits"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"app_units",
"bitflags 2.6.0",
@ -7038,7 +7038,6 @@ dependencies = [
"to_shmem",
"to_shmem_derive",
"url",
"webrender_api",
]
[[package]]
@ -7385,7 +7384,7 @@ dependencies = [
[[package]]
name = "to_shmem"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"cssparser",
"servo_arc",
@ -7398,7 +7397,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#639802f35677f444a66fa1cf01bb579065cb2a27"
source = "git+https://github.com/servo/stylo?branch=2024-11-01#4eb9da3b639baab6b16a43b8512b5c11c087fc2c"
dependencies = [
"darling",
"proc-macro2",

View file

@ -35,11 +35,11 @@ use script_traits::{
ScrollState, TouchEventType, TouchId, WheelDelta, WindowSizeData, WindowSizeType,
};
use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength};
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
use style_traits::{CSSPixel, PinchZoomFactor};
use webrender::{CaptureBits, RenderApi, Transaction};
use webrender_api::units::{
DeviceIntPoint, DeviceIntSize, DevicePoint, DeviceRect, LayoutPoint, LayoutRect, LayoutSize,
LayoutVector2D, WorldPoint,
DeviceIntPoint, DeviceIntSize, DevicePixel, DevicePoint, DeviceRect, LayoutPoint, LayoutRect,
LayoutSize, LayoutVector2D, WorldPoint,
};
use webrender_api::{
self, BuiltDisplayList, DirtyRect, DisplayListPayload, DocumentId, Epoch as WebRenderEpoch,

View file

@ -5,8 +5,7 @@
use euclid::{Point2D, Scale, Vector2D};
use log::{debug, warn};
use script_traits::{EventResult, TouchId};
use style_traits::DevicePixel;
use webrender_api::units::{DeviceIntPoint, LayoutVector2D};
use webrender_api::units::{DeviceIntPoint, DevicePixel, LayoutVector2D};
use self::TouchState::*;

View file

@ -19,8 +19,9 @@ use script_traits::{
};
use servo_geometry::{DeviceIndependentIntRect, DeviceIndependentIntSize, DeviceIndependentPixel};
use servo_url::ServoUrl;
use style_traits::DevicePixel;
use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint, DeviceRect};
use webrender_api::units::{
DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint, DeviceRect,
};
use webrender_api::ScrollLocation;
use webrender_traits::RenderingContext;

View file

@ -18,7 +18,7 @@ use bitflags::bitflags;
use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg};
use embedder_traits::Cursor;
use euclid::default::{Point2D, Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D};
use euclid::{rect, SideOffsets2D};
use euclid::{rect, Scale, SideOffsets2D};
use fnv::FnvHashMap;
use fonts::ByteIndex;
use ipc_channel::ipc;
@ -907,7 +907,12 @@ impl Fragment {
.filter_map(|(name, id)| id.as_shorthand().err().map(|id| (name, id)))
.map(|(name, id)| (name.clone(), style.computed_value_to_string(id)))
.collect();
painter.draw_a_paint_image(size_in_px, device_pixel_ratio, properties, arguments)
painter.draw_a_paint_image(
size_in_px,
Scale::new(device_pixel_ratio.get()),
properties,
arguments,
)
},
None => {
debug!("Worklet {} called before registration.", name);

View file

@ -32,8 +32,8 @@ use style::values::generics::NonNegative;
use style::values::specified::text::TextDecorationLine;
use style::values::specified::ui::CursorKind;
use style::Zero;
use style_traits::{CSSPixel, DevicePixel};
use webrender_api::units::{LayoutPixel, LayoutRect, LayoutSize};
use style_traits::CSSPixel;
use webrender_api::units::{DevicePixel, LayoutPixel, LayoutRect, LayoutSize};
use webrender_api::{
self as wr, units, BorderDetails, BoxShadowClipMode, ClipChainId, CommonItemProperties,
ImageRendering, NinePatchBorder, NinePatchBorderSource,

View file

@ -101,9 +101,10 @@ use style::traversal_flags::TraversalFlags;
use style::values::computed::font::GenericFontFamily;
use style::values::computed::{FontSize, Length, NonNegativeLength};
use style::values::specified::font::KeywordInfo;
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
use style_traits::{CSSPixel, SpeculativePainter};
use time_03::Duration;
use url::Url;
use webrender_api::units::DevicePixel;
use webrender_api::{units, ColorF, HitTestFlags};
use webrender_traits::CrossProcessCompositorApi;
@ -587,7 +588,7 @@ impl LayoutThread {
MediaType::screen(),
QuirksMode::NoQuirks,
window_size.initial_viewport,
window_size.device_pixel_ratio,
Scale::new(window_size.device_pixel_ratio.get()),
Box::new(LayoutFontMetricsProvider),
ComputedValues::initial_values_with_font_override(font),
);
@ -1400,7 +1401,8 @@ impl LayoutThread {
);
if self.stylist.device().au_viewport_size() == au_viewport_size &&
self.stylist.device().device_pixel_ratio() == window_size_data.device_pixel_ratio
self.stylist.device().device_pixel_ratio().get() ==
window_size_data.device_pixel_ratio.get()
{
return false;
}
@ -1409,7 +1411,7 @@ impl LayoutThread {
MediaType::screen(),
self.stylist.quirks_mode(),
window_size_data.initial_viewport,
window_size_data.device_pixel_ratio,
Scale::new(window_size_data.device_pixel_ratio.get()),
Box::new(LayoutFontMetricsProvider),
self.stylist.device().default_computed_values().to_arc(),
);

View file

@ -87,9 +87,9 @@ use style::values::computed::font::GenericFontFamily;
use style::values::computed::{CSSPixelLength, FontSize, Length, NonNegativeLength};
use style::values::specified::font::KeywordInfo;
use style::{driver, Zero};
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
use style_traits::{CSSPixel, SpeculativePainter};
use url::Url;
use webrender_api::units::LayoutPixel;
use webrender_api::units::{DevicePixel, LayoutPixel};
use webrender_api::{units, ExternalScrollId, HitTestFlags};
use webrender_traits::CrossProcessCompositorApi;
@ -567,7 +567,7 @@ impl LayoutThread {
MediaType::screen(),
QuirksMode::NoQuirks,
window_size.initial_viewport,
window_size.device_pixel_ratio,
Scale::new(window_size.device_pixel_ratio.get()),
Box::new(LayoutFontMetricsProvider(font_context.clone())),
ComputedValues::initial_values_with_font_override(font),
);
@ -1108,7 +1108,8 @@ impl LayoutThread {
);
if self.stylist.device().au_viewport_size() == au_viewport_size &&
self.stylist.device().device_pixel_ratio() == window_size_data.device_pixel_ratio
self.stylist.device().device_pixel_ratio().get() ==
window_size_data.device_pixel_ratio.get()
{
return false;
}
@ -1117,7 +1118,7 @@ impl LayoutThread {
MediaType::screen(),
self.stylist.quirks_mode(),
window_size_data.initial_viewport,
window_size_data.device_pixel_ratio,
Scale::new(window_size_data.device_pixel_ratio.get()),
Box::new(LayoutFontMetricsProvider(self.font_context.clone())),
self.stylist.device().default_computed_values().to_arc(),
);

View file

@ -9,7 +9,8 @@ use dom_struct::dom_struct;
use euclid::{Scale, Size2D};
use ipc_channel::ipc::IpcSender;
use servo_url::ServoUrl;
use style_traits::{CSSPixel, DevicePixel};
use style_traits::CSSPixel;
use webrender_api::units::DevicePixel;
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{
CanvasFillRule, CanvasImageSource, CanvasLineCap, CanvasLineJoin,

View file

@ -28,7 +28,8 @@ use script_traits::{DrawAPaintImageResult, PaintWorkletError, Painter};
use servo_atoms::Atom;
use servo_config::pref;
use servo_url::ServoUrl;
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
use style_traits::{CSSPixel, SpeculativePainter};
use webrender_api::units::DevicePixel;
use super::bindings::trace::HashMapTracedValues;
use crate::dom::bindings::callback::CallbackContainer;

View file

@ -75,9 +75,9 @@ use style::properties::PropertyId;
use style::selector_parser::PseudoElement;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
use style_traits::{CSSPixel, DevicePixel, ParsingMode};
use style_traits::{CSSPixel, ParsingMode};
use url::Position;
use webrender_api::units::LayoutPixel;
use webrender_api::units::{DevicePixel, LayoutPixel};
use webrender_api::{DocumentId, ExternalScrollId};
use webrender_traits::CrossProcessCompositorApi;

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use euclid::{Point2D, Size2D};
use servo::style_traits::DevicePixel;
use servo::webrender_api::units::DevicePixel;
use winit::dpi::{PhysicalPosition, PhysicalSize};
pub fn winit_size_to_euclid_size<T>(size: PhysicalSize<T>) -> Size2D<T, DevicePixel> {

View file

@ -19,8 +19,7 @@ use servo::keyboard_types::{Key, KeyState, KeyboardEvent};
use servo::script_traits::{TouchEventType, WheelDelta, WheelMode};
use servo::servo_config::{opts, pref};
use servo::servo_geometry::DeviceIndependentPixel;
use servo::style_traits::DevicePixel;
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel};
use servo::webrender_api::ScrollLocation;
use servo::webrender_traits::RenderingContext;
use surfman::{Connection, Context, Device, SurfaceType};

View file

@ -16,8 +16,7 @@ use servo::compositing::windowing::{
};
use servo::config::opts;
use servo::servo_geometry::DeviceIndependentPixel;
use servo::style_traits::DevicePixel;
use servo::webrender_api::units::DeviceIntSize;
use servo::webrender_api::units::{DeviceIntSize, DevicePixel};
use servo::webrender_traits::RenderingContext;
use surfman::{Connection, Context, Device, SurfaceType};

View file

@ -24,7 +24,7 @@ use servo::compositing::windowing::EmbedderEvent;
use servo::script_traits::TraversalDirection;
use servo::servo_geometry::DeviceIndependentPixel;
use servo::servo_url::ServoUrl;
use servo::style_traits::DevicePixel;
use servo::webrender_api::units::DevicePixel;
use servo::webrender_traits::RenderingContext;
use servo::TopLevelBrowsingContextId;
use winit::event::{ElementState, MouseButton, WindowEvent};

View file

@ -10,8 +10,7 @@ use servo::compositing::windowing::{EmbedderEvent, WindowMethods};
use servo::config::opts;
use servo::embedder_traits::Cursor;
use servo::servo_geometry::DeviceIndependentPixel;
use servo::style_traits::DevicePixel;
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize};
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize, DevicePixel};
// This should vary by zoom level and maybe actual text size (focused or under cursor)
pub const LINE_HEIGHT: f32 = 38.0;

View file

@ -25,7 +25,7 @@ use servo::script_traits::{
MediaSessionActionType, MouseButton, TouchEventType, TouchId, TraversalDirection,
};
use servo::servo_geometry::DeviceIndependentPixel;
use servo::style_traits::DevicePixel;
use servo::webrender_api::units::DevicePixel;
use servo::webrender_api::ScrollLocation;
use servo::webrender_traits::RenderingContext;
use servo::{gl, Servo, TopLevelBrowsingContextId};