mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
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.
This commit is contained in:
parent
7412e28349
commit
349edff768
34 changed files with 35 additions and 1139 deletions
|
@ -46,7 +46,6 @@ use std::fs::{create_dir_all, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
|
||||||
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
||||||
use time::{now, precise_time_ns, precise_time_s};
|
use time::{now, precise_time_ns, precise_time_s};
|
||||||
use webrender_api::units::{
|
use webrender_api::units::{
|
||||||
|
@ -507,13 +506,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
(
|
|
||||||
Msg::ViewportConstrained(pipeline_id, constraints),
|
|
||||||
ShutdownState::NotShuttingDown,
|
|
||||||
) => {
|
|
||||||
self.constrain_viewport(pipeline_id, constraints);
|
|
||||||
},
|
|
||||||
|
|
||||||
(Msg::IsReadyToSaveImageReply(is_ready), ShutdownState::NotShuttingDown) => {
|
(Msg::IsReadyToSaveImageReply(is_ready), ShutdownState::NotShuttingDown) => {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
self.ready_to_save_state,
|
self.ready_to_save_state,
|
||||||
|
@ -1363,17 +1355,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn constrain_viewport(&mut self, pipeline_id: PipelineId, constraints: ViewportConstraints) {
|
|
||||||
let is_root = self.root_pipeline.id == Some(pipeline_id);
|
|
||||||
|
|
||||||
if is_root {
|
|
||||||
self.viewport_zoom = constraints.initial_zoom;
|
|
||||||
self.min_viewport_zoom = constraints.min_zoom;
|
|
||||||
self.max_viewport_zoom = constraints.max_zoom;
|
|
||||||
self.update_zoom_transform();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
fn hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||||
if self.output_file.is_some() {
|
if self.output_file.is_some() {
|
||||||
return Scale::new(1.0);
|
return Scale::new(1.0);
|
||||||
|
|
|
@ -19,7 +19,6 @@ use profile_traits::time;
|
||||||
use script_traits::{AnimationState, EventResult, MouseButton, MouseEventType};
|
use script_traits::{AnimationState, EventResult, MouseButton, MouseEventType};
|
||||||
use std::fmt::{Debug, Error, Formatter};
|
use std::fmt::{Debug, Error, Formatter};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
use webrender_api;
|
use webrender_api;
|
||||||
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
||||||
|
@ -85,8 +84,6 @@ pub enum Msg {
|
||||||
TouchEventProcessed(EventResult),
|
TouchEventProcessed(EventResult),
|
||||||
/// Composite to a PNG file and return the Image over a passed channel.
|
/// Composite to a PNG file and return the Image over a passed channel.
|
||||||
CreatePng(Option<Rect<f32, CSSPixel>>, IpcSender<Option<Image>>),
|
CreatePng(Option<Rect<f32, CSSPixel>>, IpcSender<Option<Image>>),
|
||||||
/// Alerts the compositor that the viewport has been constrained in some manner
|
|
||||||
ViewportConstrained(PipelineId, ViewportConstraints),
|
|
||||||
/// A reply to the compositor asking if the output image is stable.
|
/// A reply to the compositor asking if the output image is stable.
|
||||||
IsReadyToSaveImageReply(bool),
|
IsReadyToSaveImageReply(bool),
|
||||||
/// Pipeline visibility changed
|
/// Pipeline visibility changed
|
||||||
|
@ -158,7 +155,6 @@ impl Debug for Msg {
|
||||||
Msg::Recomposite(..) => write!(f, "Recomposite"),
|
Msg::Recomposite(..) => write!(f, "Recomposite"),
|
||||||
Msg::TouchEventProcessed(..) => write!(f, "TouchEventProcessed"),
|
Msg::TouchEventProcessed(..) => write!(f, "TouchEventProcessed"),
|
||||||
Msg::CreatePng(..) => write!(f, "CreatePng"),
|
Msg::CreatePng(..) => write!(f, "CreatePng"),
|
||||||
Msg::ViewportConstrained(..) => write!(f, "ViewportConstrained"),
|
|
||||||
Msg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"),
|
Msg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"),
|
||||||
Msg::PipelineVisibilityChanged(..) => write!(f, "PipelineVisibilityChanged"),
|
Msg::PipelineVisibilityChanged(..) => write!(f, "PipelineVisibilityChanged"),
|
||||||
Msg::PipelineExited(..) => write!(f, "PipelineExited"),
|
Msg::PipelineExited(..) => write!(f, "PipelineExited"),
|
||||||
|
|
|
@ -442,9 +442,6 @@ mod gen {
|
||||||
},
|
},
|
||||||
#[serde(default = "default_layout_threads")]
|
#[serde(default = "default_layout_threads")]
|
||||||
threads: i64,
|
threads: i64,
|
||||||
viewport: {
|
|
||||||
enabled: bool,
|
|
||||||
},
|
|
||||||
writing_mode: {
|
writing_mode: {
|
||||||
#[serde(rename = "layout.writing-mode.enabled")]
|
#[serde(rename = "layout.writing-mode.enabled")]
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
|
|
|
@ -176,7 +176,6 @@ use std::process;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
use webgpu::{self, WebGPU, WebGPURequest};
|
use webgpu::{self, WebGPU, WebGPURequest};
|
||||||
use webrender_traits::WebrenderExternalImageRegistry;
|
use webrender_traits::WebrenderExternalImageRegistry;
|
||||||
|
@ -2110,9 +2109,6 @@ where
|
||||||
FromLayoutMsg::PendingPaintMetric(pipeline_id, epoch) => {
|
FromLayoutMsg::PendingPaintMetric(pipeline_id, epoch) => {
|
||||||
self.handle_pending_paint_metric(pipeline_id, epoch);
|
self.handle_pending_paint_metric(pipeline_id, epoch);
|
||||||
},
|
},
|
||||||
FromLayoutMsg::ViewportConstrained(pipeline_id, constraints) => {
|
|
||||||
self.handle_viewport_constrained_msg(pipeline_id, constraints);
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4934,19 +4930,6 @@ where
|
||||||
self.switch_fullscreen_mode(browsing_context_id);
|
self.switch_fullscreen_mode(browsing_context_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle updating actual viewport / zoom due to @viewport rules
|
|
||||||
fn handle_viewport_constrained_msg(
|
|
||||||
&mut self,
|
|
||||||
pipeline_id: PipelineId,
|
|
||||||
constraints: ViewportConstraints,
|
|
||||||
) {
|
|
||||||
self.compositor_proxy
|
|
||||||
.send(ToCompositorMsg::ViewportConstrained(
|
|
||||||
pipeline_id,
|
|
||||||
constraints,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks the state of all script and layout pipelines to see if they are idle
|
/// Checks the state of all script and layout pipelines to see if they are idle
|
||||||
/// and compares the current layout state to what the compositor has. This is used
|
/// and compares the current layout state to what the compositor has. This is used
|
||||||
/// to check if the output image is "stable" and can be written as a screenshot
|
/// to check if the output image is "stable" and can be written as a screenshot
|
||||||
|
|
|
@ -1015,11 +1015,7 @@ impl LayoutThread {
|
||||||
|
|
||||||
let root_size = {
|
let root_size = {
|
||||||
let root_flow = layout_root.base();
|
let root_flow = layout_root.base();
|
||||||
if self.stylist.viewport_constraints().is_some() {
|
root_flow.overflow.scroll.size
|
||||||
root_flow.position.size.to_physical(root_flow.writing_mode)
|
|
||||||
} else {
|
|
||||||
root_flow.overflow.scroll.size
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size).to_layout();
|
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size).to_layout();
|
||||||
|
@ -1207,64 +1203,39 @@ impl LayoutThread {
|
||||||
|
|
||||||
self.stylist
|
self.stylist
|
||||||
.force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change);
|
.force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change);
|
||||||
self.viewport_size =
|
self.viewport_size = current_screen_size;
|
||||||
self.stylist
|
|
||||||
.viewport_constraints()
|
|
||||||
.map_or(current_screen_size, |constraints| {
|
|
||||||
debug!("Viewport constraints: {:?}", constraints);
|
|
||||||
|
|
||||||
// other rules are evaluated against the actual viewport
|
|
||||||
Size2D::new(
|
|
||||||
Au::from_f32_px(constraints.size.width),
|
|
||||||
Au::from_f32_px(constraints.size.height),
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
let viewport_size_changed = self.viewport_size != old_viewport_size;
|
let viewport_size_changed = self.viewport_size != old_viewport_size;
|
||||||
if viewport_size_changed {
|
if viewport_size_changed && had_used_viewport_units {
|
||||||
if let Some(constraints) = self.stylist.viewport_constraints() {
|
if let Some(mut data) = root_element.mutate_data() {
|
||||||
// let the constellation know about the viewport constraints
|
data.hint.insert(RestyleHint::recascade_subtree());
|
||||||
rw_data
|
|
||||||
.constellation_chan
|
|
||||||
.send(ConstellationMsg::ViewportConstrained(
|
|
||||||
self.id,
|
|
||||||
constraints.clone(),
|
|
||||||
))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
if had_used_viewport_units {
|
|
||||||
if let Some(mut data) = root_element.mutate_data() {
|
|
||||||
data.hint.insert(RestyleHint::recascade_subtree());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if self.first_reflow.get() {
|
||||||
if self.first_reflow.get() {
|
debug!("First reflow, rebuilding user and UA rules");
|
||||||
debug!("First reflow, rebuilding user and UA rules");
|
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
|
||||||
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
|
|
||||||
self.stylist
|
|
||||||
.append_stylesheet(stylesheet.clone(), &ua_or_user_guard);
|
|
||||||
self.handle_add_stylesheet(&stylesheet.0, &ua_or_user_guard);
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.stylist.quirks_mode() != QuirksMode::NoQuirks {
|
|
||||||
self.stylist.append_stylesheet(
|
|
||||||
ua_stylesheets.quirks_mode_stylesheet.clone(),
|
|
||||||
&ua_or_user_guard,
|
|
||||||
);
|
|
||||||
self.handle_add_stylesheet(
|
|
||||||
&ua_stylesheets.quirks_mode_stylesheet.0,
|
|
||||||
&ua_or_user_guard,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if data.stylesheets_changed {
|
|
||||||
debug!("Doc sheets changed, flushing author sheets too");
|
|
||||||
self.stylist
|
self.stylist
|
||||||
.force_stylesheet_origins_dirty(Origin::Author.into());
|
.append_stylesheet(stylesheet.clone(), &ua_or_user_guard);
|
||||||
|
self.handle_add_stylesheet(&stylesheet.0, &ua_or_user_guard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.stylist.quirks_mode() != QuirksMode::NoQuirks {
|
||||||
|
self.stylist.append_stylesheet(
|
||||||
|
ua_stylesheets.quirks_mode_stylesheet.clone(),
|
||||||
|
&ua_or_user_guard,
|
||||||
|
);
|
||||||
|
self.handle_add_stylesheet(
|
||||||
|
&ua_stylesheets.quirks_mode_stylesheet.0,
|
||||||
|
&ua_or_user_guard,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.stylesheets_changed {
|
||||||
|
debug!("Doc sheets changed, flushing author sheets too");
|
||||||
|
self.stylist
|
||||||
|
.force_stylesheet_origins_dirty(Origin::Author.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if viewport_size_changed {
|
if viewport_size_changed {
|
||||||
|
|
|
@ -896,29 +896,7 @@ impl LayoutThread {
|
||||||
|
|
||||||
self.stylist
|
self.stylist
|
||||||
.force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change);
|
.force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change);
|
||||||
self.viewport_size =
|
self.viewport_size = current_screen_size;
|
||||||
self.stylist
|
|
||||||
.viewport_constraints()
|
|
||||||
.map_or(current_screen_size, |constraints| {
|
|
||||||
Size2D::new(
|
|
||||||
Au::from_f32_px(constraints.size.width),
|
|
||||||
Au::from_f32_px(constraints.size.height),
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
let viewport_size_changed = self.viewport_size != old_viewport_size;
|
|
||||||
if viewport_size_changed {
|
|
||||||
if let Some(constraints) = self.stylist.viewport_constraints() {
|
|
||||||
// let the constellation know about the viewport constraints
|
|
||||||
self.constellation_chan
|
|
||||||
.send(ConstellationMsg::ViewportConstrained(
|
|
||||||
self.id,
|
|
||||||
constraints.clone(),
|
|
||||||
))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.first_reflow.get() {
|
if self.first_reflow.get() {
|
||||||
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
|
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
|
||||||
self.stylist
|
self.stylist
|
||||||
|
|
|
@ -160,7 +160,7 @@ use style::shared_lock::{Locked as StyleLocked, SharedRwLock as StyleSharedRwLoc
|
||||||
use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
|
use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
|
||||||
use style::stylesheets::keyframes_rule::Keyframe;
|
use style::stylesheets::keyframes_rule::Keyframe;
|
||||||
use style::stylesheets::{CssRules, FontFaceRule, KeyframesRule, MediaRule, Stylesheet};
|
use style::stylesheets::{CssRules, FontFaceRule, KeyframesRule, MediaRule, Stylesheet};
|
||||||
use style::stylesheets::{ImportRule, NamespaceRule, StyleRule, SupportsRule, ViewportRule};
|
use style::stylesheets::{ImportRule, NamespaceRule, StyleRule, SupportsRule};
|
||||||
use style::stylist::CascadeData;
|
use style::stylist::CascadeData;
|
||||||
use style::values::specified::Length;
|
use style::values::specified::Length;
|
||||||
use tendril::fmt::UTF8;
|
use tendril::fmt::UTF8;
|
||||||
|
@ -914,12 +914,6 @@ unsafe impl JSTraceable for StyleLocked<StyleRule> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl JSTraceable for StyleLocked<ViewportRule> {
|
|
||||||
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl JSTraceable for StyleLocked<PropertyDeclarationBlock> {
|
unsafe impl JSTraceable for StyleLocked<PropertyDeclarationBlock> {
|
||||||
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
|
|
|
@ -16,7 +16,6 @@ use crate::dom::cssnamespacerule::CSSNamespaceRule;
|
||||||
use crate::dom::cssstylerule::CSSStyleRule;
|
use crate::dom::cssstylerule::CSSStyleRule;
|
||||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
use crate::dom::cssstylesheet::CSSStyleSheet;
|
||||||
use crate::dom::csssupportsrule::CSSSupportsRule;
|
use crate::dom::csssupportsrule::CSSSupportsRule;
|
||||||
use crate::dom::cssviewportrule::CSSViewportRule;
|
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -55,8 +54,6 @@ impl CSSRule {
|
||||||
rule as &dyn SpecificCSSRule
|
rule as &dyn SpecificCSSRule
|
||||||
} else if let Some(rule) = self.downcast::<CSSNamespaceRule>() {
|
} else if let Some(rule) = self.downcast::<CSSNamespaceRule>() {
|
||||||
rule as &dyn SpecificCSSRule
|
rule as &dyn SpecificCSSRule
|
||||||
} else if let Some(rule) = self.downcast::<CSSViewportRule>() {
|
|
||||||
rule as &dyn SpecificCSSRule
|
|
||||||
} else if let Some(rule) = self.downcast::<CSSKeyframeRule>() {
|
} else if let Some(rule) = self.downcast::<CSSKeyframeRule>() {
|
||||||
rule as &dyn SpecificCSSRule
|
rule as &dyn SpecificCSSRule
|
||||||
} else if let Some(rule) = self.downcast::<CSSImportRule>() {
|
} else if let Some(rule) = self.downcast::<CSSImportRule>() {
|
||||||
|
@ -97,14 +94,12 @@ impl CSSRule {
|
||||||
StyleCssRule::Namespace(s) => {
|
StyleCssRule::Namespace(s) => {
|
||||||
DomRoot::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s))
|
DomRoot::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s))
|
||||||
},
|
},
|
||||||
StyleCssRule::Viewport(s) => {
|
|
||||||
DomRoot::upcast(CSSViewportRule::new(window, parent_stylesheet, s))
|
|
||||||
},
|
|
||||||
StyleCssRule::Supports(s) => {
|
StyleCssRule::Supports(s) => {
|
||||||
DomRoot::upcast(CSSSupportsRule::new(window, parent_stylesheet, s))
|
DomRoot::upcast(CSSSupportsRule::new(window, parent_stylesheet, s))
|
||||||
},
|
},
|
||||||
StyleCssRule::Page(_) => unreachable!(),
|
StyleCssRule::Page(_) => unreachable!(),
|
||||||
StyleCssRule::Document(_) => unimplemented!(), // TODO
|
StyleCssRule::Document(_) => unimplemented!(), // TODO
|
||||||
|
StyleCssRule::Viewport(_) => unimplemented!(), // TODO
|
||||||
StyleCssRule::LayerBlock(_) => unimplemented!(), // TODO
|
StyleCssRule::LayerBlock(_) => unimplemented!(), // TODO
|
||||||
StyleCssRule::LayerStatement(_) => unimplemented!(), // TODO
|
StyleCssRule::LayerStatement(_) => unimplemented!(), // TODO
|
||||||
StyleCssRule::ScrollTimeline(_) => unimplemented!(), // TODO
|
StyleCssRule::ScrollTimeline(_) => unimplemented!(), // TODO
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
|
||||||
use crate::dom::bindings::root::DomRoot;
|
|
||||||
use crate::dom::bindings::str::DOMString;
|
|
||||||
use crate::dom::cssrule::{CSSRule, SpecificCSSRule};
|
|
||||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
|
||||||
use crate::dom::window::Window;
|
|
||||||
use dom_struct::dom_struct;
|
|
||||||
use servo_arc::Arc;
|
|
||||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
|
||||||
use style::stylesheets::ViewportRule;
|
|
||||||
|
|
||||||
#[dom_struct]
|
|
||||||
pub struct CSSViewportRule {
|
|
||||||
cssrule: CSSRule,
|
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
|
||||||
viewportrule: Arc<Locked<ViewportRule>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CSSViewportRule {
|
|
||||||
fn new_inherited(
|
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
|
||||||
viewportrule: Arc<Locked<ViewportRule>>,
|
|
||||||
) -> CSSViewportRule {
|
|
||||||
CSSViewportRule {
|
|
||||||
cssrule: CSSRule::new_inherited(parent_stylesheet),
|
|
||||||
viewportrule: viewportrule,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
pub fn new(
|
|
||||||
window: &Window,
|
|
||||||
parent_stylesheet: &CSSStyleSheet,
|
|
||||||
viewportrule: Arc<Locked<ViewportRule>>,
|
|
||||||
) -> DomRoot<CSSViewportRule> {
|
|
||||||
reflect_dom_object(
|
|
||||||
Box::new(CSSViewportRule::new_inherited(
|
|
||||||
parent_stylesheet,
|
|
||||||
viewportrule,
|
|
||||||
)),
|
|
||||||
window,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SpecificCSSRule for CSSViewportRule {
|
|
||||||
fn ty(&self) -> u16 {
|
|
||||||
use crate::dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants;
|
|
||||||
CSSRuleConstants::VIEWPORT_RULE
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_css(&self) -> DOMString {
|
|
||||||
let guard = self.cssrule.shared_lock().read();
|
|
||||||
self.viewportrule
|
|
||||||
.read_with(&guard)
|
|
||||||
.to_css_string(&guard)
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,7 +9,6 @@ use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::element::Element;
|
use crate::dom::element::Element;
|
||||||
use crate::dom::htmlelement::HTMLElement;
|
use crate::dom::htmlelement::HTMLElement;
|
||||||
use crate::dom::htmlmetaelement::HTMLMetaElement;
|
|
||||||
use crate::dom::node::{self, Node, VecPreOrderInsertionHelper};
|
use crate::dom::node::{self, Node, VecPreOrderInsertionHelper};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::stylesheet_set::StylesheetSetRef;
|
use crate::stylesheet_set::StylesheetSetRef;
|
||||||
|
@ -226,13 +225,7 @@ impl DocumentOrShadowRoot {
|
||||||
insertion_point: Option<StyleSheetInDocument>,
|
insertion_point: Option<StyleSheetInDocument>,
|
||||||
style_shared_lock: &StyleSharedRwLock,
|
style_shared_lock: &StyleSharedRwLock,
|
||||||
) {
|
) {
|
||||||
// FIXME(emilio): It'd be nice to unify more code between the elements
|
debug_assert!(owner.as_stylesheet_owner().is_some(), "Wat");
|
||||||
// that own stylesheets, but StylesheetOwner is more about loading
|
|
||||||
// them...
|
|
||||||
debug_assert!(
|
|
||||||
owner.as_stylesheet_owner().is_some() || owner.is::<HTMLMetaElement>(),
|
|
||||||
"Wat"
|
|
||||||
);
|
|
||||||
|
|
||||||
let sheet = StyleSheetInDocument {
|
let sheet = StyleSheetInDocument {
|
||||||
sheet,
|
sheet,
|
||||||
|
|
|
@ -3,38 +3,25 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::dom::attr::Attr;
|
use crate::dom::attr::Attr;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
|
||||||
use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods;
|
use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::element::{AttributeMutation, Element};
|
use crate::dom::element::{AttributeMutation, Element};
|
||||||
use crate::dom::htmlelement::HTMLElement;
|
use crate::dom::htmlelement::HTMLElement;
|
||||||
use crate::dom::htmlheadelement::HTMLHeadElement;
|
use crate::dom::htmlheadelement::HTMLHeadElement;
|
||||||
use crate::dom::node::{
|
use crate::dom::node::{BindContext, Node, UnbindContext};
|
||||||
document_from_node, stylesheets_owner_from_node, window_from_node, BindContext, Node,
|
|
||||||
UnbindContext,
|
|
||||||
};
|
|
||||||
use crate::dom::virtualmethods::VirtualMethods;
|
use crate::dom::virtualmethods::VirtualMethods;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use html5ever::{LocalName, Prefix};
|
use html5ever::{LocalName, Prefix};
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
use servo_arc::Arc;
|
|
||||||
use servo_config::pref;
|
|
||||||
use std::sync::atomic::AtomicBool;
|
|
||||||
use style::media_queries::MediaList;
|
|
||||||
use style::str::HTML_SPACE_CHARACTERS;
|
use style::str::HTML_SPACE_CHARACTERS;
|
||||||
use style::stylesheets::{CssRule, CssRules, Origin, Stylesheet, StylesheetContents, ViewportRule};
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLMetaElement {
|
pub struct HTMLMetaElement {
|
||||||
htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
|
||||||
stylesheet: DomRefCell<Option<Arc<Stylesheet>>>,
|
|
||||||
cssom_stylesheet: MutNullableDom<CSSStyleSheet>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLMetaElement {
|
impl HTMLMetaElement {
|
||||||
|
@ -45,8 +32,6 @@ impl HTMLMetaElement {
|
||||||
) -> HTMLMetaElement {
|
) -> HTMLMetaElement {
|
||||||
HTMLMetaElement {
|
HTMLMetaElement {
|
||||||
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
||||||
stylesheet: DomRefCell::new(None),
|
|
||||||
cssom_stylesheet: MutNullableDom::new(None),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,73 +49,17 @@ impl HTMLMetaElement {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> {
|
|
||||||
self.stylesheet.borrow().clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> {
|
|
||||||
self.get_stylesheet().map(|sheet| {
|
|
||||||
self.cssom_stylesheet.or_init(|| {
|
|
||||||
CSSStyleSheet::new(
|
|
||||||
&window_from_node(self),
|
|
||||||
self.upcast::<Element>(),
|
|
||||||
"text/css".into(),
|
|
||||||
None, // todo handle location
|
|
||||||
None, // todo handle title
|
|
||||||
sheet,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_attributes(&self) {
|
fn process_attributes(&self) {
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
if let Some(ref name) = element.get_name() {
|
if let Some(ref name) = element.get_name() {
|
||||||
let name = name.to_ascii_lowercase();
|
let name = name.to_ascii_lowercase();
|
||||||
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
|
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
|
||||||
|
|
||||||
if name == "viewport" {
|
|
||||||
self.apply_viewport();
|
|
||||||
}
|
|
||||||
|
|
||||||
if name == "referrer" {
|
if name == "referrer" {
|
||||||
self.apply_referrer();
|
self.apply_referrer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
fn apply_viewport(&self) {
|
|
||||||
if !pref!(layout.viewport.enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let element = self.upcast::<Element>();
|
|
||||||
if let Some(ref content) = element.get_attribute(&ns!(), &local_name!("content")) {
|
|
||||||
let content = content.value();
|
|
||||||
if !content.is_empty() {
|
|
||||||
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
|
|
||||||
let stylesheets_owner = stylesheets_owner_from_node(self);
|
|
||||||
let document = document_from_node(self);
|
|
||||||
let shared_lock = document.style_shared_lock();
|
|
||||||
let rule = CssRule::Viewport(Arc::new(shared_lock.wrap(translated_rule)));
|
|
||||||
let sheet = Arc::new(Stylesheet {
|
|
||||||
contents: StylesheetContents::from_data(
|
|
||||||
CssRules::new(vec![rule], shared_lock),
|
|
||||||
Origin::Author,
|
|
||||||
window_from_node(self).get_url(),
|
|
||||||
document.quirks_mode(),
|
|
||||||
),
|
|
||||||
media: Arc::new(shared_lock.wrap(MediaList::empty())),
|
|
||||||
shared_lock: shared_lock.clone(),
|
|
||||||
disabled: AtomicBool::new(false),
|
|
||||||
});
|
|
||||||
*self.stylesheet.borrow_mut() = Some(sheet.clone());
|
|
||||||
stylesheets_owner.add_stylesheet(self.upcast(), sheet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_referrer_attribute(&self) {
|
fn process_referrer_attribute(&self) {
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
if let Some(ref name) = element.get_name() {
|
if let Some(ref name) = element.get_name() {
|
||||||
|
@ -197,10 +126,6 @@ impl VirtualMethods for HTMLMetaElement {
|
||||||
|
|
||||||
if context.tree_connected {
|
if context.tree_connected {
|
||||||
self.process_referrer_attribute();
|
self.process_referrer_attribute();
|
||||||
|
|
||||||
if let Some(s) = self.stylesheet.borrow_mut().take() {
|
|
||||||
stylesheets_owner_from_node(self).remove_stylesheet(self.upcast(), &s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,6 @@ pub mod cssstylerule;
|
||||||
pub mod cssstylesheet;
|
pub mod cssstylesheet;
|
||||||
pub mod cssstylevalue;
|
pub mod cssstylevalue;
|
||||||
pub mod csssupportsrule;
|
pub mod csssupportsrule;
|
||||||
pub mod cssviewportrule;
|
|
||||||
pub mod customelementregistry;
|
pub mod customelementregistry;
|
||||||
pub mod customevent;
|
pub mod customevent;
|
||||||
pub mod dedicatedworkerglobalscope;
|
pub mod dedicatedworkerglobalscope;
|
||||||
|
|
|
@ -48,7 +48,6 @@ use crate::dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpe
|
||||||
use crate::dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers};
|
use crate::dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers};
|
||||||
use crate::dom::htmllinkelement::HTMLLinkElement;
|
use crate::dom::htmllinkelement::HTMLLinkElement;
|
||||||
use crate::dom::htmlmediaelement::{HTMLMediaElement, LayoutHTMLMediaElementHelpers};
|
use crate::dom::htmlmediaelement::{HTMLMediaElement, LayoutHTMLMediaElementHelpers};
|
||||||
use crate::dom::htmlmetaelement::HTMLMetaElement;
|
|
||||||
use crate::dom::htmlstyleelement::HTMLStyleElement;
|
use crate::dom::htmlstyleelement::HTMLStyleElement;
|
||||||
use crate::dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers};
|
use crate::dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers};
|
||||||
use crate::dom::mouseevent::MouseEvent;
|
use crate::dom::mouseevent::MouseEvent;
|
||||||
|
@ -1200,8 +1199,6 @@ impl Node {
|
||||||
node.get_stylesheet()
|
node.get_stylesheet()
|
||||||
} else if let Some(node) = self.downcast::<HTMLLinkElement>() {
|
} else if let Some(node) = self.downcast::<HTMLLinkElement>() {
|
||||||
node.get_stylesheet()
|
node.get_stylesheet()
|
||||||
} else if let Some(node) = self.downcast::<HTMLMetaElement>() {
|
|
||||||
node.get_stylesheet()
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1212,8 +1209,6 @@ impl Node {
|
||||||
node.get_cssom_stylesheet()
|
node.get_cssom_stylesheet()
|
||||||
} else if let Some(node) = self.downcast::<HTMLLinkElement>() {
|
} else if let Some(node) = self.downcast::<HTMLLinkElement>() {
|
||||||
node.get_cssom_stylesheet()
|
node.get_cssom_stylesheet()
|
||||||
} else if let Some(node) = self.downcast::<HTMLMetaElement>() {
|
|
||||||
node.get_cssom_stylesheet()
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,6 @@ partial interface CSSRule {
|
||||||
const unsigned short KEYFRAME_RULE = 8;
|
const unsigned short KEYFRAME_RULE = 8;
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-device-adapt/#css-rule-interface
|
|
||||||
partial interface CSSRule {
|
|
||||||
const unsigned short VIEWPORT_RULE = 15;
|
|
||||||
};
|
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-conditional-3/#extentions-to-cssrule-interface
|
// https://drafts.csswg.org/css-conditional-3/#extentions-to-cssrule-interface
|
||||||
partial interface CSSRule {
|
partial interface CSSRule {
|
||||||
const unsigned short SUPPORTS_RULE = 12;
|
const unsigned short SUPPORTS_RULE = 12;
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-device-adapt/#css-viewport-rule-interface
|
|
||||||
[Exposed=Window]
|
|
||||||
interface CSSViewportRule : CSSRule {
|
|
||||||
// readonly attribute CSSStyleDeclaration style;
|
|
||||||
};
|
|
|
@ -36,7 +36,6 @@ use servo_url::ServoUrl;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
use webgpu::{wgpu, WebGPU, WebGPUResponseResult};
|
use webgpu::{wgpu, WebGPU, WebGPUResponseResult};
|
||||||
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
||||||
|
@ -60,8 +59,6 @@ pub enum LayoutMsg {
|
||||||
/// Requests that the constellation inform the compositor that it needs to record
|
/// Requests that the constellation inform the compositor that it needs to record
|
||||||
/// the time when the frame with the given ID (epoch) is painted.
|
/// the time when the frame with the given ID (epoch) is painted.
|
||||||
PendingPaintMetric(PipelineId, Epoch),
|
PendingPaintMetric(PipelineId, Epoch),
|
||||||
/// Notifies the constellation that the viewport has been constrained in some manner
|
|
||||||
ViewportConstrained(PipelineId, ViewportConstraints),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for LayoutMsg {
|
impl fmt::Debug for LayoutMsg {
|
||||||
|
@ -70,7 +67,6 @@ impl fmt::Debug for LayoutMsg {
|
||||||
let variant = match *self {
|
let variant = match *self {
|
||||||
IFrameSizes(..) => "IFrameSizes",
|
IFrameSizes(..) => "IFrameSizes",
|
||||||
PendingPaintMetric(..) => "PendingPaintMetric",
|
PendingPaintMetric(..) => "PendingPaintMetric",
|
||||||
ViewportConstrained(..) => "ViewportConstrained",
|
|
||||||
};
|
};
|
||||||
write!(formatter, "LayoutMsg::{}", variant)
|
write!(formatter, "LayoutMsg::{}", variant)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,16 +36,8 @@ use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
|
||||||
use style_traits::{CssWriter, ParseError, PinchZoomFactor, StyleParseErrorKind, ToCss};
|
use style_traits::{CssWriter, ParseError, PinchZoomFactor, StyleParseErrorKind, ToCss};
|
||||||
|
|
||||||
/// Whether parsing and processing of `@viewport` rules is enabled.
|
/// Whether parsing and processing of `@viewport` rules is enabled.
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
pub fn enabled() -> bool {
|
pub fn enabled() -> bool {
|
||||||
use servo_config::pref;
|
false
|
||||||
pref!(layout.viewport.enabled)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether parsing and processing of `@viewport` rules is enabled.
|
|
||||||
#[cfg(not(feature = "servo"))]
|
|
||||||
pub fn enabled() -> bool {
|
|
||||||
false // Gecko doesn't support @viewport.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! declare_viewport_descriptor {
|
macro_rules! declare_viewport_descriptor {
|
||||||
|
|
|
@ -100,7 +100,6 @@
|
||||||
"layout.columns.enabled": false,
|
"layout.columns.enabled": false,
|
||||||
"layout.flexbox.enabled": false,
|
"layout.flexbox.enabled": false,
|
||||||
"layout.threads": 3,
|
"layout.threads": 3,
|
||||||
"layout.viewport.enabled": false,
|
|
||||||
"layout.writing-mode.enabled": false,
|
"layout.writing-mode.enabled": false,
|
||||||
"media.glvideo.enabled": false,
|
"media.glvideo.enabled": false,
|
||||||
"media.testing.enabled": false,
|
"media.testing.enabled": false,
|
||||||
|
|
|
@ -36,4 +36,3 @@ mod specified_values;
|
||||||
mod str;
|
mod str;
|
||||||
mod stylesheets;
|
mod stylesheets;
|
||||||
mod stylist;
|
mod stylist;
|
||||||
mod viewport;
|
|
||||||
|
|
|
@ -72,7 +72,6 @@ impl ParseErrorReporter for TestingErrorReporter {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_report_error_stylesheet() {
|
fn test_report_error_stylesheet() {
|
||||||
set_pref!(layout.viewport.enabled, true);
|
|
||||||
let css = r"
|
let css = r"
|
||||||
div {
|
div {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
|
@ -88,7 +87,6 @@ fn test_report_error_stylesheet() {
|
||||||
@media screen { @invalid; }
|
@media screen { @invalid; }
|
||||||
@supports (color: green) and invalid and (margin: 0) {}
|
@supports (color: green) and invalid and (margin: 0) {}
|
||||||
@keyframes foo { from invalid {} to { margin: 0 invalid 0; } }
|
@keyframes foo { from invalid {} to { margin: 0 invalid 0; } }
|
||||||
@viewport { width: 320px invalid auto; }
|
|
||||||
";
|
";
|
||||||
let url = ServoUrl::parse("about::test").unwrap();
|
let url = ServoUrl::parse("about::test").unwrap();
|
||||||
let error_reporter = TestingErrorReporter::new();
|
let error_reporter = TestingErrorReporter::new();
|
||||||
|
@ -135,11 +133,6 @@ fn test_report_error_stylesheet() {
|
||||||
52,
|
52,
|
||||||
"Unsupported keyframe property declaration: 'margin: 0 invalid 0;'",
|
"Unsupported keyframe property declaration: 'margin: 0 invalid 0;'",
|
||||||
),
|
),
|
||||||
(
|
|
||||||
20,
|
|
||||||
29,
|
|
||||||
"Unsupported @viewport descriptor declaration: 'width: 320px invalid auto;'",
|
|
||||||
),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert_eq!(error_reporter.errors.borrow()[0].url, url);
|
assert_eq!(error_reporter.errors.borrow()[0].url, url);
|
||||||
|
|
|
@ -1,629 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
use cssparser::{Parser, ParserInput};
|
|
||||||
use euclid::{Scale, Size2D};
|
|
||||||
use servo_arc::Arc;
|
|
||||||
use servo_config::set_pref;
|
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use style::context::QuirksMode;
|
|
||||||
use style::media_queries::{Device, MediaList, MediaType};
|
|
||||||
use style::parser::ParserContext;
|
|
||||||
use style::shared_lock::{SharedRwLock, StylesheetGuards};
|
|
||||||
use style::stylesheets::viewport_rule::*;
|
|
||||||
use style::stylesheets::{AllowImportRules, CssRuleType, Origin, Stylesheet, StylesheetInDocument};
|
|
||||||
use style::values::generics::length::LengthPercentageOrAuto::{self, Auto};
|
|
||||||
use style::values::generics::NonNegative;
|
|
||||||
use style::values::specified::LengthPercentage;
|
|
||||||
use style::values::specified::NoCalcLength::{self, ViewportPercentage};
|
|
||||||
use style::values::specified::ViewportPercentageLength::Vw;
|
|
||||||
use style_traits::viewport::*;
|
|
||||||
use style_traits::{ParsingMode, PinchZoomFactor};
|
|
||||||
|
|
||||||
macro_rules! stylesheet {
|
|
||||||
($css:expr, $origin:ident) => {
|
|
||||||
stylesheet!($css, $origin, SharedRwLock::new())
|
|
||||||
};
|
|
||||||
($css:expr, $origin:ident, $shared_lock:expr) => {
|
|
||||||
Arc::new(Stylesheet::from_str(
|
|
||||||
$css,
|
|
||||||
ServoUrl::parse("http://localhost").unwrap(),
|
|
||||||
Origin::$origin,
|
|
||||||
Arc::new($shared_lock.wrap(MediaList::empty())),
|
|
||||||
$shared_lock,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
0,
|
|
||||||
AllowImportRules::Yes,
|
|
||||||
))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_viewport_rule<F>(css: &str, device: &Device, callback: F)
|
|
||||||
where
|
|
||||||
F: Fn(&Vec<ViewportDescriptorDeclaration>, &str),
|
|
||||||
{
|
|
||||||
set_pref!(layout.viewport.enabled, true);
|
|
||||||
let stylesheet = stylesheet!(css, Author);
|
|
||||||
let mut rule_count = 0;
|
|
||||||
stylesheet.effective_viewport_rules(&device, &stylesheet.shared_lock.read(), |rule| {
|
|
||||||
rule_count += 1;
|
|
||||||
callback(&rule.declarations, css);
|
|
||||||
});
|
|
||||||
assert!(rule_count > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_meta_viewport<F>(meta: &str, callback: F)
|
|
||||||
where
|
|
||||||
F: Fn(&Vec<ViewportDescriptorDeclaration>, &str),
|
|
||||||
{
|
|
||||||
if let Some(mut rule) = ViewportRule::from_meta(meta) {
|
|
||||||
// from_meta uses a hash-map to collect the declarations, so we need to
|
|
||||||
// sort them in a stable order for the tests
|
|
||||||
rule.declarations.sort_by(|a, b| {
|
|
||||||
let a = a.descriptor.discriminant_value();
|
|
||||||
let b = b.descriptor.discriminant_value();
|
|
||||||
a.cmp(&b)
|
|
||||||
});
|
|
||||||
|
|
||||||
callback(&rule.declarations, meta);
|
|
||||||
} else {
|
|
||||||
panic!("no @viewport rule for {}", meta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! assert_decl_len {
|
|
||||||
($declarations:ident == 1) => {
|
|
||||||
assert_eq!(
|
|
||||||
$declarations.len(),
|
|
||||||
1,
|
|
||||||
"expected 1 declaration; have {}: {:?})",
|
|
||||||
$declarations.len(),
|
|
||||||
$declarations
|
|
||||||
)
|
|
||||||
};
|
|
||||||
($declarations:ident == $len:expr) => {
|
|
||||||
assert_eq!(
|
|
||||||
$declarations.len(),
|
|
||||||
$len,
|
|
||||||
"expected {} declarations; have {}: {:?})",
|
|
||||||
$len,
|
|
||||||
$declarations.len(),
|
|
||||||
$declarations
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! viewport_length {
|
|
||||||
($value:expr, px) => {
|
|
||||||
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(NonNegative(
|
|
||||||
LengthPercentage::Length(NoCalcLength::from_px($value)),
|
|
||||||
)))
|
|
||||||
};
|
|
||||||
($value:expr, vw) => {
|
|
||||||
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(NonNegative(
|
|
||||||
LengthPercentage::Length(ViewportPercentage(Vw($value))),
|
|
||||||
)))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn empty_viewport_rule() {
|
|
||||||
let device = Device::new(
|
|
||||||
MediaType::screen(),
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
Size2D::new(800., 600.),
|
|
||||||
Scale::new(1.0),
|
|
||||||
);
|
|
||||||
|
|
||||||
test_viewport_rule("@viewport {}", &device, |declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! assert_decl_eq {
|
|
||||||
($d:expr, $origin:ident, $expected:ident: $value:expr) => {{
|
|
||||||
assert_eq!($d.origin, Origin::$origin);
|
|
||||||
assert_eq!($d.descriptor, ViewportDescriptor::$expected($value));
|
|
||||||
assert_eq!($d.important, false, "descriptor should not be !important");
|
|
||||||
}};
|
|
||||||
($d:expr, $origin:ident, $expected:ident: $value:expr, !important) => {{
|
|
||||||
assert_eq!($d.origin, Origin::$origin);
|
|
||||||
assert_eq!($d.descriptor, ViewportDescriptor::$expected($value));
|
|
||||||
assert_eq!($d.important, true, "descriptor should be !important");
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn simple_viewport_rules() {
|
|
||||||
let device = Device::new(
|
|
||||||
MediaType::screen(),
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
Size2D::new(800., 600.),
|
|
||||||
Scale::new(1.0),
|
|
||||||
);
|
|
||||||
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { width: auto; height: auto;\
|
|
||||||
zoom: auto; min-zoom: 0; max-zoom: 200%;\
|
|
||||||
user-zoom: zoom; orientation: auto; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 9);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[2],
|
|
||||||
Author,
|
|
||||||
MinHeight: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[3],
|
|
||||||
Author,
|
|
||||||
MaxHeight: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(&declarations[4], Author, Zoom: Zoom::Auto);
|
|
||||||
assert_decl_eq!(&declarations[5], Author, MinZoom: Zoom::Number(0.));
|
|
||||||
assert_decl_eq!(&declarations[6], Author, MaxZoom: Zoom::Percentage(2.));
|
|
||||||
assert_decl_eq!(&declarations[7], Author, UserZoom: UserZoom::Zoom);
|
|
||||||
assert_decl_eq!(&declarations[8], Author, Orientation: Orientation::Auto);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { min-width: 200px; max-width: auto;\
|
|
||||||
min-height: 200px; max-height: auto; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 4);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: viewport_length!(200., px)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[2],
|
|
||||||
Author,
|
|
||||||
MinHeight: viewport_length!(200., px)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[3],
|
|
||||||
Author,
|
|
||||||
MaxHeight: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn simple_meta_viewport_contents() {
|
|
||||||
test_meta_viewport("width=500, height=600", |declarations, meta| {
|
|
||||||
println!("{}", meta);
|
|
||||||
assert_decl_len!(declarations == 4);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::ExtendToZoom
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: viewport_length!(500., px)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[2],
|
|
||||||
Author,
|
|
||||||
MinHeight: ViewportLength::ExtendToZoom
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[3],
|
|
||||||
Author,
|
|
||||||
MaxHeight: viewport_length!(600., px)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test_meta_viewport("initial-scale=1.0", |declarations, meta| {
|
|
||||||
println!("{}", meta);
|
|
||||||
assert_decl_len!(declarations == 3);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::ExtendToZoom
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: ViewportLength::ExtendToZoom
|
|
||||||
);
|
|
||||||
assert_decl_eq!(&declarations[2], Author, Zoom: Zoom::Number(1.));
|
|
||||||
});
|
|
||||||
|
|
||||||
test_meta_viewport(
|
|
||||||
"initial-scale=2.0, height=device-width",
|
|
||||||
|declarations, meta| {
|
|
||||||
println!("{}", meta);
|
|
||||||
assert_decl_len!(declarations == 5);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[2],
|
|
||||||
Author,
|
|
||||||
MinHeight: ViewportLength::ExtendToZoom
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[3],
|
|
||||||
Author,
|
|
||||||
MaxHeight: viewport_length!(100., vw)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(&declarations[4], Author, Zoom: Zoom::Number(2.));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test_meta_viewport(
|
|
||||||
"width=480, initial-scale=2.0, user-scalable=1",
|
|
||||||
|declarations, meta| {
|
|
||||||
println!("{}", meta);
|
|
||||||
assert_decl_len!(declarations == 4);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::ExtendToZoom
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: viewport_length!(480., px)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(&declarations[2], Author, Zoom: Zoom::Number(2.));
|
|
||||||
assert_decl_eq!(&declarations[3], Author, UserZoom: UserZoom::Zoom);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn cascading_within_viewport_rule() {
|
|
||||||
let device = Device::new(
|
|
||||||
MediaType::screen(),
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
Size2D::new(800., 600.),
|
|
||||||
Scale::new(1.0),
|
|
||||||
);
|
|
||||||
|
|
||||||
// normal order of appearance
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { min-width: 200px; min-width: auto; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 1);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// !important order of appearance
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { min-width: 200px !important; min-width: auto !important; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 1);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto),
|
|
||||||
!important
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// !important vs normal
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { min-width: auto !important; min-width: 200px; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 1);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto),
|
|
||||||
!important
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// normal longhands vs normal shorthand
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { min-width: 200px; max-width: 200px; width: auto; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 2);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// normal shorthand vs normal longhands
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { width: 200px; min-width: auto; max-width: auto; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 2);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: ViewportLength::Specified(Auto)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// one !important longhand vs normal shorthand
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { min-width: auto !important; width: 200px; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 2);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto),
|
|
||||||
!important
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: viewport_length!(200., px)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// both !important longhands vs normal shorthand
|
|
||||||
test_viewport_rule(
|
|
||||||
"@viewport { min-width: auto !important; max-width: auto !important; width: 200px; }",
|
|
||||||
&device,
|
|
||||||
|declarations, css| {
|
|
||||||
println!("{}", css);
|
|
||||||
assert_decl_len!(declarations == 2);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
Author,
|
|
||||||
MinWidth: ViewportLength::Specified(Auto),
|
|
||||||
!important
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
Author,
|
|
||||||
MaxWidth: ViewportLength::Specified(Auto),
|
|
||||||
!important
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn multiple_stylesheets_cascading() {
|
|
||||||
set_pref!(layout.viewport.enabled, true);
|
|
||||||
let device = Device::new(
|
|
||||||
MediaType::screen(),
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
Size2D::new(800., 600.),
|
|
||||||
Scale::new(1.0),
|
|
||||||
);
|
|
||||||
let shared_lock = SharedRwLock::new();
|
|
||||||
let stylesheets = vec![
|
|
||||||
stylesheet!(
|
|
||||||
"@viewport { min-width: 100px; min-height: 100px; zoom: 1; }",
|
|
||||||
UserAgent,
|
|
||||||
shared_lock.clone()
|
|
||||||
),
|
|
||||||
stylesheet!(
|
|
||||||
"@viewport { min-width: 200px; min-height: 200px; }",
|
|
||||||
User,
|
|
||||||
shared_lock.clone()
|
|
||||||
),
|
|
||||||
stylesheet!(
|
|
||||||
"@viewport { min-width: 300px; }",
|
|
||||||
Author,
|
|
||||||
shared_lock.clone()
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
let declarations = Cascade::from_stylesheets(
|
|
||||||
stylesheets.iter().map(|s| (&**s, Origin::Author)),
|
|
||||||
&StylesheetGuards::same(&shared_lock.read()),
|
|
||||||
&device,
|
|
||||||
)
|
|
||||||
.finish();
|
|
||||||
assert_decl_len!(declarations == 3);
|
|
||||||
assert_decl_eq!(&declarations[0], UserAgent, Zoom: Zoom::Number(1.));
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
User,
|
|
||||||
MinHeight: viewport_length!(200., px)
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[2],
|
|
||||||
Author,
|
|
||||||
MinWidth: viewport_length!(300., px)
|
|
||||||
);
|
|
||||||
|
|
||||||
let stylesheets = vec![
|
|
||||||
stylesheet!("@viewport { min-width: 100px !important; }",
|
|
||||||
UserAgent, shared_lock.clone()),
|
|
||||||
stylesheet!("@viewport { min-width: 200px !important; min-height: 200px !important; }",
|
|
||||||
User, shared_lock.clone()),
|
|
||||||
stylesheet!("@viewport { min-width: 300px !important; min-height: 300px !important; zoom: 3 !important; }",
|
|
||||||
Author, shared_lock.clone())
|
|
||||||
];
|
|
||||||
let declarations = Cascade::from_stylesheets(
|
|
||||||
stylesheets.iter().map(|s| (&**s, Origin::Author)),
|
|
||||||
&StylesheetGuards::same(&shared_lock.read()),
|
|
||||||
&device,
|
|
||||||
)
|
|
||||||
.finish();
|
|
||||||
assert_decl_len!(declarations == 3);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[0],
|
|
||||||
UserAgent,
|
|
||||||
MinWidth: viewport_length!(100., px),
|
|
||||||
!important
|
|
||||||
);
|
|
||||||
assert_decl_eq!(
|
|
||||||
&declarations[1],
|
|
||||||
User,
|
|
||||||
MinHeight: viewport_length!(200., px),
|
|
||||||
!important
|
|
||||||
);
|
|
||||||
assert_decl_eq!(&declarations[2], Author, Zoom: Zoom::Number(3.), !important);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn constrain_viewport() {
|
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
|
||||||
let context = ParserContext::new(
|
|
||||||
Origin::Author,
|
|
||||||
&url,
|
|
||||||
Some(CssRuleType::Viewport),
|
|
||||||
ParsingMode::DEFAULT,
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
macro_rules! from_css {
|
|
||||||
($css:expr) => {
|
|
||||||
&ViewportRule::parse(&context, &mut Parser::new(&mut $css)).unwrap()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let initial_viewport = Size2D::new(800., 600.);
|
|
||||||
let device = Device::new(
|
|
||||||
MediaType::screen(),
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
initial_viewport,
|
|
||||||
Scale::new(1.0),
|
|
||||||
);
|
|
||||||
let mut input = ParserInput::new("");
|
|
||||||
assert_eq!(
|
|
||||||
ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks),
|
|
||||||
None
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut input = ParserInput::new("width: 320px auto");
|
|
||||||
assert_eq!(
|
|
||||||
ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks),
|
|
||||||
Some(ViewportConstraints {
|
|
||||||
size: initial_viewport,
|
|
||||||
|
|
||||||
initial_zoom: PinchZoomFactor::new(1.),
|
|
||||||
min_zoom: None,
|
|
||||||
max_zoom: None,
|
|
||||||
|
|
||||||
user_zoom: UserZoom::Zoom,
|
|
||||||
orientation: Orientation::Auto
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut input = ParserInput::new("width: 320px auto");
|
|
||||||
assert_eq!(
|
|
||||||
ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks),
|
|
||||||
Some(ViewportConstraints {
|
|
||||||
size: initial_viewport,
|
|
||||||
|
|
||||||
initial_zoom: PinchZoomFactor::new(1.),
|
|
||||||
min_zoom: None,
|
|
||||||
max_zoom: None,
|
|
||||||
|
|
||||||
user_zoom: UserZoom::Zoom,
|
|
||||||
orientation: Orientation::Auto
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut input = ParserInput::new(
|
|
||||||
"width: 800px; height: 600px;\
|
|
||||||
zoom: 1;\
|
|
||||||
user-zoom: zoom;\
|
|
||||||
orientation: auto;",
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks),
|
|
||||||
Some(ViewportConstraints {
|
|
||||||
size: initial_viewport,
|
|
||||||
|
|
||||||
initial_zoom: PinchZoomFactor::new(1.),
|
|
||||||
min_zoom: None,
|
|
||||||
max_zoom: None,
|
|
||||||
|
|
||||||
user_zoom: UserZoom::Zoom,
|
|
||||||
orientation: Orientation::Auto
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
let initial_viewport = Size2D::new(200., 150.);
|
|
||||||
let device = Device::new(
|
|
||||||
MediaType::screen(),
|
|
||||||
QuirksMode::NoQuirks,
|
|
||||||
initial_viewport,
|
|
||||||
Scale::new(1.0),
|
|
||||||
);
|
|
||||||
let mut input = ParserInput::new("width: 320px auto");
|
|
||||||
assert_eq!(
|
|
||||||
ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks),
|
|
||||||
Some(ViewportConstraints {
|
|
||||||
size: Size2D::new(320., 240.),
|
|
||||||
|
|
||||||
initial_zoom: PinchZoomFactor::new(1.),
|
|
||||||
min_zoom: None,
|
|
||||||
max_zoom: None,
|
|
||||||
|
|
||||||
user_zoom: UserZoom::Zoom,
|
|
||||||
orientation: Orientation::Auto
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
[meta_viewport_resize.html]
|
|
||||||
type: testharness
|
|
||||||
prefs: [layout.viewport.enabled:true]
|
|
|
@ -1,3 +0,0 @@
|
||||||
prefs: [layout.viewport.enabled:true]
|
|
||||||
[viewport_meta.html]
|
|
||||||
type: reftest
|
|
|
@ -1,3 +0,0 @@
|
||||||
prefs: [layout.viewport.enabled:true]
|
|
||||||
[viewport_rule.html]
|
|
||||||
type: reftest
|
|
|
@ -6910,21 +6910,6 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"viewport_meta.html": [
|
|
||||||
"69c57539ec5076335582a4c40fc19886b6d2620f",
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
[
|
|
||||||
[
|
|
||||||
"/_mozilla/css/viewport_rule_ref.html",
|
|
||||||
"=="
|
|
||||||
]
|
|
||||||
],
|
|
||||||
{
|
|
||||||
"viewport_size": "800x600"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"viewport_percentage_vmin_vmax_a.html": [
|
"viewport_percentage_vmin_vmax_a.html": [
|
||||||
"903e4ea87426e2909ee0e2b683d6f097683f5c81",
|
"903e4ea87426e2909ee0e2b683d6f097683f5c81",
|
||||||
[
|
[
|
||||||
|
@ -6985,21 +6970,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"viewport_rule.html": [
|
|
||||||
"09d9c72a1651adf01cb14651c0eae4c5a563e682",
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
[
|
|
||||||
[
|
|
||||||
"/_mozilla/css/viewport_rule_ref.html",
|
|
||||||
"=="
|
|
||||||
]
|
|
||||||
],
|
|
||||||
{
|
|
||||||
"viewport_size": "800x600"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"visibility_hidden.html": [
|
"visibility_hidden.html": [
|
||||||
"95dbf18a0eacacb7162ab220f0d08113745efa14",
|
"95dbf18a0eacacb7162ab220f0d08113745efa14",
|
||||||
[
|
[
|
||||||
|
@ -9373,10 +9343,6 @@
|
||||||
"4fe2cd7165aa4832ac91493bc376b8cb3df84ab5",
|
"4fe2cd7165aa4832ac91493bc376b8cb3df84ab5",
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
"meta_viewport_resize_iframe.html": [
|
|
||||||
"86de04da1bdc3b72e52e8f17964389a6779d7456",
|
|
||||||
[]
|
|
||||||
],
|
|
||||||
"min_max_height_b.html": [
|
"min_max_height_b.html": [
|
||||||
"8723d65b2585b02664f01b84d1fda328321fc412",
|
"8723d65b2585b02664f01b84d1fda328321fc412",
|
||||||
[]
|
[]
|
||||||
|
@ -10231,10 +10197,6 @@
|
||||||
"488c1aada28cc3ab41e7a6d63d3f4e5b950b1f35",
|
"488c1aada28cc3ab41e7a6d63d3f4e5b950b1f35",
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
"viewport_ignore_desktop.html.ini": [
|
|
||||||
"696f7ab3ac81362267fa882303d687cbffe454df",
|
|
||||||
[]
|
|
||||||
],
|
|
||||||
"viewport_ignore_desktop_ref.html": [
|
"viewport_ignore_desktop_ref.html": [
|
||||||
"149d364517b397c14628550e5af1c7fa37c84e90",
|
"149d364517b397c14628550e5af1c7fa37c84e90",
|
||||||
[]
|
[]
|
||||||
|
@ -10247,10 +10209,6 @@
|
||||||
"07146c46a08ffe5c5e1bfd0ac451242202e93397",
|
"07146c46a08ffe5c5e1bfd0ac451242202e93397",
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
"viewport_rule_ref.html": [
|
|
||||||
"4c7be62919ac9cd9dd65861637bf10c958595e0d",
|
|
||||||
[]
|
|
||||||
],
|
|
||||||
"visibility_hidden_ref.html": [
|
"visibility_hidden_ref.html": [
|
||||||
"8f0a447ccb8175a8278438537e7597ad5116393b",
|
"8f0a447ccb8175a8278438537e7597ad5116393b",
|
||||||
[]
|
[]
|
||||||
|
@ -12564,13 +12522,6 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"meta_viewport_resize.html": [
|
|
||||||
"7cde945198d744559f65b9a2cfb473cd02550e40",
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
{}
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"offset_properties_inline.html": [
|
"offset_properties_inline.html": [
|
||||||
"44eaa4490fc515f203c3062476121f94b4337d78",
|
"44eaa4490fc515f203c3062476121f94b4337d78",
|
||||||
[
|
[
|
||||||
|
@ -13480,7 +13431,7 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"interfaces.html": [
|
"interfaces.html": [
|
||||||
"b58b16ca333f9e00afade02c2ac60689ee7eef3a",
|
"995631527b5ab6ad2001a97574d4114576064299",
|
||||||
[
|
[
|
||||||
null,
|
null,
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[viewport_meta.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[viewport_rule.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,33 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<meta charset=utf-8>
|
|
||||||
<title>Resizing the initial containing block dynamically with <meta name="viewport">
|
|
||||||
https://github.com/servo/servo/issues/8443</title>
|
|
||||||
<script src="/resources/testharness.js"></script>
|
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
|
||||||
<script>
|
|
||||||
async_test(function(t) {
|
|
||||||
var step2 = function() {
|
|
||||||
var iframe = document.getElementsByTagName("iframe")[0];
|
|
||||||
var body_style = iframe.contentWindow.getComputedStyle(iframe.contentDocument.body);
|
|
||||||
if (body_style.width === "500px") {
|
|
||||||
t.done();
|
|
||||||
} else {
|
|
||||||
window.requestAnimationFrame(step2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var step1 = function() {
|
|
||||||
var iframe = document.getElementsByTagName("iframe")[0];
|
|
||||||
var body_style = iframe.contentWindow.getComputedStyle(iframe.contentDocument.body);
|
|
||||||
if (body_style.width === "400px") {
|
|
||||||
iframe.width = 500;
|
|
||||||
window.requestAnimationFrame(step2);
|
|
||||||
} else {
|
|
||||||
window.requestAnimationFrame(step1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.run = step1;
|
|
||||||
}, "<body> inside <iframe> has the <iframe>’s width");
|
|
||||||
</script>
|
|
||||||
<iframe src="meta_viewport_resize_iframe.html" onload="run()" width=400></iframe>
|
|
|
@ -1,4 +0,0 @@
|
||||||
<meta name="viewport" content="initial-scale=1.0">
|
|
||||||
<body style="margin: 0">
|
|
||||||
Test
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
prefs: ["layout.viewport.enabled:false"]
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel=match href=viewport_rule_ref.html>
|
|
||||||
<meta name=viewport-size content=800x600>
|
|
||||||
<meta name="viewport" content="width=240">
|
|
||||||
<style>
|
|
||||||
#container {
|
|
||||||
background: blue;
|
|
||||||
height: 100vh;
|
|
||||||
width: 100vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
#box {
|
|
||||||
background: green;
|
|
||||||
height: 50vh;
|
|
||||||
width: 50vw;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="container">
|
|
||||||
<div id="box">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,31 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel=match href=viewport_rule_ref.html>
|
|
||||||
<meta name=viewport-size content=800x600>
|
|
||||||
<style>
|
|
||||||
@viewport {
|
|
||||||
height: auto;
|
|
||||||
width: 240px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container {
|
|
||||||
background: blue;
|
|
||||||
height: 100vh;
|
|
||||||
width: 100vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
#box {
|
|
||||||
background: green;
|
|
||||||
height: 50vh;
|
|
||||||
width: 50vw;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="container">
|
|
||||||
<div id="box">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<style>
|
|
||||||
#container {
|
|
||||||
background: blue;
|
|
||||||
height: 180px;
|
|
||||||
width: 240px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#box {
|
|
||||||
background: green;
|
|
||||||
height: 90px;
|
|
||||||
width: 120px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="container">
|
|
||||||
<div id="box">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -54,7 +54,6 @@ test_interfaces([
|
||||||
"CSSStyleRule",
|
"CSSStyleRule",
|
||||||
"CSSStyleSheet",
|
"CSSStyleSheet",
|
||||||
"CSSSupportsRule",
|
"CSSSupportsRule",
|
||||||
"CSSViewportRule",
|
|
||||||
"DOMMatrix",
|
"DOMMatrix",
|
||||||
"DOMMatrixReadOnly",
|
"DOMMatrixReadOnly",
|
||||||
"DOMPoint",
|
"DOMPoint",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue