Merge branch 'master' into freetype2

This commit is contained in:
dan-robertson 2018-02-08 16:59:09 +00:00 committed by GitHub
commit 426bd83a0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
346 changed files with 15991 additions and 2648 deletions

13
Cargo.lock generated
View file

@ -533,7 +533,7 @@ dependencies = [
[[package]]
name = "core-text"
version = "9.0.0"
version = "9.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -971,7 +971,7 @@ dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2918,6 +2918,7 @@ dependencies = [
"servo_url 0.0.1",
"smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"string_cache 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"style_derive 0.0.1",
"style_traits 0.0.1",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3309,7 +3310,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.57.0"
source = "git+https://github.com/servo/webrender#47f5afa5c011080ee787c1170038de1e5fc28155"
source = "git+https://github.com/servo/webrender#7ae075a3238915530144727896e5d275d4057f34"
dependencies = [
"app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3317,7 +3318,7 @@ dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3337,7 +3338,7 @@ dependencies = [
[[package]]
name = "webrender_api"
version = "0.57.0"
source = "git+https://github.com/servo/webrender#47f5afa5c011080ee787c1170038de1e5fc28155"
source = "git+https://github.com/servo/webrender#7ae075a3238915530144727896e5d275d4057f34"
dependencies = [
"app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3557,7 +3558,7 @@ dependencies = [
"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
"checksum core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb0ed45fdc32f9ab426238fba9407dfead7bacd7900c9b4dd3f396f46eafdae3"
"checksum core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c737a5c1f112943c961ed270aea64f7d0b01b425d327b040fa32b155646e07f"
"checksum core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2bd581c37283d0c23311d179aefbb891f2324ee0405da58a26e8594ab76e5748"
"checksum cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a807ac3ab7a217829c2a3b65732b926b2befe6a35f33b4bf8b503692430f223"
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
"checksum darling 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9861a8495606435477df581bc858ccf15a3469747edf175b94a4704fd9aaedac"

View file

@ -219,7 +219,7 @@ impl TouchHandler {
}
fn pinch_distance_and_center(&self) -> (f32, TypedPoint2D<f32, DevicePixel>) {
debug_assert!(self.touch_count() == 2);
debug_assert_eq!(self.touch_count(), 2);
let p0 = self.active_touch_points[0].point;
let p1 = self.active_touch_points[1].point;
let center = p0.lerp(p1, 0.5);

View file

@ -14,8 +14,7 @@
//! They are therefore not exactly analogous to constructs like Skia pictures, which consist of
//! low-level drawing primitives.
use app_units::Au;
use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D, TypedRect, SideOffsets2D};
use euclid::{Transform3D, Vector2D, TypedRect, SideOffsets2D};
use euclid::num::{One, Zero};
use gfx_traits::{self, StackingContextId};
use gfx_traits::print_tree::PrintTree;
@ -24,18 +23,19 @@ use msg::constellation_msg::PipelineId;
use net_traits::image::base::{Image, PixelFormat};
use range::Range;
use servo_geometry::MaxRect;
use std::cmp::{self, Ordering};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::f32;
use std::fmt;
use std::sync::Arc;
use text::TextRun;
use text::glyph::ByteIndex;
use webrender_api::{BorderRadius, BorderWidths, BoxShadowClipMode, ColorF, ExtendMode};
use webrender_api::{ExternalScrollId, FilterOp, GradientStop, ImageBorder, ImageKey};
use webrender_api::{ImageRendering, LayoutPoint, LayoutRect, LayoutSize, LayoutVector2D};
use webrender_api::{LineStyle, LocalClip, MixBlendMode, NormalBorder, ScrollPolicy};
use webrender_api::{ScrollSensitivity, StickyOffsetBounds, TransformStyle};
use webrender_api::{BorderRadius, BorderWidths, BoxShadowClipMode, ClipMode, ColorF};
use webrender_api::{ComplexClipRegion, ExtendMode, ExternalScrollId, FilterOp, FontInstanceKey};
use webrender_api::{GlyphInstance, GradientStop, ImageBorder, ImageKey, ImageRendering};
use webrender_api::{LayoutPoint, LayoutRect, LayoutSize, LayoutVector2D, LineStyle, LocalClip};
use webrender_api::{MixBlendMode, NormalBorder, ScrollPolicy, ScrollSensitivity};
use webrender_api::{StickyOffsetBounds, TransformStyle};
pub use style::dom::OpaqueNode;
@ -96,22 +96,22 @@ pub struct DisplayList {
impl DisplayList {
/// Return the bounds of this display list based on the dimensions of the root
/// stacking context.
pub fn bounds(&self) -> Rect<Au> {
pub fn bounds(&self) -> LayoutRect {
match self.list.get(0) {
Some(&DisplayItem::PushStackingContext(ref item)) => item.stacking_context.bounds,
Some(_) => unreachable!("Root element of display list not stacking context."),
None => Rect::zero(),
None => LayoutRect::zero(),
}
}
// Returns the text index within a node for the point of interest.
pub fn text_index(&self, node: OpaqueNode, point_in_item: &Point2D<Au>) -> Option<usize> {
pub fn text_index(&self, node: OpaqueNode, point_in_item: LayoutPoint) -> Option<usize> {
for item in &self.list {
match item {
&DisplayItem::Text(ref text) => {
let base = item.base();
if base.metadata.node == node {
let point = *point_in_item + item.base().bounds.origin.to_vector();
let point = point_in_item + item.base().bounds.origin.to_vector();
let offset = point - text.baseline_origin;
return Some(text.text_run.range_index_of_advance(&text.range, offset.x));
}
@ -194,10 +194,10 @@ pub struct StackingContext {
pub context_type: StackingContextType,
/// The position and size of this stacking context.
pub bounds: Rect<Au>,
pub bounds: LayoutRect,
/// The overflow rect for this stacking context in its coordinate system.
pub overflow: Rect<Au>,
pub overflow: LayoutRect,
/// The `z-index` for this stacking context.
pub z_index: i32,
@ -229,8 +229,8 @@ impl StackingContext {
#[inline]
pub fn new(id: StackingContextId,
context_type: StackingContextType,
bounds: &Rect<Au>,
overflow: &Rect<Au>,
bounds: LayoutRect,
overflow: LayoutRect,
z_index: i32,
filters: Vec<FilterOp>,
mix_blend_mode: MixBlendMode,
@ -243,8 +243,8 @@ impl StackingContext {
StackingContext {
id,
context_type,
bounds: *bounds,
overflow: *overflow,
bounds,
overflow,
z_index,
filters,
mix_blend_mode,
@ -261,8 +261,8 @@ impl StackingContext {
StackingContext::new(
StackingContextId::root(),
StackingContextType::Real,
&Rect::zero(),
&Rect::zero(),
LayoutRect::zero(),
LayoutRect::zero(),
0,
vec![],
MixBlendMode::Normal,
@ -394,7 +394,7 @@ pub enum DisplayItem {
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
pub struct BaseDisplayItem {
/// The boundaries of the display item, in layer coordinates.
pub bounds: Rect<Au>,
pub bounds: LayoutRect,
/// Metadata attached to this display item.
pub metadata: DisplayItemMetadata,
@ -414,7 +414,7 @@ pub struct BaseDisplayItem {
impl BaseDisplayItem {
#[inline(always)]
pub fn new(bounds: Rect<Au>,
pub fn new(bounds: LayoutRect,
metadata: DisplayItemMetadata,
local_clip: LocalClip,
section: DisplayListSection,
@ -454,23 +454,12 @@ impl BaseDisplayItem {
#[derive(Clone, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub struct ClippingRegion {
/// The main rectangular region. This does not include any corners.
pub main: Rect<Au>,
pub main: LayoutRect,
/// Any complex regions.
///
/// TODO(pcwalton): Atomically reference count these? Not sure if it's worth the trouble.
/// Measure and follow up.
pub complex: Vec<ComplexClippingRegion>,
}
/// A complex clipping region. These don't as easily admit arbitrary intersection operations, so
/// they're stored in a list over to the side. Currently a complex clipping region is just a
/// rounded rectangle, but the CSS WGs will probably make us throw more stuff in here eventually.
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub struct ComplexClippingRegion {
/// The boundaries of the rectangle.
pub rect: Rect<Au>,
/// Border radii of this rectangle.
pub radii: BorderRadii<Au>,
pub complex: Vec<ComplexClipRegion>,
}
impl ClippingRegion {
@ -478,7 +467,7 @@ impl ClippingRegion {
#[inline]
pub fn empty() -> ClippingRegion {
ClippingRegion {
main: Rect::zero(),
main: LayoutRect::zero(),
complex: Vec::new(),
}
}
@ -487,16 +476,16 @@ impl ClippingRegion {
#[inline]
pub fn max() -> ClippingRegion {
ClippingRegion {
main: Rect::max_rect(),
main: LayoutRect::max_rect(),
complex: Vec::new(),
}
}
/// Returns a clipping region that represents the given rectangle.
#[inline]
pub fn from_rect(rect: &Rect<Au>) -> ClippingRegion {
pub fn from_rect(rect: LayoutRect) -> ClippingRegion {
ClippingRegion {
main: *rect,
main: rect,
complex: Vec::new(),
}
}
@ -506,8 +495,8 @@ impl ClippingRegion {
/// TODO(pcwalton): This could more eagerly eliminate complex clipping regions, at the cost of
/// complexity.
#[inline]
pub fn intersect_rect(&mut self, rect: &Rect<Au>) {
self.main = self.main.intersection(rect).unwrap_or(Rect::zero())
pub fn intersect_rect(&mut self, rect: &LayoutRect) {
self.main = self.main.intersection(rect).unwrap_or(LayoutRect::zero())
}
/// Returns true if this clipping region might be nonempty. This can return false positives,
@ -520,7 +509,7 @@ impl ClippingRegion {
/// Returns true if this clipping region might contain the given point and false otherwise.
/// This is a quick, not a precise, test; it can yield false positives.
#[inline]
pub fn might_intersect_point(&self, point: &Point2D<Au>) -> bool {
pub fn might_intersect_point(&self, point: &LayoutPoint) -> bool {
self.main.contains(point) &&
self.complex.iter().all(|complex| complex.rect.contains(point))
}
@ -528,14 +517,14 @@ impl ClippingRegion {
/// Returns true if this clipping region might intersect the given rectangle and false
/// otherwise. This is a quick, not a precise, test; it can yield false positives.
#[inline]
pub fn might_intersect_rect(&self, rect: &Rect<Au>) -> bool {
pub fn might_intersect_rect(&self, rect: &LayoutRect) -> bool {
self.main.intersects(rect) &&
self.complex.iter().all(|complex| complex.rect.intersects(rect))
}
/// Returns true if this clipping region completely surrounds the given rect.
#[inline]
pub fn does_not_clip_rect(&self, rect: &Rect<Au>) -> bool {
pub fn does_not_clip_rect(&self, rect: &LayoutRect) -> bool {
self.main.contains(&rect.origin) && self.main.contains(&rect.bottom_right()) &&
self.complex.iter().all(|complex| {
complex.rect.contains(&rect.origin) && complex.rect.contains(&rect.bottom_right())
@ -544,7 +533,7 @@ impl ClippingRegion {
/// Returns a bounding rect that surrounds this entire clipping region.
#[inline]
pub fn bounding_rect(&self) -> Rect<Au> {
pub fn bounding_rect(&self) -> LayoutRect {
let mut rect = self.main;
for complex in &*self.complex {
rect = rect.union(&complex.rect)
@ -554,10 +543,11 @@ impl ClippingRegion {
/// Intersects this clipping region with the given rounded rectangle.
#[inline]
pub fn intersect_with_rounded_rect(&mut self, rect: &Rect<Au>, radii: &BorderRadii<Au>) {
let new_complex_region = ComplexClippingRegion {
rect: *rect,
radii: *radii,
pub fn intersect_with_rounded_rect(&mut self, rect: LayoutRect, radii: BorderRadius) {
let new_complex_region = ComplexClipRegion {
rect,
radii,
mode: ClipMode::Clip,
};
// FIXME(pcwalton): This is O(n²) worst case for disjoint clipping regions. Is that OK?
@ -576,21 +566,19 @@ impl ClippingRegion {
}
}
self.complex.push(ComplexClippingRegion {
rect: *rect,
radii: *radii,
});
self.complex.push(new_complex_region);
}
/// Translates this clipping region by the given vector.
#[inline]
pub fn translate(&self, delta: &Vector2D<Au>) -> ClippingRegion {
pub fn translate(&self, delta: &LayoutVector2D) -> ClippingRegion {
ClippingRegion {
main: self.main.translate(delta),
complex: self.complex.iter().map(|complex| {
ComplexClippingRegion {
ComplexClipRegion {
rect: complex.rect.translate(delta),
radii: complex.radii,
mode: complex.mode,
}
}).collect(),
}
@ -598,7 +586,7 @@ impl ClippingRegion {
#[inline]
pub fn is_max(&self) -> bool {
self.main == Rect::max_rect() && self.complex.is_empty()
self.main == LayoutRect::max_rect() && self.complex.is_empty()
}
}
@ -608,7 +596,7 @@ impl fmt::Debug for ClippingRegion {
write!(f, "ClippingRegion::Max")
} else if *self == ClippingRegion::empty() {
write!(f, "ClippingRegion::Empty")
} else if self.main == Rect::max_rect() {
} else if self.main == LayoutRect::max_rect() {
write!(f, "ClippingRegion(Complex={:?})", self.complex)
} else {
write!(f, "ClippingRegion(Rect={:?}, Complex={:?})", self.main, self.complex)
@ -616,17 +604,21 @@ impl fmt::Debug for ClippingRegion {
}
}
impl ComplexClippingRegion {
pub trait CompletelyEncloses {
fn completely_encloses(&self, other: &Self) -> bool;
}
impl CompletelyEncloses for ComplexClipRegion {
// TODO(pcwalton): This could be more aggressive by considering points that touch the inside of
// the border radius ellipse.
fn completely_encloses(&self, other: &ComplexClippingRegion) -> bool {
let left = cmp::max(self.radii.top_left.width, self.radii.bottom_left.width);
let top = cmp::max(self.radii.top_left.height, self.radii.top_right.height);
let right = cmp::max(self.radii.top_right.width, self.radii.bottom_right.width);
let bottom = cmp::max(self.radii.bottom_left.height, self.radii.bottom_right.height);
let interior = Rect::new(Point2D::new(self.rect.origin.x + left, self.rect.origin.y + top),
Size2D::new(self.rect.size.width - left - right,
self.rect.size.height - top - bottom));
fn completely_encloses(&self, other: &Self) -> bool {
let left = self.radii.top_left.width.max(self.radii.bottom_left.width);
let top = self.radii.top_left.height.max(self.radii.top_right.height);
let right = self.radii.top_right.width.max(self.radii.bottom_right.width);
let bottom = self.radii.bottom_left.height.max(self.radii.bottom_right.height);
let interior = LayoutRect::new(LayoutPoint::new(self.rect.origin.x + left, self.rect.origin.y + top),
LayoutSize::new(self.rect.size.width - left - right,
self.rect.size.height - top - bottom));
interior.origin.x <= other.rect.origin.x && interior.origin.y <= other.rect.origin.y &&
interior.max_x() >= other.rect.max_x() && interior.max_y() >= other.rect.max_y()
}
@ -667,14 +659,14 @@ pub struct TextDisplayItem {
/// The range of text within the text run.
pub range: Range<ByteIndex>,
/// The position of the start of the baseline of this text.
pub baseline_origin: LayoutPoint,
/// A collection of (non-whitespace) glyphs to be displayed.
pub glyphs: Vec<GlyphInstance>,
/// Reference to the font to be used.
pub font_key: FontInstanceKey,
/// The color of the text.
pub text_color: ColorF,
/// The position of the start of the baseline of this text.
pub baseline_origin: Point2D<Au>,
/// The orientation of the text: upright or sideways left/right.
pub orientation: TextOrientation,
}
#[derive(Clone, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
@ -826,68 +818,6 @@ pub struct BorderDisplayItem {
pub details: BorderDetails,
}
/// Information about the border radii.
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub struct BorderRadii<T> {
pub top_left: Size2D<T>,
pub top_right: Size2D<T>,
pub bottom_right: Size2D<T>,
pub bottom_left: Size2D<T>,
}
impl<T> Default for BorderRadii<T> where T: Default, T: Clone {
fn default() -> Self {
let top_left = Size2D::new(Default::default(),
Default::default());
let top_right = Size2D::new(Default::default(),
Default::default());
let bottom_left = Size2D::new(Default::default(),
Default::default());
let bottom_right = Size2D::new(Default::default(),
Default::default());
BorderRadii { top_left: top_left,
top_right: top_right,
bottom_left: bottom_left,
bottom_right: bottom_right }
}
}
impl BorderRadii<Au> {
// Scale the border radii by the specified factor
pub fn scale_by(&self, s: f32) -> BorderRadii<Au> {
BorderRadii { top_left: BorderRadii::scale_corner_by(self.top_left, s),
top_right: BorderRadii::scale_corner_by(self.top_right, s),
bottom_left: BorderRadii::scale_corner_by(self.bottom_left, s),
bottom_right: BorderRadii::scale_corner_by(self.bottom_right, s) }
}
// Scale the border corner radius by the specified factor
pub fn scale_corner_by(corner: Size2D<Au>, s: f32) -> Size2D<Au> {
Size2D::new(corner.width.scale_by(s), corner.height.scale_by(s))
}
}
impl<T> BorderRadii<T> where T: PartialEq + Zero {
/// Returns true if all the radii are zero.
pub fn is_square(&self) -> bool {
let zero = Zero::zero();
self.top_left == zero && self.top_right == zero && self.bottom_right == zero &&
self.bottom_left == zero
}
}
impl<T> BorderRadii<T> where T: PartialEq + Zero + Clone {
/// Returns a set of border radii that all have the given value.
pub fn all_same(value: T) -> BorderRadii<T> {
BorderRadii {
top_left: Size2D::new(value.clone(), value.clone()),
top_right: Size2D::new(value.clone(), value.clone()),
bottom_right: Size2D::new(value.clone(), value.clone()),
bottom_left: Size2D::new(value.clone(), value.clone()),
}
}
}
/// Paints a line segment.
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
pub struct LineDisplayItem {
@ -1015,7 +945,7 @@ impl DisplayItem {
self.base().section
}
pub fn bounds(&self) -> Rect<Au> {
pub fn bounds(&self) -> LayoutRect {
self.base().bounds
}
@ -1050,11 +980,7 @@ impl fmt::Debug for DisplayItem {
solid_color.color.g,
solid_color.color.b,
solid_color.color.a),
DisplayItem::Text(ref text) => {
format!("Text ({:?})",
&text.text_run.text[
text.range.begin().0 as usize..(text.range.begin().0 + text.range.length().0) as usize])
}
DisplayItem::Text(_) => "Text".to_owned(),
DisplayItem::Image(_) => "Image".to_owned(),
DisplayItem::Border(_) => "Border".to_owned(),
DisplayItem::Gradient(_) => "Gradient".to_owned(),

View file

@ -9,7 +9,7 @@ use font_cache_thread::FontCacheThread;
use font_template::FontTemplateDescriptor;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use platform::font::FontHandle;
use platform::font_context::FontContextHandle;
pub use platform::font_context::FontContextHandle;
use platform::font_template::FontTemplateData;
use servo_arc::Arc as ServoArc;
use smallvec::SmallVec;

View file

@ -127,33 +127,35 @@ impl FontTemplate {
&self.identifier
}
/// Get the data for creating a font if it matches a given descriptor.
pub fn data_for_descriptor(&mut self,
fctx: &FontContextHandle,
requested_desc: &FontTemplateDescriptor)
-> Option<Arc<FontTemplateData>> {
/// Get the descriptor. Returns `None` when instantiating the data fails.
pub fn descriptor(&mut self, font_context: &FontContextHandle) -> Option<FontTemplateDescriptor> {
// The font template data can be unloaded when nothing is referencing
// it (via the Weak reference to the Arc above). However, if we have
// already loaded a font, store the style information about it separately,
// so that we can do font matching against it again in the future
// without having to reload the font (unless it is an actual match).
match self.descriptor {
Some(actual_desc) if *requested_desc == actual_desc => self.data().ok(),
Some(_) => None,
None => {
if self.instantiate(fctx).is_err() {
return None
}
if self.descriptor
.as_ref()
.expect("Instantiation succeeded but no descriptor?") == requested_desc {
self.data().ok()
} else {
None
}
self.descriptor.or_else(|| {
if self.instantiate(font_context).is_err() {
return None
};
Some(self.descriptor.expect("Instantiation succeeded but no descriptor?"))
})
}
/// Get the data for creating a font if it matches a given descriptor.
pub fn data_for_descriptor(&mut self,
fctx: &FontContextHandle,
requested_desc: &FontTemplateDescriptor)
-> Option<Arc<FontTemplateData>> {
self.descriptor(&fctx).and_then(|descriptor| {
if *requested_desc == descriptor {
self.data().ok()
} else {
None
}
}
})
}
/// Returns the font data along with the distance between this font's descriptor and the given
@ -162,24 +164,11 @@ impl FontTemplate {
font_context: &FontContextHandle,
requested_descriptor: &FontTemplateDescriptor)
-> Option<(Arc<FontTemplateData>, u32)> {
match self.descriptor {
Some(actual_descriptor) => {
self.data().ok().map(|data| {
(data, actual_descriptor.distance_from(requested_descriptor))
})
}
None => {
if self.instantiate(font_context).is_ok() {
let distance = self.descriptor
.as_ref()
.expect("Instantiation successful but no descriptor?")
.distance_from(requested_descriptor);
self.data().ok().map(|data| (data, distance))
} else {
None
}
}
}
self.descriptor(&font_context).and_then(|descriptor| {
self.data().ok().map(|data| {
(data, descriptor.distance_from(requested_descriptor))
})
})
}
fn instantiate(&mut self, font_context: &FontContextHandle) -> Result<(), ()> {

View file

@ -52,6 +52,17 @@ impl FontTableMethods for FontTable {
}
}
/// Data from the OS/2 table of an OpenType font.
/// See https://www.microsoft.com/typography/otspec/os2.htm
#[derive(Debug)]
struct OS2Table {
us_weight_class: u16,
us_width_class: u16,
y_strikeout_size: i16,
y_strikeout_position: i16,
sx_height: i16,
}
#[derive(Debug)]
pub struct FontHandle {
// The font binary. This must stay valid for the lifetime of the font,
@ -113,14 +124,17 @@ impl FontHandleMethods for FontHandle {
}
}
}
fn template(&self) -> Arc<FontTemplateData> {
self.font_data.clone()
}
fn family_name(&self) -> String {
unsafe {
c_str_to_string((*self.face).family_name as *const c_char)
}
}
fn face_name(&self) -> Option<String> {
unsafe {
let name = FT_Get_Postscript_Name(self.face) as *const c_char;
@ -132,49 +146,43 @@ impl FontHandleMethods for FontHandle {
}
}
}
fn is_italic(&self) -> bool {
unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC as c_long != 0 }
}
fn boldness(&self) -> FontWeight {
let default_weight = FontWeight::normal();
unsafe {
let os2 = FT_Get_Sfnt_Table(self.face, FT_Sfnt_Tag::FT_SFNT_OS2) as *mut TT_OS2;
let valid = !os2.is_null() && (*os2).version != 0xffff;
if valid {
let weight =(*os2).usWeightClass as i32;
if weight < 10 {
FontWeight::from_int(weight * 100).unwrap()
} else if weight >= 100 && weight < 1000 {
FontWeight::from_int(weight / 100 * 100).unwrap()
} else {
default_weight
}
if let Some(os2) = self.os2_table() {
let weight = os2.us_weight_class as i32;
if weight < 10 {
FontWeight::from_int(weight * 100).unwrap()
} else if weight >= 100 && weight < 1000 {
FontWeight::from_int(weight / 100 * 100).unwrap()
} else {
default_weight
FontWeight::normal()
}
} else {
FontWeight::normal()
}
}
fn stretchiness(&self) -> FontStretch {
let default_stretch = FontStretch::Normal;
unsafe {
let os2 = FT_Get_Sfnt_Table(self.face, FT_Sfnt_Tag::FT_SFNT_OS2) as *mut TT_OS2;
let valid = !os2.is_null() && (*os2).version != 0xffff;
if valid {
match (*os2).usWidthClass {
1 => FontStretch::UltraCondensed,
2 => FontStretch::ExtraCondensed,
3 => FontStretch::Condensed,
4 => FontStretch::SemiCondensed,
5 => FontStretch::Normal, // called medium in TrueType spec
6 => FontStretch::SemiExpanded,
7 => FontStretch::Expanded,
8 => FontStretch::ExtraExpanded,
9 => FontStretch::UltraExpanded,
_ => default_stretch,
}
} else {
default_stretch
if let Some(os2) = self.os2_table() {
match os2.us_width_class {
1 => FontStretch::UltraCondensed,
2 => FontStretch::ExtraCondensed,
3 => FontStretch::Condensed,
4 => FontStretch::SemiCondensed,
5 => FontStretch::Normal,
6 => FontStretch::SemiExpanded,
7 => FontStretch::Expanded,
8 => FontStretch::ExtraExpanded,
9 => FontStretch::UltraExpanded,
_ => FontStretch::Normal
}
} else {
FontStretch::Normal
}
}
@ -251,14 +259,11 @@ impl FontHandleMethods for FontHandle {
let mut strikeout_size = Au(0);
let mut strikeout_offset = Au(0);
let mut x_height = Au(0);
unsafe {
let os2 = FT_Get_Sfnt_Table(face, FT_Sfnt_Tag::FT_SFNT_OS2) as *mut TT_OS2;
let valid = !os2.is_null() && (*os2).version != 0xffff;
if valid {
strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as f64);
strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as f64);
x_height = self.font_units_to_au((*os2).sxHeight as f64);
}
if let Some(os2) = self.os2_table() {
strikeout_size = self.font_units_to_au(os2.y_strikeout_size as f64);
strikeout_offset = self.font_units_to_au(os2.y_strikeout_position as f64);
x_height = self.font_units_to_au(os2.sx_height as f64);
}
let average_advance = self.glyph_index('0')
@ -341,4 +346,23 @@ impl<'a> FontHandle {
Au::from_f64_px(value * x_scale)
}
fn os2_table(&self) -> Option<OS2Table> {
unsafe {
let os2 = FT_Get_Sfnt_Table(self.face_rec_mut(), FT_Sfnt_Tag::FT_SFNT_OS2) as *mut TT_OS2;
let valid = !os2.is_null() && (*os2).version != 0xffff;
if !valid {
return None
}
Some(OS2Table {
us_weight_class: (*os2).usWeightClass,
us_width_class: (*os2).usWidthClass,
y_strikeout_size: (*os2).yStrikeoutSize,
y_strikeout_position: (*os2).yStrikeoutPosition,
sx_height: (*os2).sxHeight,
})
}
}
}

View file

@ -0,0 +1,67 @@
/* 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 http://mozilla.org/MPL/2.0/. */
#[cfg(not(target_os = "macos"))] extern crate gfx;
#[cfg(not(target_os = "macos"))] extern crate servo_atoms;
#[cfg(not(target_os = "macos"))] extern crate style;
// Test doesn't yet run on Mac, see https://github.com/servo/servo/pull/19928 for explanation.
#[cfg(not(target_os = "macos"))]
#[test]
fn test_font_template_descriptor() {
use gfx::font_context::FontContextHandle;
use gfx::font_template::{FontTemplate, FontTemplateDescriptor};
use servo_atoms::Atom;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use style::computed_values::font_stretch::T as FontStretch;
use style::values::computed::font::FontWeight;
fn descriptor(filename: &str) -> FontTemplateDescriptor {
let mut path: PathBuf = [
env!("CARGO_MANIFEST_DIR"),
"tests",
"support",
"dejavu-fonts-ttf-2.37",
"ttf",
].iter().collect();
path.push(format!("{}.ttf", filename));
let file = File::open(path).unwrap();
let mut template = FontTemplate::new(
Atom::from(filename),
Some(file.bytes().map(|b| b.unwrap()).collect())
).unwrap();
let context = FontContextHandle::new();
template.descriptor(&context).unwrap()
}
assert_eq!(descriptor("DejaVuSans"), FontTemplateDescriptor {
weight: FontWeight::normal(),
stretch: FontStretch::Normal,
italic: false,
});
assert_eq!(descriptor("DejaVuSans-Bold"), FontTemplateDescriptor {
weight: FontWeight::bold(),
stretch: FontStretch::Normal,
italic: false,
});
assert_eq!(descriptor("DejaVuSans-Oblique"), FontTemplateDescriptor {
weight: FontWeight::normal(),
stretch: FontStretch::Normal,
italic: true,
});
assert_eq!(descriptor("DejaVuSansCondensed-BoldOblique"), FontTemplateDescriptor {
weight: FontWeight::bold(),
stretch: FontStretch::SemiCondensed,
italic: true,
});
}

View file

@ -0,0 +1,57 @@
abysta at yandex.ru
Adrian Schroeter
Aleksey Chalabyan
Andrey Valentinovich Panov
Ben Laenen
Besarion Gugushvili
Bhikkhu Pesala
Clayborne Arevalo
Dafydd Harries
Danilo Segan
Davide Viti
David Jez
David Lawrence Ramsey
Denis Jacquerye
Dwayne Bailey
Eugeniy Meshcheryakov
Frédéric Wang
Gee Fung Sit
Heikki Lindroos
James Cloos
James Crippen
John Karp
Keenan Pepper
Lars Næsbye Christensen
Lior Halphon
MaEr
Mashrab Kuvatov
Max Berger
Mederic Boquien
Michael Everson
MihailJP
Misu Moldovan
Nguyen Thai Ngoc Duy
Nicolas Mailhot
Norayr Chilingarian
Olleg Samoylov
Ognyan Kulev
Ondrej Koala Vacha
Peter Cernak
Remy Oudompheng
Roozbeh Pournader
Rouben Hakobian
Sahak Petrosyan
Sami Tarazi
Sander Vesik
Stepan Roh
Stephen Hartke
Steve Tinney
Tavmjong Bah
Thomas Henlich
Tim May
Valentin Stoykov
Vasek Stodulka
Wesley Transue
Yoshiki Ohshima
$Id$

View file

@ -0,0 +1,3 @@
See http://dejavu.sourceforge.net/wiki/index.php/Bugs
$Id$

View file

@ -0,0 +1,187 @@
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
Bitstream Vera Fonts Copyright
------------------------------
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:
The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".
This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.
The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.
Arev Fonts Copyright
------------------------------
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:
The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.
The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".
This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.
The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.
TeX Gyre DJV Math
-----------------
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Math extensions done by B. Jackowski, P. Strzelczyk and P. Pianowski
(on behalf of TeX users groups) are in public domain.
Letters imported from Euler Fraktur from AMSfonts are (c) American
Mathematical Society (see below).
Bitstream Vera Fonts Copyright
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera
is a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license (“Fonts”) and associated
documentation
files (the “Font Software”), to reproduce and distribute the Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute,
and/or sell copies of the Font Software, and to permit persons to whom
the Font Software is furnished to do so, subject to the following
conditions:
The above copyright and trademark notices and this permission notice
shall be
included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional
glyphs or characters may be added to the Fonts, only if the fonts are
renamed
to names not containing either the words “Bitstream” or the word “Vera”.
This License becomes null and void to the extent applicable to Fonts or
Font Software
that has been modified and is distributed under the “Bitstream Vera”
names.
The Font Software may be sold as part of a larger software package but
no copy
of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL,
SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN
ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
INABILITY TO USE
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of GNOME, the GNOME
Foundation,
and Bitstream Inc., shall not be used in advertising or otherwise to promote
the sale, use or other dealings in this Font Software without prior written
authorization from the GNOME Foundation or Bitstream Inc., respectively.
For further information, contact: fonts at gnome dot org.
AMSFonts (v. 2.2) copyright
The PostScript Type 1 implementation of the AMSFonts produced by and
previously distributed by Blue Sky Research and Y&Y, Inc. are now freely
available for general use. This has been accomplished through the
cooperation
of a consortium of scientific publishers with Blue Sky Research and Y&Y.
Members of this consortium include:
Elsevier Science IBM Corporation Society for Industrial and Applied
Mathematics (SIAM) Springer-Verlag American Mathematical Society (AMS)
In order to assure the authenticity of these fonts, copyright will be
held by
the American Mathematical Society. This is not meant to restrict in any way
the legitimate use of the fonts, such as (but not limited to) electronic
distribution of documents containing these fonts, inclusion of these fonts
into other public domain or commercial font collections or computer
applications, use of the outline data to create derivative fonts and/or
faces, etc. However, the AMS does require that the AMS copyright notice be
removed from any derivative versions of the fonts which have been altered in
any way. In addition, to ensure the fidelity of TeX documents using Computer
Modern fonts, Professor Donald Knuth, creator of the Computer Modern faces,
has requested that any alterations which yield different font metrics be
given a different name.
$Id$

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,67 @@
[![Build Status](https://travis-ci.org/dejavu-fonts/dejavu-fonts.svg)](https://travis-ci.org/dejavu-fonts/dejavu-fonts)
DejaVu fonts 2.37 (c)2004-2016 DejaVu fonts team
------------------------------------------------
The DejaVu fonts are a font family based on the Bitstream Vera Fonts
(http://gnome.org/fonts/). Its purpose is to provide a wider range of
characters (see status.txt for more information) while maintaining the
original look and feel.
DejaVu fonts are based on Bitstream Vera fonts version 1.10.
Available fonts (Sans = sans serif, Mono = monospaced):
DejaVu Sans Mono
DejaVu Sans Mono Bold
DejaVu Sans Mono Bold Oblique
DejaVu Sans Mono Oblique
DejaVu Sans
DejaVu Sans Bold
DejaVu Sans Bold Oblique
DejaVu Sans Oblique
DejaVu Sans ExtraLight (experimental)
DejaVu Serif
DejaVu Serif Bold
DejaVu Serif Bold Italic (experimental)
DejaVu Serif Italic (experimental)
DejaVu Sans Condensed (experimental)
DejaVu Sans Condensed Bold (experimental)
DejaVu Sans Condensed Bold Oblique (experimental)
DejaVu Sans Condensed Oblique (experimental)
DejaVu Serif Condensed (experimental)
DejaVu Serif Condensed Bold (experimental)
DejaVu Serif Condensed Bold Italic (experimental)
DejaVu Serif Condensed Italic (experimental)
DejaVu Math TeX Gyre
All fonts are also available as derivative called DejaVu LGC with support
only for Latin, Greek and Cyrillic scripts.
For license information see LICENSE. What's new is described in NEWS. Known
bugs are in BUGS. All authors are mentioned in AUTHORS.
Fonts are published in source form as SFD files (Spline Font Database from
FontForge - http://fontforge.sf.net/) and in compiled form as TTF files
(TrueType fonts).
For more information go to http://dejavu.sourceforge.net/.
Characters from Arev fonts, Copyright (c) 2006 by Tavmjong Bah:
---------------------------
U+01BA, U+01BF, U+01F7, U+021C-U+021D, U+0220, U+0222-U+0223,
U+02B9, U+02BA, U+02BD, U+02C2-U+02C5, U+02d4-U+02D5,
U+02D7, U+02EC-U+02EE, U+0346-U+034E, U+0360, U+0362,
U+03E2-03EF, U+0460-0463, U+0466-U+0486, U+0488-U+0489, U+04A8-U+04A9,
U+0500-U+050F, U+2055-205E, U+20B0, U+20B2-U+20B3, U+2102, U+210D, U+210F,
U+2111, U+2113, U+2115, U+2118-U+211A, U+211C-U+211D, U+2124, U+2135,
U+213C-U+2140, U+2295-U+2298, U+2308-U+230B, U+26A2-U+26B1, U+2701-U+2704,
U+2706-U+2709, U+270C-U+274B, U+2758-U+275A, U+2761-U+2775, U+2780-U+2794,
U+2798-U+27AF, U+27B1-U+27BE, U+FB05-U+FB06
DejaVu Math TeX Gyre
--------------------
TeX Gyre DJV Math by B. Jackowski, P. Strzelczyk and P. Pianowski
(on behalf of TeX users groups).
$Id$

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<fontconfig>
<!-- /etc/fonts/conf.d/20-unhint-small-dejavu-sans-mono.conf
Disable hinting manually at smaller sizes (< 8ppem)
This is a copy of the Bistream Vera fonts fonts rule, as DejaVu is
derived from Vera.
The Bistream Vera fonts have GASP entries suggesting that hinting be
disabled below 8 ppem, but FreeType ignores those, preferring to use
the data found in the instructed hints. The initial Vera release
didn't include the right instructions in the 'prep' table.
-->
<match target="font">
<test name="family">
<string>DejaVu Sans Mono</string>
</test>
<test compare="less" name="pixelsize">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
</fontconfig>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<fontconfig>
<!-- /etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf
Disable hinting manually at smaller sizes (< 8ppem)
This is a copy of the Bistream Vera fonts fonts rule, as DejaVu is
derived from Vera.
The Bistream Vera fonts have GASP entries suggesting that hinting be
disabled below 8 ppem, but FreeType ignores those, preferring to use
the data found in the instructed hints. The initial Vera release
didn't include the right instructions in the 'prep' table.
-->
<match target="font">
<test name="family">
<string>DejaVu Sans</string>
</test>
<test compare="less" name="pixelsize">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
</fontconfig>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<fontconfig>
<!-- /etc/fonts/conf.d/20-unhint-small-dejavu-serif.conf
Disable hinting manually at smaller sizes (< 8ppem)
This is a copy of the Bistream Vera fonts fonts rule, as DejaVu is
derived from Vera.
The Bistream Vera fonts have GASP entries suggesting that hinting be
disabled below 8 ppem, but FreeType ignores those, preferring to use
the data found in the instructed hints. The initial Vera release
didn't include the right instructions in the 'prep' table.
-->
<match target="font">
<test name="family">
<string>DejaVu Serif</string>
</test>
<test compare="less" name="pixelsize">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
</fontconfig>

View file

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<!-- /etc/fonts/conf.d/57-dejavu-sans-mono.conf
Define aliasing and other fontconfig settings for
DejaVu Sans Mono.
© 2006-2008 Nicolas Mailhot <nicolas.mailhot at laposte.net>
-->
<fontconfig>
<!-- Font substitution rules -->
<alias binding="same">
<family>Bepa Mono</family>
<accept>
<family>DejaVu Sans Mono</family>
</accept>
</alias>
<alias binding="same">
<family>Bitstream Prima Sans Mono</family>
<accept>
<family>DejaVu Sans Mono</family>
</accept>
</alias>
<alias binding="same">
<family>Bitstream Vera Sans Mono</family>
<accept>
<family>DejaVu Sans Mono</family>
</accept>
</alias>
<alias binding="same">
<family>DejaVu LGC Sans Mono</family>
<accept>
<family>DejaVu Sans Mono</family>
</accept>
</alias>
<alias binding="same">
<family>Olwen Sans Mono</family>
<accept>
<family>DejaVu Sans Mono</family>
</accept>
</alias>
<alias binding="same">
<family>SUSE Sans Mono</family>
<accept>
<family>DejaVu Sans Mono</family>
</accept>
</alias>
<!-- Generic name assignment -->
<alias>
<family>DejaVu Sans Mono</family>
<default>
<family>monospace</family>
</default>
</alias>
<!-- Generic name aliasing -->
<alias>
<family>monospace</family>
<prefer>
<family>DejaVu Sans Mono</family>
</prefer>
</alias>
</fontconfig>

View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<!-- /etc/fonts/conf.d/57-dejavu-sans.conf
Define aliasing and other fontconfig settings for
DejaVu Sans.
© 2006-2008 Nicolas Mailhot <nicolas.mailhot at laposte.net>
-->
<fontconfig>
<!-- Font substitution rules -->
<alias binding="same">
<family>Arev Sans</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>Bepa</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>Bitstream Prima Sans</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>Bitstream Vera Sans</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>DejaVu LGC Sans</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>Hunky Sans</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>Olwen Sans</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>SUSE Sans</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<alias binding="same">
<family>Verajja</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<!-- In case VerajjaPDA stops declaring itself as Verajja -->
<alias binding="same">
<family>VerajjaPDA</family>
<accept>
<family>DejaVu Sans</family>
</accept>
</alias>
<!-- Generic name assignment -->
<alias>
<family>DejaVu Sans</family>
<default>
<family>sans-serif</family>
</default>
</alias>
<!-- Generic name aliasing -->
<alias>
<family>sans-serif</family>
<prefer>
<family>DejaVu Sans</family>
</prefer>
</alias>
</fontconfig>

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<!-- /etc/fonts/conf.d/57-dejavu-serif.conf
Define aliasing and other fontconfig settings for
DejaVu Serif.
© 2006-2008 Nicolas Mailhot <nicolas.mailhot at laposte.net>
-->
<fontconfig>
<!-- Font substitution rules -->
<alias binding="same">
<family>Bitstream Prima Serif</family>
<accept>
<family>DejaVu Serif</family>
</accept>
</alias>
<alias binding="same">
<family>Bitstream Vera Serif</family>
<accept>
<family>DejaVu Serif</family>
</accept>
</alias>
<alias binding="same">
<family>DejaVu LGC Serif</family>
<accept>
<family>DejaVu Serif</family>
</accept>
</alias>
<alias binding="same">
<family>Hunky Serif</family>
<accept>
<family>DejaVu Serif</family>
</accept>
</alias>
<alias binding="same">
<family>Olwen Serif</family>
<accept>
<family>DejaVu Serif</family>
</accept>
</alias>
<alias binding="same">
<family>SUSE Serif</family>
<accept>
<family>DejaVu Serif</family>
</accept>
</alias>
<!-- In case Verajja Serif stops declaring itself as DejaVu Serif -->
<alias binding="same">
<family>Verajja Serif</family>
<accept>
<family>DejaVu Serif</family>
</accept>
</alias>
<!-- Generic name assignment -->
<alias>
<family>DejaVu Serif</family>
<default>
<family>serif</family>
</default>
</alias>
<!-- Generic name aliasing -->
<alias>
<family>serif</family>
<prefer>
<family>DejaVu Serif</family>
</prefer>
</alias>
</fontconfig>

View file

@ -0,0 +1,250 @@
This is the language coverage file for DejaVu fonts
($Id$)
Sans Serif Sans Mono
aa Afar 100% (62/62) 100% (62/62) 100% (62/62)
ab Abkhazia 100% (90/90) 93% (84/90) 84% (76/90)
af Afrikaans 100% (69/69) 100% (69/69) 100% (69/69)
ak Akan 100% (73/73) 100% (73/73) 100% (73/73)
am Amharic (0/264) (0/264) (0/264)
an Aragonese 100% (66/66) 100% (66/66) 100% (66/66)
ar Arabic 100% (36/36) (0/36) 100% (36/36)
as Assamese (0/64) (0/64) (0/64)
ast Asturian/Bable/Leonese/Asturleonese 100% (70/70) 100% (70/70) 100% (70/70)
av Avaric 100% (67/67) 100% (67/67) 100% (67/67)
ay Aymara 100% (60/60) 100% (60/60) 100% (60/60)
az-az Azerbaijani in Azerbaijan 100% (66/66) 100% (66/66) 100% (66/66)
az-ir Azerbaijani in Iran 100% (40/40) (0/40) 100% (40/40)
ba Bashkir 100% (82/82) 100% (82/82) 97% (80/82)
be Byelorussian 100% (68/68) 100% (68/68) 100% (68/68)
ber-dz Berber in Algeria 100% (70/70) 100% (70/70) 100% (70/70)
ber-ma Berber in Morocco 100% (32/32) (0/32) (0/32)
bg Bulgarian 100% (60/60) 100% (60/60) 100% (60/60)
bh Bihari (Devanagari script) (0/68) (0/68) (0/68)
bho Bhojpuri (Devanagari script) (0/68) (0/68) (0/68)
bi Bislama 100% (58/58) 100% (58/58) 100% (58/58)
bin Edo or Bini 100% (78/78) 100% (78/78) 100% (78/78)
bm Bambara 100% (60/60) 100% (60/60) 100% (60/60)
bn Bengali (0/63) (0/63) (0/63)
bo Tibetan (0/95) (0/95) (0/95)
br Breton 100% (64/64) 100% (64/64) 100% (64/64)
brx Bodo (Devanagari script) (0/82) (0/82) (0/82)
bs Bosnian 100% (62/62) 100% (62/62) 100% (62/62)
bua Buriat (Buryat) 100% (70/70) 100% (70/70) 100% (70/70)
byn Blin/Bilin (0/255) (0/255) (0/255)
ca Catalan 100% (74/74) 100% (74/74) 100% (74/74)
ce Chechen 100% (67/67) 100% (67/67) 100% (67/67)
ch Chamorro 100% (58/58) 100% (58/58) 100% (58/58)
chm Mari (Lower Cheremis / Upper Cheremis) 100% (76/76) 100% (76/76) 100% (76/76)
chr Cherokee (0/85) (0/85) (0/85)
co Corsican 100% (84/84) 100% (84/84) 100% (84/84)
crh Crimean Tatar/Crimean Turkish 100% (68/68) 100% (68/68) 100% (68/68)
cs Czech 100% (82/82) 100% (82/82) 100% (82/82)
csb Kashubian 100% (74/74) 100% (74/74) 100% (74/74)
cu Old Church Slavonic 100% (103/103) 90% (93/103) 78% (81/103)
cv Chuvash 100% (74/74) 100% (74/74) 100% (74/74)
cy Welsh 100% (78/78) 100% (78/78) 100% (78/78)
da Danish 100% (70/70) 100% (70/70) 100% (70/70)
de German 100% (59/59) 100% (59/59) 100% (59/59)
doi Dogri (0/85) (0/85) (0/85)
dv Divehi/Dhivehi/Maldivian (0/49) (0/49) (0/49)
dz Dzongkha (0/95) (0/95) (0/95)
ee Ewe 100% (99/99) 100% (99/99) 100% (99/99)
el Greek 100% (69/69) 100% (69/69) 100% (69/69)
en English 100% (72/72) 100% (72/72) 100% (72/72)
eo Esperanto 100% (64/64) 100% (64/64) 100% (64/64)
es Spanish 100% (66/66) 100% (66/66) 100% (66/66)
et Estonian 100% (64/64) 100% (64/64) 100% (64/64)
eu Basque 100% (56/56) 100% (56/56) 100% (56/56)
fa Persian 100% (40/40) (0/40) 100% (40/40)
fat Fanti 100% (73/73) 100% (73/73) 100% (73/73)
ff Fulah (Fula) 100% (62/62) 100% (62/62) 100% (62/62)
fi Finnish 100% (62/62) 100% (62/62) 100% (62/62)
fil Filipino 100% (84/84) 100% (84/84) 100% (84/84)
fj Fijian 100% (52/52) 100% (52/52) 100% (52/52)
fo Faroese 100% (68/68) 100% (68/68) 100% (68/68)
fr French 100% (84/84) 100% (84/84) 100% (84/84)
fur Friulian 100% (66/66) 100% (66/66) 100% (66/66)
fy Frisian 100% (75/75) 100% (75/75) 100% (75/75)
ga Irish 100% (80/80) 100% (80/80) 100% (80/80)
gd Scots Gaelic 100% (70/70) 100% (70/70) 100% (70/70)
gez Ethiopic (Geez) (0/218) (0/218) (0/218)
gl Galician 100% (66/66) 100% (66/66) 100% (66/66)
gn Guarani 100% (70/70) 100% (70/70) 100% (70/70)
gu Gujarati (0/68) (0/68) (0/68)
gv Manx Gaelic 100% (54/54) 100% (54/54) 100% (54/54)
ha Hausa 100% (60/60) 100% (60/60) 100% (60/60)
haw Hawaiian 100% (63/63) 100% (63/63) 100% (63/63)
he Hebrew 100% (27/27) (0/27) (0/27)
hi Hindi (Devanagari script) (0/68) (0/68) (0/68)
hne Chhattisgarhi (0/68) (0/68) (0/68)
ho Hiri Motu 100% (52/52) 100% (52/52) 100% (52/52)
hr Croatian 100% (62/62) 100% (62/62) 100% (62/62)
hsb Upper Sorbian 100% (72/72) 100% (72/72) 100% (72/72)
ht Haitian/Haitian Creole 100% (56/56) 100% (56/56) 100% (56/56)
hu Hungarian 100% (70/70) 100% (70/70) 100% (70/70)
hy Armenian 100% (77/77) 100% (77/77) 100% (77/77)
hz Herero 100% (57/57) 100% (57/57) 100% (57/57)
ia Interlingua 100% (52/52) 100% (52/52) 100% (52/52)
id Indonesian 100% (54/54) 100% (54/54) 100% (54/54)
ie Interlingue 100% (52/52) 100% (52/52) 100% (52/52)
ig Igbo 100% (58/58) 100% (58/58) 100% (58/58)
ii Sichuan Yi/Nuosu (0/1165) (0/1165) (0/1165)
ik Inupiaq (Inupiak, Eskimo) 100% (68/68) 100% (68/68) 100% (68/68)
io Ido 100% (52/52) 100% (52/52) 100% (52/52)
is Icelandic 100% (70/70) 100% (70/70) 100% (70/70)
it Italian 100% (72/72) 100% (72/72) 100% (72/72)
iu Inuktitut 100% (161/161) (0/161) (0/161)
ja Japanese (0/2314) (0/2314) (0/2314)
jv Javanese 100% (56/56) 100% (56/56) 100% (56/56)
ka Georgian 100% (33/33) 100% (33/33) 100% (33/33)
kaa Kara-Kalpak (Karakalpak) 100% (78/78) 100% (78/78) 100% (78/78)
kab Kabyle 100% (70/70) 100% (70/70) 100% (70/70)
ki Kikuyu 100% (56/56) 100% (56/56) 100% (56/56)
kj Kuanyama/Kwanyama 100% (52/52) 100% (52/52) 100% (52/52)
kk Kazakh 100% (77/77) 100% (77/77) 100% (77/77)
kl Greenlandic 100% (81/81) 100% (81/81) 100% (81/81)
km Central Khmer (0/63) (0/63) (0/63)
kn Kannada (0/70) (0/70) (0/70)
ko Korean (0/2442) (0/2442) (0/2442)
kok Kokani (Devanagari script) (0/68) (0/68) (0/68)
kr Kanuri 100% (56/56) 100% (56/56) 100% (56/56)
ks Kashmiri 78% (26/33) (0/33) 69% (23/33)
ku-am Kurdish in Armenia 100% (64/64) 100% (64/64) 100% (64/64)
ku-iq Kurdish in Iraq 100% (32/32) (0/32) 87% (28/32)
ku-ir Kurdish in Iran 100% (32/32) (0/32) 87% (28/32)
ku-tr Kurdish in Turkey 100% (62/62) 100% (62/62) 100% (62/62)
kum Kumyk 100% (66/66) 100% (66/66) 100% (66/66)
kv Komi (Komi-Permyak/Komi-Siryan) 100% (70/70) 100% (70/70) 100% (70/70)
kw Cornish 100% (64/64) 100% (64/64) 100% (64/64)
kwm Kwambi 100% (52/52) 100% (52/52) 100% (52/52)
ky Kirgiz 100% (70/70) 100% (70/70) 100% (70/70)
la Latin 100% (68/68) 100% (68/68) 100% (68/68)
lah Lahnda 92% (25/27) (0/27) 85% (23/27)
lb Luxembourgish (Letzeburgesch) 100% (75/75) 100% (75/75) 100% (75/75)
lez Lezghian (Lezgian) 100% (67/67) 100% (67/67) 100% (67/67)
lg Ganda 100% (54/54) 100% (54/54) 100% (54/54)
li Limburgan/Limburger/Limburgish 100% (62/62) 100% (62/62) 100% (62/62)
ln Lingala 100% (81/81) 100% (81/81) 100% (81/81)
lo Lao 100% (55/55) (0/55) 83% (46/55)
lt Lithuanian 100% (70/70) 100% (70/70) 100% (70/70)
lv Latvian 100% (78/78) 100% (78/78) 100% (78/78)
mai Maithili (Devanagari script) (0/68) (0/68) (0/68)
mg Malagasy 100% (56/56) 100% (56/56) 100% (56/56)
mh Marshallese 100% (62/62) 100% (62/62) 100% (62/62)
mi Maori 100% (64/64) 100% (64/64) 100% (64/64)
mk Macedonian 100% (42/42) 100% (42/42) 100% (42/42)
ml Malayalam (0/68) (0/68) (0/68)
mn-cn Mongolian in China (0/130) (0/130) (0/130)
mn-mn Mongolian in Mongolia 100% (70/70) 100% (70/70) 100% (70/70)
mni Maniputi (0/78) (0/78) (0/78)
mo Moldavian 100% (128/128) 100% (128/128) 100% (128/128)
mr Marathi (Devanagari script) (0/68) (0/68) (0/68)
ms Malay 100% (52/52) 100% (52/52) 100% (52/52)
mt Maltese 100% (72/72) 100% (72/72) 100% (72/72)
my Burmese (Myanmar) (0/48) (0/48) (0/48)
na Nauru 100% (60/60) 100% (60/60) 100% (60/60)
nb Norwegian Bokmal 100% (70/70) 100% (70/70) 100% (70/70)
nds Low Saxon 100% (59/59) 100% (59/59) 100% (59/59)
ne Nepali (0/72) (0/72) (0/72)
ng Ndonga 100% (52/52) 100% (52/52) 100% (52/52)
nl Dutch 100% (82/82) 100% (82/82) 100% (82/82)
nn Norwegian Nynorsk 100% (76/76) 100% (76/76) 100% (76/76)
no Norwegian (Bokmal) 100% (70/70) 100% (70/70) 100% (70/70)
nqo N'Ko 91% (54/59) (0/59) (0/59)
nr Ndebele, South 100% (52/52) 100% (52/52) 100% (52/52)
nso Northern Sotho 100% (58/58) 100% (58/58) 100% (58/58)
nv Navajo/Navaho 100% (72/72) 100% (72/72) 100% (72/72)
ny Chichewa 100% (54/54) 100% (54/54) 100% (54/54)
oc Occitan 100% (70/70) 100% (70/70) 100% (70/70)
om Oromo or Galla 100% (52/52) 100% (52/52) 100% (52/52)
or Oriya (0/68) (0/68) (0/68)
os Ossetic 100% (66/66) 100% (66/66) 100% (66/66)
ota Ottoman Turkish 100% (37/37) (0/37) 97% (36/37)
pa Panjabi/Punjabi (0/63) (0/63) (0/63)
pa-pk Panjabi/Punjabi in Pakistan 92% (25/27) (0/27) 85% (23/27)
pap-an Papiamento in Netherlands Antilles 100% (72/72) 100% (72/72) 100% (72/72)
pap-aw Papiamento in Aruba 100% (54/54) 100% (54/54) 100% (54/54)
pes Western Farsi 100% (40/40) (0/40) 100% (40/40)
pl Polish 100% (70/70) 100% (70/70) 100% (70/70)
prs Dari/Eastern Farsi 100% (40/40) (0/40) 100% (40/40)
ps-af Pashto in Afghanistan 97% (48/49) (0/49) 77% (38/49)
ps-pk Pashto in Pakistan 95% (47/49) (0/49) 75% (37/49)
pt Portuguese 100% (82/82) 100% (82/82) 100% (82/82)
qu Quechua 100% (55/55) 100% (55/55) 100% (55/55)
quz Cusco Quechua 100% (55/55) 100% (55/55) 100% (55/55)
rm Rhaeto-Romance (Romansch) 100% (66/66) 100% (66/66) 100% (66/66)
rn Rundi 100% (52/52) 100% (52/52) 100% (52/52)
ro Romanian 100% (62/62) 100% (62/62) 100% (62/62)
ru Russian 100% (66/66) 100% (66/66) 100% (66/66)
rw Kinyarwanda 100% (52/52) 100% (52/52) 100% (52/52)
sa Sanskrit (Devanagari script) (0/68) (0/68) (0/68)
sah Yakut 100% (76/76) 100% (76/76) 100% (76/76)
sat Santali (Devanagari script) (0/70) (0/70) (0/70)
sc Sardinian 100% (62/62) 100% (62/62) 100% (62/62)
sco Scots 100% (56/56) 100% (56/56) 100% (56/56)
sd Sindhi 100% (54/54) (0/54) 79% (43/54)
se North Sami 100% (66/66) 100% (66/66) 100% (66/66)
sel Selkup (Ostyak-Samoyed) 100% (66/66) 100% (66/66) 100% (66/66)
sg Sango 100% (72/72) 100% (72/72) 100% (72/72)
sh Serbo-Croatian 100% (156/156) 100% (156/156) 98% (154/156)
shs Secwepemctsin 100% (48/48) 100% (48/48) 100% (48/48)
si Sinhala/Sinhalese (0/73) (0/73) (0/73)
sid Sidamo (0/281) (0/281) (0/281)
sk Slovak 100% (86/86) 100% (86/86) 100% (86/86)
sl Slovenian 100% (62/62) 100% (62/62) 100% (62/62)
sm Samoan 100% (53/53) 100% (53/53) 100% (53/53)
sma South Sami 100% (60/60) 100% (60/60) 100% (60/60)
smj Lule Sami 100% (60/60) 100% (60/60) 100% (60/60)
smn Inari Sami 100% (68/68) 100% (68/68) 100% (68/68)
sms Skolt Sami 100% (80/80) 100% (80/80) 97% (78/80)
sn Shona 100% (52/52) 100% (52/52) 100% (52/52)
so Somali 100% (52/52) 100% (52/52) 100% (52/52)
sq Albanian 100% (56/56) 100% (56/56) 100% (56/56)
sr Serbian 100% (60/60) 100% (60/60) 100% (60/60)
ss Swati 100% (52/52) 100% (52/52) 100% (52/52)
st Sotho, Southern 100% (52/52) 100% (52/52) 100% (52/52)
su Sundanese 100% (54/54) 100% (54/54) 100% (54/54)
sv Swedish 100% (68/68) 100% (68/68) 100% (68/68)
sw Swahili 100% (52/52) 100% (52/52) 100% (52/52)
syr Syriac (0/45) (0/45) (0/45)
ta Tamil (0/48) (0/48) (0/48)
te Telugu (0/70) (0/70) (0/70)
tg Tajik 100% (78/78) 100% (78/78) 97% (76/78)
th Thai 1% (1/74) 1% (1/74) 1% (1/74)
ti-er Eritrean Tigrinya (0/255) (0/255) (0/255)
ti-et Ethiopian Tigrinya (0/281) (0/281) (0/281)
tig Tigre (0/221) (0/221) (0/221)
tk Turkmen 100% (68/68) 100% (68/68) 100% (68/68)
tl Tagalog 100% (84/84) 100% (84/84) 100% (84/84)
tn Tswana 100% (58/58) 100% (58/58) 100% (58/58)
to Tonga 100% (53/53) 100% (53/53) 100% (53/53)
tr Turkish 100% (70/70) 100% (70/70) 100% (70/70)
ts Tsonga 100% (52/52) 100% (52/52) 100% (52/52)
tt Tatar 100% (76/76) 100% (76/76) 100% (76/76)
tw Twi 100% (73/73) 100% (73/73) 100% (73/73)
ty Tahitian 100% (65/65) 100% (65/65) 100% (65/65)
tyv Tuvinian 100% (70/70) 100% (70/70) 100% (70/70)
ug Uyghur 100% (33/33) (0/33) 78% (26/33)
uk Ukrainian 100% (72/72) 100% (72/72) 100% (72/72)
ur Urdu 92% (25/27) (0/27) 85% (23/27)
uz Uzbek 100% (52/52) 100% (52/52) 100% (52/52)
ve Venda 100% (62/62) 100% (62/62) 100% (62/62)
vi Vietnamese 100% (194/194) 100% (194/194) 76% (148/194)
vo Volapuk 100% (54/54) 100% (54/54) 100% (54/54)
vot Votic 100% (62/62) 100% (62/62) 100% (62/62)
wa Walloon 100% (70/70) 100% (70/70) 100% (70/70)
wal Wolaitta/Wolaytta (0/281) (0/281) (0/281)
wen Sorbian languages (lower and upper) 100% (76/76) 100% (76/76) 100% (76/76)
wo Wolof 100% (66/66) 100% (66/66) 100% (66/66)
xh Xhosa 100% (52/52) 100% (52/52) 100% (52/52)
yap Yapese 100% (58/58) 100% (58/58) 100% (58/58)
yi Yiddish 100% (27/27) (0/27) (0/27)
yo Yoruba 100% (119/119) 100% (119/119) 100% (119/119)
za Zhuang/Chuang 100% (52/52) 100% (52/52) 100% (52/52)
zh-cn Chinese (simplified) 0% (2/6765) 0% (2/6765) 0% (2/6765)
zh-hk Chinese Hong Kong Supplementary Character Set (0/1083) (0/1083) (0/1083)
zh-mo Chinese in Macau (0/1083) (0/1083) (0/1083)
zh-sg Chinese in Singapore 0% (2/6765) 0% (2/6765) 0% (2/6765)
zh-tw Chinese (traditional) (0/13063) (0/13063) (0/13063)
zu Zulu 100% (52/52) 100% (52/52) 100% (52/52)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,279 @@
This is the Unicode coverage file for DejaVu fonts
($Id$)
Control and similar characters are discounted from totals.
Sans Serif Sans Mono
U+0000 Basic Latin 100% (95/95) 100% (95/95) 100% (95/95)
U+0080 Latin-1 Supplement 100% (96/96) 100% (96/96) 100% (96/96)
U+0100 Latin Extended-A 100% (128/128) 100% (128/128) 100% (128/128)
U+0180 Latin Extended-B 100% (208/208) 100% (208/208) 86% (180/208)
U+0250 IPA Extensions 100% (96/96) 100% (96/96) 100% (96/96)
U+02b0 Spacing Modifier Letters 78% (63/80) 73% (59/80) 62% (50/80)
U+0300 Combining Diacritical Marks 83% (93/112) 61% (69/112) 59% (67/112)
U+0370 Greek and Coptic 100% (135/135) 89% (121/135) 85% (116/135)
U+0400 Cyrillic 100% (256/256) 79% (204/256) 70% (180/256)
U+0500 Cyrillic Supplement 79% (38/48) 20% (10/48) 12% (6/48)
U+0530 Armenian 96% (86/89) 96% (86/89) 96% (86/89)
U+0590 Hebrew 62% (54/87) (0/87) (0/87)
U+0600 Arabic 64% (165/255) (0/255) 38% (99/255)
U+0700 Syriac (0/77) (0/77) (0/77)
U+0750 Arabic Supplement (0/48) (0/48) (0/48)
U+0780 Thaana (0/50) (0/50) (0/50)
U+07c0 NKo 91% (54/59) (0/59) (0/59)
U+0800 Samaritan (0/61) (0/61) (0/61)
U+0840 Mandaic (0/29) (0/29) (0/29)
U+08a0 Arabic Extended-A (0/73) (0/73) (0/73)
U+0900 Devanagari (0/128) (0/128) (0/128)
U+0980 Bengali (0/93) (0/93) (0/93)
U+0a00 Gurmukhi (0/79) (0/79) (0/79)
U+0a80 Gujarati (0/85) (0/85) (0/85)
U+0b00 Oriya (0/90) (0/90) (0/90)
U+0b80 Tamil (0/72) (0/72) (0/72)
U+0c00 Telugu (0/96) (0/96) (0/96)
U+0c80 Kannada (0/88) (0/88) (0/88)
U+0d00 Malayalam (0/114) (0/114) (0/114)
U+0d80 Sinhala (0/90) (0/90) (0/90)
U+0e00 Thai 1% (1/87) 1% (1/87) 1% (1/87)
U+0e80 Lao 97% (65/67) (0/67) 68% (46/67)
U+0f00 Tibetan (0/211) (0/211) (0/211)
U+1000 Myanmar (0/160) (0/160) (0/160)
U+10a0 Georgian 94% (83/88) 94% (83/88) 51% (45/88)
U+1100 Hangul Jamo (0/256) (0/256) (0/256)
U+1200 Ethiopic (0/358) (0/358) (0/358)
U+1380 Ethiopic Supplement (0/26) (0/26) (0/26)
U+13a0 Cherokee (0/92) (0/92) (0/92)
U+1400 Unified Canadian Aboriginal Syllabics 63% (404/640) (0/640) (0/640)
U+1680 Ogham 100% (29/29) (0/29) (0/29)
U+16a0 Runic (0/89) (0/89) (0/89)
U+1700 Tagalog (0/20) (0/20) (0/20)
U+1720 Hanunoo (0/23) (0/23) (0/23)
U+1740 Buhid (0/20) (0/20) (0/20)
U+1760 Tagbanwa (0/18) (0/18) (0/18)
U+1780 Khmer (0/114) (0/114) (0/114)
U+1800 Mongolian (0/156) (0/156) (0/156)
U+18b0 Unified Canadian Aboriginal Syllabics Extended (0/70) (0/70) (0/70)
U+1900 Limbu (0/68) (0/68) (0/68)
U+1950 Tai Le (0/35) (0/35) (0/35)
U+1980 New Tai Lue (0/83) (0/83) (0/83)
U+19e0 Khmer Symbols (0/32) (0/32) (0/32)
U+1a00 Buginese (0/30) (0/30) (0/30)
U+1a20 Tai Tham (0/127) (0/127) (0/127)
U+1ab0 Combining Diacritical Marks Extended (0/15) (0/15) (0/15)
U+1b00 Balinese (0/121) (0/121) (0/121)
U+1b80 Sundanese (0/64) (0/64) (0/64)
U+1bc0 Batak (0/56) (0/56) (0/56)
U+1c00 Lepcha (0/74) (0/74) (0/74)
U+1c50 Ol Chiki (0/48) (0/48) (0/48)
U+1c80 Cyrillic Extended-C (0/9) (0/9) (0/9)
U+1cc0 Sundanese Supplement (0/8) (0/8) (0/8)
U+1cd0 Vedic Extensions (0/41) (0/41) (0/41)
U+1d00 Phonetic Extensions 82% (106/128) 89% (115/128) 48% (62/128)
U+1d80 Phonetic Extensions Supplement 59% (38/64) 59% (38/64) 57% (37/64)
U+1dc0 Combining Diacritical Marks Supplement 10% (6/59) 10% (6/59) (0/59)
U+1e00 Latin Extended Additional 98% (252/256) 98% (252/256) 71% (182/256)
U+1f00 Greek Extended 100% (233/233) 100% (233/233) 100% (233/233)
U+2000 General Punctuation 96% (107/111) 78% (87/111) 48% (54/111)
U+2070 Superscripts and Subscripts 100% (42/42) 100% (42/42) 100% (42/42)
U+20a0 Currency Symbols 83% (26/31) 32% (10/31) 83% (26/31)
U+20d0 Combining Diacritical Marks for Symbols 21% (7/33) (0/33) (0/33)
U+2100 Letterlike Symbols 93% (75/80) 42% (34/80) 22% (18/80)
U+2150 Number Forms 91% (55/60) 91% (55/60) 26% (16/60)
U+2190 Arrows 100% (112/112) 100% (112/112) 100% (112/112)
U+2200 Mathematical Operators 100% (256/256) 39% (101/256) 69% (178/256)
U+2300 Miscellaneous Technical 25% (65/255) 14% (36/255) 53% (136/255)
U+2400 Control Pictures 5% (2/39) 2% (1/39) 2% (1/39)
U+2440 Optical Character Recognition (0/11) (0/11) (0/11)
U+2460 Enclosed Alphanumerics 6% (10/160) (0/160) (0/160)
U+2500 Box Drawing 100% (128/128) 100% (128/128) 100% (128/128)
U+2580 Block Elements 100% (32/32) 100% (32/32) 100% (32/32)
U+25a0 Geometric Shapes 100% (96/96) 100% (96/96) 100% (96/96)
U+2600 Miscellaneous Symbols 73% (189/256) 11% (30/256) 58% (149/256)
U+2700 Dingbats 90% (174/192) 0% (1/192) 75% (144/192)
U+27c0 Miscellaneous Mathematical Symbols-A 18% (9/48) 10% (5/48) 22% (11/48)
U+27f0 Supplemental Arrows-A 100% (16/16) 100% (16/16) 18% (3/16)
U+2800 Braille Patterns 100% (256/256) 100% (256/256) (0/256)
U+2900 Supplemental Arrows-B 4% (6/128) 100% (128/128) (0/128)
U+2980 Miscellaneous Mathematical Symbols-B 10% (13/128) 0% (1/128) 5% (7/128)
U+2a00 Supplemental Mathematical Operators 28% (74/256) 2% (6/256) 1% (4/256)
U+2b00 Miscellaneous Symbols and Arrows 16% (35/206) 13% (27/206) 8% (18/206)
U+2c00 Glagolitic (0/94) (0/94) (0/94)
U+2c60 Latin Extended-C 96% (31/32) 84% (27/32) 43% (14/32)
U+2c80 Coptic (0/123) (0/123) (0/123)
U+2d00 Georgian Supplement 95% (38/40) 95% (38/40) (0/40)
U+2d30 Tifinagh 93% (55/59) (0/59) (0/59)
U+2d80 Ethiopic Extended (0/79) (0/79) (0/79)
U+2de0 Cyrillic Extended-A (0/32) (0/32) (0/32)
U+2e00 Supplemental Punctuation 10% (7/69) 10% (7/69) 10% (7/69)
U+2e80 CJK Radicals Supplement (0/115) (0/115) (0/115)
U+2f00 Kangxi Radicals (0/214) (0/214) (0/214)
U+2ff0 Ideographic Description Characters (0/12) (0/12) (0/12)
U+3000 CJK Symbols and Punctuation (0/64) (0/64) (0/64)
U+3040 Hiragana (0/93) (0/93) (0/93)
U+30a0 Katakana (0/96) (0/96) (0/96)
U+3100 Bopomofo (0/41) (0/41) (0/41)
U+3130 Hangul Compatibility Jamo (0/94) (0/94) (0/94)
U+3190 Kanbun (0/16) (0/16) (0/16)
U+31a0 Bopomofo Extended (0/27) (0/27) (0/27)
U+31c0 CJK Strokes (0/36) (0/36) (0/36)
U+31f0 Katakana Phonetic Extensions (0/16) (0/16) (0/16)
U+3200 Enclosed CJK Letters and Months (0/254) (0/254) (0/254)
U+3300 CJK Compatibility (0/256) (0/256) (0/256)
U+3400 CJK Unified Ideographs Extension A (0/0) (0/0) (0/0)
U+4dc0 Yijing Hexagram Symbols 100% (64/64) (0/64) (0/64)
U+4e00 CJK Unified Ideographs (0/0) (0/0) (0/0)
U+a000 Yi Syllables (0/1165) (0/1165) (0/1165)
U+a490 Yi Radicals (0/55) (0/55) (0/55)
U+a4d0 Lisu 100% (48/48) (0/48) (0/48)
U+a500 Vai (0/300) (0/300) (0/300)
U+a640 Cyrillic Extended-B 34% (33/96) 12% (12/96) (0/96)
U+a6a0 Bamum (0/88) (0/88) (0/88)
U+a700 Modifier Tone Letters 62% (20/32) 62% (20/32) 62% (20/32)
U+a720 Latin Extended-D 48% (77/160) 37% (60/160) 10% (17/160)
U+a800 Syloti Nagri (0/44) (0/44) (0/44)
U+a830 Common Indic Number Forms (0/10) (0/10) (0/10)
U+a840 Phags-pa (0/56) (0/56) (0/56)
U+a880 Saurashtra (0/82) (0/82) (0/82)
U+a8e0 Devanagari Extended (0/30) (0/30) (0/30)
U+a900 Kayah Li (0/48) (0/48) (0/48)
U+a930 Rejang (0/37) (0/37) (0/37)
U+a960 Hangul Jamo Extended-A (0/29) (0/29) (0/29)
U+a980 Javanese (0/91) (0/91) (0/91)
U+a9e0 Myanmar Extended-B (0/31) (0/31) (0/31)
U+aa00 Cham (0/83) (0/83) (0/83)
U+aa60 Myanmar Extended-A (0/32) (0/32) (0/32)
U+aa80 Tai Viet (0/72) (0/72) (0/72)
U+aae0 Meetei Mayek Extensions (0/23) (0/23) (0/23)
U+ab00 Ethiopic Extended-A (0/32) (0/32) (0/32)
U+ab30 Latin Extended-E (0/54) (0/54) (0/54)
U+ab70 Cherokee Supplement (0/80) (0/80) (0/80)
U+abc0 Meetei Mayek (0/56) (0/56) (0/56)
U+ac00 Hangul Syllables (0/0) (0/0) (0/0)
U+d7b0 Hangul Jamo Extended-B (0/72) (0/72) (0/72)
U+d800 High Surrogates (0/0) (0/0) (0/0)
U+db80 High Private Use Surrogates (0/0) (0/0) (0/0)
U+dc00 Low Surrogates (0/0) (0/0) (0/0)
U+e000 Private Use Area (0/0) (0/0) (0/0)
U+f900 CJK Compatibility Ideographs (0/472) (0/472) (0/472)
U+fb00 Alphabetic Presentation Forms 100% (58/58) 12% (7/58) 3% (2/58)
U+fb50 Arabic Presentation Forms-A 17% (108/611) (0/611) 11% (72/611)
U+fe00 Variation Selectors 100% (16/16) 100% (16/16) (0/16)
U+fe10 Vertical Forms (0/10) (0/10) (0/10)
U+fe20 Combining Half Marks 25% (4/16) (0/16) (0/16)
U+fe30 CJK Compatibility Forms (0/32) (0/32) (0/32)
U+fe50 Small Form Variants (0/26) (0/26) (0/26)
U+fe70 Arabic Presentation Forms-B 100% (141/141) (0/141) 100% (141/141)
U+ff00 Halfwidth and Fullwidth Forms (0/225) (0/225) (0/225)
U+fff0 Specials 100% (5/5) 100% (5/5) 100% (5/5)
U+10000 Linear B Syllabary (0/88) (0/88) (0/88)
U+10080 Linear B Ideograms (0/123) (0/123) (0/123)
U+10100 Aegean Numbers (0/57) (0/57) (0/57)
U+10140 Ancient Greek Numbers (0/79) (0/79) (0/79)
U+10190 Ancient Symbols (0/13) (0/13) (0/13)
U+101d0 Phaistos Disc (0/46) (0/46) (0/46)
U+10280 Lycian (0/29) (0/29) (0/29)
U+102a0 Carian (0/49) (0/49) (0/49)
U+102e0 Coptic Epact Numbers (0/28) (0/28) (0/28)
U+10300 Old Italic 97% (35/36) (0/36) (0/36)
U+10330 Gothic (0/27) (0/27) (0/27)
U+10350 Old Permic (0/43) (0/43) (0/43)
U+10380 Ugaritic (0/31) (0/31) (0/31)
U+103a0 Old Persian (0/50) (0/50) (0/50)
U+10400 Deseret (0/80) (0/80) (0/80)
U+10450 Shavian (0/48) (0/48) (0/48)
U+10480 Osmanya (0/40) (0/40) (0/40)
U+104b0 Osage (0/72) (0/72) (0/72)
U+10500 Elbasan (0/40) (0/40) (0/40)
U+10530 Caucasian Albanian (0/53) (0/53) (0/53)
U+10600 Linear A (0/341) (0/341) (0/341)
U+10800 Cypriot Syllabary (0/55) (0/55) (0/55)
U+10840 Imperial Aramaic (0/31) (0/31) (0/31)
U+10860 Palmyrene (0/32) (0/32) (0/32)
U+10880 Nabataean (0/40) (0/40) (0/40)
U+108e0 Hatran (0/26) (0/26) (0/26)
U+10900 Phoenician (0/29) (0/29) (0/29)
U+10920 Lydian (0/27) (0/27) (0/27)
U+10980 Meroitic Hieroglyphs (0/32) (0/32) (0/32)
U+109a0 Meroitic Cursive (0/90) (0/90) (0/90)
U+10a00 Kharoshthi (0/65) (0/65) (0/65)
U+10a60 Old South Arabian (0/32) (0/32) (0/32)
U+10a80 Old North Arabian (0/32) (0/32) (0/32)
U+10ac0 Manichaean (0/51) (0/51) (0/51)
U+10b00 Avestan (0/61) (0/61) (0/61)
U+10b40 Inscriptional Parthian (0/30) (0/30) (0/30)
U+10b60 Inscriptional Pahlavi (0/27) (0/27) (0/27)
U+10b80 Psalter Pahlavi (0/29) (0/29) (0/29)
U+10c00 Old Turkic (0/73) (0/73) (0/73)
U+10c80 Old Hungarian (0/108) (0/108) (0/108)
U+10e60 Rumi Numeral Symbols (0/31) (0/31) (0/31)
U+11000 Brahmi (0/109) (0/109) (0/109)
U+11080 Kaithi (0/66) (0/66) (0/66)
U+110d0 Sora Sompeng (0/35) (0/35) (0/35)
U+11100 Chakma (0/67) (0/67) (0/67)
U+11150 Mahajani (0/39) (0/39) (0/39)
U+11180 Sharada (0/94) (0/94) (0/94)
U+111e0 Sinhala Archaic Numbers (0/20) (0/20) (0/20)
U+11200 Khojki (0/62) (0/62) (0/62)
U+11280 Multani (0/38) (0/38) (0/38)
U+112b0 Khudawadi (0/69) (0/69) (0/69)
U+11300 Grantha (0/85) (0/85) (0/85)
U+11400 Newa (0/92) (0/92) (0/92)
U+11480 Tirhuta (0/82) (0/82) (0/82)
U+11580 Siddham (0/92) (0/92) (0/92)
U+11600 Modi (0/79) (0/79) (0/79)
U+11660 Mongolian Supplement (0/13) (0/13) (0/13)
U+11680 Takri (0/66) (0/66) (0/66)
U+11700 Ahom (0/57) (0/57) (0/57)
U+118a0 Warang Citi (0/84) (0/84) (0/84)
U+11ac0 Pau Cin Hau (0/57) (0/57) (0/57)
U+11c00 Bhaiksuki (0/97) (0/97) (0/97)
U+11c70 Marchen (0/68) (0/68) (0/68)
U+12000 Cuneiform (0/922) (0/922) (0/922)
U+12400 Cuneiform Numbers and Punctuation (0/116) (0/116) (0/116)
U+12480 Early Dynastic Cuneiform (0/196) (0/196) (0/196)
U+13000 Egyptian Hieroglyphs (0/1071) (0/1071) (0/1071)
U+14400 Anatolian Hieroglyphs (0/583) (0/583) (0/583)
U+16800 Bamum Supplement (0/569) (0/569) (0/569)
U+16a40 Mro (0/43) (0/43) (0/43)
U+16ad0 Bassa Vah (0/36) (0/36) (0/36)
U+16b00 Pahawh Hmong (0/127) (0/127) (0/127)
U+16f00 Miao (0/133) (0/133) (0/133)
U+16fe0 Ideographic Symbols and Punctuation (0/1) (0/1) (0/1)
U+17000 Tangut (0/0) (0/0) (0/0)
U+18800 Tangut Components (0/755) (0/755) (0/755)
U+1b000 Kana Supplement (0/2) (0/2) (0/2)
U+1bc00 Duployan (0/143) (0/143) (0/143)
U+1bca0 Shorthand Format Controls (0/4) (0/4) (0/4)
U+1d000 Byzantine Musical Symbols (0/246) (0/246) (0/246)
U+1d100 Musical Symbols (0/231) (0/231) (0/231)
U+1d200 Ancient Greek Musical Notation (0/70) (0/70) (0/70)
U+1d300 Tai Xuan Jing Symbols 100% (87/87) (0/87) (0/87)
U+1d360 Counting Rod Numerals (0/18) (0/18) (0/18)
U+1d400 Mathematical Alphanumeric Symbols 11% (117/996) 10% (108/996) 6% (63/996)
U+1d800 Sutton SignWriting (0/672) (0/672) (0/672)
U+1e000 Glagolitic Supplement (0/38) (0/38) (0/38)
U+1e800 Mende Kikakui (0/213) (0/213) (0/213)
U+1e900 Adlam (0/87) (0/87) (0/87)
U+1ee00 Arabic Mathematical Alphabetic Symbols 51% (74/143) (0/143) (0/143)
U+1f000 Mahjong Tiles (0/44) (0/44) (0/44)
U+1f030 Domino Tiles 100% (100/100) (0/100) (0/100)
U+1f0a0 Playing Cards 71% (59/82) (0/82) (0/82)
U+1f100 Enclosed Alphanumeric Supplement (0/191) (0/191) (0/191)
U+1f200 Enclosed Ideographic Supplement (0/58) (0/58) (0/58)
U+1f300 Miscellaneous Symbols and Pictographs 1% (12/768) (0/768) (0/768)
U+1f600 Emoticons 80% (64/80) (0/80) (0/80)
U+1f650 Ornamental Dingbats (0/48) (0/48) (0/48)
U+1f680 Transport and Map Symbols (0/103) (0/103) (0/103)
U+1f700 Alchemical Symbols (0/116) (0/116) (0/116)
U+1f780 Geometric Shapes Extended (0/85) (0/85) (0/85)
U+1f800 Supplemental Arrows-C (0/148) (0/148) (0/148)
U+1f900 Supplemental Symbols and Pictographs (0/82) (0/82) (0/82)
U+20000 CJK Unified Ideographs Extension B (0/0) (0/0) (0/0)
U+2a700 CJK Unified Ideographs Extension C (0/0) (0/0) (0/0)
U+2b740 CJK Unified Ideographs Extension D (0/0) (0/0) (0/0)
U+2b820 CJK Unified Ideographs Extension E (0/0) (0/0) (0/0)
U+2f800 CJK Compatibility Ideographs Supplement (0/542) (0/542) (0/542)
U+e0000 Tags (0/98) (0/98) (0/98)
U+e0100 Variation Selectors Supplement (0/240) (0/240) (0/240)
U+f0000 Supplementary Private Use Area-A (0/0) (0/0) (0/0)
U+100000 Supplementary Private Use Area-B (0/0) (0/0) (0/0)

View file

@ -333,10 +333,10 @@ impl<'a> TextRun {
}
/// Returns the index in the range of the first glyph advancing over given advance
pub fn range_index_of_advance(&self, range: &Range<ByteIndex>, advance: Au) -> usize {
pub fn range_index_of_advance(&self, range: &Range<ByteIndex>, advance: f32) -> usize {
// TODO(Issue #199): alter advance direction for RTL
// TODO(Issue #98): using inter-char and inter-word spacing settings when measuring text
let mut remaining = advance;
let mut remaining = Au::from_f32_px(advance);
self.natural_word_slices_in_range(range)
.map(|slice| {
let (slice_index, slice_advance) =

View file

@ -499,7 +499,7 @@ fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
loop {
displacement += 1;
let probe = bucket.next();
debug_assert!(probe.index() != idx_end);
debug_assert_ne!(probe.index(), idx_end);
let full_bucket = match probe.peek() {
Empty(bucket) => {
@ -578,7 +578,7 @@ impl<K, V, S> HashMap<K, V, S>
Full(b) => b.into_bucket(),
};
buckets.next();
debug_assert!(buckets.index() != start_index);
debug_assert_ne!(buckets.index(), start_index);
}
}
}

View file

@ -485,7 +485,7 @@ pub enum MarginsMayCollapseFlag {
MarginsMayNotCollapse,
}
#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum FormattingContextType {
None,
Block,
@ -1472,7 +1472,7 @@ impl BlockFlow {
fn assign_inline_position_for_formatting_context(&mut self,
layout_context: &LayoutContext,
content_box: LogicalRect<Au>) {
debug_assert!(self.formatting_context_type() != FormattingContextType::None);
debug_assert_ne!(self.formatting_context_type(), FormattingContextType::None);
if !self.base.restyle_damage.intersects(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW) {
return

View file

@ -37,14 +37,12 @@ use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use servo_config::opts;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::LinkedList;
use std::marker::PhantomData;
use std::mem;
use std::sync::Arc;
use std::sync::atomic::Ordering;
use style::computed_values::caption_side::T as CaptionSide;
use style::computed_values::content::ContentItem;
use style::computed_values::display::T as Display;
use style::computed_values::empty_cells::T as EmptyCells;
use style::computed_values::float::T as Float;
@ -58,6 +56,7 @@ use style::properties::longhands::list_style_image;
use style::selector_parser::{PseudoElement, RestyleDamage};
use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::Either;
use style::values::computed::counters::ContentItem;
use table::TableFlow;
use table_caption::TableCaptionFlow;
use table_cell::TableCellFlow;
@ -598,7 +597,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// Add whitespace results. They will be stripped out later on when
// between block elements, and retained when between inline elements.
let fragment_info = SpecificFragmentInfo::UnscannedText(
Box::new(UnscannedTextFragmentInfo::new(" ".to_owned(), None))
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(" "), None))
);
let fragment = Fragment::from_opaque_node_and_style(whitespace_node,
whitespace_pseudo,
@ -754,7 +753,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
ContentItem::String(string) => {
let info = Box::new(UnscannedTextFragmentInfo::new(string, None));
SpecificFragmentInfo::UnscannedText(info)
}
},
content_item => {
let content_item = Box::new(GeneratedContentInfo::ContentItem(content_item));
SpecificFragmentInfo::GeneratedContent(content_item)
@ -873,7 +872,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
whitespace_damage)) => {
// Instantiate the whitespace fragment.
let fragment_info = SpecificFragmentInfo::UnscannedText(
Box::new(UnscannedTextFragmentInfo::new(" ".to_owned(), None))
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(" "), None))
);
let fragment =
Fragment::from_opaque_node_and_style(whitespace_node,
@ -895,7 +894,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
if is_empty && node_style.has_padding_or_border() {
// An empty inline box needs at least one fragment to draw its background and borders.
let info = SpecificFragmentInfo::UnscannedText(
Box::new(UnscannedTextFragmentInfo::new(String::new(), None))
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(""), None))
);
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
node.get_pseudo_element_type(),
@ -1296,7 +1295,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
unscanned_marker_fragments.push_back(Fragment::new(
node,
SpecificFragmentInfo::UnscannedText(
Box::new(UnscannedTextFragmentInfo::new(text, None))
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(text), None))
),
self.layout_context));
let marker_fragments =
@ -1899,7 +1898,7 @@ where
E: TElement,
{
let info = SpecificFragmentInfo::UnscannedText(
Box::new(UnscannedTextFragmentInfo::new(String::from(text), None))
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(text), None))
);
let text_style = context.stylist.style_for_anonymous::<E>(
&context.guards,

View file

@ -17,8 +17,7 @@ use context::LayoutContext;
use display_list::ToLayout;
use display_list::background::{compute_background_image_size, tile_image_axis};
use display_list::background::{convert_linear_gradient, convert_radial_gradient};
use display_list::webrender_helpers::ToBorderRadius;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Transform3D, TypedRect, TypedSize2D, Vector2D};
use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Transform3D, TypedSize2D, Vector2D, rect};
use flex::FlexFlow;
use flow::{BaseFlow, Flow, FlowFlags};
use flow_ref::FlowRef;
@ -27,7 +26,7 @@ use fragment::{CanvasFragmentSource, CoordinateSystem, Fragment, ScannedTextFrag
use fragment::SpecificFragmentInfo;
use gfx::display_list;
use gfx::display_list::{BaseDisplayItem, BorderDetails, BorderDisplayItem, BLUR_INFLATION_FACTOR};
use gfx::display_list::{BorderRadii, BoxShadowDisplayItem, ClipScrollNode};
use gfx::display_list::{BoxShadowDisplayItem, ClipScrollNode};
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
use gfx::display_list::{DisplayListSection, GradientDisplayItem, IframeDisplayItem};
@ -36,6 +35,8 @@ use gfx::display_list::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem}
use gfx::display_list::{RadialGradientDisplayItem, SolidColorDisplayItem, StackingContext};
use gfx::display_list::{StackingContextType, StickyFrameData, TextDisplayItem, TextOrientation};
use gfx::display_list::WebRenderImageInfo;
use gfx::text::TextRun;
use gfx::text::glyph::ByteIndex;
use gfx_traits::{combine_id_with_fragment_type, FragmentType, StackingContextId};
use inline::{InlineFlow, InlineFragmentNodeFlags};
use ipc_channel::ipc;
@ -47,8 +48,8 @@ use net_traits::image_cache::UsePlaceholder;
use range::Range;
use servo_config::opts;
use servo_geometry::MaxRect;
use std::{cmp, f32};
use std::default::Default;
use std::f32;
use std::mem;
use std::sync::Arc;
use style::computed_values::background_attachment::single_value::T as BackgroundAttachment;
@ -73,10 +74,11 @@ use style_traits::CSSPixel;
use style_traits::ToCss;
use style_traits::cursor::CursorKind;
use table_cell::CollapsedBordersForCell;
use webrender_api::{self, BorderSide, BoxShadowClipMode, ClipMode, ColorF, ComplexClipRegion};
use webrender_api::{ExternalScrollId, FilterOp, ImageBorder, ImageRendering, LayoutRect};
use webrender_api::{LayoutSize, LayoutVector2D, LineStyle, LocalClip, NinePatchDescriptor};
use webrender_api::{NormalBorder, ScrollPolicy, ScrollSensitivity, StickyOffsetBounds};
use webrender_api::{self, BorderRadius, BorderSide, BoxShadowClipMode, ClipMode, ColorF};
use webrender_api::{ComplexClipRegion, ExternalScrollId, FilterOp, GlyphInstance, ImageBorder};
use webrender_api::{ImageRendering, LayoutRect, LayoutSize, LayoutVector2D, LineStyle, LocalClip};
use webrender_api::{NinePatchDescriptor, NormalBorder, ScrollPolicy, ScrollSensitivity};
use webrender_api::StickyOffsetBounds;
trait ResolvePercentage {
fn resolve(&self, length: u32) -> u32;
@ -244,7 +246,7 @@ impl StackingContextCollectionState {
// takes care of adding this root node and it can be ignored during DL conversion.
let root_node = ClipScrollNode {
parent_index: ClipScrollNodeIndex(0),
clip: ClippingRegion::from_rect(&TypedRect::zero()),
clip: ClippingRegion::from_rect(LayoutRect::zero()),
content_rect: LayoutRect::zero(),
node_type: ClipScrollNodeType::ScrollFrame(
ScrollSensitivity::ScriptAndInputEvents,
@ -389,7 +391,7 @@ impl<'a> DisplayListBuildState<'a> {
};
BaseDisplayItem::new(
*bounds,
bounds.to_layout(),
DisplayItemMetadata {
node,
// Store cursor id in display list.
@ -708,16 +710,25 @@ pub trait FragmentDisplayListBuilding {
fn fragment_type(&self) -> FragmentType;
}
fn handle_overlapping_radii(size: &Size2D<Au>, radii: &BorderRadii<Au>) -> BorderRadii<Au> {
fn scale_border_radii(radii: BorderRadius, factor: f32) -> BorderRadius {
BorderRadius {
top_left: radii.top_left * factor,
top_right: radii.top_right * factor,
bottom_left: radii.bottom_left * factor,
bottom_right: radii.bottom_right * factor,
}
}
fn handle_overlapping_radii(size: LayoutSize, radii: BorderRadius) -> BorderRadius {
// No two corners' border radii may add up to more than the length of the edge
// between them. To prevent that, all radii are scaled down uniformly.
fn scale_factor(radius_a: Au, radius_b: Au, edge_length: Au) -> f32 {
fn scale_factor(radius_a: f32, radius_b: f32, edge_length: f32) -> f32 {
let required = radius_a + radius_b;
if required <= edge_length {
1.0
} else {
edge_length.to_f32_px() / required.to_f32_px()
edge_length / required
}
}
@ -738,39 +749,39 @@ fn handle_overlapping_radii(size: &Size2D<Au>, radii: &BorderRadii<Au>) -> Borde
.min(left_factor)
.min(right_factor);
if min_factor < 1.0 {
radii.scale_by(min_factor)
scale_border_radii(radii, min_factor)
} else {
*radii
radii
}
}
fn build_border_radius(
abs_bounds: &Rect<Au>,
border_style: &style_structs::Border,
) -> BorderRadii<Au> {
) -> BorderRadius {
// TODO(cgaebel): Support border radii even in the case of multiple border widths.
// This is an extension of supporting elliptical radii. For now, all percentage
// radii will be relative to the width.
handle_overlapping_radii(
&abs_bounds.size,
&BorderRadii {
abs_bounds.size.to_layout(),
BorderRadius {
top_left: model::specified_border_radius(
border_style.border_top_left_radius,
abs_bounds.size,
),
).to_layout(),
top_right: model::specified_border_radius(
border_style.border_top_right_radius,
abs_bounds.size,
),
).to_layout(),
bottom_right: model::specified_border_radius(
border_style.border_bottom_right_radius,
abs_bounds.size,
),
).to_layout(),
bottom_left: model::specified_border_radius(
border_style.border_bottom_left_radius,
abs_bounds.size,
),
).to_layout(),
},
)
}
@ -780,9 +791,9 @@ fn build_border_radius(
fn build_border_radius_for_inner_rect(
outer_rect: &Rect<Au>,
style: &ComputedValues,
) -> BorderRadii<Au> {
) -> BorderRadius {
let radii = build_border_radius(&outer_rect, style.get_border());
if radii.is_square() {
if radii.is_zero() {
return radii;
}
@ -830,20 +841,23 @@ fn simple_normal_border(color: ColorF, style: webrender_api::BorderStyle) -> Nor
}
fn calculate_inner_border_radii(
mut radii: BorderRadii<Au>,
mut radii: BorderRadius,
offsets: SideOffsets2D<Au>,
) -> BorderRadii<Au> {
radii.top_left.width = cmp::max(Au(0), radii.top_left.width - offsets.left);
radii.bottom_left.width = cmp::max(Au(0), radii.bottom_left.width - offsets.left);
) -> BorderRadius {
fn inner_length(x: f32, offset: Au) -> f32 {
0.0_f32.max(x - offset.to_f32_px())
}
radii.top_left.width = inner_length(radii.top_left.width, offsets.left);
radii.bottom_left.width = inner_length(radii.bottom_left.width, offsets.left);
radii.top_right.width = cmp::max(Au(0), radii.top_right.width - offsets.right);
radii.bottom_right.width = cmp::max(Au(0), radii.bottom_right.width - offsets.right);
radii.top_right.width = inner_length(radii.top_right.width, offsets.right);
radii.bottom_right.width = inner_length(radii.bottom_right.width, offsets.right);
radii.top_left.height = cmp::max(Au(0), radii.top_left.height - offsets.top);
radii.top_right.height = cmp::max(Au(0), radii.top_right.height - offsets.top);
radii.top_left.height = inner_length(radii.top_left.height, offsets.top);
radii.top_right.height = inner_length(radii.top_right.height, offsets.top);
radii.bottom_left.height = cmp::max(Au(0), radii.bottom_left.height - offsets.bottom);
radii.bottom_right.height = cmp::max(Au(0), radii.bottom_right.height - offsets.bottom);
radii.bottom_left.height = inner_length(radii.bottom_left.height, offsets.bottom);
radii.bottom_right.height = inner_length(radii.bottom_right.height, offsets.bottom);
radii
}
@ -877,6 +891,35 @@ fn build_image_border_details(
}
}
fn convert_text_run_to_glyphs(
text_run: Arc<TextRun>,
range: Range<ByteIndex>,
mut origin: Point2D<Au>,
) -> Vec<GlyphInstance> {
let mut glyphs = vec![];
for slice in text_run.natural_word_slices_in_visual_order(&range) {
for glyph in slice.glyphs.iter_glyphs_for_byte_range(&slice.range) {
let glyph_advance = if glyph.char_is_space() {
glyph.advance() + text_run.extra_word_spacing
} else {
glyph.advance()
};
if !slice.glyphs.is_whitespace() {
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
let point = origin + glyph_offset.to_vector();
let glyph = GlyphInstance {
index: glyph.id(),
point: point.to_layout(),
};
glyphs.push(glyph);
}
origin.x += glyph_advance;
}
}
return glyphs;
}
impl FragmentDisplayListBuilding for Fragment {
fn collect_stacking_contexts_for_blocklike_fragment(
&mut self,
@ -946,14 +989,10 @@ impl FragmentDisplayListBuilding for Fragment {
},
}
let clip = if !border_radii.is_square() {
let clip = if !border_radii.is_zero() {
LocalClip::RoundedRect(
bounds.to_layout(),
ComplexClipRegion::new(
bounds.to_layout(),
border_radii.to_border_radius(),
ClipMode::Clip,
),
ComplexClipRegion::new(bounds.to_layout(), border_radii, ClipMode::Clip),
)
} else {
LocalClip::Rect(bounds.to_layout())
@ -1325,7 +1364,7 @@ impl FragmentDisplayListBuilding for Fragment {
),
blur_radius: box_shadow.base.blur.px(),
spread_radius: box_shadow.spread.px(),
border_radius: border_radius.to_border_radius(),
border_radius: border_radius,
clip_mode: if box_shadow.inset {
BoxShadowClipMode::Inset
} else {
@ -1420,7 +1459,7 @@ impl FragmentDisplayListBuilding for Fragment {
color: style.resolve_color(colors.bottom).to_layout(),
style: border_style.bottom.to_layout(),
},
radius: border_radius.to_border_radius(),
radius: border_radius,
})),
Either::Second(Image::Gradient(ref gradient)) => {
Some(match gradient.kind {
@ -1653,27 +1692,19 @@ impl FragmentDisplayListBuilding for Fragment {
let insertion_point_bounds;
let cursor;
if !self.style.writing_mode.is_vertical() {
insertion_point_bounds = Rect::new(
Point2D::new(
stacking_relative_border_box.origin.x + advance,
stacking_relative_border_box.origin.y,
),
Size2D::new(
INSERTION_POINT_LOGICAL_WIDTH,
stacking_relative_border_box.size.height,
),
insertion_point_bounds = rect(
stacking_relative_border_box.origin.x + advance,
stacking_relative_border_box.origin.y,
INSERTION_POINT_LOGICAL_WIDTH,
stacking_relative_border_box.size.height,
);
cursor = CursorKind::Text;
} else {
insertion_point_bounds = Rect::new(
Point2D::new(
stacking_relative_border_box.origin.x,
stacking_relative_border_box.origin.y + advance,
),
Size2D::new(
stacking_relative_border_box.size.width,
INSERTION_POINT_LOGICAL_WIDTH,
),
insertion_point_bounds = rect(
stacking_relative_border_box.origin.x,
stacking_relative_border_box.origin.y + advance,
stacking_relative_border_box.size.width,
INSERTION_POINT_LOGICAL_WIDTH,
);
cursor = CursorKind::VerticalText;
};
@ -1842,12 +1873,12 @@ impl FragmentDisplayListBuilding for Fragment {
// Adjust the clipping region as necessary to account for `border-radius`.
let build_local_clip = |style: &ComputedValues| {
let radii = build_border_radius_for_inner_rect(&stacking_relative_border_box, style);
if !radii.is_square() {
if !radii.is_zero() {
LocalClip::RoundedRect(
stacking_relative_border_box.to_layout(),
ComplexClipRegion::new(
stacking_relative_content_box.to_layout(),
radii.to_border_radius(),
radii,
ClipMode::Clip,
),
)
@ -1946,10 +1977,7 @@ impl FragmentDisplayListBuilding for Fragment {
iframe: pipeline_id,
}));
let size = Size2D::new(
item.bounds().size.width.to_f32_px(),
item.bounds().size.height.to_f32_px(),
);
let size = Size2D::new(item.bounds().size.width, item.bounds().size.height);
state
.iframe_sizes
.push((browsing_context_id, TypedSize2D::from_untyped(&size)));
@ -2067,8 +2095,8 @@ impl FragmentDisplayListBuilding for Fragment {
StackingContext::new(
id,
context_type,
&border_box,
&overflow,
border_box.to_layout(),
overflow.to_layout(),
self.effective_z_index(),
filters,
self.style().get_effects().mix_blend_mode.to_layout(),
@ -2100,7 +2128,7 @@ impl FragmentDisplayListBuilding for Fragment {
};
// Determine the orientation and cursor to use.
let (orientation, cursor) = if self.style.writing_mode.is_vertical() {
let (_orientation, cursor) = if self.style.writing_mode.is_vertical() {
// TODO: Distinguish between 'sideways-lr' and 'sideways-rl' writing modes in CSS
// Writing Modes Level 4.
(TextOrientation::SidewaysRight, CursorKind::VerticalText)
@ -2181,14 +2209,22 @@ impl FragmentDisplayListBuilding for Fragment {
}
// Text
state.add_display_item(DisplayItem::Text(Box::new(TextDisplayItem {
base: base.clone(),
text_run: text_fragment.run.clone(),
range: text_fragment.range,
text_color: text_color.to_layout(),
orientation: orientation,
baseline_origin: baseline_origin,
})));
let glyphs = convert_text_run_to_glyphs(
text_fragment.run.clone(),
text_fragment.range,
baseline_origin,
);
if !glyphs.is_empty() {
state.add_display_item(DisplayItem::Text(Box::new(TextDisplayItem {
base: base.clone(),
text_run: text_fragment.run.clone(),
range: text_fragment.range,
baseline_origin: baseline_origin.to_layout(),
glyphs: glyphs,
font_key: text_fragment.run.font_key,
text_color: text_color.to_layout(),
})));
}
// TODO(#17715): emit text-emphasis marks here.
// (just push another TextDisplayItem?)
@ -2435,25 +2471,20 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
Rect::max_rect()
},
Some(transform) => {
let clip = Rect::new(
Point2D::new(
(clip.origin.x - origin.x).to_f32_px(),
(clip.origin.y - origin.y).to_f32_px(),
),
Size2D::new(clip.size.width.to_f32_px(), clip.size.height.to_f32_px()),
let clip = rect(
(clip.origin.x - origin.x).to_f32_px(),
(clip.origin.y - origin.y).to_f32_px(),
clip.size.width.to_f32_px(),
clip.size.height.to_f32_px(),
);
let clip = transform.transform_rect(&clip);
Rect::new(
Point2D::new(
Au::from_f32_px(clip.origin.x),
Au::from_f32_px(clip.origin.y),
),
Size2D::new(
Au::from_f32_px(clip.size.width),
Au::from_f32_px(clip.size.height),
),
rect(
Au::from_f32_px(clip.origin.x),
Au::from_f32_px(clip.origin.y),
Au::from_f32_px(clip.size.width),
Au::from_f32_px(clip.size.height),
)
},
None => Rect::zero(),
@ -2669,7 +2700,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let new_clip_scroll_index = state.add_clip_scroll_node(ClipScrollNode {
parent_index: self.clipping_and_scrolling().scrolling,
clip: ClippingRegion::from_rect(border_box),
clip: ClippingRegion::from_rect(border_box.to_layout()),
content_rect: LayoutRect::zero(),
node_type: ClipScrollNodeType::StickyFrame(sticky_frame_data),
});
@ -2709,10 +2740,10 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
};
let clip_rect = build_inner_border_box_for_border_rect(&border_box, &self.fragment.style);
let mut clip = ClippingRegion::from_rect(&clip_rect);
let mut clip = ClippingRegion::from_rect(clip_rect.to_layout());
let radii = build_border_radius_for_inner_rect(&border_box, &self.fragment.style);
if !radii.is_square() {
clip.intersect_with_rounded_rect(&clip_rect, &radii)
if !radii.is_zero() {
clip.intersect_with_rounded_rect(clip_rect.to_layout(), radii)
}
let content_size = self.base.overflow.scroll.origin + self.base.overflow.scroll.size;
@ -2776,7 +2807,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let new_index = state.add_clip_scroll_node(ClipScrollNode {
parent_index: self.clipping_and_scrolling().scrolling,
clip: ClippingRegion::from_rect(&clip_rect),
clip: ClippingRegion::from_rect(clip_rect.to_layout()),
content_rect: LayoutRect::zero(), // content_rect isn't important for clips.
node_type: ClipScrollNodeType::Clip,
});

View file

@ -7,14 +7,11 @@
// This might be achieved by sharing types between WR and Servo display lists, or
// completely converting layout to directly generate WebRender display lists, for example.
use app_units::Au;
use display_list::ToLayout;
use euclid::Point2D;
use gfx::display_list::{BorderDetails, BorderRadii, ClipScrollNode};
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingRegion, DisplayItem};
use gfx::display_list::{BorderDetails, ClipScrollNode};
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, DisplayItem};
use gfx::display_list::{DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId;
use webrender_api::{self, ClipAndScrollInfo, ClipId, ClipMode, ComplexClipRegion};
use webrender_api::{self, ClipAndScrollInfo, ClipId};
use webrender_api::{DisplayListBuilder, LayoutTransform};
pub trait WebRenderDisplayListConverter {
@ -32,26 +29,11 @@ trait WebRenderDisplayItemConverter {
);
}
pub trait ToBorderRadius {
fn to_border_radius(&self) -> webrender_api::BorderRadius;
}
impl ToBorderRadius for BorderRadii<Au> {
fn to_border_radius(&self) -> webrender_api::BorderRadius {
webrender_api::BorderRadius {
top_left: self.top_left.to_layout(),
top_right: self.top_right.to_layout(),
bottom_left: self.bottom_left.to_layout(),
bottom_right: self.bottom_right.to_layout(),
}
}
}
impl WebRenderDisplayListConverter for DisplayList {
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder {
let mut builder = DisplayListBuilder::with_capacity(
pipeline_id.to_webrender(),
self.bounds().size.to_layout(),
self.bounds().size,
1024 * 1024,
); // 1 MB of space
@ -81,7 +63,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
None => None,
};
webrender_api::LayoutPrimitiveInfo {
rect: self.base().bounds.to_layout(),
rect: self.base().bounds,
local_clip: self.base().local_clip,
// TODO(gw): Make use of the WR backface visibility functionality.
is_backface_visible: true,
@ -121,42 +103,13 @@ impl WebRenderDisplayItemConverter for DisplayItem {
builder.push_rect(&self.prim_info(), item.color);
},
DisplayItem::Text(ref item) => {
let mut origin = item.baseline_origin.clone();
let mut glyphs = vec![];
for slice in item.text_run
.natural_word_slices_in_visual_order(&item.range)
{
for glyph in slice.glyphs.iter_glyphs_for_byte_range(&slice.range) {
let glyph_advance = if glyph.char_is_space() {
glyph.advance() + item.text_run.extra_word_spacing
} else {
glyph.advance()
};
if !slice.glyphs.is_whitespace() {
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
let x = (origin.x + glyph_offset.x).to_f32_px();
let y = (origin.y + glyph_offset.y).to_f32_px();
let point = webrender_api::LayoutPoint::new(x, y);
let glyph = webrender_api::GlyphInstance {
index: glyph.id(),
point: point,
};
glyphs.push(glyph);
}
origin.x = origin.x + glyph_advance;
}
}
if glyphs.len() > 0 {
builder.push_text(
&self.prim_info(),
&glyphs,
item.text_run.font_key,
item.text_color,
None,
);
}
builder.push_text(
&self.prim_info(),
&item.glyphs,
item.font_key,
item.text_color,
None,
);
},
DisplayItem::Image(ref item) => {
if let Some(id) = item.webrender_image.key {
@ -233,7 +186,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
builder.push_line(
&self.prim_info(),
// TODO(gw): Use a better estimate for wavy line thickness.
(0.33 * item.base.bounds.size.height.to_f32_px()).ceil(),
(0.33 * item.base.bounds.size.height).ceil(),
webrender_api::LineOrientation::Horizontal,
&item.color,
item.style,
@ -269,7 +222,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
},
DisplayItem::PushStackingContext(ref item) => {
let stacking_context = &item.stacking_context;
debug_assert!(stacking_context.context_type == StackingContextType::Real);
debug_assert_eq!(stacking_context.context_type, StackingContextType::Real);
let transform = stacking_context
.transform
@ -279,7 +232,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
.map(|perspective| LayoutTransform::from_untyped(&perspective));
builder.push_stacking_context(
&webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds.to_layout()),
&webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds),
stacking_context.scroll_policy,
transform,
stacking_context.transform_style,
@ -292,13 +245,13 @@ impl WebRenderDisplayItemConverter for DisplayItem {
DisplayItem::DefineClipScrollNode(ref item) => {
let node = &clip_scroll_nodes[item.node_index.0];
let parent_id = get_id(clip_ids, node.parent_index);
let item_rect = node.clip.main.to_layout();
let item_rect = node.clip.main;
let webrender_id = match node.node_type {
ClipScrollNodeType::Clip => builder.define_clip_with_parent(
parent_id,
item_rect,
node.clip.get_complex_clips(),
node.clip.complex.clone(),
None,
),
ClipScrollNodeType::ScrollFrame(scroll_sensitivity, external_id) => builder
@ -306,8 +259,8 @@ impl WebRenderDisplayItemConverter for DisplayItem {
parent_id,
Some(external_id),
node.content_rect,
node.clip.main.to_layout(),
node.clip.get_complex_clips(),
node.clip.main,
node.clip.complex.clone(),
None,
scroll_sensitivity,
),
@ -331,22 +284,3 @@ impl WebRenderDisplayItemConverter for DisplayItem {
}
}
}
trait ToWebRenderClip {
fn get_complex_clips(&self) -> Vec<ComplexClipRegion>;
}
impl ToWebRenderClip for ClippingRegion {
fn get_complex_clips(&self) -> Vec<ComplexClipRegion> {
self.complex
.iter()
.map(|complex_clipping_region| {
ComplexClipRegion::new(
complex_clipping_region.rect.to_layout(),
complex_clipping_region.radii.to_border_radius(),
ClipMode::Clip,
)
})
.collect()
}
}

View file

@ -44,7 +44,6 @@ use style::computed_values::border_collapse::T as BorderCollapse;
use style::computed_values::box_sizing::T as BoxSizing;
use style::computed_values::clear::T as Clear;
use style::computed_values::color::T as Color;
use style::computed_values::content::ContentItem;
use style::computed_values::display::T as Display;
use style::computed_values::mix_blend_mode::T as MixBlendMode;
use style::computed_values::overflow_wrap::T as OverflowWrap;
@ -61,6 +60,7 @@ use style::servo::restyle_damage::ServoRestyleDamage;
use style::str::char_is_whitespace;
use style::values::{self, Either, Auto};
use style::values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::counters::ContentItem;
use style::values::generics::box_::VerticalAlign;
use style::values::generics::transform;
use text;
@ -570,9 +570,9 @@ pub struct UnscannedTextFragmentInfo {
impl UnscannedTextFragmentInfo {
/// Creates a new instance of `UnscannedTextFragmentInfo` from the given text.
#[inline]
pub fn new(text: String, selection: Option<Range<ByteIndex>>) -> UnscannedTextFragmentInfo {
pub fn new(text: Box<str>, selection: Option<Range<ByteIndex>>) -> UnscannedTextFragmentInfo {
UnscannedTextFragmentInfo {
text: text.into_boxed_str(),
text: text,
selection: selection,
}
}
@ -760,14 +760,14 @@ impl Fragment {
let mut ellipsis_fragment = self.transform(
self.border_box.size,
SpecificFragmentInfo::UnscannedText(
Box::new(UnscannedTextFragmentInfo::new(text_overflow_string, None))
Box::new(UnscannedTextFragmentInfo::new(text_overflow_string.into_boxed_str(), None))
)
);
unscanned_ellipsis_fragments.push_back(ellipsis_fragment);
let ellipsis_fragments = with_thread_local_font_context(layout_context, |font_context| {
TextRunScanner::new().scan_for_runs(font_context, unscanned_ellipsis_fragments)
});
debug_assert!(ellipsis_fragments.len() == 1);
debug_assert_eq!(ellipsis_fragments.len(), 1);
ellipsis_fragment = ellipsis_fragments.fragments.into_iter().next().unwrap();
ellipsis_fragment.flags |= FragmentFlags::IS_ELLIPSIS;
ellipsis_fragment

View file

@ -15,12 +15,12 @@ use gfx::display_list::OpaqueNode;
use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList};
use style::computed_values::content::ContentItem;
use style::computed_values::display::T as Display;
use style::computed_values::list_style_type::T as ListStyleType;
use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::computed::counters::ContentItem;
use text::TextRunScanner;
use traversal::InorderFlowTraversal;
@ -189,7 +189,7 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
let temporary_counter = Counter::new();
let counter = self.traversal
.counters
.get(&*counter_name)
.get(&**counter_name)
.unwrap_or(&temporary_counter);
new_info = counter.render(self.traversal.layout_context,
fragment.node,
@ -204,7 +204,7 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
let temporary_counter = Counter::new();
let counter = self.traversal
.counters
.get(&*counter_name)
.get(&**counter_name)
.unwrap_or(&temporary_counter);
new_info = counter.render(self.traversal.layout_context,
fragment.node,
@ -437,7 +437,7 @@ fn render_text(layout_context: &LayoutContext,
-> Option<SpecificFragmentInfo> {
let mut fragments = LinkedList::new();
let info = SpecificFragmentInfo::UnscannedText(
Box::new(UnscannedTextFragmentInfo::new(string, None))
Box::new(UnscannedTextFragmentInfo::new(string.into_boxed_str(), None))
);
fragments.push_back(Fragment::from_opaque_node_and_style(node,
pseudo,

View file

@ -804,7 +804,7 @@ impl LineBreaker {
self.work_list.push_front(cur_fragment);
for fragment_index in (last_known_line_breaking_opportunity.get()..
self.pending_line.range.end().get()).rev() {
debug_assert!(fragment_index == (self.new_fragments.len() as isize) - 1);
debug_assert_eq!(fragment_index, (self.new_fragments.len() as isize) - 1);
self.work_list.push_front(self.new_fragments.pop().unwrap());
}

View file

@ -125,7 +125,7 @@ impl TableFlow {
}
} else {
// We discovered a new column. Initialize its data.
debug_assert!(column_index == parent_inline_sizes.len());
debug_assert_eq!(column_index, parent_inline_sizes.len());
if child_cell_inline_size.column_span > 1 {
// TODO(pcwalton): Perform the recursive algorithm specified in INTRINSIC §
// 4. For now we make this column contribute no width.
@ -635,7 +635,7 @@ impl<T> VecExt<T> for Vec<T> {
if index < self.len() {
self[index] = value
} else {
debug_assert!(index == self.len());
debug_assert_eq!(index, self.len());
self.push(value)
}
&mut self[index]
@ -643,7 +643,7 @@ impl<T> VecExt<T> for Vec<T> {
fn get_mut_or_push(&mut self, index: usize, zero: T) -> &mut T {
if index >= self.len() {
debug_assert!(index == self.len());
debug_assert_eq!(index, self.len());
self.push(zero)
}
&mut self[index]

View file

@ -532,7 +532,7 @@ fn split_first_fragment_at_newline_if_necessary(fragments: &mut LinkedList<Fragm
first_fragment.transform(
first_fragment.border_box.size,
SpecificFragmentInfo::UnscannedText(Box::new(
UnscannedTextFragmentInfo::new(string_before, selection_before)
UnscannedTextFragmentInfo::new(string_before.into_boxed_str(), selection_before)
))
)
};

View file

@ -34,9 +34,9 @@ use atomic_refcell::{AtomicRef, AtomicRefMut};
use data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use script_layout_interface::wrapper_traits::GetLayoutData;
use style::computed_values::content::{self, ContentItem};
use style::dom::{NodeInfo, TNode};
use style::selector_parser::RestyleDamage;
use style::values::computed::counters::{Content, ContentItem};
pub trait LayoutNodeLayoutData {
/// Similar to borrow_data*, but returns the full PersistentLayoutData rather
@ -114,14 +114,14 @@ impl<T: ThreadSafeLayoutNode> ThreadSafeLayoutNodeHelpers for T {
let style = self.as_element().unwrap().resolved_style();
return match style.as_ref().get_counters().content {
content::T::Items(ref value) if !value.is_empty() => {
TextContent::GeneratedContent((*value).clone())
Content::Items(ref value) if !value.is_empty() => {
TextContent::GeneratedContent((*value).to_vec())
}
_ => TextContent::GeneratedContent(vec![]),
};
}
return TextContent::Text(self.node_text_content());
TextContent::Text(self.node_text_content().into_boxed_str())
}
fn restyle_damage(self) -> RestyleDamage {
@ -156,7 +156,7 @@ impl<T: ThreadSafeLayoutNode> ThreadSafeLayoutNodeHelpers for T {
}
pub enum TextContent {
Text(String),
Text(Box<str>),
GeneratedContent(Vec<ContentItem>),
}

View file

@ -68,6 +68,7 @@ use layout::context::LayoutContext;
use layout::context::RegisteredPainter;
use layout::context::RegisteredPainters;
use layout::context::malloc_size_of_persistent_local_context;
use layout::display_list::ToLayout;
use layout::display_list::WebRenderDisplayListConverter;
use layout::flow::{Flow, GetBaseFlow, ImmutableFlowUtils, MutableOwnedFlowUtils};
use layout::flow_ref::FlowRef;
@ -706,7 +707,7 @@ impl LayoutThread {
let mut txn = webrender_api::Transaction::new();
txn.scroll_node_with_id(
webrender_api::LayoutPoint::from_untyped(&point),
webrender_api::IdType::ExternalScrollId(state.scroll_id),
webrender_api::ScrollNodeIdType::ExternalScrollId(state.scroll_id),
webrender_api::ScrollClamping::ToContentBounds
);
self.webrender_api.send_transaction(self.webrender_document, txn);
@ -986,7 +987,7 @@ impl LayoutThread {
}
};
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size);
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size).to_layout();
build_state.root_stacking_context.bounds = origin;
build_state.root_stacking_context.overflow = origin;
@ -1364,7 +1365,7 @@ impl LayoutThread {
rw_data.display_list
.as_ref()
.expect("Tried to hit test with no display list")
.text_index(opaque_node, &point_in_node)
.text_index(opaque_node, point_in_node.to_layout())
);
},
ReflowGoal::NodeGeometryQuery(node) => {

View file

@ -56,9 +56,9 @@ extern crate smallbitvec;
extern crate smallvec;
#[cfg(feature = "servo")]
extern crate string_cache;
#[cfg(feature = "servo")]
#[cfg(feature = "url")]
extern crate url;
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
extern crate webrender_api;
#[cfg(feature = "servo")]
extern crate xml5ever;
@ -803,7 +803,7 @@ malloc_size_of_is_0!(app_units::Au);
malloc_size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType);
#[cfg(feature = "servo")]
#[cfg(feature = "url")]
impl MallocSizeOf for url::Host {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
match *self {
@ -812,49 +812,55 @@ impl MallocSizeOf for url::Host {
}
}
}
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::BorderRadius);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::BorderStyle);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::BorderWidths);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::BoxShadowClipMode);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ClipAndScrollInfo);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ColorF);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ComplexClipRegion);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ExtendMode);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::FilterOp);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ExternalScrollId);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::FontInstanceKey);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::GradientStop);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::GlyphInstance);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ImageBorder);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ImageKey);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ImageRendering);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::LineStyle);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::LocalClip);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::MixBlendMode);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::NormalBorder);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::RepeatMode);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ScrollPolicy);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ScrollSensitivity);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::StickyOffsetBounds);
#[cfg(feature = "servo")]
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::TransformStyle);
#[cfg(feature = "servo")]

View file

@ -771,7 +771,7 @@ fn http_network_or_cache_fetch(request: &mut Request,
// Step 11
if cors_flag || (http_request.method != Method::Get && http_request.method != Method::Head) {
debug_assert!(http_request.origin != Origin::Client);
debug_assert_ne!(http_request.origin, Origin::Client);
if let Origin::Origin(ref url_origin) = http_request.origin {
if let Some(hyper_origin) = try_immutable_origin_to_hyper_origin(url_origin) {
http_request.headers.set(hyper_origin)

View file

@ -291,7 +291,7 @@ fn split_at_utf16_code_unit_offset(s: &str, offset: u32) -> Result<(&str, Option
if c > '\u{FFFF}' {
if code_units == offset {
if opts::get().replace_surrogates {
debug_assert!(c.len_utf8() == 4);
debug_assert_eq!(c.len_utf8(), 4);
return Ok((&s[..i], Some(c), &s[i + c.len_utf8()..]))
}
panic!("\n\n\

View file

@ -1334,7 +1334,7 @@ impl TreeIterator {
}
self.depth -= 1;
}
debug_assert!(self.depth == 0);
debug_assert_eq!(self.depth, 0);
self.current = None;
Some(current)
}

View file

@ -313,7 +313,7 @@ impl WebGLTexture {
}
fn is_cube_complete(&self) -> bool {
debug_assert!(self.face_count.get() == 6);
debug_assert_eq!(self.face_count.get(), 6);
let image_info = self.base_image_info().unwrap();
if !image_info.is_defined() {

View file

@ -871,13 +871,12 @@ impl<T: ClipboardProvider> TextInput<T> {
fn offset_to_text_point(&self, abs_point: usize) -> TextPoint {
let mut index = abs_point;
let mut line = 0;
let last_line_idx = self.lines.len() - 1;
self.lines.iter().enumerate().fold(0, |acc, (i, val)| {
if i != last_line_idx {
let line_end = max(val.len(), 1);
let new_acc = acc + line_end;
if abs_point > new_acc && index > line_end {
let line_end = val.len();
let new_acc = acc + line_end + 1;
if abs_point >= new_acc && index > line_end {
index -= line_end + 1;
line += 1;
}

View file

@ -598,7 +598,7 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
assert!(items.next().is_none(), "ExactSizeIterator under-reported length");
// We should have consumed the buffer exactly.
debug_assert!(current as *mut u8 == buffer.offset(size as isize));
debug_assert_eq!(current as *mut u8, buffer.offset(size as isize));
}
// Return the fat Arc.

View file

@ -21,7 +21,7 @@ gecko = ["nsstring", "num_cpus",
use_bindgen = ["bindgen", "regex", "toml"]
servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
"cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union",
"servo_url"]
"servo_url", "string_cache"]
gecko_debug = ["nsstring/gecko_debug"]
[dependencies]
@ -61,6 +61,7 @@ servo_atoms = {path = "../atoms", optional = true}
servo_config = {path = "../config", optional = true}
smallbitvec = "1.0.6"
smallvec = "0.6"
string_cache = { version = "0.7", optional = true }
style_derive = {path = "../style_derive"}
style_traits = {path = "../style_traits"}
servo_url = {path = "../url", optional = true}

View file

@ -472,7 +472,7 @@ impl<E: TElement> SequentialTask<E> {
/// Executes this task.
pub fn execute(self) {
use self::SequentialTask::*;
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
match self {
Unused(_) => unreachable!(),
#[cfg(feature = "gecko")]
@ -560,7 +560,7 @@ impl<E: TElement> SelectorFlagsMap<E> {
/// Applies the flags. Must be called on the main thread.
fn apply_flags(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
self.cache.evict_all();
for (el, flags) in self.map.drain() {
unsafe { el.set_selector_flags(flags); }
@ -598,7 +598,7 @@ where
E: TElement,
{
fn drop(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
for task in self.0.drain(..) {
task.execute()
}
@ -751,7 +751,7 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
impl<E: TElement> Drop for ThreadLocalStyleContext<E> {
fn drop(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
// Apply any slow selector flags that need to be set on parents.
self.selector_flags.apply_flags();

View file

@ -7,7 +7,7 @@
#![deny(missing_docs)]
use context::{StyleContext, ThreadLocalStyleContext, TraversalStatistics};
use context::{StyleContext, ThreadLocalStyleContext};
use dom::{SendNode, TElement, TNode};
use parallel;
use parallel::{DispatchMode, WORK_UNIT_MAX};
@ -33,7 +33,7 @@ pub fn traverse_dom<E, D>(
traversal: &D,
token: PreTraverseToken<E>,
pool: Option<&rayon::ThreadPool>
) -> (bool, Option<TraversalStatistics>)
)
where
E: TElement,
D: DomTraversal<E>,
@ -43,7 +43,6 @@ where
let dump_stats = traversal.shared_context().options.dump_style_statistics;
let is_nightly = traversal.shared_context().options.is_nightly();
let mut used_parallel = false;
let start_time = if dump_stats { Some(time::precise_time_s()) } else { None };
// Declare the main-thread context, as well as the worker-thread contexts,
@ -90,7 +89,6 @@ where
// moving to the next level in the dom so that we can pass the same
// depth for all the children.
if pool.is_some() && discovered.len() > WORK_UNIT_MAX {
used_parallel = true;
let pool = pool.unwrap();
maybe_tls = Some(ScopedTLS::<ThreadLocalStyleContext<E>>::new(pool));
let root_opaque = root.as_node().opaque();
@ -115,7 +113,6 @@ where
nodes_remaining_at_current_depth = discovered.len();
}
}
let mut maybe_stats = None;
// Accumulate statistics
if dump_stats || is_nightly {
let mut aggregate =
@ -136,8 +133,5 @@ where
aggregate.finish(traversal, parallel, start_time.unwrap());
println!("{}", aggregate);
}
maybe_stats = Some(aggregate);
}
(used_parallel, maybe_stats)
}

View file

@ -5,7 +5,6 @@
//! Data needed to style a Gecko document.
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use context::TraversalStatistics;
use dom::TElement;
use gecko_bindings::bindings::{self, RawServoStyleSet};
use gecko_bindings::structs::{RawGeckoPresContextOwned, ServoStyleSetSizes, ServoStyleSheet};
@ -18,7 +17,6 @@ use properties::ComputedValues;
use selector_parser::SnapshotMap;
use servo_arc::Arc;
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use std::sync::atomic::{AtomicUsize, Ordering};
use stylesheets::{StylesheetContents, StylesheetInDocument};
use stylist::Stylist;
@ -110,40 +108,11 @@ impl StylesheetInDocument for GeckoStyleSheet {
}
}
#[derive(Default)]
/// Helper struct for counting traversals
pub struct TraversalCount {
/// Total number of events
pub total_count: AtomicUsize,
/// Number of events which were parallel
pub parallel_count: AtomicUsize
}
impl TraversalCount {
fn record(&self, parallel: bool, count: u32) {
self.total_count.fetch_add(count as usize, Ordering::Relaxed);
if parallel {
self.parallel_count.fetch_add(count as usize, Ordering::Relaxed);
}
}
fn get(&self) -> (u32, u32) {
(self.total_count.load(Ordering::Relaxed) as u32,
self.parallel_count.load(Ordering::Relaxed) as u32)
}
}
/// The container for data that a Servo-backed Gecko document needs to style
/// itself.
pub struct PerDocumentStyleDataImpl {
/// Rule processor.
pub stylist: Stylist,
/// Counter for traversals that could have been parallel, for telemetry
pub traversal_count: TraversalCount,
/// Counter for traversals, weighted by elements traversed,
pub traversal_count_traversed: TraversalCount,
/// Counter for traversals, weighted by elements styled,
pub traversal_count_styled: TraversalCount,
}
/// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
@ -165,9 +134,6 @@ impl PerDocumentStyleData {
PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
stylist: Stylist::new(device, quirks_mode.into()),
traversal_count: Default::default(),
traversal_count_traversed: Default::default(),
traversal_count_styled: Default::default(),
}))
}
@ -187,13 +153,6 @@ impl Drop for PerDocumentStyleDataImpl {
if !structs::GECKO_IS_NIGHTLY {
return
}
let (total, parallel) = self.traversal_count.get();
let (total_t, parallel_t) = self.traversal_count_traversed.get();
let (total_s, parallel_s) = self.traversal_count_styled.get();
unsafe { bindings::Gecko_RecordTraversalStatistics(total, parallel,
total_t, parallel_t,
total_s, parallel_s) }
}
}
@ -261,15 +220,6 @@ impl PerDocumentStyleDataImpl {
pub fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) {
self.stylist.add_size_of(ops, sizes);
}
/// Record that a traversal happened for later collection as telemetry
pub fn record_traversal(&self, was_parallel: bool, stats: Option<TraversalStatistics>) {
self.traversal_count.record(was_parallel, 1);
if let Some(stats) = stats {
self.traversal_count_traversed.record(was_parallel, stats.elements_traversed);
self.traversal_count_styled.record(was_parallel, stats.elements_styled);
}
}
}
unsafe impl HasFFI for PerDocumentStyleData {

View file

@ -18,6 +18,7 @@ use gecko_bindings::structs::mozilla::dom::CallerType;
use gecko_bindings::structs::mozilla::AnonymousCounterStyle;
use gecko_bindings::structs::mozilla::AtomArray;
use gecko_bindings::structs::mozilla::MallocSizeOf;
use gecko_bindings::structs::mozilla::ServoStyleSet;
use gecko_bindings::structs::mozilla::OriginFlags;
use gecko_bindings::structs::mozilla::UniquePtr;
use gecko_bindings::structs::ServoRawOffsetArc;
@ -25,6 +26,7 @@ use gecko_bindings::structs::nsIContent;
use gecko_bindings::structs::nsIDocument;
use gecko_bindings::structs::nsIDocument_DocumentTheme;
use gecko_bindings::structs::nsSimpleContentList;
use gecko_bindings::structs::MediumFeaturesChangedResult;
use gecko_bindings::structs::RawGeckoAnimationPropertySegment;
use gecko_bindings::structs::RawGeckoComputedTiming;
use gecko_bindings::structs::RawGeckoCSSPropertyIDList;
@ -544,16 +546,6 @@ extern "C" {
extern "C" {
pub fn Servo_SourceSizeList_Drop(ptr: RawServoSourceSizeListOwned);
}
extern "C" {
pub fn Gecko_RecordTraversalStatistics(
total: u32,
parallel: u32,
total_t: u32,
parallel_t: u32,
total_s: u32,
parallel_s: u32,
);
}
extern "C" {
pub fn Gecko_IsSignificantChild(
node: RawGeckoNodeBorrowed,
@ -2097,15 +2089,10 @@ extern "C" {
}
extern "C" {
pub fn Servo_StyleSet_MediumFeaturesChanged(
set: RawServoStyleSetBorrowed,
viewport_units_used: *mut bool,
) -> u8;
}
extern "C" {
pub fn Servo_StyleSet_SetDevice(
set: RawServoStyleSetBorrowed,
pres_context: RawGeckoPresContextOwned,
) -> u8;
document_set: RawServoStyleSetBorrowed,
non_document_sets: *const nsTArray<*mut ServoStyleSet>,
may_affect_default_style: bool,
) -> MediumFeaturesChangedResult;
}
extern "C" {
pub fn Servo_StyleSet_CompatModeChanged(raw_data: RawServoStyleSetBorrowed);

View file

@ -1728,10 +1728,10 @@ impl ToCss for PseudoElement {
dest.write_char('(')?;
let mut iter = args.iter();
if let Some(first) = iter.next() {
serialize_identifier(&first.to_string(), dest)?;
serialize_atom_identifier(first, dest)?;
for item in iter {
dest.write_str(", ")?;
serialize_identifier(&item.to_string(), dest)?;
serialize_atom_identifier(item, dest)?;
}
}
dest.write_char(')')?;

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
use app_units::AU_PER_PX;
use app_units::Au;
use context::QuirksMode;
use cssparser::{CssStringWriter, Parser, RGBA, Token, BasicParseErrorKind};
use cssparser::{Parser, RGBA, Token, BasicParseErrorKind};
use euclid::Size2D;
use euclid::TypedScale;
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
@ -28,7 +28,7 @@ use style_traits::{CSSPixel, CssWriter, DevicePixel};
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
use style_traits::viewport::ViewportConstraints;
use stylesheets::Origin;
use values::{CSSFloat, CustomIdent, KeyframesName};
use values::{CSSFloat, CustomIdent, KeyframesName, serialize_atom_identifier};
use values::computed::{self, ToComputedValue};
use values::computed::font::FontSize;
use values::specified::{Integer, Length, Number};
@ -352,15 +352,11 @@ pub enum MediaExpressionValue {
/// feature's `mData` member.
Enumerated(i16),
/// An identifier.
///
/// TODO(emilio): Maybe atomize?
Ident(String),
Ident(Atom),
}
impl MediaExpressionValue {
fn from_css_value(for_expr: &Expression, css_value: &nsCSSValue) -> Option<Self> {
use gecko::conversions::string_from_chars_pointer;
// NB: If there's a null value, that means that we don't support the
// feature.
if css_value.mUnit == nsCSSUnit::eCSSUnit_Null {
@ -369,7 +365,7 @@ impl MediaExpressionValue {
match for_expr.feature.mValueType {
nsMediaFeature_ValueType::eLength => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Pixel);
let pixels = css_value.float_unchecked();
Some(MediaExpressionValue::Length(Length::from_px(pixels)))
}
@ -379,17 +375,17 @@ impl MediaExpressionValue {
Some(MediaExpressionValue::Integer(i as u32))
}
nsMediaFeature_ValueType::eFloat => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Number);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Number);
Some(MediaExpressionValue::Float(css_value.float_unchecked()))
}
nsMediaFeature_ValueType::eBoolInteger => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Integer);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Integer);
let i = css_value.integer_unchecked();
debug_assert!(i == 0 || i == 1);
Some(MediaExpressionValue::BoolInteger(i == 1))
}
nsMediaFeature_ValueType::eResolution => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Pixel);
Some(MediaExpressionValue::Resolution(Resolution::Dppx(css_value.float_unchecked())))
}
nsMediaFeature_ValueType::eEnumerated => {
@ -397,13 +393,10 @@ impl MediaExpressionValue {
Some(MediaExpressionValue::Enumerated(value))
}
nsMediaFeature_ValueType::eIdent => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Ident);
let string = unsafe {
let buffer = *css_value.mValue.mString.as_ref();
debug_assert!(!buffer.is_null());
string_from_chars_pointer(buffer.offset(1) as *const u16)
};
Some(MediaExpressionValue::Ident(string))
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_AtomIdent);
Some(MediaExpressionValue::Ident(Atom::from(unsafe {
*css_value.mValue.mAtom.as_ref()
})))
}
nsMediaFeature_ValueType::eIntRatio => {
let array = unsafe { css_value.array_unchecked() };
@ -436,7 +429,7 @@ impl MediaExpressionValue {
},
MediaExpressionValue::Resolution(ref r) => r.to_css(dest),
MediaExpressionValue::Ident(ref ident) => {
CssStringWriter::new(dest).write_str(ident)
serialize_atom_identifier(ident, dest)
}
MediaExpressionValue::Enumerated(value) => unsafe {
use std::{slice, str};
@ -561,7 +554,7 @@ fn parse_feature_value<'i, 't>(
MediaExpressionValue::Enumerated(value)
}
nsMediaFeature_ValueType::eIdent => {
MediaExpressionValue::Ident(input.expect_ident()?.as_ref().to_owned())
MediaExpressionValue::Ident(Atom::from(input.expect_ident()?.as_ref()))
}
};
@ -774,11 +767,11 @@ impl Expression {
one.to_dpi().partial_cmp(&actual_dpi).unwrap()
}
(&Ident(ref one), &Ident(ref other)) => {
debug_assert!(self.feature.mRangeType != nsMediaFeature_RangeType::eMinMaxAllowed);
debug_assert_ne!(self.feature.mRangeType, nsMediaFeature_RangeType::eMinMaxAllowed);
return one == other;
}
(&Enumerated(one), &Enumerated(other)) => {
debug_assert!(self.feature.mRangeType != nsMediaFeature_RangeType::eMinMaxAllowed);
debug_assert_ne!(self.feature.mRangeType, nsMediaFeature_RangeType::eMinMaxAllowed);
return one == other;
}
_ => unreachable!(),

View file

@ -8,13 +8,14 @@
//! `pseudo_element_definition.mako.rs`. If you touch that file, you probably
//! need to update the checked-in files for Servo.
use cssparser::{ToCss, serialize_identifier};
use cssparser::ToCss;
use gecko_bindings::structs::{self, CSSPseudoElementType};
use properties::{CascadeFlags, ComputedValues, PropertyFlags};
use properties::longhands::display::computed_value::T as Display;
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use std::fmt;
use string_cache::Atom;
use values::serialize_atom_identifier;
include!(concat!(env!("OUT_DIR"), "/gecko/pseudo_element_definition.rs"));

View file

@ -277,10 +277,10 @@ impl ToCss for PseudoElement {
dest.write_char('(')?;
let mut iter = args.iter();
if let Some(first) = iter.next() {
serialize_identifier(&first.to_string(), dest)?;
serialize_atom_identifier(&first, dest)?;
for item in iter {
dest.write_str(", ")?;
serialize_identifier(&item.to_string(), dest)?;
serialize_atom_identifier(item, dest)?;
}
}
dest.write_char(')')?;

View file

@ -16,8 +16,8 @@ use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataVa
use media_queries::Device;
use nsstring::{nsACString, nsCStr};
use std::cmp::max;
use values::{Auto, Either, ExtremumLength, None_, Normal};
use values::computed::{Angle, Length, LengthOrPercentage, LengthOrPercentageOrAuto};
use values::{Auto, Either, None_, Normal};
use values::computed::{Angle, ExtremumLength, Length, LengthOrPercentage, LengthOrPercentageOrAuto};
use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
use values::computed::{MaxLength, MozLength, Percentage};
use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber};

View file

@ -378,7 +378,7 @@ pub unsafe trait CoordDataMut : CoordData {
/// Gets the `Calc` value mutably, asserts in debug builds if the unit is
/// not `Calc`.
unsafe fn as_calc_mut(&mut self) -> &mut nsStyleCoord_Calc {
debug_assert!(self.unit() == nsStyleUnit::eStyleUnit_Calc);
debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
&mut *(*self.union().mPointer.as_mut() as *mut nsStyleCoord_Calc)
}
@ -451,7 +451,7 @@ pub unsafe trait CoordData {
/// Pretend inner value is a calc; obtain it.
/// Ensure that the unit is Calc before calling this.
unsafe fn get_calc_value(&self) -> nsStyleCoord_CalcValue {
debug_assert!(self.unit() == nsStyleUnit::eStyleUnit_Calc);
debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
(*self.as_calc())._base
}
@ -459,7 +459,7 @@ pub unsafe trait CoordData {
#[inline]
/// Pretend the inner value is a calc expression, and obtain it.
unsafe fn as_calc(&self) -> &nsStyleCoord_Calc {
debug_assert!(self.unit() == nsStyleUnit::eStyleUnit_Calc);
debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
&*(*self.union().mPointer.as_ref() as *const nsStyleCoord_Calc)
}
}

View file

@ -13,15 +13,14 @@ use gecko_bindings::bindings::Gecko_ReleaseAtom;
use gecko_bindings::structs::{nsAtom, nsAtom_AtomKind, nsStaticAtom};
use nsstring::{nsAString, nsStr};
use precomputed_hash::PrecomputedHash;
use std::{mem, slice, str};
#[allow(unused_imports)] use std::ascii::AsciiExt;
use std::borrow::{Cow, Borrow};
use std::char::{self, DecodeUtf16};
use std::fmt::{self, Write};
use std::hash::{Hash, Hasher};
use std::iter::Cloned;
use std::mem;
use std::ops::Deref;
use std::slice;
#[macro_use]
#[allow(improper_ctypes, non_camel_case_types, missing_docs)]
@ -128,21 +127,38 @@ impl WeakAtom {
/// Find alternatives to this function when possible, please, since it's
/// pretty slow.
pub fn with_str<F, Output>(&self, cb: F) -> Output
where F: FnOnce(&str) -> Output
where
F: FnOnce(&str) -> Output
{
// FIXME(bholley): We should measure whether it makes more sense to
// cache the UTF-8 version in the Gecko atom table somehow.
let owned = self.to_string();
cb(&owned)
}
let mut buffer: [u8; 64] = unsafe { mem::uninitialized() };
/// Convert this Atom into a string, decoding the UTF-16 bytes.
///
/// Find alternatives to this function when possible, please, since it's
/// pretty slow.
#[inline]
pub fn to_string(&self) -> String {
String::from_utf16(self.as_slice()).unwrap()
// The total string length in utf16 is going to be less than or equal
// the slice length (each utf16 character is going to take at least one
// and at most 2 items in the utf16 slice).
//
// Each of those characters will take at most four bytes in the utf8
// one. Thus if the slice is less than 64 / 4 (16) we can guarantee that
// we'll decode it in place.
let owned_string;
let len = self.len();
let utf8_slice = if len <= 16 {
let mut total_len = 0;
for c in self.chars() {
let c = c.unwrap_or(char::REPLACEMENT_CHARACTER);
let utf8_len = c.encode_utf8(&mut buffer[total_len..]).len();
total_len += utf8_len;
}
let slice = unsafe { str::from_utf8_unchecked(&buffer[..total_len]) };
debug_assert_eq!(slice, String::from_utf16_lossy(self.as_slice()));
slice
} else {
owned_string = String::from_utf16_lossy(self.as_slice());
&*owned_string
};
cb(utf8_slice)
}
/// Returns whether this atom is static.

View file

@ -68,6 +68,7 @@ pub extern crate servo_arc;
#[cfg(feature = "servo")] extern crate servo_url;
extern crate smallbitvec;
extern crate smallvec;
#[cfg(feature = "servo")] extern crate string_cache;
#[macro_use]
extern crate style_derive;
extern crate style_traits;

View file

@ -149,7 +149,6 @@ class Longhand(object):
predefined_type=None, servo_pref=None, gecko_pref=None,
enabled_in="content", need_index=False,
gecko_ffi_name=None,
is_gecko_size_type_hack=False,
allowed_in_keyframe_block=True, cast_type='u8',
logical=False, alias=None, extra_prefixes=None, boxed=False,
flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=False,
@ -186,7 +185,6 @@ class Longhand(object):
self.allow_quirks = allow_quirks
self.ignored_when_colors_disabled = ignored_when_colors_disabled
self.is_vector = vector
self.is_gecko_size_type_hack = is_gecko_size_type_hack
# https://drafts.csswg.org/css-animations/#keyframes
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property

View file

@ -1213,7 +1213,7 @@ fn clone_single_transform_function(
let convert_shared_list_to_operations = |value: &structs::nsCSSValue|
-> Vec<TransformOperation> {
debug_assert!(value.mUnit == structs::nsCSSUnit::eCSSUnit_SharedList);
debug_assert_eq!(value.mUnit, structs::nsCSSUnit::eCSSUnit_SharedList);
let value_list = unsafe {
value.mValue.mSharedList.as_ref()
.as_mut().expect("List pointer should be non-null").mHead.as_ref()
@ -1804,7 +1804,7 @@ fn static_assert() {
use gecko_bindings::structs::nsStyleUnit;
// z-index is never a calc(). If it were, we'd be leaking here, so
// assert that it isn't.
debug_assert!(self.gecko.mZIndex.unit() != nsStyleUnit::eStyleUnit_Calc);
debug_assert_ne!(self.gecko.mZIndex.unit(), nsStyleUnit::eStyleUnit_Calc);
unsafe {
self.gecko.mZIndex.copy_from_unchecked(&other.gecko.mZIndex);
}
@ -1837,7 +1837,7 @@ fn static_assert() {
}
pub fn set_computed_justify_items(&mut self, v: values::specified::JustifyItems) {
debug_assert!(v.0 != ::values::specified::align::AlignFlags::AUTO);
debug_assert_ne!(v.0, ::values::specified::align::AlignFlags::AUTO);
self.gecko.mJustifyItems = v.into();
}
@ -2885,7 +2885,7 @@ fn static_assert() {
I::IntoIter: ExactSizeIterator + Clone
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
self.gecko.m${type.capitalize()}s.ensure_len(input_len);
@ -2910,7 +2910,7 @@ fn static_assert() {
I::IntoIter: ExactSizeIterator + Clone
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
self.gecko.m${type.capitalize()}s.ensure_len(input_len);
@ -2966,7 +2966,7 @@ fn static_assert() {
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
self.gecko.mAnimations.ensure_len(input_len);
@ -3364,7 +3364,7 @@ fn static_assert() {
I::IntoIter: ExactSizeIterator
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
self.gecko.mAnimations.ensure_len(v.len());
self.gecko.mAnimationNameCount = v.len() as u32;
@ -3957,7 +3957,7 @@ fn static_assert() {
if ty == DimensionType::eAuto as u8 {
LengthOrPercentageOrAuto::Auto
} else {
debug_assert!(ty == DimensionType::eLengthPercentage as u8);
debug_assert_eq!(ty, DimensionType::eLengthPercentage as u8);
value.into()
}
}
@ -3965,11 +3965,11 @@ fn static_assert() {
longhands::background_size::computed_value::T(
self.gecko.${image_layers_field}.mLayers.iter().map(|ref layer| {
if DimensionType::eCover as u8 == layer.mSize.mWidthType {
debug_assert!(layer.mSize.mHeightType == DimensionType::eCover as u8);
debug_assert_eq!(layer.mSize.mHeightType, DimensionType::eCover as u8);
return BackgroundSize::Cover
}
if DimensionType::eContain as u8 == layer.mSize.mWidthType {
debug_assert!(layer.mSize.mHeightType == DimensionType::eContain as u8);
debug_assert_eq!(layer.mSize.mHeightType, DimensionType::eContain as u8);
return BackgroundSize::Contain
}
BackgroundSize::Explicit {
@ -4368,28 +4368,28 @@ fn static_assert() {
ClipRectOrAuto::auto()
} else {
let left = if self.gecko.mClipFlags & NS_STYLE_CLIP_LEFT_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.x == 0);
debug_assert_eq!(self.gecko.mClip.x, 0);
None
} else {
Some(Au(self.gecko.mClip.x).into())
};
let top = if self.gecko.mClipFlags & NS_STYLE_CLIP_TOP_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.y == 0);
debug_assert_eq!(self.gecko.mClip.y, 0);
None
} else {
Some(Au(self.gecko.mClip.y).into())
};
let bottom = if self.gecko.mClipFlags & NS_STYLE_CLIP_BOTTOM_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.height == 1 << 30); // NS_MAXSIZE
debug_assert_eq!(self.gecko.mClip.height, 1 << 30); // NS_MAXSIZE
None
} else {
Some(Au(self.gecko.mClip.y + self.gecko.mClip.height).into())
};
let right = if self.gecko.mClipFlags & NS_STYLE_CLIP_RIGHT_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.width == 1 << 30); // NS_MAXSIZE
debug_assert_eq!(self.gecko.mClip.width, 1 << 30); // NS_MAXSIZE
None
} else {
Some(Au(self.gecko.mClip.x + self.gecko.mClip.width).into())
@ -5459,8 +5459,7 @@ clip-path
}
pub fn set_content(&mut self, v: longhands::content::computed_value::T, device: &Device) {
use properties::longhands::content::computed_value::T;
use properties::longhands::content::computed_value::ContentItem;
use values::computed::counters::{Content, ContentItem};
use values::generics::CounterStyleOrNone;
use gecko_bindings::structs::nsStyleContentData;
use gecko_bindings::structs::nsStyleContentType;
@ -5494,8 +5493,8 @@ clip-path
}
match v {
T::None |
T::Normal => {
Content::None |
Content::Normal => {
// Ensure destructors run, otherwise we could leak.
if !self.gecko.mContents.is_empty() {
unsafe {
@ -5503,14 +5502,14 @@ clip-path
}
}
},
T::MozAltContent => {
Content::MozAltContent => {
unsafe {
Gecko_ClearAndResizeStyleContents(&mut self.gecko, 1);
*self.gecko.mContents[0].mContent.mString.as_mut() = ptr::null_mut();
}
self.gecko.mContents[0].mType = eStyleContentType_AltContent;
},
T::Items(items) => {
Content::Items(items) => {
unsafe {
Gecko_ClearAndResizeStyleContents(&mut self.gecko,
items.len() as u32);
@ -5522,8 +5521,8 @@ clip-path
unsafe {
*self.gecko.mContents[i].mContent.mString.as_mut() = ptr::null_mut();
}
match item {
ContentItem::String(value) => {
match *item {
ContentItem::String(ref value) => {
self.gecko.mContents[i].mType = eStyleContentType_String;
unsafe {
// NB: we share allocators, so doing this is fine.
@ -5531,17 +5530,18 @@ clip-path
as_utf16_and_forget(&value);
}
}
ContentItem::Attr(attr) => {
ContentItem::Attr(ref attr) => {
self.gecko.mContents[i].mType = eStyleContentType_Attr;
let s = if let Some((_, ns)) = attr.namespace {
format!("{}|{}", ns, attr.attribute)
} else {
attr.attribute.into()
};
unsafe {
// NB: we share allocators, so doing this is fine.
*self.gecko.mContents[i].mContent.mString.as_mut() =
as_utf16_and_forget(&s);
*self.gecko.mContents[i].mContent.mString.as_mut() = match attr.namespace {
Some((_, ns)) => {
as_utf16_and_forget(&format!("{}|{}", ns, attr.attribute))
},
None => {
as_utf16_and_forget(&attr.attribute)
}
};
}
}
ContentItem::OpenQuote
@ -5552,13 +5552,13 @@ clip-path
=> self.gecko.mContents[i].mType = eStyleContentType_NoOpenQuote,
ContentItem::NoCloseQuote
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
ContentItem::Counter(name, style) => {
ContentItem::Counter(ref name, ref style) => {
set_counter_function(&mut self.gecko.mContents[i],
eStyleContentType_Counter, &name, "", style, device);
eStyleContentType_Counter, &name, "", style.clone(), device);
}
ContentItem::Counters(name, sep, style) => {
ContentItem::Counters(ref name, ref sep, ref style) => {
set_counter_function(&mut self.gecko.mContents[i],
eStyleContentType_Counters, &name, &sep, style, device);
eStyleContentType_Counters, &name, &sep, style.clone(), device);
}
ContentItem::Url(ref url) => {
unsafe {
@ -5586,22 +5586,22 @@ clip-path
pub fn clone_content(&self) -> longhands::content::computed_value::T {
use gecko::conversions::string_from_chars_pointer;
use gecko_bindings::structs::nsStyleContentType::*;
use properties::longhands::content::computed_value::{T, ContentItem};
use values::computed::counters::{Content, ContentItem};
use values::Either;
use values::generics::CounterStyleOrNone;
use values::specified::url::SpecifiedUrl;
use values::specified::Attr;
if self.gecko.mContents.is_empty() {
return T::Normal;
return Content::Normal;
}
if self.gecko.mContents.len() == 1 &&
self.gecko.mContents[0].mType == eStyleContentType_AltContent {
return T::MozAltContent;
return Content::MozAltContent;
}
T::Items(
Content::Items(
self.gecko.mContents.iter().map(|gecko_content| {
match gecko_content.mType {
eStyleContentType_OpenQuote => ContentItem::OpenQuote,
@ -5611,7 +5611,7 @@ clip-path
eStyleContentType_String => {
let gecko_chars = unsafe { gecko_content.mContent.mString.as_ref() };
let string = unsafe { string_from_chars_pointer(*gecko_chars) };
ContentItem::String(string)
ContentItem::String(string.into_boxed_str())
},
eStyleContentType_Attr => {
let gecko_chars = unsafe { gecko_content.mContent.mString.as_ref() };
@ -5641,10 +5641,10 @@ clip-path
unreachable!("counter function shouldn't have single string type"),
};
if gecko_content.mType == eStyleContentType_Counter {
ContentItem::Counter(ident, style)
ContentItem::Counter(ident.into_boxed_str(), style)
} else {
let separator = gecko_function.mSeparator.to_string();
ContentItem::Counters(ident, separator, style)
ContentItem::Counters(ident.into_boxed_str(), separator.into_boxed_str(), style)
}
},
eStyleContentType_Image => {
@ -5659,7 +5659,7 @@ clip-path
},
_ => panic!("Found unexpected value in style struct for content property"),
}
}).collect()
}).collect::<Vec<_>>().into_boxed_slice()
)
}

View file

@ -303,7 +303,7 @@
DeclaredValue::Value(value)
},
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
debug_assert!(declaration.id == LonghandId::${property.camel_case});
debug_assert_eq!(declaration.id, LonghandId::${property.camel_case});
DeclaredValue::CSSWideKeyword(declaration.keyword)
},
PropertyDeclaration::WithVariables(..) => {
@ -894,116 +894,3 @@
return "nsCSSPropertyID::eCSSProperty_%s" % ident
%>
</%def>
// Define property that supports prefixed intrinsic size keyword values for gecko.
// E.g. -moz-max-content, -moz-min-content, etc.
//
// FIXME(emilio): This feels a lot like a huge hack, get rid of this.
<%def name="gecko_size_type(name, length_type, initial_value, logical, **kwargs)">
<%call expr="longhand(name,
predefined_type=length_type,
logical=logical,
is_gecko_size_type_hack=True,
**kwargs)">
% if not logical:
use values::specified::AllowQuirks;
% endif
use values::specified::${length_type};
pub mod computed_value {
pub type T = ::values::computed::${length_type};
}
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub struct SpecifiedValue(pub ${length_type});
% if length_type == "MozLength":
impl SpecifiedValue {
/// Returns the `auto` value.
pub fn auto() -> Self {
use values::specified::length::LengthOrPercentageOrAuto;
SpecifiedValue(MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto))
}
/// Returns a value representing a `0` length.
pub fn zero() -> Self {
use values::specified::length::LengthOrPercentageOrAuto;
SpecifiedValue(MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::zero()))
}
/// Returns a value representing a `0%` length.
pub fn zero_percent() -> Self {
use values::specified::length::LengthOrPercentageOrAuto;
SpecifiedValue(MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::zero_percent()))
}
}
% endif
#[inline]
pub fn get_initial_value() -> computed_value::T {
use values::computed::${length_type};
${length_type}::${initial_value}
}
impl Parse for SpecifiedValue {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<SpecifiedValue, ParseError<'i>> {
% if logical:
let ret = ${length_type}::parse(context, input);
% else:
let ret = ${length_type}::parse_quirky(context, input, AllowQuirks::Yes);
% endif
// Keyword values don't make sense in the block direction; don't parse them
% if "block" in name:
if let Ok(${length_type}::ExtremumLength(..)) = ret {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
% endif
ret.map(SpecifiedValue)
}
}
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<SpecifiedValue, ParseError<'i>> {
SpecifiedValue::parse(context, input)
}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
% if not logical or "block" in name:
use values::computed::${length_type};
% endif
let computed = self.0.to_computed_value(context);
// filter out keyword values in the block direction
% if logical:
% if "block" in name:
if let ${length_type}::ExtremumLength(..) = computed {
return get_initial_value()
}
% endif
% else:
if let ${length_type}::ExtremumLength(..) = computed {
<% is_height = "true" if "height" in name else "false" %>
if ${is_height} != context.builder.writing_mode.is_vertical() {
return get_initial_value()
}
}
% endif
computed
}
#[inline]
fn from_computed_value(computed: &computed_value::T) -> Self {
SpecifiedValue(ToComputedValue::from_computed_value(computed))
}
}
</%call>
</%def>

View file

@ -2871,25 +2871,6 @@ impl ToAnimatedZero for AnimatedFilter {
}
}
// FIXME(nox): This should be derived.
impl ComputeSquaredDistance for AnimatedFilter {
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
match (self, other) {
% for func in FILTER_FUNCTIONS:
(&Filter::${func}(ref this), &Filter::${func}(ref other)) => {
this.compute_squared_distance(other)
},
% endfor
% if product == "gecko":
(&Filter::DropShadow(ref this), &Filter::DropShadow(ref other)) => {
this.compute_squared_distance(other)
},
% endif
_ => Err(()),
}
}
}
impl Animate for AnimatedFilterList {
#[inline]
fn animate(

View file

@ -6,235 +6,12 @@
<% data.new_style_struct("Counters", inherited=False, gecko_name="Content") %>
<%helpers:longhand name="content" boxed="True" animation_value_type="discrete"
spec="https://drafts.csswg.org/css-content/#propdef-content">
#[cfg(feature = "gecko")]
use values::generics::CounterStyleOrNone;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl;
#[cfg(feature = "gecko")]
use values::specified::Attr;
#[cfg(feature = "servo")]
use super::list_style_type;
pub use self::computed_value::T as SpecifiedValue;
pub use self::computed_value::ContentItem;
pub mod computed_value {
use cssparser;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl;
#[cfg(feature = "servo")]
type CounterStyleType = super::super::list_style_type::computed_value::T;
#[cfg(feature = "gecko")]
type CounterStyleType = ::values::generics::CounterStyleOrNone;
#[cfg(feature = "gecko")]
use values::specified::Attr;
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)]
pub enum ContentItem {
/// Literal string content.
String(String),
/// `counter(name, style)`.
Counter(String, CounterStyleType),
/// `counters(name, separator, style)`.
Counters(String, String, CounterStyleType),
/// `open-quote`.
OpenQuote,
/// `close-quote`.
CloseQuote,
/// `no-open-quote`.
NoOpenQuote,
/// `no-close-quote`.
NoCloseQuote,
% if product == "gecko":
/// `attr([namespace? `|`]? ident)`
Attr(Attr),
/// `url(url)`
Url(SpecifiedUrl),
% endif
}
impl ToCss for ContentItem {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
match *self {
ContentItem::String(ref s) => s.to_css(dest),
ContentItem::Counter(ref s, ref counter_style) => {
dest.write_str("counter(")?;
cssparser::serialize_identifier(&**s, dest)?;
dest.write_str(", ")?;
counter_style.to_css(dest)?;
dest.write_str(")")
}
ContentItem::Counters(ref s, ref separator, ref counter_style) => {
dest.write_str("counters(")?;
cssparser::serialize_identifier(&**s, dest)?;
dest.write_str(", ")?;
separator.to_css(dest)?;
dest.write_str(", ")?;
counter_style.to_css(dest)?;
dest.write_str(")")
}
ContentItem::OpenQuote => dest.write_str("open-quote"),
ContentItem::CloseQuote => dest.write_str("close-quote"),
ContentItem::NoOpenQuote => dest.write_str("no-open-quote"),
ContentItem::NoCloseQuote => dest.write_str("no-close-quote"),
% if product == "gecko":
ContentItem::Attr(ref attr) => {
attr.to_css(dest)
}
ContentItem::Url(ref url) => url.to_css(dest),
% endif
}
}
}
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)]
pub enum T {
Normal,
None,
#[cfg(feature = "gecko")]
MozAltContent,
Items(Vec<ContentItem>),
}
impl ToCss for T {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
match *self {
T::Normal => dest.write_str("normal"),
T::None => dest.write_str("none"),
% if product == "gecko":
T::MozAltContent => dest.write_str("-moz-alt-content"),
% endif
T::Items(ref content) => {
let mut iter = content.iter();
iter.next().unwrap().to_css(dest)?;
for c in iter {
dest.write_str(" ")?;
c.to_css(dest)?;
}
Ok(())
}
}
}
}
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
computed_value::T::Normal
}
#[cfg(feature = "servo")]
fn parse_counter_style(context: &ParserContext, input: &mut Parser) -> list_style_type::computed_value::T {
input.try(|input| {
input.expect_comma()?;
list_style_type::parse(context, input)
}).unwrap_or(list_style_type::computed_value::T::Decimal)
}
#[cfg(feature = "gecko")]
fn parse_counter_style(context: &ParserContext, input: &mut Parser) -> CounterStyleOrNone {
input.try(|input| {
input.expect_comma()?;
CounterStyleOrNone::parse(context, input)
}).unwrap_or(CounterStyleOrNone::decimal())
}
// normal | none | [ <string> | <counter> | open-quote | close-quote | no-open-quote |
// no-close-quote ]+
// TODO: <uri>, attr(<identifier>)
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<SpecifiedValue, ParseError<'i>> {
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
return Ok(SpecifiedValue::Normal)
}
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
return Ok(SpecifiedValue::None)
}
% if product == "gecko":
if input.try(|input| input.expect_ident_matching("-moz-alt-content")).is_ok() {
return Ok(SpecifiedValue::MozAltContent)
}
% endif
let mut content = vec![];
loop {
% if product == "gecko":
if let Ok(mut url) = input.try(|i| SpecifiedUrl::parse(context, i)) {
url.build_image_value();
content.push(ContentItem::Url(url));
continue;
}
% endif
// FIXME: remove clone() when lifetimes are non-lexical
match input.next().map(|t| t.clone()) {
Ok(Token::QuotedString(ref value)) => {
content.push(ContentItem::String(value.as_ref().to_owned()))
}
Ok(Token::Function(ref name)) => {
let result = match_ignore_ascii_case! { &name,
"counter" => Some(input.parse_nested_block(|input| {
let name = input.expect_ident()?.as_ref().to_owned();
let style = parse_counter_style(context, input);
Ok(ContentItem::Counter(name, style))
})),
"counters" => Some(input.parse_nested_block(|input| {
let name = input.expect_ident()?.as_ref().to_owned();
input.expect_comma()?;
let separator = input.expect_string()?.as_ref().to_owned();
let style = parse_counter_style(context, input);
Ok(ContentItem::Counters(name, separator, style))
})),
% if product == "gecko":
"attr" => Some(input.parse_nested_block(|input| {
Ok(ContentItem::Attr(Attr::parse_function(context, input)?))
})),
% endif
_ => None
};
match result {
Some(result) => content.push(result?),
None => return Err(input.new_custom_error(
StyleParseErrorKind::UnexpectedFunction(name.clone())
))
}
}
Ok(Token::Ident(ref ident)) => {
let valid = match_ignore_ascii_case! { &ident,
"open-quote" => { content.push(ContentItem::OpenQuote); true },
"close-quote" => { content.push(ContentItem::CloseQuote); true },
"no-open-quote" => { content.push(ContentItem::NoOpenQuote); true },
"no-close-quote" => { content.push(ContentItem::NoCloseQuote); true },
_ => false,
};
if !valid {
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
}
}
Err(_) => break,
Ok(t) => return Err(input.new_unexpected_token_error(t))
}
}
if content.is_empty() {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
Ok(SpecifiedValue::Items(content))
}
</%helpers:longhand>
${helpers.predefined_type("content",
"Content",
"computed::Content::normal()",
initial_specified_value="specified::Content::normal()",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-content/#propdef-content")}
${helpers.predefined_type(
"counter-increment",

View file

@ -160,18 +160,21 @@ ${helpers.predefined_type("order", "Integer", "0",
animation_value_type="ComputedValue",
spec="https://drafts.csswg.org/css-flexbox/#order-property")}
// FIXME(emilio): All the sizes stuff, and the MozLength values should be
// unified with Servo, or at least be less hacky.
//
// The block direction ones don't even accept extremum lengths during parsing,
// and should be converted to just LengthOrPercentage.
% if product == "gecko":
// FIXME: Gecko doesn't support content value yet.
${helpers.gecko_size_type("flex-basis", "MozLength", "auto()",
logical=False,
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
extra_prefixes="webkit",
animation_value_type="MozLength")}
//
// FIXME(emilio): I suspect this property shouldn't allow quirks, and this
// was just a mistake, it's kind of justificable to support it given the
// spec grammar is just `content | <width>`, but other browsers don't...
${helpers.predefined_type(
"flex-basis",
"MozLength",
"computed::MozLength::auto()",
extra_prefixes="webkit",
animation_value_type="MozLength",
allow_quirks=True,
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property"
)}
% else:
// FIXME: This property should be animatable.
${helpers.predefined_type("flex-basis",
@ -183,29 +186,54 @@ ${helpers.predefined_type("order", "Integer", "0",
% endif
% for (size, logical) in ALL_SIZES:
<%
spec = "https://drafts.csswg.org/css-box/#propdef-%s"
if logical:
spec = "https://drafts.csswg.org/css-logical-props/#propdef-%s"
spec = "https://drafts.csswg.org/css-box/#propdef-%s"
if logical:
spec = "https://drafts.csswg.org/css-logical-props/#propdef-%s"
%>
// NOTE: Block-size doesn't support -moz-*-content keywords, since they make
// no sense on the block axis, but it simplifies things the have that it has
// the same type as the other properties, since otherwise we'd need to
// handle logical props where the types are different, which looks like a
// pain.
% if product == "gecko":
<%
parse_function = "parse" if size != "block-size" else "parse_disallow_keyword"
%>
// width, height, block-size, inline-size
${helpers.gecko_size_type("%s" % size, "MozLength", "auto()",
logical,
spec=spec % size,
animation_value_type="MozLength")}
${helpers.predefined_type(
size,
"MozLength",
"computed::MozLength::auto()",
parse_function,
logical=logical,
allow_quirks=not logical,
spec=spec % size,
animation_value_type="MozLength"
)}
// min-width, min-height, min-block-size, min-inline-size,
// max-width, max-height, max-block-size, max-inline-size
${helpers.gecko_size_type("min-%s" % size, "MozLength", "auto()",
logical,
spec=spec % size,
animation_value_type="MozLength")}
${helpers.gecko_size_type("max-%s" % size, "MaxLength", "none()",
logical,
spec=spec % size,
animation_value_type="MaxLength")}
${helpers.predefined_type(
"min-%s" % size,
"MozLength",
"computed::MozLength::auto()",
parse_function,
logical=logical,
allow_quirks=not logical,
spec=spec % size,
animation_value_type="MozLength"
)}
${helpers.predefined_type(
"max-%s" % size,
"MaxLength",
"computed::MaxLength::none()",
parse_function,
logical=logical,
allow_quirks=not logical,
spec=spec % size,
animation_value_type="MaxLength",
)}
% else:
// servo versions (no keyword support)
${helpers.predefined_type("%s" % size,
${helpers.predefined_type(size,
"LengthOrPercentageOrAuto",
"computed::LengthOrPercentageOrAuto::Auto",
"parse_non_negative",

View file

@ -208,7 +208,7 @@ pub mod animated_properties {
variants = []
for property in data.longhands:
if property.predefined_type and not property.is_vector and not property.is_gecko_size_type_hack:
if property.predefined_type and not property.is_vector:
ty = "::values::specified::{}".format(property.predefined_type)
else:
ty = "longhands::{}::SpecifiedValue".format(property.ident)

View file

@ -143,27 +143,14 @@
None
}
% endif
enum SerializeFor {
Normal,
% if product == "gecko":
Canvas,
% endif
}
impl<'a> LonghandsToSerialize<'a> {
fn to_css_for<W>(
&self,
serialize_for: SerializeFor,
dest: &mut CssWriter<W>,
) -> fmt::Result
where
W: Write,
{
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
% if product == "gecko":
match self.check_system() {
CheckSystemResult::AllSystem(sys) => return sys.to_css(dest),
CheckSystemResult::SomeSystem => return Ok(()),
CheckSystemResult::None => ()
CheckSystemResult::None => {}
}
% endif
@ -178,14 +165,7 @@
// In case of serialization for canvas font, we need to drop
// initial values of properties other than size and family.
% for name in "style variant_caps weight stretch".split():
let needs_this_property = match serialize_for {
SerializeFor::Normal => true,
% if product == "gecko":
SerializeFor::Canvas =>
self.font_${name} != &font_${name}::get_initial_specified_value(),
% endif
};
if needs_this_property {
if self.font_${name} != &font_${name}::get_initial_specified_value() {
self.font_${name}.to_css(dest)?;
dest.write_str(" ")?;
}
@ -203,45 +183,35 @@
Ok(())
}
% if product == "gecko":
/// Check if some or all members are system fonts
fn check_system(&self) -> CheckSystemResult {
let mut sys = None;
let mut all = true;
% for prop in SYSTEM_FONT_LONGHANDS:
if let Some(s) = self.${prop}.get_system() {
debug_assert!(sys.is_none() || s == sys.unwrap());
sys = Some(s);
} else {
all = false;
}
% endfor
if self.line_height != &LineHeight::normal() {
all = false
}
if all {
CheckSystemResult::AllSystem(sys.unwrap())
} else if sys.is_some() {
CheckSystemResult::SomeSystem
} else {
CheckSystemResult::None
}
}
/// Serialize the shorthand value for canvas font attribute.
pub fn to_css_for_canvas<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
self.to_css_for(SerializeFor::Canvas, dest)
}
% endif
}
// This may be a bit off, unsure, possibly needs changes
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
self.to_css_for(SerializeFor::Normal, dest)
impl<'a> LonghandsToSerialize<'a> {
% if product == "gecko":
/// Check if some or all members are system fonts
fn check_system(&self) -> CheckSystemResult {
let mut sys = None;
let mut all = true;
% for prop in SYSTEM_FONT_LONGHANDS:
if let Some(s) = self.${prop}.get_system() {
debug_assert!(sys.is_none() || s == sys.unwrap());
sys = Some(s);
} else {
all = false;
}
% endfor
if self.line_height != &LineHeight::normal() {
all = false
}
if all {
CheckSystemResult::AllSystem(sys.unwrap())
} else if sys.is_some() {
CheckSystemResult::SomeSystem
} else {
CheckSystemResult::None
}
}
% endif
}
</%helpers:shorthand>

View file

@ -55,7 +55,7 @@ impl Drop for RuleTree {
unsafe { self.gc(); }
// After the GC, the free list should be empty.
debug_assert!(self.root.get().next_free.load(Ordering::Relaxed) == FREE_LIST_SENTINEL);
debug_assert_eq!(self.root.get().next_free.load(Ordering::Relaxed), FREE_LIST_SENTINEL);
// Remove the sentinel. This indicates that GCs will no longer occur.
// Any further drops of StrongRuleNodes must occur on the main thread,
@ -846,7 +846,7 @@ malloc_size_of_is_0!(StrongRuleNode);
impl StrongRuleNode {
fn new(n: Box<RuleNode>) -> Self {
debug_assert!(n.parent.is_none() == !n.source.is_some());
debug_assert_eq!(n.parent.is_none(), !n.source.is_some());
let ptr = Box::into_raw(n);
log_new(ptr);
@ -1074,7 +1074,7 @@ impl StrongRuleNode {
me.free_count().store(0, Ordering::Relaxed);
debug_assert!(me.next_free.load(Ordering::Relaxed) == FREE_LIST_SENTINEL);
debug_assert_eq!(me.next_free.load(Ordering::Relaxed), FREE_LIST_SENTINEL);
}
unsafe fn maybe_gc(&self) {

View file

@ -8,7 +8,7 @@
use Atom;
use cssparser::{AtRuleParser, AtRuleType, BasicParseErrorKind, DeclarationListParser, DeclarationParser, Parser};
use cssparser::{CowRcStr, RuleListParser, SourceLocation, QualifiedRuleParser, Token, serialize_identifier};
use cssparser::{CowRcStr, RuleListParser, SourceLocation, QualifiedRuleParser, Token};
use error_reporting::{ContextualParseError, ParseErrorReporter};
#[cfg(feature = "gecko")]
use gecko_bindings::bindings::Gecko_AppendFeatureValueHashEntry;
@ -21,6 +21,7 @@ use str::CssStringWriter;
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use stylesheets::CssRuleType;
use values::computed::font::FamilyName;
use values::serialize_atom_identifier;
/// A @font-feature-values block declaration.
/// It is `<ident>: <integer>+`.
@ -41,7 +42,7 @@ impl<T: ToCss> ToCss for FFVDeclaration<T> {
where
W: Write,
{
serialize_identifier(&self.name.to_string(), dest)?;
serialize_atom_identifier(&self.name, dest)?;
dest.write_str(": ")?;
self.value.to_css(dest)?;
dest.write_str(";")

View file

@ -998,7 +998,7 @@ impl Stylist {
// Gecko calls this from sequential mode, so we can directly apply
// the flags.
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
let self_flags = flags.for_self();
if !self_flags.is_empty() {
unsafe { element.set_selector_flags(self_flags); }
@ -1089,9 +1089,6 @@ impl Stylist {
///
/// Also, the device that arrives here may need to take the viewport rules
/// into account.
///
/// For Gecko, this is called when XBL bindings are used by different
/// documents.
pub fn set_device(
&mut self,
mut device: Device,
@ -1119,14 +1116,22 @@ impl Stylist {
}
self.device = device;
self.media_features_change_changed_style(guards)
self.media_features_change_changed_style(guards, &self.device)
}
/// Returns whether, given a media feature change, any previously-applicable
/// style has become non-applicable, or vice-versa for each origin.
/// style has become non-applicable, or vice-versa for each origin, using
/// `device`.
///
/// Passing `device` is needed because this is used for XBL in Gecko, which
/// can be stale in various ways, so we need to pass the device of the
/// document itself, which is what is kept up-to-date.
///
/// Arguably XBL should use something more lightweight than a Stylist.
pub fn media_features_change_changed_style(
&self,
guards: &StylesheetGuards,
device: &Device,
) -> OriginSet {
debug!("Stylist::media_features_change_changed_style");
@ -1145,7 +1150,7 @@ impl Stylist {
let affected_changed = !origin_cascade_data.media_feature_affected_matches(
stylesheet,
guard,
&self.device,
device,
self.quirks_mode
);

View file

@ -4,11 +4,202 @@
//! Computed values for counter properties
#[cfg(feature = "servo")]
use computed_values::list_style_type::T as ListStyleType;
use cssparser::{self, Parser, Token};
use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseErrorKind;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
#[cfg(feature = "gecko")]
use values::generics::CounterStyleOrNone;
use values::generics::counters::CounterIncrement as GenericCounterIncrement;
use values::generics::counters::CounterReset as GenericCounterReset;
#[cfg(feature = "gecko")]
use values::specified::Attr;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl;
pub use values::specified::{Content, ContentItem};
/// A computed value for the `counter-increment` property.
pub type CounterIncrement = GenericCounterIncrement<i32>;
/// A computed value for the `counter-increment` property.
pub type CounterReset = GenericCounterReset<i32>;
impl Content {
/// Set `content` property to `normal`.
#[inline]
pub fn normal() -> Self {
Content::Normal
}
#[cfg(feature = "servo")]
fn parse_counter_style(
input: &mut Parser
) -> ListStyleType {
input.try(|input| {
input.expect_comma()?;
ListStyleType::parse(input)
}).unwrap_or(ListStyleType::Decimal)
}
#[cfg(feature = "gecko")]
fn parse_counter_style(
context: &ParserContext,
input: &mut Parser
) -> CounterStyleOrNone {
input.try(|input| {
input.expect_comma()?;
CounterStyleOrNone::parse(context, input)
}).unwrap_or(CounterStyleOrNone::decimal())
}
}
impl Parse for Content {
// normal | none | [ <string> | <counter> | open-quote | close-quote | no-open-quote |
// no-close-quote ]+
// TODO: <uri>, attr(<identifier>)
fn parse<'i, 't>(
_context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>> {
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
return Ok(Content::Normal);
}
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
return Ok(Content::None);
}
#[cfg(feature = "gecko")] {
if input.try(|input| input.expect_ident_matching("-moz-alt-content")).is_ok() {
return Ok(Content::MozAltContent);
}
}
let mut content = vec![];
loop {
#[cfg(feature = "gecko")] {
if let Ok(mut url) = input.try(|i| SpecifiedUrl::parse(_context, i)) {
url.build_image_value();
content.push(ContentItem::Url(url));
continue;
}
}
// FIXME: remove clone() when lifetimes are non-lexical
match input.next().map(|t| t.clone()) {
Ok(Token::QuotedString(ref value)) => {
content.push(ContentItem::String(value.as_ref().to_owned().into_boxed_str()));
}
Ok(Token::Function(ref name)) => {
let result = match_ignore_ascii_case! { &name,
"counter" => Some(input.parse_nested_block(|input| {
let name = input.expect_ident()?.as_ref().to_owned().into_boxed_str();
#[cfg(feature = "servo")]
let style = Content::parse_counter_style(input);
#[cfg(feature = "gecko")]
let style = Content::parse_counter_style(_context, input);
Ok(ContentItem::Counter(name, style))
})),
"counters" => Some(input.parse_nested_block(|input| {
let name = input.expect_ident()?.as_ref().to_owned().into_boxed_str();
input.expect_comma()?;
let separator = input.expect_string()?.as_ref().to_owned().into_boxed_str();
#[cfg(feature = "servo")]
let style = Content::parse_counter_style(input);
#[cfg(feature = "gecko")]
let style = Content::parse_counter_style(_context, input);
Ok(ContentItem::Counters(name, separator, style))
})),
#[cfg(feature = "gecko")]
"attr" => Some(input.parse_nested_block(|input| {
Ok(ContentItem::Attr(Attr::parse_function(_context, input)?))
})),
_ => None
};
match result {
Some(result) => content.push(result?),
None => return Err(input.new_custom_error(
StyleParseErrorKind::UnexpectedFunction(name.clone())
))
}
}
Ok(Token::Ident(ref ident)) => {
content.push(
match_ignore_ascii_case! { &ident,
"open-quote" => ContentItem::OpenQuote,
"close-quote" => ContentItem::CloseQuote,
"no-open-quote" => ContentItem::NoOpenQuote,
"no-close-quote" => ContentItem::NoCloseQuote,
_ => return Err(input.new_custom_error(
SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
}
);
}
Err(_) => break,
Ok(t) => return Err(input.new_unexpected_token_error(t))
}
}
if content.is_empty() {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
Ok(Content::Items(content.into_boxed_slice()))
}
}
impl ToCss for Content {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where W: Write,
{
match *self {
Content::Normal => dest.write_str("normal"),
Content::None => dest.write_str("none"),
#[cfg(feature = "gecko")]
Content::MozAltContent => dest.write_str("-moz-alt-content"),
Content::Items(ref content) => {
let mut iter = content.iter();
iter.next().unwrap().to_css(dest)?;
for c in iter {
dest.write_str(" ")?;
c.to_css(dest)?;
}
Ok(())
}
}
}
}
impl ToCss for ContentItem {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where W: Write,
{
match *self {
ContentItem::String(ref s) => s.to_css(dest),
ContentItem::Counter(ref s, ref counter_style) => {
dest.write_str("counter(")?;
cssparser::serialize_identifier(&**s, dest)?;
dest.write_str(", ")?;
counter_style.to_css(dest)?;
dest.write_str(")")
}
ContentItem::Counters(ref s, ref separator, ref counter_style) => {
dest.write_str("counters(")?;
cssparser::serialize_identifier(&**s, dest)?;
dest.write_str(", ")?;
separator.to_css(dest)?;
dest.write_str(", ")?;
counter_style.to_css(dest)?;
dest.write_str(")")
}
ContentItem::OpenQuote => dest.write_str("open-quote"),
ContentItem::CloseQuote => dest.write_str("close-quote"),
ContentItem::NoOpenQuote => dest.write_str("no-open-quote"),
ContentItem::NoCloseQuote => dest.write_str("no-close-quote"),
#[cfg(feature = "gecko")]
ContentItem::Attr(ref attr) => {
attr.to_css(dest)
}
#[cfg(feature = "gecko")]
ContentItem::Url(ref url) => url.to_css(dest),
}
}
}

View file

@ -461,6 +461,7 @@ impl SingleFontFamily {
/// Get the corresponding font-family with family name
fn from_font_family_name(family: &structs::FontFamilyName) -> SingleFontFamily {
use gecko_bindings::structs::FontFamilyType;
use values::serialize_atom_identifier;
match family.mType {
FontFamilyType::eFamily_sans_serif => SingleFontFamily::Generic(atom!("sans-serif")),
@ -472,7 +473,7 @@ impl SingleFontFamily {
FontFamilyType::eFamily_named => {
let name = Atom::from(&*family.mName);
let mut serialization = String::new();
serialize_identifier(&name.to_string(), &mut serialization).unwrap();
serialize_atom_identifier(&name, &mut serialization).unwrap();
SingleFontFamily::FamilyName(FamilyName {
name: name.clone(),
syntax: FamilyNameSyntax::Identifiers(serialization),

View file

@ -5,13 +5,15 @@
//! `<length>` computed values, and related ones.
use app_units::Au;
use logical_geometry::WritingMode;
use ordered_float::NotNaN;
use properties::LonghandId;
use std::fmt::{self, Write};
use std::ops::{Add, Neg};
use style_traits::{CssWriter, ToCss};
use style_traits::values::specified::AllowedNumericType;
use super::{Number, ToComputedValue, Context, Percentage};
use values::{Auto, CSSFloat, Either, ExtremumLength, None_, Normal, specified};
use values::{Auto, CSSFloat, Either, None_, Normal, specified};
use values::animated::{Animate, Procedure, ToAnimatedZero};
use values::computed::NonNegativeNumber;
use values::distance::{ComputeSquaredDistance, SquaredDistance};
@ -874,7 +876,58 @@ pub type NonNegativeLengthOrNormal = Either<NonNegativeLength, Normal>;
/// Either a computed NonNegativeLength or a NonNegativeNumber value.
pub type NonNegativeLengthOrNumber = Either<NonNegativeLength, NonNegativeNumber>;
/// A value suitable for a `min-width`, `min-height`, `width` or `height` property.
/// A type for possible values for min- and max- flavors of width, height,
/// block-size, and inline-size.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
pub enum ExtremumLength {
MozMaxContent,
MozMinContent,
MozFitContent,
MozAvailable,
}
impl ExtremumLength {
/// Returns whether this size keyword can be used for the given writing-mode
/// and property.
///
/// TODO: After these values are supported for both axes (and maybe
/// unprefixed, see bug 1322780) all this complexity can go away, and
/// everything can be derived (no need for uncacheable stuff).
fn valid_for(&self, wm: WritingMode, longhand: LonghandId) -> bool {
// We only make sense on the inline axis.
match longhand {
// FIXME(emilio): The flex-basis thing is not quite clear...
LonghandId::FlexBasis |
LonghandId::MinWidth |
LonghandId::MaxWidth |
LonghandId::Width => !wm.is_vertical(),
LonghandId::MinHeight |
LonghandId::MaxHeight |
LonghandId::Height => wm.is_vertical(),
LonghandId::MinInlineSize |
LonghandId::MaxInlineSize |
LonghandId::InlineSize => true,
// The block-* properties are rejected at parse-time, so they're
// unexpected here.
_ => {
debug_assert!(
false,
"Unexpected property using ExtremumLength: {:?}",
longhand,
);
false
}
}
}
}
/// A value suitable for a `min-width`, `min-height`, `width` or `height`
/// property.
///
/// See values/specified/length.rs for more details.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
@ -888,6 +941,7 @@ pub enum MozLength {
impl MozLength {
/// Returns the `auto` value.
#[inline]
pub fn auto() -> Self {
MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)
}
@ -898,16 +952,22 @@ impl ToComputedValue for specified::MozLength {
#[inline]
fn to_computed_value(&self, context: &Context) -> MozLength {
debug_assert!(
context.for_non_inherited_property.is_some(),
"Someone added a MozLength to an inherited property? Evil!"
);
match *self {
specified::MozLength::LengthOrPercentageOrAuto(ref lopoa) => {
MozLength::LengthOrPercentageOrAuto(lopoa.to_computed_value(context))
}
specified::MozLength::ExtremumLength(ref ext) => {
debug_assert!(context.for_non_inherited_property.is_some(),
"should check whether we're a non-inherited property");
specified::MozLength::ExtremumLength(ext) => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
MozLength::ExtremumLength(ext.clone())
if !ext.valid_for(context.builder.writing_mode, context.for_non_inherited_property.unwrap()) {
MozLength::auto()
} else {
MozLength::ExtremumLength(ext)
}
}
}
}
@ -915,11 +975,14 @@ impl ToComputedValue for specified::MozLength {
#[inline]
fn from_computed_value(computed: &MozLength) -> Self {
match *computed {
MozLength::LengthOrPercentageOrAuto(ref lopoa) =>
MozLength::LengthOrPercentageOrAuto(ref lopoa) => {
specified::MozLength::LengthOrPercentageOrAuto(
specified::LengthOrPercentageOrAuto::from_computed_value(&lopoa)),
MozLength::ExtremumLength(ref ext) =>
specified::MozLength::ExtremumLength(ext.clone()),
specified::LengthOrPercentageOrAuto::from_computed_value(lopoa)
)
},
MozLength::ExtremumLength(ext) => {
specified::MozLength::ExtremumLength(ext)
}
}
}
}
@ -937,21 +1000,33 @@ pub enum MaxLength {
impl MaxLength {
/// Returns the `none` value.
#[inline]
pub fn none() -> Self {
MaxLength::LengthOrPercentageOrNone(LengthOrPercentageOrNone::None)
}
}
impl ToComputedValue for specified::MaxLength {
type ComputedValue = MaxLength;
#[inline]
fn to_computed_value(&self, context: &Context) -> MaxLength {
debug_assert!(
context.for_non_inherited_property.is_some(),
"Someone added a MaxLength to an inherited property? Evil!"
);
match *self {
specified::MaxLength::LengthOrPercentageOrNone(ref lopon) => {
MaxLength::LengthOrPercentageOrNone(lopon.to_computed_value(context))
}
specified::MaxLength::ExtremumLength(ref ext) => {
MaxLength::ExtremumLength(ext.clone())
specified::MaxLength::ExtremumLength(ext) => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
if !ext.valid_for(context.builder.writing_mode, context.for_non_inherited_property.unwrap()) {
MaxLength::none()
} else {
MaxLength::ExtremumLength(ext)
}
}
}
}

View file

@ -4,7 +4,9 @@
//! Computed values.
use {Atom, Namespace};
use Atom;
#[cfg(feature = "servo")]
use Prefix;
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontMetricsProvider, get_metrics_provider_for_product};
@ -46,7 +48,7 @@ pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier,
pub use self::box_::{AnimationIterationCount, AnimationName, Display, OverscrollBehavior, Contain};
pub use self::box_::{OverflowClipBox, ScrollSnapType, TouchAction, VerticalAlign, WillChange};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::counters::{CounterIncrement, CounterReset};
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset};
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
pub use self::flex::FlexBasis;
pub use self::image::{Gradient, GradientItem, Image, ImageLayer, LineDirection, MozImageRect};
@ -58,7 +60,7 @@ pub use super::{Auto, Either, None_};
pub use super::specified::{BorderStyle, TextDecorationLine};
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNone, LengthOrNumber, LengthOrPercentage};
pub use self::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
pub use self::length::{CSSPixelLength, NonNegativeLength, NonNegativeLengthOrPercentage};
pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength, NonNegativeLengthOrPercentage};
pub use self::list::{ListStyleImage, Quotes};
#[cfg(feature = "gecko")]
pub use self::list::ListStyleType;
@ -414,7 +416,8 @@ trivial_to_computed_value!(u32);
trivial_to_computed_value!(Atom);
trivial_to_computed_value!(BorderStyle);
trivial_to_computed_value!(CursorKind);
trivial_to_computed_value!(Namespace);
#[cfg(feature = "servo")]
trivial_to_computed_value!(Prefix);
trivial_to_computed_value!(String);
trivial_to_computed_value!(Box<str>);

View file

@ -71,7 +71,7 @@ impl ToCss for TextOverflow {
W: Write,
{
if self.sides_are_logical {
debug_assert!(self.first == TextOverflowSide::Clip);
debug_assert_eq!(self.first, TextOverflowSide::Clip);
self.second.to_css(dest)?;
} else {
self.first.to_css(dest)?;

View file

@ -24,7 +24,8 @@ pub struct BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
/// A generic value for a single `filter`.
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)]
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
#[derive(ToAnimatedValue, ToComputedValue, ToCss)]
pub enum Filter<Angle, Factor, Length, DropShadow> {
/// `blur(<length>)`
#[css(function)]
@ -57,6 +58,7 @@ pub enum Filter<Angle, Factor, Length, DropShadow> {
#[css(function)]
DropShadow(DropShadow),
/// `<url>`
#[animation(error)]
#[cfg(feature = "gecko")]
Url(SpecifiedUrl),
}

View file

@ -7,11 +7,11 @@
//! [images]: https://drafts.csswg.org/css-images/#image-values
use Atom;
use cssparser::serialize_identifier;
use custom_properties;
use servo_arc::Arc;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};
use values::serialize_atom_identifier;
/// An [image].
///
@ -151,7 +151,7 @@ impl ToCss for PaintWorklet {
W: Write,
{
dest.write_str("paint(")?;
serialize_identifier(&*self.name.to_string(), dest)?;
serialize_atom_identifier(&self.name, dest)?;
for argument in &self.arguments {
dest.write_str(", ")?;
argument.to_css(dest)?;
@ -200,7 +200,7 @@ impl<G, R, U> ToCss for Image<G, R, U>
Image::PaintWorklet(ref paint_worklet) => paint_worklet.to_css(dest),
Image::Element(ref selector) => {
dest.write_str("-moz-element(#")?;
serialize_identifier(&selector.to_string(), dest)?;
serialize_atom_identifier(selector, dest)?;
dest.write_str(")")
},
}

View file

@ -16,6 +16,7 @@ use selectors::parser::SelectorParseErrorKind;
use std::fmt::{self, Debug, Write};
use std::hash;
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
pub mod animated;
pub mod computed;
@ -33,6 +34,25 @@ define_keyword_type!(None_, "none");
define_keyword_type!(Auto, "auto");
define_keyword_type!(Normal, "normal");
/// Serialize an identifier which is represented as an atom.
#[cfg(feature = "gecko")]
pub fn serialize_atom_identifier<W>(ident: &Atom, dest: &mut W) -> fmt::Result
where
W: Write,
{
ident.with_str(|s| serialize_identifier(s, dest))
}
/// Serialize an identifier which is represented as an atom.
#[cfg(feature = "servo")]
pub fn serialize_atom_identifier<Static, W>(ident: &::string_cache::Atom<Static>, dest: &mut W) -> fmt::Result
where
Static: ::string_cache::StaticAtomSet,
W: Write,
{
serialize_identifier(&ident, dest)
}
/// Serialize a normalized value into percentage.
pub fn serialize_percentage<W>(value: CSSFloat, dest: &mut CssWriter<W>) -> fmt::Result
where
@ -47,6 +67,18 @@ where
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
pub enum Impossible {}
// FIXME(nox): This should be derived but the derive code cannot cope
// with uninhabited enums.
impl ComputeSquaredDistance for Impossible {
#[inline]
fn compute_squared_distance(
&self,
_other: &Self,
) -> Result<SquaredDistance, ()> {
match *self {}
}
}
impl Parse for Impossible {
fn parse<'i, 't>(
_context: &ParserContext,
@ -114,7 +146,7 @@ impl ToCss for CustomIdent {
where
W: Write,
{
serialize_identifier(&self.0.to_string(), dest)
serialize_atom_identifier(&self.0, dest)
}
}
@ -195,14 +227,3 @@ impl ToCss for KeyframesName {
}
}
/// A type for possible values for min- and max- flavors of width,
/// height, block-size, and inline-size.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
pub enum ExtremumLength {
MozMaxContent,
MozMinContent,
MozFitContent,
MozAvailable,
}

View file

@ -315,7 +315,7 @@ impl Color {
if let Some(unit) = unit {
written += (&mut serialization[written..]).write(unit.as_bytes()).unwrap();
}
debug_assert!(written == 6);
debug_assert_eq!(written, 6);
parse_hash_color(&serialization).map_err(|()| {
location.new_custom_error(StyleParseErrorKind::UnspecifiedError)
})

View file

@ -4,13 +4,21 @@
//! Specified types for counter properties.
#[cfg(feature = "servo")]
use computed_values::list_style_type::T as ListStyleType;
use cssparser::{Token, Parser};
use parser::{Parse, ParserContext};
use style_traits::{ParseError, StyleParseErrorKind};
use values::CustomIdent;
#[cfg(feature = "gecko")]
use values::generics::CounterStyleOrNone;
use values::generics::counters::CounterIncrement as GenericCounterIncrement;
use values::generics::counters::CounterReset as GenericCounterReset;
#[cfg(feature = "gecko")]
use values::specified::Attr;
use values::specified::Integer;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl;
/// A specified value for the `counter-increment` property.
pub type CounterIncrement = GenericCounterIncrement<Integer>;
@ -65,3 +73,49 @@ fn parse_counters<'i, 't>(
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
}
#[cfg(feature = "servo")]
type CounterStyleType = ListStyleType;
#[cfg(feature = "gecko")]
type CounterStyleType = CounterStyleOrNone;
/// The specified value for the `content` property.
///
/// https://drafts.csswg.org/css-content/#propdef-content
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)]
pub enum Content {
/// `normal` reserved keyword.
Normal,
/// `none` reserved keyword.
None,
/// `-moz-alt-content`.
#[cfg(feature = "gecko")]
MozAltContent,
/// Content items.
Items(Box<[ContentItem]>),
}
/// Items for the `content` property.
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)]
pub enum ContentItem {
/// Literal string content.
String(Box<str>),
/// `counter(name, style)`.
Counter(Box<str>, CounterStyleType),
/// `counters(name, separator, style)`.
Counters(Box<str>, Box<str>, CounterStyleType),
/// `open-quote`.
OpenQuote,
/// `close-quote`.
CloseQuote,
/// `no-open-quote`.
NoOpenQuote,
/// `no-close-quote`.
NoCloseQuote,
/// `attr([namespace? `|`]? ident)`
#[cfg(feature = "gecko")]
Attr(Attr),
/// `url(url)`
#[cfg(feature = "gecko")]
Url(SpecifiedUrl),
}

View file

@ -165,9 +165,10 @@ impl From<LengthOrPercentage> for FontSize {
}
/// Specifies a prioritized list of font family names or generic family names.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, ToCss)]
pub enum FontFamily {
/// List of `font-family`
#[css(iterable, comma)]
Values(FontFamilyList),
/// System font
System(SystemFont),
@ -245,26 +246,6 @@ impl MallocSizeOf for FontFamily {
}
}
impl ToCss for FontFamily {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
match *self {
FontFamily::Values(ref v) => {
let mut iter = v.iter();
iter.next().unwrap().to_css(dest)?;
for family in iter {
dest.write_str(", ")?;
family.to_css(dest)?;
}
Ok(())
}
FontFamily::System(sys) => sys.to_css(dest),
}
}
}
impl Parse for FontFamily {
/// <family-name>#
/// <family-name> = <string> | [ <ident>+ ]

View file

@ -18,8 +18,8 @@ use style_traits::{ParseError, StyleParseErrorKind};
use style_traits::values::specified::AllowedNumericType;
use stylesheets::CssRuleType;
use super::{AllowQuirks, Number, ToComputedValue, Percentage};
use values::{Auto, CSSFloat, Either, ExtremumLength, None_, Normal};
use values::computed::{self, CSSPixelLength, Context};
use values::{Auto, CSSFloat, Either, None_, Normal};
use values::computed::{self, CSSPixelLength, Context, ExtremumLength};
use values::generics::NonNegative;
use values::specified::NonNegativeNumber;
use values::specified::calc::CalcNode;
@ -933,6 +933,7 @@ impl LengthOrPercentageOrAuto {
}
/// Returns a value representing `0%`.
#[inline]
pub fn zero_percent() -> Self {
LengthOrPercentageOrAuto::Percentage(computed::Percentage::zero())
}
@ -1125,15 +1126,45 @@ impl Parse for MozLength {
}
impl MozLength {
/// Parses, without quirks, and disallowing ExtremumLength values.
///
/// Used for logical props in the block direction.
pub fn parse_disallow_keyword<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let length = LengthOrPercentageOrAuto::parse_non_negative(context, input)?;
Ok(MozLength::LengthOrPercentageOrAuto(length))
}
/// Parses, with quirks.
pub fn parse_quirky<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
input.try(ExtremumLength::parse).map(MozLength::ExtremumLength)
.or_else(|_| input.try(|i| LengthOrPercentageOrAuto::parse_non_negative_quirky(context, i, allow_quirks))
.map(MozLength::LengthOrPercentageOrAuto))
if let Ok(l) = input.try(ExtremumLength::parse) {
return Ok(MozLength::ExtremumLength(l));
}
let length = LengthOrPercentageOrAuto::parse_non_negative_quirky(
context,
input,
allow_quirks,
)?;
Ok(MozLength::LengthOrPercentageOrAuto(length))
}
/// Returns `auto`.
#[inline]
pub fn auto() -> Self {
MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::auto())
}
/// Returns `0%`.
#[inline]
pub fn zero_percent() -> Self {
MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::zero_percent())
}
}
@ -1152,14 +1183,32 @@ impl Parse for MaxLength {
}
impl MaxLength {
/// Parses, without quirks, and disallowing ExtremumLength values.
///
/// Used for logical props in the block direction.
pub fn parse_disallow_keyword<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let length = LengthOrPercentageOrNone::parse_non_negative(context, input)?;
Ok(MaxLength::LengthOrPercentageOrNone(length))
}
/// Parses, with quirks.
pub fn parse_quirky<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
input.try(ExtremumLength::parse).map(MaxLength::ExtremumLength)
.or_else(|_| input.try(|i| LengthOrPercentageOrNone::parse_non_negative_quirky(context, i, allow_quirks))
.map(MaxLength::LengthOrPercentageOrNone))
if let Ok(l) = input.try(ExtremumLength::parse) {
return Ok(MaxLength::ExtremumLength(l));
}
let length = LengthOrPercentageOrNone::parse_non_negative_quirky(
context,
input,
allow_quirks,
)?;
Ok(MaxLength::LengthOrPercentageOrNone(length))
}
}

Some files were not shown because too many files have changed in this diff Show more