mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #21724 - emilio:gecko-sync, r=emilio
style: Sync changes from mozilla-central See each individual commit for details. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21724) <!-- Reviewable:end -->
This commit is contained in:
commit
6c2f41bd0e
17 changed files with 239 additions and 68 deletions
|
@ -15,6 +15,7 @@ servo = [
|
||||||
"mozjs",
|
"mozjs",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
|
"servo_channel",
|
||||||
"string_cache",
|
"string_cache",
|
||||||
"time",
|
"time",
|
||||||
"url",
|
"url",
|
||||||
|
@ -34,7 +35,7 @@ selectors = { path = "../selectors" }
|
||||||
serde = { version = "1.0.27", optional = true }
|
serde = { version = "1.0.27", optional = true }
|
||||||
serde_bytes = { version = "0.10", optional = true }
|
serde_bytes = { version = "0.10", optional = true }
|
||||||
servo_arc = { path = "../servo_arc" }
|
servo_arc = { path = "../servo_arc" }
|
||||||
servo_channel = {path = "../channel"}
|
servo_channel = { path = "../channel", optional = true }
|
||||||
smallbitvec = "2.1.0"
|
smallbitvec = "2.1.0"
|
||||||
smallvec = "0.6"
|
smallvec = "0.6"
|
||||||
string_cache = { version = "0.7", optional = true }
|
string_cache = { version = "0.7", optional = true }
|
||||||
|
|
|
@ -59,6 +59,7 @@ extern crate serde;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
extern crate serde_bytes;
|
extern crate serde_bytes;
|
||||||
extern crate servo_arc;
|
extern crate servo_arc;
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
extern crate servo_channel;
|
extern crate servo_channel;
|
||||||
extern crate smallbitvec;
|
extern crate smallbitvec;
|
||||||
extern crate smallvec;
|
extern crate smallvec;
|
||||||
|
@ -1024,6 +1025,7 @@ where
|
||||||
|
|
||||||
// Placeholder for unique case where internals of Sender cannot be measured.
|
// Placeholder for unique case where internals of Sender cannot be measured.
|
||||||
// malloc size of is 0 macro complains about type supplied!
|
// malloc size of is 0 macro complains about type supplied!
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
impl<T> MallocSizeOf for servo_channel::Sender<T> {
|
impl<T> MallocSizeOf for servo_channel::Sender<T> {
|
||||||
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
||||||
0
|
0
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
//! CSS transitions and animations.
|
//! CSS transitions and animations.
|
||||||
|
|
||||||
|
// NOTE(emilio): This code isn't really executed in Gecko, but we don't want to
|
||||||
|
// compile it out so that people remember it exists, thus the cfg'd Sender
|
||||||
|
// import.
|
||||||
|
|
||||||
use Atom;
|
use Atom;
|
||||||
use bezier::Bezier;
|
use bezier::Bezier;
|
||||||
use context::SharedStyleContext;
|
use context::SharedStyleContext;
|
||||||
|
@ -15,8 +19,11 @@ use properties::longhands::animation_direction::computed_value::single_value::T
|
||||||
use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
|
use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
|
||||||
use rule_tree::CascadeLevel;
|
use rule_tree::CascadeLevel;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
use servo_channel::Sender;
|
use servo_channel::Sender;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
use std::sync::mpsc::Sender;
|
||||||
use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
|
use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
|
||||||
use timer::Timer;
|
use timer::Timer;
|
||||||
use values::computed::Time;
|
use values::computed::Time;
|
||||||
|
@ -25,6 +32,7 @@ use values::computed::transform::TimingFunction;
|
||||||
use values::generics::box_::AnimationIterationCount;
|
use values::generics::box_::AnimationIterationCount;
|
||||||
use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction};
|
use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction};
|
||||||
|
|
||||||
|
|
||||||
/// This structure represents a keyframes animation current iteration state.
|
/// This structure represents a keyframes animation current iteration state.
|
||||||
///
|
///
|
||||||
/// If the iteration count is infinite, there's no other state, otherwise we
|
/// If the iteration count is infinite, there's no other state, otherwise we
|
||||||
|
|
|
@ -8,6 +8,7 @@ use Atom;
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use gecko_bindings::bindings;
|
use gecko_bindings::bindings;
|
||||||
|
use gecko_bindings::structs;
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use media_queries::media_feature::{AllowsRanges, ParsingRequirements};
|
use media_queries::media_feature::{AllowsRanges, ParsingRequirements};
|
||||||
use media_queries::media_feature::{MediaFeatureDescription, Evaluator};
|
use media_queries::media_feature::{MediaFeatureDescription, Evaluator};
|
||||||
|
@ -300,6 +301,94 @@ fn eval_prefers_reduced_motion(device: &Device, query_value: Option<PrefersReduc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/mediaqueries-4/#mf-interaction
|
||||||
|
bitflags! {
|
||||||
|
struct PointerCapabilities: u8 {
|
||||||
|
const COARSE = structs::PointerCapabilities_Coarse;
|
||||||
|
const FINE = structs::PointerCapabilities_Fine;
|
||||||
|
const HOVER = structs::PointerCapabilities_Hover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn primary_pointer_capabilities(device: &Device) -> PointerCapabilities {
|
||||||
|
PointerCapabilities::from_bits_truncate(
|
||||||
|
unsafe { bindings::Gecko_MediaFeatures_PrimaryPointerCapabilities(device.document()) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn all_pointer_capabilities(device: &Device) -> PointerCapabilities {
|
||||||
|
PointerCapabilities::from_bits_truncate(
|
||||||
|
unsafe { bindings::Gecko_MediaFeatures_AllPointerCapabilities(device.document()) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, ToCss)]
|
||||||
|
#[repr(u8)]
|
||||||
|
enum Pointer {
|
||||||
|
None,
|
||||||
|
Coarse,
|
||||||
|
Fine,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn eval_pointer_capabilities(
|
||||||
|
query_value: Option<Pointer>,
|
||||||
|
pointer_capabilities: PointerCapabilities,
|
||||||
|
) -> bool {
|
||||||
|
let query_value = match query_value {
|
||||||
|
Some(v) => v,
|
||||||
|
None => return !pointer_capabilities.is_empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
match query_value {
|
||||||
|
Pointer::None => pointer_capabilities.is_empty(),
|
||||||
|
Pointer::Coarse => pointer_capabilities.intersects(PointerCapabilities::COARSE),
|
||||||
|
Pointer::Fine => pointer_capabilities.intersects(PointerCapabilities::FINE),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/mediaqueries-4/#pointer
|
||||||
|
fn eval_pointer(device: &Device, query_value: Option<Pointer>) -> bool {
|
||||||
|
eval_pointer_capabilities(query_value, primary_pointer_capabilities(device))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/mediaqueries-4/#descdef-media-any-pointer
|
||||||
|
fn eval_any_pointer(device: &Device, query_value: Option<Pointer>) -> bool {
|
||||||
|
eval_pointer_capabilities(query_value, all_pointer_capabilities(device))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, ToCss)]
|
||||||
|
#[repr(u8)]
|
||||||
|
enum Hover {
|
||||||
|
None,
|
||||||
|
Hover,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn eval_hover_capabilities(
|
||||||
|
query_value: Option<Hover>,
|
||||||
|
pointer_capabilities: PointerCapabilities,
|
||||||
|
) -> bool {
|
||||||
|
let can_hover = pointer_capabilities.intersects(PointerCapabilities::HOVER);
|
||||||
|
let query_value = match query_value {
|
||||||
|
Some(v) => v,
|
||||||
|
None => return can_hover,
|
||||||
|
};
|
||||||
|
|
||||||
|
match query_value {
|
||||||
|
Hover::None => !can_hover,
|
||||||
|
Hover::Hover => can_hover,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/mediaqueries-4/#hover
|
||||||
|
fn eval_hover(device: &Device, query_value: Option<Hover>) -> bool {
|
||||||
|
eval_hover_capabilities(query_value, primary_pointer_capabilities(device))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/mediaqueries-4/#descdef-media-any-hover
|
||||||
|
fn eval_any_hover(device: &Device, query_value: Option<Hover>) -> bool {
|
||||||
|
eval_hover_capabilities(query_value, all_pointer_capabilities(device))
|
||||||
|
}
|
||||||
|
|
||||||
fn eval_moz_is_glyph(
|
fn eval_moz_is_glyph(
|
||||||
device: &Device,
|
device: &Device,
|
||||||
query_value: Option<bool>,
|
query_value: Option<bool>,
|
||||||
|
@ -390,7 +479,7 @@ lazy_static! {
|
||||||
/// to support new types in these entries and (2) ensuring that either
|
/// to support new types in these entries and (2) ensuring that either
|
||||||
/// nsPresContext::MediaFeatureValuesChanged is called when the value that
|
/// nsPresContext::MediaFeatureValuesChanged is called when the value that
|
||||||
/// would be returned by the evaluator function could change.
|
/// would be returned by the evaluator function could change.
|
||||||
pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 43] = [
|
pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 47] = [
|
||||||
feature!(
|
feature!(
|
||||||
atom!("width"),
|
atom!("width"),
|
||||||
AllowsRanges::Yes,
|
AllowsRanges::Yes,
|
||||||
|
@ -509,6 +598,30 @@ lazy_static! {
|
||||||
keyword_evaluator!(eval_prefers_reduced_motion, PrefersReducedMotion),
|
keyword_evaluator!(eval_prefers_reduced_motion, PrefersReducedMotion),
|
||||||
ParsingRequirements::empty(),
|
ParsingRequirements::empty(),
|
||||||
),
|
),
|
||||||
|
feature!(
|
||||||
|
atom!("pointer"),
|
||||||
|
AllowsRanges::No,
|
||||||
|
keyword_evaluator!(eval_pointer, Pointer),
|
||||||
|
ParsingRequirements::empty(),
|
||||||
|
),
|
||||||
|
feature!(
|
||||||
|
atom!("any-pointer"),
|
||||||
|
AllowsRanges::No,
|
||||||
|
keyword_evaluator!(eval_any_pointer, Pointer),
|
||||||
|
ParsingRequirements::empty(),
|
||||||
|
),
|
||||||
|
feature!(
|
||||||
|
atom!("hover"),
|
||||||
|
AllowsRanges::No,
|
||||||
|
keyword_evaluator!(eval_hover, Hover),
|
||||||
|
ParsingRequirements::empty(),
|
||||||
|
),
|
||||||
|
feature!(
|
||||||
|
atom!("any-hover"),
|
||||||
|
AllowsRanges::No,
|
||||||
|
keyword_evaluator!(eval_any_hover, Hover),
|
||||||
|
ParsingRequirements::empty(),
|
||||||
|
),
|
||||||
|
|
||||||
// Internal -moz-is-glyph media feature: applies only inside SVG glyphs.
|
// Internal -moz-is-glyph media feature: applies only inside SVG glyphs.
|
||||||
// Internal because it is really only useful in the user agent anyway
|
// Internal because it is really only useful in the user agent anyway
|
||||||
|
|
|
@ -234,10 +234,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies text zoom to a font-size or line-height value (see nsStyleFont::ZoomText).
|
/// Applies text zoom to a font-size or line-height value (see nsStyleFont::ZoomText).
|
||||||
|
#[inline]
|
||||||
pub fn zoom_text(&self, size: Au) -> Au {
|
pub fn zoom_text(&self, size: Au) -> Au {
|
||||||
size.scale_by(self.pres_context().mEffectiveTextZoom)
|
size.scale_by(self.pres_context().mEffectiveTextZoom)
|
||||||
}
|
}
|
||||||
/// Un-apply text zoom (see nsStyleFont::UnzoomText).
|
|
||||||
|
/// Un-apply text zoom.
|
||||||
|
#[inline]
|
||||||
pub fn unzoom_text(&self, size: Au) -> Au {
|
pub fn unzoom_text(&self, size: Au) -> Au {
|
||||||
size.scale_by(1. / self.pres_context().mEffectiveTextZoom)
|
size.scale_by(1. / self.pres_context().mEffectiveTextZoom)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use gecko_bindings::bindings;
|
||||||
use gecko_bindings::structs::ServoBundledURI;
|
use gecko_bindings::structs::ServoBundledURI;
|
||||||
use gecko_bindings::structs::mozilla::css::URLValueData;
|
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||||
use gecko_bindings::structs::root::{RustString, nsStyleImageRequest};
|
use gecko_bindings::structs::root::{RustString, nsStyleImageRequest};
|
||||||
|
use gecko_bindings::structs::root::mozilla::CORSMode;
|
||||||
use gecko_bindings::structs::root::mozilla::css::{ImageValue, URLValue};
|
use gecko_bindings::structs::root::mozilla::css::{ImageValue, URLValue};
|
||||||
use gecko_bindings::sugar::refptr::RefPtr;
|
use gecko_bindings::sugar::refptr::RefPtr;
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||||
|
@ -186,15 +187,34 @@ impl SpecifiedImageUrl {
|
||||||
Self::from_css_url(CssUrl::parse_from_string(url, context))
|
Self::from_css_url(CssUrl::parse_from_string(url, context))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_css_url(url: CssUrl) -> Self {
|
fn from_css_url_with_cors(url: CssUrl, cors: CORSMode) -> Self {
|
||||||
let image_value = unsafe {
|
let image_value = unsafe {
|
||||||
let ptr = bindings::Gecko_ImageValue_Create(url.for_ffi());
|
let ptr = bindings::Gecko_ImageValue_Create(url.for_ffi(), cors);
|
||||||
// We do not expect Gecko_ImageValue_Create returns null.
|
// We do not expect Gecko_ImageValue_Create returns null.
|
||||||
debug_assert!(!ptr.is_null());
|
debug_assert!(!ptr.is_null());
|
||||||
RefPtr::from_addrefed(ptr)
|
RefPtr::from_addrefed(ptr)
|
||||||
};
|
};
|
||||||
Self { url, image_value }
|
Self { url, image_value }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn from_css_url(url: CssUrl) -> Self {
|
||||||
|
use gecko_bindings::structs::root::mozilla::CORSMode_CORS_NONE;
|
||||||
|
Self::from_css_url_with_cors(url, CORSMode_CORS_NONE)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_css_url_with_cors_anonymous(url: CssUrl) -> Self {
|
||||||
|
use gecko_bindings::structs::root::mozilla::CORSMode_CORS_ANONYMOUS;
|
||||||
|
Self::from_css_url_with_cors(url, CORSMode_CORS_ANONYMOUS)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provides an alternate method for parsing that associates the URL
|
||||||
|
/// with anonymous CORS headers.
|
||||||
|
pub fn parse_with_cors_anonymous<'i, 't>(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
CssUrl::parse(context, input).map(Self::from_css_url_with_cors_anonymous)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for SpecifiedImageUrl {
|
impl Parse for SpecifiedImageUrl {
|
||||||
|
|
|
@ -2403,7 +2403,8 @@ fn static_assert() {
|
||||||
/// Calculates the constrained and unconstrained font sizes to be inherited
|
/// Calculates the constrained and unconstrained font sizes to be inherited
|
||||||
/// from the parent.
|
/// from the parent.
|
||||||
///
|
///
|
||||||
/// See ComputeScriptLevelSize in Gecko's nsRuleNode.cpp
|
/// This is a port of Gecko's old ComputeScriptLevelSize function:
|
||||||
|
/// https://dxr.mozilla.org/mozilla-central/rev/35fbf14b9/layout/style/nsRuleNode.cpp#3197-3254
|
||||||
///
|
///
|
||||||
/// scriptlevel is a property that affects how font-size is inherited. If scriptlevel is
|
/// scriptlevel is a property that affects how font-size is inherited. If scriptlevel is
|
||||||
/// +1, for example, it will inherit as the script size multiplier times
|
/// +1, for example, it will inherit as the script size multiplier times
|
||||||
|
@ -2511,17 +2512,18 @@ fn static_assert() {
|
||||||
= self.calculate_script_level_size(parent, device);
|
= self.calculate_script_level_size(parent, device);
|
||||||
if adjusted_size.0 != parent.gecko.mSize ||
|
if adjusted_size.0 != parent.gecko.mSize ||
|
||||||
adjusted_unconstrained_size.0 != parent.gecko.mScriptUnconstrainedSize {
|
adjusted_unconstrained_size.0 != parent.gecko.mScriptUnconstrainedSize {
|
||||||
// This is incorrect. When there is both a keyword size being inherited
|
// FIXME(Manishearth): This is incorrect. When there is both a
|
||||||
// and a scriptlevel change, we must handle the keyword size the same
|
// keyword size being inherited and a scriptlevel change, we must
|
||||||
// way we handle em units. This complicates things because we now have
|
// handle the keyword size the same way we handle em units. This
|
||||||
// to keep track of the adjusted and unadjusted ratios in the kw font size.
|
// complicates things because we now have to keep track of the
|
||||||
// This only affects the use case of a generic font being used in MathML.
|
// adjusted and unadjusted ratios in the kw font size. This only
|
||||||
|
// affects the use case of a generic font being used in MathML.
|
||||||
//
|
//
|
||||||
// If we were to fix this I would prefer doing it by removing the
|
// If we were to fix this I would prefer doing it not doing
|
||||||
// ruletree walk on the Gecko side in nsRuleNode::SetGenericFont
|
// something like the ruletree walk that Gecko used to do in
|
||||||
// and instead using extra bookkeeping in the mSize and mScriptUnconstrainedSize
|
// nsRuleNode::SetGenericFont and instead using extra bookkeeping in
|
||||||
// values, and reusing those instead of font_size_keyword.
|
// the mSize and mScriptUnconstrainedSize values, and reusing those
|
||||||
|
// instead of font_size_keyword.
|
||||||
|
|
||||||
// In the case that MathML has given us an adjusted size, apply it.
|
// In the case that MathML has given us an adjusted size, apply it.
|
||||||
// Keep track of the unconstrained adjusted size.
|
// Keep track of the unconstrained adjusted size.
|
||||||
|
|
|
@ -1200,9 +1200,6 @@ impl StrongRuleNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of `nsRuleNode::HasAuthorSpecifiedRules` for Servo rule
|
|
||||||
/// nodes.
|
|
||||||
///
|
|
||||||
/// Returns true if any properties specified by `rule_type_mask` was set by
|
/// Returns true if any properties specified by `rule_type_mask` was set by
|
||||||
/// an author rule.
|
/// an author rule.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
|
|
@ -98,6 +98,18 @@ impl CssUrl {
|
||||||
resolved: ServoUrl::parse(url).ok(),
|
resolved: ServoUrl::parse(url).ok(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parses a URL request and records that the corresponding request needs to
|
||||||
|
/// be CORS-enabled.
|
||||||
|
///
|
||||||
|
/// This is only for shape images and masks in Gecko, thus unimplemented for
|
||||||
|
/// now so somebody notices when trying to do so.
|
||||||
|
pub fn parse_with_cors_anonymous<'i, 't>(
|
||||||
|
_context: &ParserContext,
|
||||||
|
_input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
unimplemented!("Need to record somewhere that the request needs to be CORS-enabled")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for CssUrl {
|
impl Parse for CssUrl {
|
||||||
|
|
|
@ -11,7 +11,6 @@ use values::computed::{Angle, Number};
|
||||||
use values::computed::length::Length;
|
use values::computed::length::Length;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use values::computed::url::ComputedUrl;
|
use values::computed::url::ComputedUrl;
|
||||||
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
|
||||||
use values::generics::effects::BoxShadow as GenericBoxShadow;
|
use values::generics::effects::BoxShadow as GenericBoxShadow;
|
||||||
use values::generics::effects::Filter as GenericFilter;
|
use values::generics::effects::Filter as GenericFilter;
|
||||||
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||||
|
@ -29,14 +28,3 @@ pub type Filter = GenericFilter<Angle, Number, Length, Impossible, Impossible>;
|
||||||
|
|
||||||
/// An animated value for the `drop-shadow()` filter.
|
/// An animated value for the `drop-shadow()` filter.
|
||||||
pub type SimpleShadow = GenericSimpleShadow<Color, Length, Length>;
|
pub type SimpleShadow = GenericSimpleShadow<Color, Length, Length>;
|
||||||
|
|
||||||
impl ComputeSquaredDistance for BoxShadow {
|
|
||||||
#[inline]
|
|
||||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
|
||||||
if self.inset != other.inset {
|
|
||||||
return Err(());
|
|
||||||
}
|
|
||||||
Ok(self.base.compute_squared_distance(&other.base)? +
|
|
||||||
self.spread.compute_squared_distance(&other.spread)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#[derive(
|
#[derive(
|
||||||
Animate,
|
Animate,
|
||||||
Clone,
|
Clone,
|
||||||
|
ComputeSquaredDistance,
|
||||||
Debug,
|
Debug,
|
||||||
MallocSizeOf,
|
MallocSizeOf,
|
||||||
PartialEq,
|
PartialEq,
|
||||||
|
|
|
@ -13,7 +13,6 @@ use std::fmt::{self, Write};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use style_traits::{CssWriter, KeywordsCollectFn, ParseError};
|
use style_traits::{CssWriter, KeywordsCollectFn, ParseError};
|
||||||
use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
||||||
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-fonts-4/#feature-tag-value
|
/// https://drafts.csswg.org/css-fonts-4/#feature-tag-value
|
||||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue)]
|
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue)]
|
||||||
|
@ -47,7 +46,16 @@ where
|
||||||
///
|
///
|
||||||
/// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
/// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
||||||
#[derive(
|
#[derive(
|
||||||
Animate, Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
Animate,
|
||||||
|
Clone,
|
||||||
|
ComputeSquaredDistance,
|
||||||
|
Debug,
|
||||||
|
Eq,
|
||||||
|
MallocSizeOf,
|
||||||
|
PartialEq,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToComputedValue,
|
||||||
|
ToCss,
|
||||||
)]
|
)]
|
||||||
pub struct VariationValue<Number> {
|
pub struct VariationValue<Number> {
|
||||||
/// A four-character tag, packed into a u32 (one byte per character).
|
/// A four-character tag, packed into a u32 (one byte per character).
|
||||||
|
@ -57,19 +65,6 @@ pub struct VariationValue<Number> {
|
||||||
pub value: Number,
|
pub value: Number,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Number> ComputeSquaredDistance for VariationValue<Number>
|
|
||||||
where
|
|
||||||
Number: ComputeSquaredDistance,
|
|
||||||
{
|
|
||||||
#[inline]
|
|
||||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
|
||||||
if self.tag != other.tag {
|
|
||||||
return Err(());
|
|
||||||
}
|
|
||||||
self.value.compute_squared_distance(&other.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A value both for font-variation-settings and font-feature-settings.
|
/// A value both for font-variation-settings and font-feature-settings.
|
||||||
#[css(comma)]
|
#[css(comma)]
|
||||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||||
|
|
|
@ -71,7 +71,12 @@ impl Parse for ClippingShape {
|
||||||
return Ok(ShapeSource::Path(p));
|
return Ok(ShapeSource::Path(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::parse_internal(context, input)
|
|
||||||
|
if let Ok(url) = input.try(|i| SpecifiedUrl::parse(context, i)) {
|
||||||
|
return Ok(ShapeSource::ImageOrUrl(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
Self::parse_common(context, input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,17 +86,20 @@ impl Parse for FloatAreaShape {
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
Self::parse_internal(context, input)
|
if let Ok(image) = input.try(|i| Image::parse_with_cors_anonymous(context, i)) {
|
||||||
|
return Ok(ShapeSource::ImageOrUrl(image));
|
||||||
|
}
|
||||||
|
|
||||||
|
Self::parse_common(context, input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<ReferenceBox, ImageOrUrl> ShapeSource<BasicShape, ReferenceBox, ImageOrUrl>
|
impl<ReferenceBox, ImageOrUrl> ShapeSource<BasicShape, ReferenceBox, ImageOrUrl>
|
||||||
where
|
where
|
||||||
ReferenceBox: Parse,
|
ReferenceBox: Parse,
|
||||||
ImageOrUrl: Parse,
|
|
||||||
{
|
{
|
||||||
/// The internal parser for ShapeSource.
|
/// The internal parser for ShapeSource.
|
||||||
fn parse_internal<'i, 't>(
|
fn parse_common<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
@ -99,10 +107,6 @@ where
|
||||||
return Ok(ShapeSource::None);
|
return Ok(ShapeSource::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(image_or_url) = input.try(|i| ImageOrUrl::parse(context, i)) {
|
|
||||||
return Ok(ShapeSource::ImageOrUrl(image_or_url));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_component<U: Parse>(
|
fn parse_component<U: Parse>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser,
|
input: &mut Parser,
|
||||||
|
|
|
@ -746,7 +746,12 @@ impl ToComputedValue for KeywordSize {
|
||||||
fn to_computed_value(&self, cx: &Context) -> NonNegativeLength {
|
fn to_computed_value(&self, cx: &Context) -> NonNegativeLength {
|
||||||
use context::QuirksMode;
|
use context::QuirksMode;
|
||||||
use values::specified::length::au_to_int_px;
|
use values::specified::length::au_to_int_px;
|
||||||
// Data from nsRuleNode.cpp in Gecko
|
|
||||||
|
// The tables in this function are originally from
|
||||||
|
// nsRuleNode::CalcFontPointSize in Gecko:
|
||||||
|
//
|
||||||
|
// https://dxr.mozilla.org/mozilla-central/rev/35fbf14b9/layout/style/nsRuleNode.cpp#3262-3336
|
||||||
|
|
||||||
// Mapping from base size and HTML size to pixels
|
// Mapping from base size and HTML size to pixels
|
||||||
// The first index is (base_size - 9), the second is the
|
// The first index is (base_size - 9), the second is the
|
||||||
// HTML size. "0" is CSS keyword xx-small, not HTML size 0,
|
// HTML size. "0" is CSS keyword xx-small, not HTML size 0,
|
||||||
|
@ -765,9 +770,6 @@ impl ToComputedValue for KeywordSize {
|
||||||
[9, 10, 13, 16, 18, 24, 32, 48],
|
[9, 10, 13, 16, 18, 24, 32, 48],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Data from nsRuleNode.cpp in Gecko
|
|
||||||
// (https://dxr.mozilla.org/mozilla-central/rev/35fbf14b9/layout/style/nsRuleNode.cpp#3303)
|
|
||||||
//
|
|
||||||
// This table gives us compatibility with WinNav4 for the default fonts only.
|
// This table gives us compatibility with WinNav4 for the default fonts only.
|
||||||
// In WinNav4, the default fonts were:
|
// In WinNav4, the default fonts were:
|
||||||
//
|
//
|
||||||
|
|
|
@ -166,6 +166,21 @@ impl Image {
|
||||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Provides an alternate method for parsing that associates the URL with
|
||||||
|
/// anonymous CORS headers.
|
||||||
|
///
|
||||||
|
/// FIXME(emilio): It'd be nicer for this to pass a `CorsMode` parameter to
|
||||||
|
/// a shared function instead.
|
||||||
|
pub fn parse_with_cors_anonymous<'i, 't>(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Image, ParseError<'i>> {
|
||||||
|
if let Ok(url) = input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input)) {
|
||||||
|
return Ok(generic::Image::Url(url));
|
||||||
|
}
|
||||||
|
Self::parse(context, input)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Gradient {
|
impl Parse for Gradient {
|
||||||
|
|
|
@ -538,13 +538,6 @@ impl ToCss for ArcFlag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComputeSquaredDistance for ArcFlag {
|
|
||||||
#[inline]
|
|
||||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
|
||||||
(self.0 as i32).compute_squared_distance(&(other.0 as i32))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// SVG Path parser.
|
/// SVG Path parser.
|
||||||
struct PathParser<'a> {
|
struct PathParser<'a> {
|
||||||
chars: Peekable<Cloned<slice::Iter<'a, u8>>>,
|
chars: Peekable<Cloned<slice::Iter<'a, u8>>>,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use animate::{AnimationInputAttrs, AnimationVariantAttrs};
|
use animate::{AnimationInputAttrs, AnimationVariantAttrs, AnimationFieldAttrs};
|
||||||
use cg;
|
use cg;
|
||||||
use quote::Tokens;
|
use quote::Tokens;
|
||||||
use syn::{DeriveInput, Path};
|
use syn::{DeriveInput, Path};
|
||||||
|
@ -47,9 +47,24 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
||||||
parse_quote!(#ty: ::values::distance::ComputeSquaredDistance),
|
parse_quote!(#ty: ::values::distance::ComputeSquaredDistance),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let animation_field_attrs =
|
||||||
|
cg::parse_field_attrs::<AnimationFieldAttrs>(&this.ast());
|
||||||
|
|
||||||
|
if animation_field_attrs.constant {
|
||||||
|
quote! {
|
||||||
|
{
|
||||||
|
if #this != #other {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
::values::distance::SquaredDistance::from_sqrt(0.)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
::values::distance::ComputeSquaredDistance::compute_squared_distance(#this, #other)?
|
::values::distance::ComputeSquaredDistance::compute_squared_distance(#this, #other)?
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}), quote!(+));
|
}), quote!(+));
|
||||||
sum
|
sum
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue