Bug 1551991 - Remove nsCSSValue usage from GetPad. r=jwatt

Depends on D31315

Differential Revision: https://phabricator.services.mozilla.com/D31316

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-05-16 23:05:10 +00:00
parent c8338578d2
commit 854582f70f
2 changed files with 31 additions and 10 deletions

View File

@ -1242,16 +1242,13 @@ bool CustomCounterStyle::IsOrdinalInAutoRange(CounterValue aOrdinal) {
void CustomCounterStyle::GetPad(PadType& aResult) {
if (!(mFlags & FLAG_PAD_INITED)) {
mFlags |= FLAG_PAD_INITED;
nsCSSValue value = GetDesc(eCSSCounterDesc_Pad);
if (value.GetUnit() == eCSSUnit_Pair) {
const nsCSSValuePair& pair = value.GetPairValue();
mPad.width = pair.mXValue.GetIntValue();
pair.mYValue.GetStringValue(mPad.symbol);
} else if (IsExtendsSystem()) {
GetExtends()->GetPad(mPad);
} else {
mPad.width = 0;
mPad.symbol.Truncate();
if (!Servo_CounterStyleRule_GetPad(mRule, &mPad.width, &mPad.symbol)) {
if (IsExtendsSystem()) {
GetExtends()->GetPad(mPad);
} else {
mPad.width = 0;
mPad.symbol.Truncate();
}
}
}
aResult = mPad;

View File

@ -2959,6 +2959,30 @@ pub unsafe extern "C" fn Servo_CounterStyleRule_GetGeneration(
read_locked_arc(rule, |rule: &CounterStyleRule| rule.generation())
}
fn symbol_to_string(s: &counter_style::Symbol) -> nsString {
match *s {
counter_style::Symbol::String(ref s) => nsString::from(&**s),
counter_style::Symbol::Ident(ref i) => nsString::from(i.0.as_slice())
}
}
#[no_mangle]
pub unsafe extern "C" fn Servo_CounterStyleRule_GetPad(
rule: &RawServoCounterStyleRule,
width: &mut i32,
symbol: &mut nsString,
) -> bool {
read_locked_arc(rule, |rule: &CounterStyleRule| {
let pad = match rule.pad() {
Some(pad) => pad,
None => return false,
};
*width = pad.0.value();
*symbol = symbol_to_string(&pad.1);
true
})
}
#[no_mangle]
pub unsafe extern "C" fn Servo_CounterStyleRule_GetSystem(
rule: &RawServoCounterStyleRule,