Skip to content

Commit 6572869

Browse files
jdmLoirooriol
authored andcommitted
Revert "Add device-width/device-height media features." (#394)
Reverts #368 More work is required in Servo to integrate this.
1 parent dafbd04 commit 6572869

3 files changed

Lines changed: 1 addition & 48 deletions

File tree

style/device/servo.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ pub(super) struct ExtraDeviceData {
5656
media_type: MediaType,
5757
/// The current viewport size, in CSS pixels.
5858
viewport_size: Size2D<f32, CSSPixel>,
59-
/// The current screen size, in device pixels.
60-
device_size: Size2D<f32, DevicePixel>,
6159
/// The current device pixel ratio, from CSS pixels to device pixels.
6260
device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>,
6361
/// The current quirks mode.
@@ -77,7 +75,6 @@ impl Device {
7775
media_type: MediaType,
7876
quirks_mode: QuirksMode,
7977
viewport_size: Size2D<f32, CSSPixel>,
80-
device_size: Size2D<f32, DevicePixel>,
8178
device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>,
8279
font_metrics_provider: Box<dyn FontMetricsProvider>,
8380
default_values: Arc<ComputedValues>,
@@ -104,7 +101,6 @@ impl Device {
104101
extra: ExtraDeviceData {
105102
media_type,
106103
viewport_size,
107-
device_size,
108104
device_pixel_ratio,
109105
quirks_mode,
110106
prefers_color_scheme,
@@ -211,21 +207,6 @@ impl Device {
211207
self.extra.device_pixel_ratio = device_pixel_ratio;
212208
}
213209

214-
/// Set the device size on this [`Device`] (e.g. the available screen dimensions).
215-
///
216-
/// Note that this does not update any associated `Stylist`. For this you must call
217-
/// `Stylist::media_features_change_changed_style` and
218-
/// `Stylist::force_stylesheet_origins_dirty`.
219-
pub fn set_device_size(&mut self, device_size: Size2D<f32, DevicePixel>) {
220-
self.extra.device_size = device_size;
221-
}
222-
223-
/// Returns the screen size of the current device in app units.
224-
#[inline]
225-
pub fn device_size(&self) -> Size2D<f32, DevicePixel> {
226-
self.extra.device_size
227-
}
228-
229210
/// Gets the size of the scrollbar in CSS pixels.
230211
pub fn scrollbar_inline_size(&self) -> CSSPixelLength {
231212
// TODO: implement this.

style/servo/media_features.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@ fn eval_width(context: &Context) -> CSSPixelLength {
1515
CSSPixelLength::new(context.device().au_viewport_size().width.to_f32_px())
1616
}
1717

18-
/// https://drafts.csswg.org/mediaqueries-4/#device-width
19-
fn eval_device_width(context: &Context) -> CSSPixelLength {
20-
let device = context.device();
21-
let scaled = device.device_size() / device.device_pixel_ratio();
22-
CSSPixelLength::new(scaled.width)
23-
}
24-
25-
/// https://drafts.csswg.org/mediaqueries-4/#device-height
26-
fn eval_device_height(context: &Context) -> CSSPixelLength {
27-
let device = context.device();
28-
let scaled = device.device_size() / device.device_pixel_ratio();
29-
CSSPixelLength::new(scaled.height)
30-
}
31-
3218
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, ToCss)]
3319
#[repr(u8)]
3420
enum Scan {
@@ -61,25 +47,13 @@ fn eval_prefers_color_scheme(context: &Context, query_value: Option<PrefersColor
6147
}
6248

6349
/// A list with all the media features that Servo supports.
64-
pub static MEDIA_FEATURES: [QueryFeatureDescription; 8] = [
50+
pub static MEDIA_FEATURES: [QueryFeatureDescription; 6] = [
6551
feature!(
6652
atom!("width"),
6753
AllowsRanges::Yes,
6854
Evaluator::Length(eval_width),
6955
FeatureFlags::empty(),
7056
),
71-
feature!(
72-
atom!("device-width"),
73-
AllowsRanges::Yes,
74-
Evaluator::Length(eval_device_width),
75-
FeatureFlags::empty(),
76-
),
77-
feature!(
78-
atom!("device-height"),
79-
AllowsRanges::Yes,
80-
Evaluator::Length(eval_device_height),
81-
FeatureFlags::empty(),
82-
),
8357
feature!(
8458
atom!("scan"),
8559
AllowsRanges::No,

stylo_atoms/static_atoms.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ datachannel
4949
date
5050
datetime-local
5151
dir
52-
device-height
5352
device-pixel-ratio
54-
device-width
5553
durationchange
5654
email
5755
emptied

0 commit comments

Comments
 (0)