Skip to content

Commit 3f7e5b1

Browse files
authored
Auto merge of servo#29850 - servo:css-viewport-removal, r=mrobinson
CSS viewport removal It was removed from the spec and it's disabled everywhere. This also removes the meta viewport support (which was implemented on top), but that also had a single test and is disabled everywhere, so I'm not too concerned, it can be implemented again if / when needed. - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix servo#26349 - [x] There are tests for these changes
2 parents cc54fbc + 349edff commit 3f7e5b1

34 files changed

+34
-1138
lines changed

components/compositing/compositor.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use std::fs::{create_dir_all, File};
4646
use std::io::Write;
4747
use std::num::NonZeroU32;
4848
use std::rc::Rc;
49-
use style_traits::viewport::ViewportConstraints;
5049
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
5150
use time::{now, precise_time_ns, precise_time_s};
5251
use webrender_api::units::{
@@ -507,13 +506,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
507506
}
508507
},
509508

510-
(
511-
Msg::ViewportConstrained(pipeline_id, constraints),
512-
ShutdownState::NotShuttingDown,
513-
) => {
514-
self.constrain_viewport(pipeline_id, constraints);
515-
},
516-
517509
(Msg::IsReadyToSaveImageReply(is_ready), ShutdownState::NotShuttingDown) => {
518510
assert_eq!(
519511
self.ready_to_save_state,
@@ -1363,17 +1355,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
13631355
}
13641356
}
13651357

1366-
fn constrain_viewport(&mut self, pipeline_id: PipelineId, constraints: ViewportConstraints) {
1367-
let is_root = self.root_pipeline.id == Some(pipeline_id);
1368-
1369-
if is_root {
1370-
self.viewport_zoom = constraints.initial_zoom;
1371-
self.min_viewport_zoom = constraints.min_zoom;
1372-
self.max_viewport_zoom = constraints.max_zoom;
1373-
self.update_zoom_transform();
1374-
}
1375-
}
1376-
13771358
fn hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
13781359
if self.output_file.is_some() {
13791360
return Scale::new(1.0);

components/compositing/compositor_thread.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use profile_traits::time;
1919
use script_traits::{AnimationState, EventResult, MouseButton, MouseEventType};
2020
use std::fmt::{Debug, Error, Formatter};
2121
use std::rc::Rc;
22-
use style_traits::viewport::ViewportConstraints;
2322
use style_traits::CSSPixel;
2423
use webrender_api;
2524
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
@@ -85,8 +84,6 @@ pub enum Msg {
8584
TouchEventProcessed(EventResult),
8685
/// Composite to a PNG file and return the Image over a passed channel.
8786
CreatePng(Option<Rect<f32, CSSPixel>>, IpcSender<Option<Image>>),
88-
/// Alerts the compositor that the viewport has been constrained in some manner
89-
ViewportConstrained(PipelineId, ViewportConstraints),
9087
/// A reply to the compositor asking if the output image is stable.
9188
IsReadyToSaveImageReply(bool),
9289
/// Pipeline visibility changed
@@ -158,7 +155,6 @@ impl Debug for Msg {
158155
Msg::Recomposite(..) => write!(f, "Recomposite"),
159156
Msg::TouchEventProcessed(..) => write!(f, "TouchEventProcessed"),
160157
Msg::CreatePng(..) => write!(f, "CreatePng"),
161-
Msg::ViewportConstrained(..) => write!(f, "ViewportConstrained"),
162158
Msg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"),
163159
Msg::PipelineVisibilityChanged(..) => write!(f, "PipelineVisibilityChanged"),
164160
Msg::PipelineExited(..) => write!(f, "PipelineExited"),

components/config/prefs.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,6 @@ mod gen {
442442
},
443443
#[serde(default = "default_layout_threads")]
444444
threads: i64,
445-
viewport: {
446-
enabled: bool,
447-
},
448445
writing_mode: {
449446
#[serde(rename = "layout.writing-mode.enabled")]
450447
enabled: bool,

components/constellation/constellation.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ use std::process;
176176
use std::rc::{Rc, Weak};
177177
use std::sync::{Arc, Mutex};
178178
use std::thread;
179-
use style_traits::viewport::ViewportConstraints;
180179
use style_traits::CSSPixel;
181180
use webgpu::{self, WebGPU, WebGPURequest};
182181
use webrender_traits::WebrenderExternalImageRegistry;
@@ -2110,9 +2109,6 @@ where
21102109
FromLayoutMsg::PendingPaintMetric(pipeline_id, epoch) => {
21112110
self.handle_pending_paint_metric(pipeline_id, epoch);
21122111
},
2113-
FromLayoutMsg::ViewportConstrained(pipeline_id, constraints) => {
2114-
self.handle_viewport_constrained_msg(pipeline_id, constraints);
2115-
},
21162112
}
21172113
}
21182114

@@ -4934,19 +4930,6 @@ where
49344930
self.switch_fullscreen_mode(browsing_context_id);
49354931
}
49364932

4937-
/// Handle updating actual viewport / zoom due to @viewport rules
4938-
fn handle_viewport_constrained_msg(
4939-
&mut self,
4940-
pipeline_id: PipelineId,
4941-
constraints: ViewportConstraints,
4942-
) {
4943-
self.compositor_proxy
4944-
.send(ToCompositorMsg::ViewportConstrained(
4945-
pipeline_id,
4946-
constraints,
4947-
));
4948-
}
4949-
49504933
/// Checks the state of all script and layout pipelines to see if they are idle
49514934
/// and compares the current layout state to what the compositor has. This is used
49524935
/// to check if the output image is "stable" and can be written as a screenshot

components/layout_thread/lib.rs

Lines changed: 26 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,7 @@ impl LayoutThread {
10151015

10161016
let root_size = {
10171017
let root_flow = layout_root.base();
1018-
if self.stylist.viewport_constraints().is_some() {
1019-
root_flow.position.size.to_physical(root_flow.writing_mode)
1020-
} else {
1021-
root_flow.overflow.scroll.size
1022-
}
1018+
root_flow.overflow.scroll.size
10231019
};
10241020

10251021
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size).to_layout();
@@ -1207,66 +1203,41 @@ impl LayoutThread {
12071203

12081204
self.stylist
12091205
.force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change);
1210-
self.viewport_size =
1211-
self.stylist
1212-
.viewport_constraints()
1213-
.map_or(current_screen_size, |constraints| {
1214-
debug!("Viewport constraints: {:?}", constraints);
1215-
1216-
// other rules are evaluated against the actual viewport
1217-
Size2D::new(
1218-
Au::from_f32_px(constraints.size.width),
1219-
Au::from_f32_px(constraints.size.height),
1220-
)
1221-
});
1206+
self.viewport_size = current_screen_size;
12221207

12231208
let viewport_size_changed = self.viewport_size != old_viewport_size;
1224-
if viewport_size_changed {
1225-
if let Some(constraints) = self.stylist.viewport_constraints() {
1226-
// let the constellation know about the viewport constraints
1227-
rw_data
1228-
.constellation_chan
1229-
.send(ConstellationMsg::ViewportConstrained(
1230-
self.id,
1231-
constraints.clone(),
1232-
))
1233-
.unwrap();
1234-
}
1235-
if had_used_viewport_units {
1236-
if let Some(mut data) = root_element.mutate_data() {
1237-
data.hint.insert(RestyleHint::recascade_subtree());
1238-
}
1209+
if viewport_size_changed && had_used_viewport_units {
1210+
if let Some(mut data) = root_element.mutate_data() {
1211+
data.hint.insert(RestyleHint::recascade_subtree());
12391212
}
12401213
}
12411214

1242-
{
1243-
if self.first_reflow.get() {
1244-
debug!("First reflow, rebuilding user and UA rules");
1245-
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
1246-
self.stylist
1247-
.append_stylesheet(stylesheet.clone(), &ua_or_user_guard);
1248-
self.handle_add_stylesheet(&stylesheet.0, &ua_or_user_guard);
1249-
}
1250-
1251-
if self.stylist.quirks_mode() != QuirksMode::NoQuirks {
1252-
self.stylist.append_stylesheet(
1253-
ua_stylesheets.quirks_mode_stylesheet.clone(),
1254-
&ua_or_user_guard,
1255-
);
1256-
self.handle_add_stylesheet(
1257-
&ua_stylesheets.quirks_mode_stylesheet.0,
1258-
&ua_or_user_guard,
1259-
);
1260-
}
1215+
if self.first_reflow.get() {
1216+
debug!("First reflow, rebuilding user and UA rules");
1217+
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
1218+
self.stylist
1219+
.append_stylesheet(stylesheet.clone(), &ua_or_user_guard);
1220+
self.handle_add_stylesheet(&stylesheet.0, &ua_or_user_guard);
12611221
}
12621222

1263-
if data.stylesheets_changed {
1264-
debug!("Doc sheets changed, flushing author sheets too");
1265-
self.stylist
1266-
.force_stylesheet_origins_dirty(Origin::Author.into());
1223+
if self.stylist.quirks_mode() != QuirksMode::NoQuirks {
1224+
self.stylist.append_stylesheet(
1225+
ua_stylesheets.quirks_mode_stylesheet.clone(),
1226+
&ua_or_user_guard,
1227+
);
1228+
self.handle_add_stylesheet(
1229+
&ua_stylesheets.quirks_mode_stylesheet.0,
1230+
&ua_or_user_guard,
1231+
);
12671232
}
12681233
}
12691234

1235+
if data.stylesheets_changed {
1236+
debug!("Doc sheets changed, flushing author sheets too");
1237+
self.stylist
1238+
.force_stylesheet_origins_dirty(Origin::Author.into());
1239+
}
1240+
12701241
if viewport_size_changed {
12711242
if let Some(mut flow) = self.try_get_layout_root(root_element.as_node()) {
12721243
LayoutThread::reflow_all_nodes(FlowRef::deref_mut(&mut flow));

components/layout_thread_2020/lib.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -896,29 +896,7 @@ impl LayoutThread {
896896

897897
self.stylist
898898
.force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change);
899-
self.viewport_size =
900-
self.stylist
901-
.viewport_constraints()
902-
.map_or(current_screen_size, |constraints| {
903-
Size2D::new(
904-
Au::from_f32_px(constraints.size.width),
905-
Au::from_f32_px(constraints.size.height),
906-
)
907-
});
908-
909-
let viewport_size_changed = self.viewport_size != old_viewport_size;
910-
if viewport_size_changed {
911-
if let Some(constraints) = self.stylist.viewport_constraints() {
912-
// let the constellation know about the viewport constraints
913-
self.constellation_chan
914-
.send(ConstellationMsg::ViewportConstrained(
915-
self.id,
916-
constraints.clone(),
917-
))
918-
.unwrap();
919-
}
920-
}
921-
899+
self.viewport_size = current_screen_size;
922900
if self.first_reflow.get() {
923901
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
924902
self.stylist

components/script/dom/bindings/trace.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ use style::shared_lock::{Locked as StyleLocked, SharedRwLock as StyleSharedRwLoc
160160
use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
161161
use style::stylesheets::keyframes_rule::Keyframe;
162162
use style::stylesheets::{CssRules, FontFaceRule, KeyframesRule, MediaRule, Stylesheet};
163-
use style::stylesheets::{ImportRule, NamespaceRule, StyleRule, SupportsRule, ViewportRule};
163+
use style::stylesheets::{ImportRule, NamespaceRule, StyleRule, SupportsRule};
164164
use style::stylist::CascadeData;
165165
use style::values::specified::Length;
166166
use tendril::fmt::UTF8;
@@ -914,12 +914,6 @@ unsafe impl JSTraceable for StyleLocked<StyleRule> {
914914
}
915915
}
916916

917-
unsafe impl JSTraceable for StyleLocked<ViewportRule> {
918-
unsafe fn trace(&self, _trc: *mut JSTracer) {
919-
// Do nothing.
920-
}
921-
}
922-
923917
unsafe impl JSTraceable for StyleLocked<PropertyDeclarationBlock> {
924918
unsafe fn trace(&self, _trc: *mut JSTracer) {
925919
// Do nothing.

components/script/dom/cssrule.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::dom::cssnamespacerule::CSSNamespaceRule;
1616
use crate::dom::cssstylerule::CSSStyleRule;
1717
use crate::dom::cssstylesheet::CSSStyleSheet;
1818
use crate::dom::csssupportsrule::CSSSupportsRule;
19-
use crate::dom::cssviewportrule::CSSViewportRule;
2019
use crate::dom::window::Window;
2120
use dom_struct::dom_struct;
2221
use std::cell::Cell;
@@ -55,8 +54,6 @@ impl CSSRule {
5554
rule as &dyn SpecificCSSRule
5655
} else if let Some(rule) = self.downcast::<CSSNamespaceRule>() {
5756
rule as &dyn SpecificCSSRule
58-
} else if let Some(rule) = self.downcast::<CSSViewportRule>() {
59-
rule as &dyn SpecificCSSRule
6057
} else if let Some(rule) = self.downcast::<CSSKeyframeRule>() {
6158
rule as &dyn SpecificCSSRule
6259
} else if let Some(rule) = self.downcast::<CSSImportRule>() {
@@ -97,14 +94,12 @@ impl CSSRule {
9794
StyleCssRule::Namespace(s) => {
9895
DomRoot::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s))
9996
},
100-
StyleCssRule::Viewport(s) => {
101-
DomRoot::upcast(CSSViewportRule::new(window, parent_stylesheet, s))
102-
},
10397
StyleCssRule::Supports(s) => {
10498
DomRoot::upcast(CSSSupportsRule::new(window, parent_stylesheet, s))
10599
},
106100
StyleCssRule::Page(_) => unreachable!(),
107101
StyleCssRule::Document(_) => unimplemented!(), // TODO
102+
StyleCssRule::Viewport(_) => unimplemented!(), // TODO
108103
StyleCssRule::LayerBlock(_) => unimplemented!(), // TODO
109104
StyleCssRule::LayerStatement(_) => unimplemented!(), // TODO
110105
StyleCssRule::ScrollTimeline(_) => unimplemented!(), // TODO

components/script/dom/cssviewportrule.rs

Lines changed: 0 additions & 63 deletions
This file was deleted.

components/script/dom/documentorshadowroot.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::dom::bindings::num::Finite;
99
use crate::dom::bindings::root::{Dom, DomRoot};
1010
use crate::dom::element::Element;
1111
use crate::dom::htmlelement::HTMLElement;
12-
use crate::dom::htmlmetaelement::HTMLMetaElement;
1312
use crate::dom::node::{self, Node, VecPreOrderInsertionHelper};
1413
use crate::dom::window::Window;
1514
use crate::stylesheet_set::StylesheetSetRef;
@@ -226,13 +225,7 @@ impl DocumentOrShadowRoot {
226225
insertion_point: Option<StyleSheetInDocument>,
227226
style_shared_lock: &StyleSharedRwLock,
228227
) {
229-
// FIXME(emilio): It'd be nice to unify more code between the elements
230-
// that own stylesheets, but StylesheetOwner is more about loading
231-
// them...
232-
debug_assert!(
233-
owner.as_stylesheet_owner().is_some() || owner.is::<HTMLMetaElement>(),
234-
"Wat"
235-
);
228+
debug_assert!(owner.as_stylesheet_owner().is_some(), "Wat");
236229

237230
let sheet = StyleSheetInDocument {
238231
sheet,

0 commit comments

Comments
 (0)