mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +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
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1171,7 +1171,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.30.0"
|
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 = [
|
dependencies = [
|
||||||
"cssparser-macros",
|
"cssparser-macros",
|
||||||
"dtoa-short",
|
"dtoa-short",
|
||||||
|
@ -1187,7 +1187,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser-macros"
|
name = "cssparser-macros"
|
||||||
version = "0.6.0"
|
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 = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.103",
|
"syn 1.0.103",
|
||||||
|
|
|
@ -27,7 +27,7 @@ compositing_traits = { path = "components/shared/compositing" }
|
||||||
content-security-policy = { version = "0.5", features = ["serde"] }
|
content-security-policy = { version = "0.5", features = ["serde"] }
|
||||||
cookie = "0.12"
|
cookie = "0.12"
|
||||||
crossbeam-channel = "0.5"
|
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 }
|
darling = { version = "0.14", default-features = false }
|
||||||
data-url = "0.1.0"
|
data-url = "0.1.0"
|
||||||
devtools_traits = { path = "components/shared/devtools" }
|
devtools_traits = { path = "components/shared/devtools" }
|
||||||
|
|
|
@ -885,10 +885,10 @@ pub fn clamp_floor_256_f32(val: f32) -> u8 {
|
||||||
impl ToRaqoteGradientStop for CanvasGradientStop {
|
impl ToRaqoteGradientStop for CanvasGradientStop {
|
||||||
fn to_raqote(&self) -> raqote::GradientStop {
|
fn to_raqote(&self) -> raqote::GradientStop {
|
||||||
let color = raqote::Color::new(
|
let color = raqote::Color::new(
|
||||||
clamp_unit_f32(self.color.alpha),
|
self.color.alpha.map(clamp_unit_f32).unwrap_or(0),
|
||||||
self.color.red,
|
self.color.red.unwrap_or(0),
|
||||||
self.color.green,
|
self.color.green.unwrap_or(0),
|
||||||
self.color.blue,
|
self.color.blue.unwrap_or(0),
|
||||||
);
|
);
|
||||||
let position = self.offset as f32;
|
let position = self.offset as f32;
|
||||||
raqote::GradientStop { position, color }
|
raqote::GradientStop { position, color }
|
||||||
|
@ -902,10 +902,10 @@ impl<'a> ToRaqotePattern<'_> for FillOrStrokeStyle {
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Color(color) => Some(Pattern::Color(
|
Color(color) => Some(Pattern::Color(
|
||||||
clamp_unit_f32(color.alpha),
|
color.alpha.map(clamp_unit_f32).unwrap_or(0),
|
||||||
color.red,
|
color.red.unwrap_or(0),
|
||||||
color.green,
|
color.green.unwrap_or(0),
|
||||||
color.blue,
|
color.blue.unwrap_or(0),
|
||||||
)),
|
)),
|
||||||
LinearGradient(style) => {
|
LinearGradient(style) => {
|
||||||
let start = Point2D::new(style.x0 as f32, style.y0 as f32);
|
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 {
|
fn to_raqote_style(self) -> Self::Target {
|
||||||
raqote::SolidSource::from_unpremultiplied_argb(
|
raqote::SolidSource::from_unpremultiplied_argb(
|
||||||
clamp_unit_f32(self.alpha),
|
self.alpha.map(clamp_unit_f32).unwrap_or(0),
|
||||||
self.red,
|
self.red.unwrap_or(0),
|
||||||
self.green,
|
self.green.unwrap_or(0),
|
||||||
self.blue,
|
self.blue.unwrap_or(0),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl CanvasContextState {
|
||||||
const DEFAULT_FONT_STYLE: &'static str = "10px sans-serif";
|
const DEFAULT_FONT_STYLE: &'static str = "10px sans-serif";
|
||||||
|
|
||||||
pub(crate) fn new() -> CanvasContextState {
|
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 {
|
CanvasContextState {
|
||||||
global_alpha: 1.0,
|
global_alpha: 1.0,
|
||||||
global_composition: CompositionOrBlending::default(),
|
global_composition: CompositionOrBlending::default(),
|
||||||
|
@ -127,7 +127,7 @@ impl CanvasContextState {
|
||||||
shadow_offset_x: 0.0,
|
shadow_offset_x: 0.0,
|
||||||
shadow_offset_y: 0.0,
|
shadow_offset_y: 0.0,
|
||||||
shadow_blur: 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,
|
font_style: None,
|
||||||
text_align: Default::default(),
|
text_align: Default::default(),
|
||||||
text_baseline: 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)
|
.resolve_into_absolute(¤t_color)
|
||||||
.to_color_space(ColorSpace::Srgb);
|
.to_color_space(ColorSpace::Srgb);
|
||||||
Ok(RGBA::from_floats(
|
Ok(RGBA::from_floats(
|
||||||
rgba.components.0,
|
Some(rgba.components.0),
|
||||||
rgba.components.1,
|
Some(rgba.components.1),
|
||||||
rgba.components.2,
|
Some(rgba.components.2),
|
||||||
rgba.alpha,
|
Some(rgba.alpha),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
None => Err(()),
|
None => Err(()),
|
||||||
|
@ -1732,11 +1732,12 @@ pub fn serialize<W>(color: &RGBA, dest: &mut W) -> fmt::Result
|
||||||
where
|
where
|
||||||
W: fmt::Write,
|
W: fmt::Write,
|
||||||
{
|
{
|
||||||
let red = color.red;
|
let red = color.red.unwrap_or(0);
|
||||||
let green = color.green;
|
let green = color.green.unwrap_or(0);
|
||||||
let blue = color.blue;
|
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!(
|
write!(
|
||||||
dest,
|
dest,
|
||||||
"#{:x}{:x}{:x}{:x}{:x}{:x}",
|
"#{:x}{:x}{:x}{:x}{:x}{:x}",
|
||||||
|
@ -1748,14 +1749,7 @@ where
|
||||||
blue & 0xF
|
blue & 0xF
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(dest, "rgba({}, {}, {}, {})", red, green, blue, alpha)
|
||||||
dest,
|
|
||||||
"rgba({}, {}, {}, {})",
|
|
||||||
red,
|
|
||||||
green,
|
|
||||||
blue,
|
|
||||||
color.alpha_f32()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()[2] as char),
|
||||||
hex(input.as_bytes()[3] 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.
|
// Steps 15-20.
|
||||||
return Ok(RGBA::new(
|
return Ok(RGBA::new(
|
||||||
hex_string(red).unwrap(),
|
Some(hex_string(red).unwrap()),
|
||||||
hex_string(green).unwrap(),
|
Some(hex_string(green).unwrap()),
|
||||||
hex_string(blue).unwrap(),
|
Some(hex_string(blue).unwrap()),
|
||||||
1.0,
|
Some(1.0),
|
||||||
));
|
));
|
||||||
|
|
||||||
fn hex(ch: char) -> Result<u8, ()> {
|
fn hex(ch: char) -> Result<u8, ()> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue