mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto-generate 'image-rendering' using 'single_keyword'
This commit is contained in:
parent
12f429e23b
commit
e7cbd10ece
4 changed files with 11 additions and 80 deletions
|
@ -223,7 +223,7 @@ impl<'a> PaintContext<'a> {
|
||||||
// Something like Scale2x would be ideal.
|
// Something like Scale2x would be ideal.
|
||||||
let draw_surface_filter = match image_rendering {
|
let draw_surface_filter = match image_rendering {
|
||||||
image_rendering::T::auto => Filter::Linear,
|
image_rendering::T::auto => Filter::Linear,
|
||||||
image_rendering::T::crispedges | image_rendering::T::pixelated => Filter::Point,
|
image_rendering::T::crisp_edges | image_rendering::T::pixelated => Filter::Point,
|
||||||
};
|
};
|
||||||
|
|
||||||
let draw_surface_options = DrawSurfaceOptions::new(draw_surface_filter, true);
|
let draw_surface_options = DrawSurfaceOptions::new(draw_surface_filter, true);
|
||||||
|
|
|
@ -213,7 +213,7 @@ trait ToImageRendering {
|
||||||
impl ToImageRendering for image_rendering::T {
|
impl ToImageRendering for image_rendering::T {
|
||||||
fn to_image_rendering(&self) -> webrender_traits::ImageRendering {
|
fn to_image_rendering(&self) -> webrender_traits::ImageRendering {
|
||||||
match *self {
|
match *self {
|
||||||
image_rendering::T::crispedges => webrender_traits::ImageRendering::CrispEdges,
|
image_rendering::T::crisp_edges => webrender_traits::ImageRendering::CrispEdges,
|
||||||
image_rendering::T::auto => webrender_traits::ImageRendering::Auto,
|
image_rendering::T::auto => webrender_traits::ImageRendering::Auto,
|
||||||
image_rendering::T::pixelated => webrender_traits::ImageRendering::Pixelated,
|
image_rendering::T::pixelated => webrender_traits::ImageRendering::Pixelated,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1625,17 +1625,6 @@ fn static_assert() {
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
|
||||||
<%self:impl_trait style_struct_name="InheritedBox"
|
|
||||||
skip_longhands="image-rendering">
|
|
||||||
|
|
||||||
<% render_keyword = Keyword("image-rendering",
|
|
||||||
"auto optimizequality optimizespeed crispedges") %>
|
|
||||||
|
|
||||||
${impl_keyword('image_rendering', 'mImageRendering', render_keyword, need_clone=False)}
|
|
||||||
|
|
||||||
</%self:impl_trait>
|
|
||||||
|
|
||||||
|
|
||||||
<%self:impl_trait style_struct_name="InheritedText"
|
<%self:impl_trait style_struct_name="InheritedText"
|
||||||
skip_longhands="text-align text-emphasis-style text-shadow line-height letter-spacing word-spacing">
|
skip_longhands="text-align text-emphasis-style text-shadow line-height letter-spacing word-spacing">
|
||||||
|
|
||||||
|
|
|
@ -40,73 +40,15 @@ ${helpers.single_keyword("color-adjust",
|
||||||
"economy exact", products="gecko",
|
"economy exact", products="gecko",
|
||||||
animatable=False)}
|
animatable=False)}
|
||||||
|
|
||||||
<%helpers:longhand name="image-rendering" animatable="False">
|
<% image_rendering_custom_consts = { "crisp-edges": "CRISPEDGES" } %>
|
||||||
pub mod computed_value {
|
// According to to CSS-IMAGES-3, `optimizespeed` and `optimizequality` are synonyms for `auto`
|
||||||
use cssparser::ToCss;
|
// And, firefox doesn't support `pixelated` yet (https://bugzilla.mozilla.org/show_bug.cgi?id=856337)
|
||||||
use std::fmt;
|
${helpers.single_keyword("image-rendering",
|
||||||
|
"auto crisp-edges",
|
||||||
#[allow(non_camel_case_types)]
|
extra_gecko_values="optimizespeed optimizequality",
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
extra_servo_values="pixelated",
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
custom_consts=image_rendering_custom_consts,
|
||||||
pub enum T {
|
animatable=False)}
|
||||||
auto,
|
|
||||||
crispedges,
|
|
||||||
% if product == "gecko":
|
|
||||||
optimizequality,
|
|
||||||
optimizespeed,
|
|
||||||
% else:
|
|
||||||
pixelated, // firefox doesn't support it (https://bugzilla.mozilla.org/show_bug.cgi?id=856337)
|
|
||||||
% endif
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToCss for T {
|
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
|
||||||
match *self {
|
|
||||||
T::auto => dest.write_str("auto"),
|
|
||||||
T::crispedges => dest.write_str("crisp-edges"),
|
|
||||||
% if product == "gecko":
|
|
||||||
T::optimizequality => dest.write_str("optimizeQuality"),
|
|
||||||
T::optimizespeed => dest.write_str("optimizeSpeed"),
|
|
||||||
% else:
|
|
||||||
T::pixelated => dest.write_str("pixelated"),
|
|
||||||
% endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use values::NoViewportPercentage;
|
|
||||||
impl NoViewportPercentage for SpecifiedValue {}
|
|
||||||
|
|
||||||
pub type SpecifiedValue = computed_value::T;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
|
||||||
computed_value::T::auto
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
|
||||||
// According to to CSS-IMAGES-3, `optimizespeed` and `optimizequality` are synonyms for
|
|
||||||
// `auto`.
|
|
||||||
match_ignore_ascii_case! {
|
|
||||||
try!(input.expect_ident()),
|
|
||||||
"auto" => Ok(computed_value::T::auto),
|
|
||||||
"crisp-edges" => Ok(computed_value::T::crispedges),
|
|
||||||
% if product == "gecko":
|
|
||||||
"optimizequality" => Ok(computed_value::T::optimizequality),
|
|
||||||
"optimizespeed" => Ok(computed_value::T::optimizespeed),
|
|
||||||
% else:
|
|
||||||
"optimizequality" => Ok(computed_value::T::auto),
|
|
||||||
"optimizespeed" => Ok(computed_value::T::auto),
|
|
||||||
"pixelated" => Ok(computed_value::T::pixelated),
|
|
||||||
% endif
|
|
||||||
_ => Err(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use values::computed::ComputedValueAsSpecified;
|
|
||||||
impl ComputedValueAsSpecified for SpecifiedValue { }
|
|
||||||
</%helpers:longhand>
|
|
||||||
|
|
||||||
// Used in the bottom-up flow construction traversal to avoid constructing flows for
|
// Used in the bottom-up flow construction traversal to avoid constructing flows for
|
||||||
// descendants of nodes with `display: none`.
|
// descendants of nodes with `display: none`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue