зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551991 - Remove nsCSSValue usage for range checks in CounterStyleRule. r=jwatt
Depends on D31317 Differential Revision: https://phabricator.services.mozilla.com/D31318 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7e0fc30e7d
Коммит
88428d31cd
|
@ -1183,23 +1183,21 @@ static inline bool IsRangeValueInfinite(const nsCSSValue& aValue) {
|
|||
|
||||
/* virtual */
|
||||
bool CustomCounterStyle::IsOrdinalInRange(CounterValue aOrdinal) {
|
||||
nsCSSValue value = GetDesc(eCSSCounterDesc_Range);
|
||||
if (value.GetUnit() == eCSSUnit_PairList) {
|
||||
for (const nsCSSValuePairList* item = value.GetPairListValue();
|
||||
item != nullptr; item = item->mNext) {
|
||||
const nsCSSValue& lowerBound = item->mXValue;
|
||||
const nsCSSValue& upperBound = item->mYValue;
|
||||
if ((IsRangeValueInfinite(lowerBound) ||
|
||||
aOrdinal >= lowerBound.GetIntValue()) &&
|
||||
(IsRangeValueInfinite(upperBound) ||
|
||||
aOrdinal <= upperBound.GetIntValue())) {
|
||||
return true;
|
||||
auto inRange = Servo_CounterStyleRule_IsInRange(mRule, aOrdinal);
|
||||
switch (inRange) {
|
||||
case StyleIsOrdinalInRange::InRange:
|
||||
return true;
|
||||
case StyleIsOrdinalInRange::NotInRange:
|
||||
return false;
|
||||
case StyleIsOrdinalInRange::NoOrdinalSpecified:
|
||||
if (IsExtendsSystem()) {
|
||||
return GetExtends()->IsOrdinalInRange(aOrdinal);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (IsExtendsSystem() && value.GetUnit() == eCSSUnit_None) {
|
||||
// Only use the range of extended style when 'range' is not specified.
|
||||
return GetExtends()->IsOrdinalInRange(aOrdinal);
|
||||
break;
|
||||
case StyleIsOrdinalInRange::Auto:
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unkown result from IsInRange?");
|
||||
}
|
||||
return IsOrdinalInAutoRange(aOrdinal);
|
||||
}
|
||||
|
|
|
@ -3032,6 +3032,54 @@ pub unsafe extern "C" fn Servo_CounterStyleRule_GetNegative(
|
|||
})
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
pub enum IsOrdinalInRange {
|
||||
Auto,
|
||||
InRange,
|
||||
NotInRange,
|
||||
NoOrdinalSpecified,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_CounterStyleRule_IsInRange(
|
||||
rule: &RawServoCounterStyleRule,
|
||||
ordinal: i32,
|
||||
) -> IsOrdinalInRange {
|
||||
use style::counter_style::CounterBound;
|
||||
read_locked_arc(rule, |rule: &CounterStyleRule| {
|
||||
let range = match rule.range() {
|
||||
Some(r) => r,
|
||||
None => return IsOrdinalInRange::NoOrdinalSpecified,
|
||||
};
|
||||
|
||||
if range.0.is_empty() {
|
||||
return IsOrdinalInRange::Auto;
|
||||
}
|
||||
|
||||
let in_range = range.0.iter().any(|r| {
|
||||
if let CounterBound::Integer(start) = r.start {
|
||||
if start.value() > ordinal {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if let CounterBound::Integer(end) = r.end {
|
||||
if end.value() < ordinal {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
});
|
||||
|
||||
if in_range {
|
||||
IsOrdinalInRange::InRange
|
||||
} else {
|
||||
IsOrdinalInRange::NotInRange
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_CounterStyleRule_GetSystem(
|
||||
rule: &RawServoCounterStyleRule,
|
||||
|
|
Загрузка…
Ссылка в новой задаче