mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-07 14:55:30 +02:00
feat: add backwards compatibility for moz-bool-pref after removal
This commit is contained in:
parent
12bdf7541f
commit
7abae9d69e
3 changed files with 124 additions and 0 deletions
54
src/servo/components/style/gecko/media_features-rs.patch
Normal file
54
src/servo/components/style/gecko/media_features-rs.patch
Normal file
|
@ -0,0 +1,54 @@
|
|||
diff --git a/servo/components/style/gecko/media_features.rs b/servo/components/style/gecko/media_features.rs
|
||||
index 2baf0df323c83107a9a38e76bda3a273892b121e..f14fc90e048534f7345be102783e0669fa03ae75 100644
|
||||
--- a/servo/components/style/gecko/media_features.rs
|
||||
+++ b/servo/components/style/gecko/media_features.rs
|
||||
@@ -9,10 +9,13 @@ use crate::gecko_bindings::structs;
|
||||
use crate::media_queries::{Device, MediaType};
|
||||
use crate::queries::feature::{AllowsRanges, Evaluator, FeatureFlags, QueryFeatureDescription};
|
||||
use crate::queries::values::Orientation;
|
||||
+use crate::queries::condition::MozPrefFeatureValue;
|
||||
use crate::values::computed::{CSSPixelLength, Context, Ratio, Resolution};
|
||||
use crate::values::specified::color::ForcedColors;
|
||||
+use crate::values::AtomString;
|
||||
use app_units::Au;
|
||||
use euclid::default::Size2D;
|
||||
+use selectors::kleene_value::KleeneValue;
|
||||
|
||||
fn device_size(device: &Device) -> Size2D<Au> {
|
||||
let mut width = 0;
|
||||
@@ -615,6 +618,13 @@ fn eval_moz_overlay_scrollbars(context: &Context) -> bool {
|
||||
unsafe { bindings::Gecko_MediaFeatures_UseOverlayScrollbars(context.device().document()) }
|
||||
}
|
||||
|
||||
+fn eval_moz_bool_pref(_: &Context, pref: Option<&AtomString>) -> KleeneValue {
|
||||
+ let Some(pref) = pref else {
|
||||
+ return KleeneValue::False;
|
||||
+ };
|
||||
+ KleeneValue::from(unsafe { bindings::Gecko_EvalMozPrefFeature(pref.as_ptr(), &MozPrefFeatureValue::<i32>::None) })
|
||||
+}
|
||||
+
|
||||
fn get_lnf_int(int_id: i32) -> i32 {
|
||||
unsafe { bindings::Gecko_GetLookAndFeelInt(int_id) }
|
||||
}
|
||||
@@ -662,7 +672,7 @@ macro_rules! lnf_int_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: [QueryFeatureDescription; 61] = [
|
||||
+pub static MEDIA_FEATURES: [QueryFeatureDescription; 62] = [
|
||||
feature!(
|
||||
atom!("width"),
|
||||
AllowsRanges::Yes,
|
||||
@@ -927,6 +937,12 @@ pub static MEDIA_FEATURES: [QueryFeatureDescription; 61] = [
|
||||
Evaluator::BoolInteger(eval_moz_overlay_scrollbars),
|
||||
FeatureFlags::CHROME_AND_UA_ONLY,
|
||||
),
|
||||
+ feature!(
|
||||
+ atom!("-moz-bool-pref"),
|
||||
+ AllowsRanges::No,
|
||||
+ Evaluator::String(eval_moz_bool_pref),
|
||||
+ FeatureFlags::CHROME_AND_UA_ONLY,
|
||||
+ ),
|
||||
lnf_int_feature!(
|
||||
atom!("-moz-scrollbar-start-backward"),
|
||||
ScrollArrowStyle,
|
20
src/servo/components/style/queries/feature-rs.patch
Normal file
20
src/servo/components/style/queries/feature-rs.patch
Normal file
|
@ -0,0 +1,20 @@
|
|||
diff --git a/servo/components/style/queries/feature.rs b/servo/components/style/queries/feature.rs
|
||||
index a9a4decb178234037a6d285ddd3206bd52f214e5..18ea220a14cbb59ef3c9809cb679f8fdb5352f98 100644
|
||||
--- a/servo/components/style/queries/feature.rs
|
||||
+++ b/servo/components/style/queries/feature.rs
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
use crate::parser::ParserContext;
|
||||
use crate::values::computed::{self, CSSPixelLength, Ratio, Resolution};
|
||||
+use crate::values::AtomString;
|
||||
use crate::Atom;
|
||||
use cssparser::Parser;
|
||||
use selectors::kleene_value::KleeneValue;
|
||||
@@ -44,6 +45,7 @@ pub enum Evaluator {
|
||||
OptionalNumberRatio(QueryFeatureGetter<Option<Ratio>>),
|
||||
/// A resolution.
|
||||
Resolution(QueryFeatureGetter<Resolution>),
|
||||
+ String(fn(&computed::Context, Option<&AtomString>) -> KleeneValue),
|
||||
/// A keyword value.
|
||||
Enumerated {
|
||||
/// The parser to get a discriminant given a string.
|
|
@ -0,0 +1,50 @@
|
|||
diff --git a/servo/components/style/queries/feature_expression.rs b/servo/components/style/queries/feature_expression.rs
|
||||
index 31ba4839aacf740eae4a753c17ee34d9e13562eb..e59bea9cd82d85ff6b195051fef595a45dff520c 100644
|
||||
--- a/servo/components/style/queries/feature_expression.rs
|
||||
+++ b/servo/components/style/queries/feature_expression.rs
|
||||
@@ -11,7 +11,7 @@ use crate::parser::{Parse, ParserContext};
|
||||
use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
|
||||
use crate::values::computed::{self, Ratio, ToComputedValue};
|
||||
use crate::values::specified::{Integer, Length, Number, Resolution};
|
||||
-use crate::values::CSSFloat;
|
||||
+use crate::values::{AtomString, CSSFloat};
|
||||
use crate::{Atom, Zero};
|
||||
use cssparser::{Parser, Token};
|
||||
use selectors::kleene_value::KleeneValue;
|
||||
@@ -639,6 +639,10 @@ impl QueryFeatureExpression {
|
||||
.map(|v| *expect!(Enumerated, v));
|
||||
return evaluator(context, computed);
|
||||
},
|
||||
+ Evaluator::String(evaluator) => {
|
||||
+ let string = self.kind.non_ranged_value().map(|v| expect!(String, v));
|
||||
+ return evaluator(context, string);
|
||||
+ },
|
||||
Evaluator::BoolInteger(eval) => {
|
||||
let computed = self
|
||||
.kind
|
||||
@@ -677,6 +681,7 @@ pub enum QueryExpressionValue {
|
||||
/// An enumerated value, defined by the variant keyword table in the
|
||||
/// feature's `mData` member.
|
||||
Enumerated(KeywordDiscriminant),
|
||||
+ String(AtomString),
|
||||
}
|
||||
|
||||
impl QueryExpressionValue {
|
||||
@@ -695,6 +700,7 @@ impl QueryExpressionValue {
|
||||
Evaluator::Enumerated { serializer, .. } => dest.write_str(&*serializer(value)),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
+ QueryExpressionValue::String(ref s) => s.to_css(dest),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,6 +738,9 @@ impl QueryExpressionValue {
|
||||
Evaluator::Resolution(..) => {
|
||||
QueryExpressionValue::Resolution(Resolution::parse(context, input)?)
|
||||
},
|
||||
+ Evaluator::String(..) => {
|
||||
+ QueryExpressionValue::String(input.expect_string()?.as_ref().into())
|
||||
+ },
|
||||
Evaluator::Enumerated { parser, .. } => {
|
||||
QueryExpressionValue::Enumerated(parser(context, input)?)
|
||||
},
|
Loading…
Add table
Add a link
Reference in a new issue