mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
Introduce CSSPixel as a replacement for ViewportPx and PagePx.
This commit is contained in:
parent
56a99577b3
commit
30ff2f8f0d
16 changed files with 81 additions and 92 deletions
|
@ -10,7 +10,7 @@ use euclid::{Size2D, TypedSize2D};
|
|||
use media_queries::MediaType;
|
||||
use properties::ComputedValues;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ViewportPx};
|
||||
use style_traits::{CSSPixel, ToCss};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use values::computed::{self, ToComputedValue};
|
||||
use values::specified;
|
||||
|
@ -23,14 +23,14 @@ use values::specified;
|
|||
pub struct Device {
|
||||
/// The current media type used by de device.
|
||||
media_type: MediaType,
|
||||
/// The current viewport size, in viewport pixels.
|
||||
viewport_size: TypedSize2D<f32, ViewportPx>,
|
||||
/// The current viewport size, in CSS pixels.
|
||||
viewport_size: TypedSize2D<f32, CSSPixel>,
|
||||
}
|
||||
|
||||
impl Device {
|
||||
/// Trivially construct a new `Device`.
|
||||
pub fn new(media_type: MediaType,
|
||||
viewport_size: TypedSize2D<f32, ViewportPx>)
|
||||
viewport_size: TypedSize2D<f32, CSSPixel>)
|
||||
-> Device {
|
||||
Device {
|
||||
media_type: media_type,
|
||||
|
@ -53,7 +53,7 @@ impl Device {
|
|||
|
||||
/// Returns the viewport size in pixels.
|
||||
#[inline]
|
||||
pub fn px_viewport_size(&self) -> TypedSize2D<f32, ViewportPx> {
|
||||
pub fn px_viewport_size(&self) -> TypedSize2D<f32, CSSPixel> {
|
||||
self.viewport_size
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
use app_units::Au;
|
||||
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
|
||||
use cssparser::ToCss as ParserToCss;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::TypedSize2D;
|
||||
use media_queries::Device;
|
||||
use parser::{ParserContext, log_css_error};
|
||||
|
@ -21,7 +20,7 @@ use std::borrow::Cow;
|
|||
use std::fmt;
|
||||
use std::iter::Enumerate;
|
||||
use std::str::Chars;
|
||||
use style_traits::ToCss;
|
||||
use style_traits::{PinchZoomFactor, ToCss};
|
||||
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
|
||||
use stylesheets::{Stylesheet, Origin};
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
|
@ -796,9 +795,9 @@ impl MaybeNew for ViewportConstraints {
|
|||
size: TypedSize2D::new(width.to_f32_px(), height.to_f32_px()),
|
||||
|
||||
// TODO: compute a zoom factor for 'auto' as suggested by DEVICE-ADAPT § 10.
|
||||
initial_zoom: ScaleFactor::new(initial_zoom.unwrap_or(1.)),
|
||||
min_zoom: min_zoom.map(ScaleFactor::new),
|
||||
max_zoom: max_zoom.map(ScaleFactor::new),
|
||||
initial_zoom: PinchZoomFactor::new(initial_zoom.unwrap_or(1.)),
|
||||
min_zoom: min_zoom.map(PinchZoomFactor::new),
|
||||
max_zoom: max_zoom.map(PinchZoomFactor::new),
|
||||
|
||||
user_zoom: user_zoom,
|
||||
orientation: orientation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue