mirror of
https://github.com/servo/servo.git
synced 2025-08-16 02:45:36 +01:00
compositing: Implement cursor
per CSS3-UI § 8.1.1 in the CEF/Mac port.
I'm not sure how we want to handle Linux cursors, and GLFW has no ability to set cursors (short of disabling it and managing it yourself).
This commit is contained in:
parent
636641f905
commit
7371e0b8e3
23 changed files with 564 additions and 171 deletions
|
@ -32,7 +32,7 @@ import re
|
|||
|
||||
def to_rust_ident(name):
|
||||
name = name.replace("-", "_")
|
||||
if name in ["static", "super", "box"]: # Rust keywords
|
||||
if name in ["static", "super", "box", "move"]: # Rust keywords
|
||||
name += "_"
|
||||
return name
|
||||
|
||||
|
@ -1349,6 +1349,139 @@ pub mod longhands {
|
|||
|
||||
${single_keyword("box-sizing", "content-box border-box")}
|
||||
|
||||
${new_style_struct("Pointing", is_inherited=True)}
|
||||
|
||||
<%self:single_component_value name="cursor">
|
||||
use servo_util::cursor as util_cursor;
|
||||
pub use super::computed_as_specified as to_computed_value;
|
||||
|
||||
pub mod computed_value {
|
||||
use servo_util::cursor::Cursor;
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub enum T {
|
||||
AutoCursor,
|
||||
SpecifiedCursor(Cursor),
|
||||
}
|
||||
}
|
||||
pub type SpecifiedValue = computed_value::T;
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T::AutoCursor
|
||||
}
|
||||
pub fn from_component_value(value: &ComponentValue, _: &Url)
|
||||
-> Result<SpecifiedValue,()> {
|
||||
match value {
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("auto") => Ok(T::AutoCursor),
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("none") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NoCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("default") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::DefaultCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("pointer") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::PointerCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("context-menu") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::ContextMenuCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("help") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::HelpCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("progress") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::ProgressCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("wait") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::WaitCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("cell") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::CellCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("crosshair") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::CrosshairCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("text") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::TextCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("vertical-text") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::VerticalTextCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("alias") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::AliasCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("copy") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::CopyCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("move") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::MoveCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("no-drop") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NoDropCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("not-allowed") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NotAllowedCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("grab") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::GrabCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("grabbing") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::GrabbingCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("e-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::EResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("n-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("ne-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NeResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("nw-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NwResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("s-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::SResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("se-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::SeResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("sw-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::SwResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("w-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::WResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("ew-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::EwResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("ns-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NsResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("nesw-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NeswResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("nwse-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::NwseResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("col-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::ColResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("row-resize") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::RowResizeCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("all-scroll") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::AllScrollCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("zoom-in") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::ZoomInCursor))
|
||||
}
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("zoom-out") => {
|
||||
Ok(T::SpecifiedCursor(util_cursor::ZoomOutCursor))
|
||||
}
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
</%self:single_component_value>
|
||||
|
||||
// Box-shadow, etc.
|
||||
${new_style_struct("Effects", is_inherited=False)}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue