mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Further changes required by Servo
This commit is contained in:
parent
fb4501c5b4
commit
11414d0c94
5 changed files with 32 additions and 38 deletions
|
@ -885,10 +885,10 @@ pub fn clamp_floor_256_f32(val: f32) -> u8 {
|
|||
impl ToRaqoteGradientStop for CanvasGradientStop {
|
||||
fn to_raqote(&self) -> raqote::GradientStop {
|
||||
let color = raqote::Color::new(
|
||||
clamp_unit_f32(self.color.alpha),
|
||||
self.color.red,
|
||||
self.color.green,
|
||||
self.color.blue,
|
||||
self.color.alpha.map(clamp_unit_f32).unwrap_or(0),
|
||||
self.color.red.unwrap_or(0),
|
||||
self.color.green.unwrap_or(0),
|
||||
self.color.blue.unwrap_or(0),
|
||||
);
|
||||
let position = self.offset as f32;
|
||||
raqote::GradientStop { position, color }
|
||||
|
@ -902,10 +902,10 @@ impl<'a> ToRaqotePattern<'_> for FillOrStrokeStyle {
|
|||
|
||||
match self {
|
||||
Color(color) => Some(Pattern::Color(
|
||||
clamp_unit_f32(color.alpha),
|
||||
color.red,
|
||||
color.green,
|
||||
color.blue,
|
||||
color.alpha.map(clamp_unit_f32).unwrap_or(0),
|
||||
color.red.unwrap_or(0),
|
||||
color.green.unwrap_or(0),
|
||||
color.blue.unwrap_or(0),
|
||||
)),
|
||||
LinearGradient(style) => {
|
||||
let start = Point2D::new(style.x0 as f32, style.y0 as f32);
|
||||
|
@ -961,10 +961,10 @@ impl ToRaqoteStyle for RGBA {
|
|||
|
||||
fn to_raqote_style(self) -> Self::Target {
|
||||
raqote::SolidSource::from_unpremultiplied_argb(
|
||||
clamp_unit_f32(self.alpha),
|
||||
self.red,
|
||||
self.green,
|
||||
self.blue,
|
||||
self.alpha.map(clamp_unit_f32).unwrap_or(0),
|
||||
self.red.unwrap_or(0),
|
||||
self.green.unwrap_or(0),
|
||||
self.blue.unwrap_or(0),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ impl CanvasContextState {
|
|||
const DEFAULT_FONT_STYLE: &'static str = "10px sans-serif";
|
||||
|
||||
pub(crate) fn new() -> CanvasContextState {
|
||||
let black = RGBA::new(0, 0, 0, 1.0);
|
||||
let black = RGBA::new(Some(0), Some(0), Some(0), Some(1.0));
|
||||
CanvasContextState {
|
||||
global_alpha: 1.0,
|
||||
global_composition: CompositionOrBlending::default(),
|
||||
|
@ -127,7 +127,7 @@ impl CanvasContextState {
|
|||
shadow_offset_x: 0.0,
|
||||
shadow_offset_y: 0.0,
|
||||
shadow_blur: 0.0,
|
||||
shadow_color: RGBA::transparent(),
|
||||
shadow_color: RGBA::new(Some(0), Some(0), Some(0), Some(0.0)),
|
||||
font_style: None,
|
||||
text_align: Default::default(),
|
||||
text_baseline: Default::default(),
|
||||
|
@ -1711,10 +1711,10 @@ pub fn parse_color(canvas: Option<&HTMLCanvasElement>, string: &str) -> Result<R
|
|||
.resolve_into_absolute(¤t_color)
|
||||
.to_color_space(ColorSpace::Srgb);
|
||||
Ok(RGBA::from_floats(
|
||||
rgba.components.0,
|
||||
rgba.components.1,
|
||||
rgba.components.2,
|
||||
rgba.alpha,
|
||||
Some(rgba.components.0),
|
||||
Some(rgba.components.1),
|
||||
Some(rgba.components.2),
|
||||
Some(rgba.alpha),
|
||||
))
|
||||
},
|
||||
None => Err(()),
|
||||
|
@ -1732,11 +1732,12 @@ pub fn serialize<W>(color: &RGBA, dest: &mut W) -> fmt::Result
|
|||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
let red = color.red;
|
||||
let green = color.green;
|
||||
let blue = color.blue;
|
||||
let red = color.red.unwrap_or(0);
|
||||
let green = color.green.unwrap_or(0);
|
||||
let blue = color.blue.unwrap_or(0);
|
||||
let alpha = color.alpha.unwrap_or(0.0);
|
||||
|
||||
if color.alpha == 1.0 {
|
||||
if alpha == 1.0 {
|
||||
write!(
|
||||
dest,
|
||||
"#{:x}{:x}{:x}{:x}{:x}{:x}",
|
||||
|
@ -1748,14 +1749,7 @@ where
|
|||
blue & 0xF
|
||||
)
|
||||
} else {
|
||||
write!(
|
||||
dest,
|
||||
"rgba({}, {}, {}, {})",
|
||||
red,
|
||||
green,
|
||||
blue,
|
||||
color.alpha_f32()
|
||||
)
|
||||
write!(dest, "rgba({}, {}, {}, {})", red, green, blue, alpha)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,7 +431,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
|
|||
hex(input.as_bytes()[2] as char),
|
||||
hex(input.as_bytes()[3] as char),
|
||||
) {
|
||||
return Ok(RGBA::new(r * 17, g * 17, b * 17, 1.0));
|
||||
return Ok(RGBA::new(Some(r * 17), Some(g * 17), Some(b * 17), Some(1.0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,10 +501,10 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
|
|||
|
||||
// Steps 15-20.
|
||||
return Ok(RGBA::new(
|
||||
hex_string(red).unwrap(),
|
||||
hex_string(green).unwrap(),
|
||||
hex_string(blue).unwrap(),
|
||||
1.0,
|
||||
Some(hex_string(red).unwrap()),
|
||||
Some(hex_string(green).unwrap()),
|
||||
Some(hex_string(blue).unwrap()),
|
||||
Some(1.0),
|
||||
));
|
||||
|
||||
fn hex(ch: char) -> Result<u8, ()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue