mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Further changes required by Servo
This commit is contained in:
parent
fb4501c5b4
commit
11414d0c94
5 changed files with 32 additions and 38 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1171,7 +1171,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cssparser"
|
||||
version = "0.30.0"
|
||||
source = "git+https://github.com/servo/rust-cssparser?rev=b196a164dcbb317016d4aa6c58c13147e6045ebb#b196a164dcbb317016d4aa6c58c13147e6045ebb"
|
||||
source = "git+https://github.com/servo/rust-cssparser?rev=45bc47e2bcb846f1efb5aea156be5fe7d18624bf#45bc47e2bcb846f1efb5aea156be5fe7d18624bf"
|
||||
dependencies = [
|
||||
"cssparser-macros",
|
||||
"dtoa-short",
|
||||
|
@ -1187,7 +1187,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cssparser-macros"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/servo/rust-cssparser?rev=b196a164dcbb317016d4aa6c58c13147e6045ebb#b196a164dcbb317016d4aa6c58c13147e6045ebb"
|
||||
source = "git+https://github.com/servo/rust-cssparser?rev=45bc47e2bcb846f1efb5aea156be5fe7d18624bf#45bc47e2bcb846f1efb5aea156be5fe7d18624bf"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.103",
|
||||
|
|
|
@ -27,7 +27,7 @@ compositing_traits = { path = "components/shared/compositing" }
|
|||
content-security-policy = { version = "0.5", features = ["serde"] }
|
||||
cookie = "0.12"
|
||||
crossbeam-channel = "0.5"
|
||||
cssparser = { version = "0.30", git = "https://github.com/servo/rust-cssparser", rev = "b196a164dcbb317016d4aa6c58c13147e6045ebb" }
|
||||
cssparser = { version = "0.30", git = "https://github.com/servo/rust-cssparser", rev = "45bc47e2bcb846f1efb5aea156be5fe7d18624bf" }
|
||||
darling = { version = "0.14", default-features = false }
|
||||
data-url = "0.1.0"
|
||||
devtools_traits = { path = "components/shared/devtools" }
|
||||
|
|
|
@ -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