mirror of
https://github.com/servo/servo.git
synced 2025-07-07 07:23:38 +01:00
stylo: Support color presentation attributes
This commit is contained in:
parent
5cc0fa5ec2
commit
404ebf5b3a
1 changed files with 38 additions and 6 deletions
|
@ -1103,18 +1103,50 @@ pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations:
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor(_:
|
pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
_: nsCSSPropertyID) {
|
property: nsCSSPropertyID) {
|
||||||
|
use cssparser::Color;
|
||||||
|
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId};
|
||||||
|
use style::values::specified::CSSColor;
|
||||||
|
|
||||||
|
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||||
|
let long = get_longhand_from_id!(property);
|
||||||
|
let cc = CSSColor { parsed: Color::CurrentColor, authored: None };
|
||||||
|
|
||||||
|
let prop = match_wrap_declared! { long,
|
||||||
|
BorderTopColor => cc,
|
||||||
|
BorderRightColor => cc,
|
||||||
|
BorderBottomColor => cc,
|
||||||
|
BorderLeftColor => cc,
|
||||||
|
};
|
||||||
|
declarations.write().declarations.push((prop, Default::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_DeclarationBlock_SetColorValue(_:
|
pub extern "C" fn Servo_DeclarationBlock_SetColorValue(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
_: nsCSSPropertyID,
|
property: nsCSSPropertyID,
|
||||||
_: structs::nscolor) {
|
value: structs::nscolor) {
|
||||||
|
use cssparser::Color;
|
||||||
|
use style::gecko::values::convert_nscolor_to_rgba;
|
||||||
|
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId};
|
||||||
|
use style::values::specified::{CSSColor, CSSRGBA};
|
||||||
|
|
||||||
|
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||||
|
let long = get_longhand_from_id!(property);
|
||||||
|
let rgba = convert_nscolor_to_rgba(value);
|
||||||
|
let color = CSSColor { parsed: Color::RGBA(rgba), authored: None };
|
||||||
|
|
||||||
|
let prop = match_wrap_declared! { long,
|
||||||
|
BorderTopColor => color,
|
||||||
|
BorderRightColor => color,
|
||||||
|
BorderBottomColor => color,
|
||||||
|
BorderLeftColor => color,
|
||||||
|
Color => CSSRGBA { parsed: rgba, authored: None },
|
||||||
|
BackgroundColor => color,
|
||||||
|
};
|
||||||
|
declarations.write().declarations.push((prop, Default::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue