diff --git a/browser/base/content/test/tabcrashed/browser_shown.js b/browser/base/content/test/tabcrashed/browser_shown.js index c81f73d9524c..9577acaa794c 100644 --- a/browser/base/content/test/tabcrashed/browser_shown.js +++ b/browser/base/content/test/tabcrashed/browser_shown.js @@ -90,6 +90,7 @@ add_task(async function test_default() { {}, { SubmittedFrom: "CrashedTab", + Throttleable: "1", Comments: null, URL: "", } @@ -103,6 +104,7 @@ add_task(async function test_just_a_comment() { await crashTabTestHelper( { SubmittedFrom: "CrashedTab", + Throttleable: "1", comments: COMMENTS, }, { @@ -119,6 +121,7 @@ add_task(async function test_send_URL() { await crashTabTestHelper( { SubmittedFrom: "CrashedTab", + Throttleable: "1", includeURL: true, }, { @@ -135,6 +138,7 @@ add_task(async function test_send_all() { await crashTabTestHelper( { SubmittedFrom: "CrashedTab", + Throttleable: "1", includeURL: true, comments: COMMENTS, }, diff --git a/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js b/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js index ea6bc7b4b4da..0a45016cfcc2 100644 --- a/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js +++ b/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js @@ -372,6 +372,7 @@ add_task(async function test_can_submit() { } Assert.equal(extra.get("SubmittedFrom"), "Infobar"); + Assert.equal(extra.get("Throttleable"), "1"); } let reportIDs = await createPendingCrashReports(1); @@ -480,6 +481,7 @@ add_task(async function test_can_submit_always() { Assert.equal(result, null, "The notification should not be shown"); promiseReports = await waitForSubmittedReports(reportIDs, extra => { Assert.equal(extra.get("SubmittedFrom"), "Auto"); + Assert.equal(extra.get("Throttleable"), "1"); }); // And revert back to default now. diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp index 6c17e503387e..0bc844bac3ae 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -13,9 +13,6 @@ #include "VideoUtils.h" #include "VPXDecoder.h" #include "mozilla/layers/KnowsCompositor.h" -#if defined(MOZ_AV1) && defined(FFVPX_VERSION) && defined(MOZ_WAYLAND) -# include "AOMDecoder.h" -#endif #if LIBAVCODEC_VERSION_MAJOR >= 57 # include "mozilla/layers/TextureClient.h" #endif @@ -27,6 +24,12 @@ # include "va/va.h" #endif +#if defined(MOZ_AV1) && defined(MOZ_WAYLAND) && \ + (defined(FFVPX_VERSION) || LIBAVCODEC_VERSION_MAJOR >= 59) +# define FFMPEG_AV1_DECODE 1 +# include "AOMDecoder.h" +#endif + #include "libavutil/pixfmt.h" #if LIBAVCODEC_VERSION_MAJOR < 54 # define AVPixelFormat PixelFormat @@ -989,7 +992,7 @@ MediaResult FFmpegVideoDecoder::CreateImage( #if LIBAVCODEC_VERSION_MAJOR >= 57 || mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P12LE #endif -#if defined(MOZ_AV1) && defined(FFVPX_VERSION) && defined(MOZ_WAYLAND) +#if defined(FFMPEG_AV1_DECODE) || mCodecContext->pix_fmt == AV_PIX_FMT_GBRP #endif ) { @@ -1151,7 +1154,7 @@ AVCodecID FFmpegVideoDecoder::GetCodecId( } #endif -#if defined(MOZ_AV1) && defined(FFVPX_VERSION) && defined(MOZ_WAYLAND) +#if defined(FFMPEG_AV1_DECODE) if (AOMDecoder::IsAV1(aMimeType)) { return AV_CODEC_ID_AV1; } diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.cpp index ac2dace5bb83..243a3dee7cc6 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoFramePool.cpp @@ -38,16 +38,21 @@ VideoFrameSurface::VideoFrameSurface(DMABufSurface* aSurface) void VideoFrameSurface::LockVAAPIData( AVCodecContext* aAVCodecContext, AVFrame* aAVFrame, FFmpegLibWrapper* aLib) { - FFMPEG_LOG("VideoFrameSurface: VAAPI locking dmabuf surface UID = %d", - mSurface->GetUID()); mLib = aLib; mAVHWDeviceContext = aLib->av_buffer_ref(aAVCodecContext->hw_device_ctx); mHWAVBuffer = aLib->av_buffer_ref(aAVFrame->buf[0]); + FFMPEG_LOG( + "VideoFrameSurface: VAAPI locking dmabuf surface UID = %d " + "mAVHWDeviceContext %p mHWAVBuffer %p", + mSurface->GetUID(), mAVHWDeviceContext, mHWAVBuffer); } void VideoFrameSurface::ReleaseVAAPIData(bool aForFrameRecycle) { - FFMPEG_LOG("VideoFrameSurface: VAAPI releasing dmabuf surface UID = %d", - mSurface->GetUID()); + FFMPEG_LOG( + "VideoFrameSurface: VAAPI releasing dmabuf surface UID = %d " + "aForFrameRecycle %d mLib %p mAVHWDeviceContext %p mHWAVBuffer %p", + mSurface->GetUID(), aForFrameRecycle, mLib, mAVHWDeviceContext, + mHWAVBuffer); // It's possible to unref GPU data while IsUsed() is still set. // It can happens when VideoFramePool is deleted while decoder shutdown @@ -58,6 +63,7 @@ void VideoFrameSurface::ReleaseVAAPIData(bool aForFrameRecycle) { if (mLib) { mLib->av_buffer_unref(&mHWAVBuffer); mLib->av_buffer_unref(&mAVHWDeviceContext); + mLib = nullptr; } // If we want to recycle the frame, make sure it's not used diff --git a/servo/components/style/gecko/media_features.rs b/servo/components/style/gecko/media_features.rs index 9789d9646b6a..c2e24349de99 100644 --- a/servo/components/style/gecko/media_features.rs +++ b/servo/components/style/gecko/media_features.rs @@ -6,8 +6,7 @@ use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs; -use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements}; -use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription}; +use crate::queries::feature::{AllowsRanges, Evaluator, ParsingRequirements, QueryFeatureDescription}; use crate::media_queries::{Device, MediaType}; use crate::values::computed::{Context, CSSPixelLength, Ratio, Resolution}; use app_units::Au; @@ -583,7 +582,7 @@ macro_rules! bool_pref_feature { /// to support new types in these entries and (2) ensuring that either /// nsPresContext::MediaFeatureValuesChanged is called when the value that /// would be returned by the evaluator function could change. -pub static MEDIA_FEATURES: [MediaFeatureDescription; 60] = [ +pub static MEDIA_FEATURES: [QueryFeatureDescription; 60] = [ feature!( atom!("width"), AllowsRanges::Yes, diff --git a/servo/components/style/lib.rs b/servo/components/style/lib.rs index 9ea9188bcb94..843e8b151946 100644 --- a/servo/components/style/lib.rs +++ b/servo/components/style/lib.rs @@ -103,10 +103,11 @@ pub mod invalidation; #[allow(missing_docs)] // TODO. pub mod logical_geometry; pub mod matching; -#[macro_use] pub mod media_queries; pub mod parallel; pub mod parser; +#[macro_use] +pub mod queries; pub mod rule_cache; pub mod rule_collector; pub mod rule_tree; diff --git a/servo/components/style/media_queries/media_query.rs b/servo/components/style/media_queries/media_query.rs index 83e34c5037fe..5db84585d426 100644 --- a/servo/components/style/media_queries/media_query.rs +++ b/servo/components/style/media_queries/media_query.rs @@ -6,7 +6,7 @@ //! //! https://drafts.csswg.org/mediaqueries/#typedef-media-query -use super::media_condition::MediaCondition; +use crate::queries::QueryCondition; use crate::parser::ParserContext; use crate::str::string_as_ascii_lowercase; use crate::values::CustomIdent; @@ -66,7 +66,7 @@ pub struct MediaQuery { pub media_type: MediaQueryType, /// The condition that this media query contains. This cannot have `or` /// in the first level. - pub condition: Option, + pub condition: Option, } impl ToCss for MediaQuery { @@ -134,9 +134,9 @@ impl MediaQuery { .unwrap_or_default(); let condition = if explicit_media_type.is_none() { - Some(MediaCondition::parse(context, input)?) + Some(QueryCondition::parse(context, input)?) } else if input.try_parse(|i| i.expect_ident_matching("and")).is_ok() { - Some(MediaCondition::parse_disallow_or(context, input)?) + Some(QueryCondition::parse_disallow_or(context, input)?) } else { None }; diff --git a/servo/components/style/media_queries/mod.rs b/servo/components/style/media_queries/mod.rs index ca385857481a..833f6f53cb98 100644 --- a/servo/components/style/media_queries/mod.rs +++ b/servo/components/style/media_queries/mod.rs @@ -6,15 +6,9 @@ //! //! [mq]: https://drafts.csswg.org/mediaqueries/ -mod media_condition; mod media_list; mod media_query; -#[macro_use] -pub mod media_feature; -pub mod media_feature_expression; -pub use self::media_condition::MediaCondition; -pub use self::media_feature_expression::MediaFeatureExpression; pub use self::media_list::MediaList; pub use self::media_query::{MediaQuery, MediaQueryType, MediaType, Qualifier}; diff --git a/servo/components/style/media_queries/media_condition.rs b/servo/components/style/queries/condition.rs similarity index 76% rename from servo/components/style/media_queries/media_condition.rs rename to servo/components/style/queries/condition.rs index 63e130ba4ffa..43b8dc002906 100644 --- a/servo/components/style/media_queries/media_condition.rs +++ b/servo/components/style/queries/condition.rs @@ -2,11 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -//! A media query condition: +//! A query condition: //! //! https://drafts.csswg.org/mediaqueries-4/#typedef-media-condition +//! https://drafts.csswg.org/css-contain-3/#typedef-container-condition -use super::MediaFeatureExpression; +use super::QueryFeatureExpression; use crate::parser::ParserContext; use crate::values::computed; use cssparser::{Parser, Token}; @@ -28,38 +29,38 @@ enum AllowOr { No, } -/// Represents a media condition. +/// Represents a condition. #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToShmem)] -pub enum MediaCondition { - /// A simple media feature expression, implicitly parenthesized. - Feature(MediaFeatureExpression), +pub enum QueryCondition { + /// A simple feature expression, implicitly parenthesized. + Feature(QueryFeatureExpression), /// A negation of a condition. - Not(Box), + Not(Box), /// A set of joint operations. - Operation(Box<[MediaCondition]>, Operator), + Operation(Box<[QueryCondition]>, Operator), /// A condition wrapped in parenthesis. - InParens(Box), + InParens(Box), } -impl ToCss for MediaCondition { +impl ToCss for QueryCondition { fn to_css(&self, dest: &mut CssWriter) -> fmt::Result where W: fmt::Write, { match *self { - // NOTE(emilio): MediaFeatureExpression already includes the + // NOTE(emilio): QueryFeatureExpression already includes the // parenthesis. - MediaCondition::Feature(ref f) => f.to_css(dest), - MediaCondition::Not(ref c) => { + QueryCondition::Feature(ref f) => f.to_css(dest), + QueryCondition::Not(ref c) => { dest.write_str("not ")?; c.to_css(dest) }, - MediaCondition::InParens(ref c) => { + QueryCondition::InParens(ref c) => { dest.write_char('(')?; c.to_css(dest)?; dest.write_char(')') }, - MediaCondition::Operation(ref list, op) => { + QueryCondition::Operation(ref list, op) => { let mut iter = list.iter(); iter.next().unwrap().to_css(dest)?; for item in iter { @@ -74,8 +75,8 @@ impl ToCss for MediaCondition { } } -impl MediaCondition { - /// Parse a single media condition. +impl QueryCondition { + /// Parse a single condition. pub fn parse<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, @@ -83,9 +84,9 @@ impl MediaCondition { Self::parse_internal(context, input, AllowOr::Yes) } - /// Parse a single media condition, disallowing `or` expressions. + /// Parse a single condition, disallowing `or` expressions. /// - /// To be used from the legacy media query syntax. + /// To be used from the legacy query syntax. pub fn parse_disallow_or<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, @@ -109,7 +110,7 @@ impl MediaCondition { if is_negation { let inner_condition = Self::parse_in_parens(context, input)?; - return Ok(MediaCondition::Not(Box::new(inner_condition))); + return Ok(QueryCondition::Not(Box::new(inner_condition))); } // ParenthesisBlock. @@ -134,7 +135,7 @@ impl MediaCondition { loop { if input.try_parse(|i| i.expect_ident_matching(delim)).is_err() { - return Ok(MediaCondition::Operation( + return Ok(QueryCondition::Operation( conditions.into_boxed_slice(), operator, )); @@ -144,7 +145,7 @@ impl MediaCondition { } } - /// Parse a media condition in parentheses. + /// Parse a condition in parentheses. pub fn parse_in_parens<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, @@ -160,20 +161,20 @@ impl MediaCondition { input.parse_nested_block(|input| { // Base case. if let Ok(inner) = input.try_parse(|i| Self::parse(context, i)) { - return Ok(MediaCondition::InParens(Box::new(inner))); + return Ok(QueryCondition::InParens(Box::new(inner))); } - let expr = MediaFeatureExpression::parse_in_parenthesis_block(context, input)?; - Ok(MediaCondition::Feature(expr)) + let expr = QueryFeatureExpression::parse_in_parenthesis_block(context, input)?; + Ok(QueryCondition::Feature(expr)) }) } /// Whether this condition matches the device and quirks mode. pub fn matches(&self, context: &computed::Context) -> bool { match *self { - MediaCondition::Feature(ref f) => f.matches(context), - MediaCondition::InParens(ref c) => c.matches(context), - MediaCondition::Not(ref c) => !c.matches(context), - MediaCondition::Operation(ref conditions, op) => { + QueryCondition::Feature(ref f) => f.matches(context), + QueryCondition::InParens(ref c) => c.matches(context), + QueryCondition::Not(ref c) => !c.matches(context), + QueryCondition::Operation(ref conditions, op) => { let mut iter = conditions.iter(); match op { Operator::And => iter.all(|c| c.matches(context)), diff --git a/servo/components/style/media_queries/media_feature.rs b/servo/components/style/queries/feature.rs similarity index 78% rename from servo/components/style/media_queries/media_feature.rs rename to servo/components/style/queries/feature.rs index df39d0245a08..3390127887b3 100644 --- a/servo/components/style/media_queries/media_feature.rs +++ b/servo/components/style/queries/feature.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -//! Media features. +//! Query features. use crate::parser::ParserContext; use crate::values::computed::{self, CSSPixelLength, Resolution, Ratio}; @@ -14,7 +14,7 @@ use style_traits::ParseError; /// A generic discriminant for an enum value. pub type KeywordDiscriminant = u8; -type MediaFeatureGetter = fn(device: &computed::Context) -> T; +type QueryFeatureGetter = fn(device: &computed::Context) -> T; /// Serializes a given discriminant. /// @@ -28,19 +28,19 @@ pub type KeywordParser = for<'a, 'i, 't> fn( input: &'a mut Parser<'i, 't>, ) -> Result>; -/// An evaluator for a given media feature. +/// An evaluator for a given feature. /// /// This determines the kind of values that get parsed, too. #[allow(missing_docs)] pub enum Evaluator { - Length(MediaFeatureGetter), - Integer(MediaFeatureGetter), - Float(MediaFeatureGetter), - BoolInteger(MediaFeatureGetter), + Length(QueryFeatureGetter), + Integer(QueryFeatureGetter), + Float(QueryFeatureGetter), + BoolInteger(QueryFeatureGetter), /// A non-negative number ratio, such as the one from device-pixel-ratio. - NumberRatio(MediaFeatureGetter), + NumberRatio(QueryFeatureGetter), /// A resolution. - Resolution(MediaFeatureGetter), + Resolution(QueryFeatureGetter), /// A keyword value. Enumerated { /// The parser to get a discriminant given a string. @@ -67,14 +67,14 @@ macro_rules! keyword_evaluator { context: &$crate::parser::ParserContext, input: &mut $crate::cssparser::Parser<'i, 't>, ) -> Result< - $crate::media_queries::media_feature::KeywordDiscriminant, + $crate::queries::feature::KeywordDiscriminant, ::style_traits::ParseError<'i>, > { let kw = <$keyword_type as $crate::parser::Parse>::parse(context, input)?; - Ok(kw as $crate::media_queries::media_feature::KeywordDiscriminant) + Ok(kw as $crate::queries::feature::KeywordDiscriminant) } - fn __serialize(kw: $crate::media_queries::media_feature::KeywordDiscriminant) -> String { + fn __serialize(kw: $crate::queries::feature::KeywordDiscriminant) -> String { // This unwrap is ok because the only discriminants that get // back to us is the ones that `parse` produces. let value: $keyword_type = ::num_traits::cast::FromPrimitive::from_u8(kw).unwrap(); @@ -83,7 +83,7 @@ macro_rules! keyword_evaluator { fn __evaluate( context: &$crate::values::computed::Context, - value: Option<$crate::media_queries::media_feature::KeywordDiscriminant>, + value: Option<$crate::queries::feature::KeywordDiscriminant>, ) -> bool { // This unwrap is ok because the only discriminants that get // back to us is the ones that `parse` produces. @@ -92,7 +92,7 @@ macro_rules! keyword_evaluator { $actual_evaluator(context, value) } - $crate::media_queries::media_feature::Evaluator::Enumerated { + $crate::queries::feature::Evaluator::Enumerated { parser: __parse, serializer: __serialize, evaluator: __evaluate, @@ -111,7 +111,7 @@ bitflags! { } } -/// Whether a media feature allows ranges or not. +/// Whether a feature allows ranges or not. #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[allow(missing_docs)] pub enum AllowsRanges { @@ -119,9 +119,9 @@ pub enum AllowsRanges { No, } -/// A description of a media feature. -pub struct MediaFeatureDescription { - /// The media feature name, in ascii lowercase. +/// A description of a feature. +pub struct QueryFeatureDescription { + /// The feature name, in ascii lowercase. pub name: Atom, /// Whether min- / max- prefixes are allowed or not. pub allows_ranges: AllowsRanges, @@ -133,18 +133,18 @@ pub struct MediaFeatureDescription { pub requirements: ParsingRequirements, } -impl MediaFeatureDescription { - /// Whether this media feature allows ranges. +impl QueryFeatureDescription { + /// Whether this feature allows ranges. #[inline] pub fn allows_ranges(&self) -> bool { self.allows_ranges == AllowsRanges::Yes } } -/// A simple helper to construct a `MediaFeatureDescription`. +/// A simple helper to construct a `QueryFeatureDescription`. macro_rules! feature { ($name:expr, $allows_ranges:expr, $evaluator:expr, $reqs:expr,) => { - $crate::media_queries::media_feature::MediaFeatureDescription { + $crate::queries::feature::QueryFeatureDescription { name: $name, allows_ranges: $allows_ranges, evaluator: $evaluator, @@ -153,9 +153,9 @@ macro_rules! feature { }; } -impl fmt::Debug for MediaFeatureDescription { +impl fmt::Debug for QueryFeatureDescription { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("MediaFeatureExpression") + f.debug_struct("QueryFeatureDescription") .field("name", &self.name) .field("allows_ranges", &self.allows_ranges) .field("requirements", &self.requirements) diff --git a/servo/components/style/media_queries/media_feature_expression.rs b/servo/components/style/queries/feature_expression.rs similarity index 86% rename from servo/components/style/media_queries/media_feature_expression.rs rename to servo/components/style/queries/feature_expression.rs index 651dbf0002f5..a031218db801 100644 --- a/servo/components/style/media_queries/media_feature_expression.rs +++ b/servo/components/style/queries/feature_expression.rs @@ -2,11 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -//! Parsing for media feature expressions, like `(foo: bar)` or +//! Parsing for query feature expressions, like `(foo: bar)` or //! `(width >= 400px)`. -use super::media_feature::{Evaluator, MediaFeatureDescription}; -use super::media_feature::{KeywordDiscriminant, ParsingRequirements}; +use super::feature::{Evaluator, QueryFeatureDescription}; +use super::feature::{KeywordDiscriminant, ParsingRequirements}; #[cfg(feature = "gecko")] use crate::gecko::media_features::MEDIA_FEATURES; use crate::parser::{Parse, ParserContext}; @@ -22,7 +22,7 @@ use std::cmp::{Ordering, PartialOrd}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -/// The kind of matching that should be performed on a media feature value. +/// The kind of matching that should be performed on a feature value. #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToShmem)] pub enum Range { /// At least the specified value. @@ -31,7 +31,7 @@ pub enum Range { Max, } -/// The operator that was specified in this media feature. +/// The operator that was specified in this feature. #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToShmem)] pub enum Operator { /// = @@ -63,8 +63,7 @@ impl ToCss for Operator { /// Either a `Range` or an `Operator`. /// -/// Ranged media features are not allowed with operations (that'd make no -/// sense). +/// Ranged features are not allowed with operations (that'd make no sense). #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToShmem)] pub enum RangeOrOperator { /// A `Range`. @@ -121,16 +120,16 @@ impl RangeOrOperator { } } -/// A feature expression contains a reference to the media feature, the value -/// the media query contained, and the range to evaluate. +/// A feature expression contains a reference to the feature, the value the +/// query contained, and the range to evaluate. #[derive(Clone, Debug, MallocSizeOf, ToShmem, PartialEq)] -pub struct MediaFeatureExpression { +pub struct QueryFeatureExpression { feature_index: usize, - value: Option, + value: Option, range_or_operator: Option, } -impl ToCss for MediaFeatureExpression { +impl ToCss for QueryFeatureExpression { fn to_css(&self, dest: &mut CssWriter) -> fmt::Result where W: fmt::Write, @@ -243,10 +242,10 @@ fn disabled_by_pref(feature: &Atom, context: &ParserContext) -> bool { false } -impl MediaFeatureExpression { +impl QueryFeatureExpression { fn new( feature_index: usize, - value: Option, + value: Option, range_or_operator: Option, ) -> Self { debug_assert!(feature_index < MEDIA_FEATURES.len()); @@ -257,11 +256,11 @@ impl MediaFeatureExpression { } } - fn feature(&self) -> &'static MediaFeatureDescription { + fn feature(&self) -> &'static QueryFeatureDescription { &MEDIA_FEATURES[self.feature_index] } - /// Parse a media expression of the form: + /// Parse a feature expression of the form: /// /// ``` /// (media-feature: media-value) @@ -274,8 +273,7 @@ impl MediaFeatureExpression { input.parse_nested_block(|input| Self::parse_in_parenthesis_block(context, input)) } - /// Parse a media feature expression where we've already consumed the - /// parenthesis. + /// Parse a feature expression where we've already consumed the parenthesis. pub fn parse_in_parenthesis_block<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, @@ -332,9 +330,8 @@ impl MediaFeatureExpression { let operator = input.try_parse(consume_operation_or_colon); let operator = match operator { Err(..) => { - // If there's no colon, this is a media query of the - // form '()', that is, there's no value - // specified. + // If there's no colon, this is a query of the form + // '()', that is, there's no value specified. // // Gecko doesn't allow ranged expressions without a // value, so just reject them here too. @@ -370,7 +367,7 @@ impl MediaFeatureExpression { }, }; - let value = MediaExpressionValue::parse(feature, context, input).map_err(|err| { + let value = QueryExpressionValue::parse(feature, context, input).map_err(|err| { err.location .new_custom_error(StyleParseErrorKind::MediaQueryExpectedFeatureValue) })?; @@ -378,15 +375,15 @@ impl MediaFeatureExpression { Ok(Self::new(feature_index, Some(value), range_or_operator)) } - /// Returns whether this media query evaluates to true for the given device. + /// Returns whether this query evaluates to true for the given device. pub fn matches(&self, context: &computed::Context) -> bool { let value = self.value.as_ref(); macro_rules! expect { ($variant:ident) => { value.map(|value| match *value { - MediaExpressionValue::$variant(ref v) => v, - _ => unreachable!("Unexpected MediaExpressionValue"), + QueryExpressionValue::$variant(ref v) => v, + _ => unreachable!("Unexpected QueryExpressionValue"), }) }; } @@ -442,7 +439,7 @@ impl MediaFeatureExpression { } } -/// A value found or expected in a media expression. +/// A value found or expected in a expression. /// /// FIXME(emilio): How should calc() serialize in the Number / Integer / /// BoolInteger / NumberRatio case, as computed or as specified value? @@ -451,7 +448,7 @@ impl MediaFeatureExpression { /// /// See: https://github.com/w3c/csswg-drafts/issues/1968 #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToShmem)] -pub enum MediaExpressionValue { +pub enum QueryExpressionValue { /// A length. Length(Length), /// A (non-negative) integer. @@ -470,19 +467,19 @@ pub enum MediaExpressionValue { Enumerated(KeywordDiscriminant), } -impl MediaExpressionValue { - fn to_css(&self, dest: &mut CssWriter, for_expr: &MediaFeatureExpression) -> fmt::Result +impl QueryExpressionValue { + fn to_css(&self, dest: &mut CssWriter, for_expr: &QueryFeatureExpression) -> fmt::Result where W: fmt::Write, { match *self { - MediaExpressionValue::Length(ref l) => l.to_css(dest), - MediaExpressionValue::Integer(v) => v.to_css(dest), - MediaExpressionValue::Float(v) => v.to_css(dest), - MediaExpressionValue::BoolInteger(v) => dest.write_str(if v { "1" } else { "0" }), - MediaExpressionValue::NumberRatio(ratio) => ratio.to_css(dest), - MediaExpressionValue::Resolution(ref r) => r.to_css(dest), - MediaExpressionValue::Enumerated(value) => match for_expr.feature().evaluator { + QueryExpressionValue::Length(ref l) => l.to_css(dest), + QueryExpressionValue::Integer(v) => v.to_css(dest), + QueryExpressionValue::Float(v) => v.to_css(dest), + QueryExpressionValue::BoolInteger(v) => dest.write_str(if v { "1" } else { "0" }), + QueryExpressionValue::NumberRatio(ratio) => ratio.to_css(dest), + QueryExpressionValue::Resolution(ref r) => r.to_css(dest), + QueryExpressionValue::Enumerated(value) => match for_expr.feature().evaluator { Evaluator::Enumerated { serializer, .. } => dest.write_str(&*serializer(value)), _ => unreachable!(), }, @@ -490,18 +487,18 @@ impl MediaExpressionValue { } fn parse<'i, 't>( - for_feature: &MediaFeatureDescription, + for_feature: &QueryFeatureDescription, context: &ParserContext, input: &mut Parser<'i, 't>, - ) -> Result> { + ) -> Result> { Ok(match for_feature.evaluator { Evaluator::Length(..) => { let length = Length::parse_non_negative(context, input)?; - MediaExpressionValue::Length(length) + QueryExpressionValue::Length(length) }, Evaluator::Integer(..) => { let integer = Integer::parse_non_negative(context, input)?; - MediaExpressionValue::Integer(integer.value() as u32) + QueryExpressionValue::Integer(integer.value() as u32) }, Evaluator::BoolInteger(..) => { let integer = Integer::parse_non_negative(context, input)?; @@ -509,22 +506,22 @@ impl MediaExpressionValue { if value > 1 { return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } - MediaExpressionValue::BoolInteger(value == 1) + QueryExpressionValue::BoolInteger(value == 1) }, Evaluator::Float(..) => { let number = Number::parse(context, input)?; - MediaExpressionValue::Float(number.get()) + QueryExpressionValue::Float(number.get()) }, Evaluator::NumberRatio(..) => { use crate::values::specified::Ratio as SpecifiedRatio; let ratio = SpecifiedRatio::parse(context, input)?; - MediaExpressionValue::NumberRatio(Ratio::new(ratio.0.get(), ratio.1.get())) + QueryExpressionValue::NumberRatio(Ratio::new(ratio.0.get(), ratio.1.get())) }, Evaluator::Resolution(..) => { - MediaExpressionValue::Resolution(Resolution::parse(context, input)?) + QueryExpressionValue::Resolution(Resolution::parse(context, input)?) }, Evaluator::Enumerated { parser, .. } => { - MediaExpressionValue::Enumerated(parser(context, input)?) + QueryExpressionValue::Enumerated(parser(context, input)?) }, }) } diff --git a/servo/components/style/queries/mod.rs b/servo/components/style/queries/mod.rs new file mode 100644 index 000000000000..ccc9e7434462 --- /dev/null +++ b/servo/components/style/queries/mod.rs @@ -0,0 +1,17 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +//! Code shared between [media queries][mq] and [container queries][cq]. +//! +//! [mq]: https://drafts.csswg.org/mediaqueries/ +//! [cq]: https://drafts.csswg.org/css-contain-3/#container-rule + +mod condition; + +#[macro_use] +pub mod feature; +pub mod feature_expression; + +pub use self::condition::QueryCondition; +pub use self::feature_expression::QueryFeatureExpression; diff --git a/servo/components/style/stylesheets/container_rule.rs b/servo/components/style/stylesheets/container_rule.rs index e2e21735b3bb..c71fc0177c6c 100644 --- a/servo/components/style/stylesheets/container_rule.rs +++ b/servo/components/style/stylesheets/container_rule.rs @@ -6,7 +6,7 @@ //! //! [container]: https://drafts.csswg.org/css-contain-3/#container-rule -use crate::media_queries::MediaCondition; +use crate::queries::QueryCondition; use crate::shared_lock::{ DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard, }; @@ -76,4 +76,4 @@ impl ToCssWithGuard for ContainerRule { } /// TODO: Factor out the media query code to work with containers. -pub type ContainerCondition = MediaCondition; +pub type ContainerCondition = QueryCondition; diff --git a/servo/components/style/values/specified/source_size_list.rs b/servo/components/style/values/specified/source_size_list.rs index fe1731d981fb..42b272c19eec 100644 --- a/servo/components/style/values/specified/source_size_list.rs +++ b/servo/components/style/values/specified/source_size_list.rs @@ -6,8 +6,9 @@ #[cfg(feature = "gecko")] use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; -use crate::media_queries::{Device, MediaCondition}; +use crate::media_queries::Device; use crate::parser::{Parse, ParserContext}; +use crate::queries::QueryCondition; use crate::values::computed::{self, ToComputedValue}; use crate::values::specified::{Length, NoCalcLength, ViewportPercentageLength}; use app_units::Au; @@ -20,7 +21,7 @@ use style_traits::ParseError; /// https://html.spec.whatwg.org/multipage/#source-size #[derive(Debug)] pub struct SourceSize { - condition: MediaCondition, + condition: QueryCondition, value: Length, } @@ -29,9 +30,8 @@ impl Parse for SourceSize { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - let condition = MediaCondition::parse(context, input)?; + let condition = QueryCondition::parse(context, input)?; let value = Length::parse_non_negative(context, input)?; - Ok(Self { condition, value }) } } diff --git a/testing/web-platform/meta/streams/readable-byte-streams/__dir__.ini b/testing/web-platform/meta/streams/readable-byte-streams/__dir__.ini deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/toolkit/crashreporter/CrashAnnotations.yaml b/toolkit/crashreporter/CrashAnnotations.yaml index 4e2ebcc27168..48beabb56521 100644 --- a/toolkit/crashreporter/CrashAnnotations.yaml +++ b/toolkit/crashreporter/CrashAnnotations.yaml @@ -895,6 +895,14 @@ TextureUsage: type: string ping: true +Throttleable: + description: > + Whether Socorro can selectively discard this crash report or not. If set + to "0" the crash report will always be processed by Socorro. Do not set + this annotation within Gecko code, it's only supposed to be used by the + crash reporting machinery. + type: boolean + TotalPageFile: description: > Maximum amount of memory that can be committed without extending the swap/page file. diff --git a/toolkit/crashreporter/CrashSubmit.jsm b/toolkit/crashreporter/CrashSubmit.jsm index 41f189ab501e..347db2fdf974 100644 --- a/toolkit/crashreporter/CrashSubmit.jsm +++ b/toolkit/crashreporter/CrashSubmit.jsm @@ -229,12 +229,11 @@ Submitter.prototype = { let formData = new FormData(); + // tell the server not to throttle this if requested + this.extraKeyVals.Throttleable = this.noThrottle ? "0" : "1"; + // add the data let payload = Object.assign({}, this.extraKeyVals); - if (this.noThrottle) { - // tell the server not to throttle this, since it was manually submitted - payload.Throttleable = "0"; - } let json = new Blob([JSON.stringify(payload)], { type: "application/json", }); @@ -454,7 +453,7 @@ var CrashSubmit = { * If true, a submission event is recorded in CrashManager. * - noThrottle * If true, this crash report should be submitted with - * an extra parameter of "Throttleable=0" indicating that + * the Throttleable annotation set to "0" indicating that * it should be processed right away. This should be set * when the report is being submitted and the user expects * to see the results immediately. Defaults to false.