Further changes required by Servo

This commit is contained in:
Oriol Brufau 2023-11-02 22:34:38 +01:00 committed by Martin Robinson
parent 4559546fbb
commit bb55e923bb
15 changed files with 76 additions and 38 deletions

View file

@ -12,7 +12,7 @@ use canvas_traits::canvas::{
FillRule, LineCapStyle, LineJoinStyle, LinearGradientStyle, RadialGradientStyle,
RepetitionStyle, TextAlign, TextBaseline,
};
use cssparser::{Color as CSSColor, Parser, ParserInput, RGBA};
use cssparser::{AbsoluteColor, Color as CSSColor, Parser, ParserInput, RGBA};
use euclid::default::{Point2D, Rect, Size2D, Transform2D};
use euclid::vec2;
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
@ -106,7 +106,7 @@ impl CanvasContextState {
const DEFAULT_FONT_STYLE: &'static str = "10px sans-serif";
pub(crate) fn new() -> CanvasContextState {
let black = RGBA::new(0, 0, 0, 255);
let black = RGBA::new(0, 0, 0, 1.0);
CanvasContextState {
global_alpha: 1.0,
global_composition: CompositionOrBlending::default(),
@ -302,7 +302,7 @@ impl CanvasState {
let color = CSSColor::parse(&mut parser);
if parser.is_exhausted() {
match color {
Ok(CSSColor::RGBA(rgba)) => Ok(rgba),
Ok(CSSColor::Absolute(AbsoluteColor::Rgba(rgba))) => Ok(rgba),
Ok(CSSColor::CurrentColor) => {
// TODO: https://github.com/whatwg/html/issues/1099
// Reconsider how to calculate currentColor in a display:none canvas
@ -313,7 +313,7 @@ impl CanvasState {
// https://drafts.css-houdini.org/css-paint-api/#2d-rendering-context
// Whenever "currentColor" is used as a color in the PaintRenderingContext2D API,
// it is treated as opaque black.
None => return Ok(RGBA::new(0, 0, 0, 255)),
None => return Ok(RGBA::new(0, 0, 0, 1.0)),
Some(ref canvas) => &**canvas,
};
@ -323,7 +323,7 @@ impl CanvasState {
Some(ref s) if canvas_element.has_css_layout_box() => {
Ok(s.get_inherited_text().color)
},
_ => Ok(RGBA::new(0, 0, 0, 255)),
_ => Ok(RGBA::new(0, 0, 0, 1.0)),
}
},
_ => Err(()),
@ -1706,7 +1706,7 @@ pub fn parse_color(string: &str) -> Result<RGBA, ()> {
let mut input = ParserInput::new(string);
let mut parser = Parser::new(&mut input);
match CSSColor::parse(&mut parser) {
Ok(CSSColor::RGBA(rgba)) => {
Ok(CSSColor::Absolute(AbsoluteColor::Rgba(rgba))) => {
if parser.is_exhausted() {
Ok(rgba)
} else {
@ -1732,7 +1732,7 @@ where
let green = color.green;
let blue = color.blue;
if color.alpha == 255 {
if color.alpha == 1.0 {
write!(
dest,
"#{:x}{:x}{:x}{:x}{:x}{:x}",