mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Support image-set() on the cursor property
Differential Revision: https://phabricator.services.mozilla.com/D106745
This commit is contained in:
parent
e1f254854d
commit
685d269e31
4 changed files with 49 additions and 20 deletions
|
@ -7,17 +7,17 @@
|
|||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::values::generics::ui as generics;
|
||||
use crate::values::specified::color::Color;
|
||||
use crate::values::specified::url::SpecifiedImageUrl;
|
||||
use crate::values::specified::image::Image;
|
||||
use crate::values::specified::Number;
|
||||
use cssparser::Parser;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
||||
|
||||
/// A specified value for the `cursor` property.
|
||||
pub type Cursor = generics::GenericCursor<CursorImage>;
|
||||
|
||||
/// A specified value for item of `image cursors`.
|
||||
pub type CursorImage = generics::GenericCursorImage<SpecifiedImageUrl, Number>;
|
||||
pub type CursorImage = generics::GenericCursorImage<Image, Number>;
|
||||
|
||||
impl Parse for Cursor {
|
||||
/// cursor: [<url> [<number> <number>]?]# [auto | default | ...]
|
||||
|
@ -47,7 +47,7 @@ impl Parse for CursorImage {
|
|||
) -> Result<Self, ParseError<'i>> {
|
||||
use crate::Zero;
|
||||
|
||||
let url = SpecifiedImageUrl::parse(context, input)?;
|
||||
let image = Image::parse_only_url(context, input)?;
|
||||
let mut has_hotspot = false;
|
||||
let mut hotspot_x = Number::zero();
|
||||
let mut hotspot_y = Number::zero();
|
||||
|
@ -59,7 +59,7 @@ impl Parse for CursorImage {
|
|||
}
|
||||
|
||||
Ok(Self {
|
||||
url,
|
||||
image,
|
||||
has_hotspot,
|
||||
hotspot_x,
|
||||
hotspot_y,
|
||||
|
@ -67,6 +67,10 @@ impl Parse for CursorImage {
|
|||
}
|
||||
}
|
||||
|
||||
// This trait is manually implemented because we don't support the whole <image>
|
||||
// syntax for cursors
|
||||
impl SpecifiedValueInfo for CursorImage {}
|
||||
|
||||
/// Specified value of `-moz-force-broken-image-icon`
|
||||
#[derive(
|
||||
Clone,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue