aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/compositor.rs4
-rw-r--r--components/compositing/compositor_thread.rs4
-rw-r--r--components/compositing/windowing.rs4
-rw-r--r--components/constellation/constellation.rs4
-rw-r--r--components/gfx/display_list/mod.rs4
-rw-r--r--components/layout/display_list/builder.rs50
-rw-r--r--components/script_traits/lib.rs4
-rw-r--r--components/script_traits/script_msg.rs4
-rw-r--r--components/style/properties/gecko.mako.rs167
-rw-r--r--components/style/properties/longhand/pointing.mako.rs142
-rw-r--r--components/style/values/computed/mod.rs8
-rw-r--r--components/style/values/computed/pointing.rs138
-rw-r--r--components/style/values/specified/mod.rs4
-rw-r--r--components/style/values/specified/pointing.rs40
-rw-r--r--components/style_traits/cursor.rs32
-rw-r--r--ports/cef/window.rs87
-rw-r--r--ports/glutin/window.rs77
17 files changed, 413 insertions, 360 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 496a75b0cc3..aae68db03eb 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -29,7 +29,7 @@ use std::rc::Rc;
use std::sync::mpsc::Sender;
use std::time::{Duration, Instant};
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use style_traits::viewport::ViewportConstraints;
use time::{precise_time_ns, precise_time_s};
use touch::{TouchHandler, TouchAction};
@@ -769,7 +769,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
warn!("Sending event to constellation failed ({}).", e);
}
- if let Some(cursor) = Cursor::from_u8(item.tag.1 as _).ok() {
+ if let Some(cursor) = CursorKind::from_u8(item.tag.1 as _).ok() {
let msg = ConstellationMsg::SetCursor(cursor);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending event to constellation failed ({}).", e);
diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs
index 31ac2f32783..2e3d69f8057 100644
--- a/components/compositing/compositor_thread.rs
+++ b/components/compositing/compositor_thread.rs
@@ -17,7 +17,7 @@ use script_traits::{AnimationState, ConstellationMsg, EventResult, LoadData};
use servo_url::ServoUrl;
use std::fmt::{Debug, Error, Formatter};
use std::sync::mpsc::{Receiver, Sender};
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use style_traits::viewport::ViewportConstraints;
use webrender;
use webrender_api;
@@ -133,7 +133,7 @@ pub enum EmbedderMsg {
/// Sends an unconsumed key event back to the embedder.
KeyEvent(Option<TopLevelBrowsingContextId>, Option<char>, Key, KeyState, KeyModifiers),
/// Changes the cursor.
- SetCursor(Cursor),
+ SetCursor(CursorKind),
/// A favicon was detected
NewFavicon(TopLevelBrowsingContextId, ServoUrl),
/// <head> tag finished parsing
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs
index 5a2f0bc8237..94e9bd19865 100644
--- a/components/compositing/windowing.rs
+++ b/components/compositing/windowing.rs
@@ -17,7 +17,7 @@ use servo_url::ServoUrl;
use std::fmt::{Debug, Error, Formatter};
use std::rc::Rc;
use style_traits::DevicePixel;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use webrender_api::{DeviceUintSize, DeviceUintRect, ScrollLocation};
#[derive(Clone)]
@@ -173,7 +173,7 @@ pub trait WindowMethods {
fn prepare_for_composite(&self, width: usize, height: usize) -> bool;
/// Sets the cursor to be used in the window.
- fn set_cursor(&self, cursor: Cursor);
+ fn set_cursor(&self, cursor: CursorKind);
/// Process a key event.
fn handle_key(&self, ctx: Option<TopLevelBrowsingContextId>, ch: Option<char>, key: Key, mods: KeyModifiers);
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index ec023e3971b..bc1f5dc0086 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -154,7 +154,7 @@ use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use style_traits::CSSPixel;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use style_traits::viewport::ViewportConstraints;
use timer_scheduler::TimerScheduler;
use webrender_api;
@@ -1818,7 +1818,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
self.compositor_proxy.send(ToCompositorMsg::PendingPaintMetric(pipeline_id, epoch))
}
- fn handle_set_cursor_msg(&mut self, cursor: Cursor) {
+ fn handle_set_cursor_msg(&mut self, cursor: CursorKind) {
self.embedder_proxy.send(EmbedderMsg::SetCursor(cursor))
}
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs
index edde7e118f7..d481ef17017 100644
--- a/components/gfx/display_list/mod.rs
+++ b/components/gfx/display_list/mod.rs
@@ -30,7 +30,7 @@ use std::f32;
use std::fmt;
use std::sync::Arc;
use style::values::computed::Filter;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use text::TextRun;
use text::glyph::ByteIndex;
use webrender_api::{BoxShadowClipMode, ClipId, ColorF, ExtendMode, GradientStop, ImageKey};
@@ -646,7 +646,7 @@ pub struct DisplayItemMetadata {
pub node: OpaqueNode,
/// The value of the `cursor` property when the mouse hovers over this display item. If `None`,
/// this display item is ineligible for pointer events (`pointer-events: none`).
- pub pointing: Option<Cursor>,
+ pub pointing: Option<CursorKind>,
}
/// Paints a solid color.
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index 33daf270ccc..d66fe380734 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -55,7 +55,6 @@ use style::computed_values::background_attachment::single_value::T as Background
use style::computed_values::background_clip::single_value::T as BackgroundClip;
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
use style::computed_values::border_style::T as BorderStyle;
-use style::computed_values::cursor;
use style::computed_values::overflow_x::T as StyleOverflow;
use style::computed_values::pointer_events::T as PointerEvents;
use style::computed_values::position::T as StylePosition;
@@ -67,12 +66,13 @@ use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::{Either, RGBA};
use style::values::computed::{Gradient, NumberOrPercentage};
use style::values::computed::effects::SimpleShadow;
+use style::values::computed::pointing::Cursor;
use style::values::generics::background::BackgroundSize;
use style::values::generics::effects::Filter;
use style::values::generics::image::{GradientKind, Image, PaintWorklet};
use style_traits::CSSPixel;
use style_traits::ToCss;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use table_cell::CollapsedBordersForCell;
use webrender_api::{self, BoxShadowClipMode, ClipId, ClipMode, ColorF, ComplexClipRegion};
use webrender_api::{ImageRendering, LayoutSize, LayoutVector2D, LineStyle};
@@ -375,7 +375,7 @@ impl<'a> DisplayListBuildState<'a> {
bounds: &Rect<Au>,
clip: LocalClip,
node: OpaqueNode,
- cursor: Option<Cursor>,
+ cursor: Option<CursorKind>,
section: DisplayListSection,
) -> BaseDisplayItem {
let clipping_and_scrolling = if self.is_background_or_border_of_clip_scroll_node(section) {
@@ -930,7 +930,7 @@ impl FragmentDisplayListBuilding for Fragment {
&bounds,
clip,
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
display_list_section,
);
state.add_display_item(DisplayItem::SolidColor(Box::new(SolidColorDisplayItem {
@@ -1121,7 +1121,7 @@ impl FragmentDisplayListBuilding for Fragment {
&placement.bounds,
LocalClip::Rect(placement.css_clip.to_layout()),
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
display_list_section,
);
@@ -1213,7 +1213,7 @@ impl FragmentDisplayListBuilding for Fragment {
&placement.bounds,
LocalClip::Rect(placement.css_clip.to_layout()),
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
display_list_section,
);
@@ -1274,7 +1274,7 @@ impl FragmentDisplayListBuilding for Fragment {
&bounds,
LocalClip::from(clip.to_layout()),
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
display_list_section,
);
let border_radius = build_border_radius(absolute_bounds, style.get_border());
@@ -1370,7 +1370,7 @@ impl FragmentDisplayListBuilding for Fragment {
&bounds,
LocalClip::from(clip.to_layout()),
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
display_list_section,
);
@@ -1544,7 +1544,7 @@ impl FragmentDisplayListBuilding for Fragment {
&bounds,
LocalClip::from(clip.to_layout()),
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
DisplayListSection::Outlines,
);
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
@@ -1571,7 +1571,7 @@ impl FragmentDisplayListBuilding for Fragment {
stacking_relative_border_box,
LocalClip::from(clip.to_layout()),
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
@@ -1597,7 +1597,7 @@ impl FragmentDisplayListBuilding for Fragment {
&baseline,
LocalClip::from(clip.to_layout()),
self.node,
- style.get_cursor(Cursor::Default),
+ style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Line(Box::new(LineDisplayItem {
@@ -1618,7 +1618,7 @@ impl FragmentDisplayListBuilding for Fragment {
stacking_relative_border_box,
LocalClip::from(clip.to_layout()),
self.node,
- self.style.get_cursor(Cursor::Default),
+ self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
@@ -1655,7 +1655,7 @@ impl FragmentDisplayListBuilding for Fragment {
stacking_relative_border_box,
LocalClip::from(clip.to_layout()),
self.node,
- self.style.get_cursor(Cursor::Default),
+ self.style.get_cursor(CursorKind::Default),
display_list_section,
);
state.add_display_item(DisplayItem::SolidColor(Box::new(SolidColorDisplayItem {
@@ -1688,7 +1688,7 @@ impl FragmentDisplayListBuilding for Fragment {
stacking_relative_border_box.size.height,
),
);
- cursor = Cursor::Text;
+ cursor = CursorKind::Text;
} else {
insertion_point_bounds = Rect::new(
Point2D::new(
@@ -1700,7 +1700,7 @@ impl FragmentDisplayListBuilding for Fragment {
INSERTION_POINT_LOGICAL_WIDTH,
),
);
- cursor = Cursor::VerticalText;
+ cursor = CursorKind::VerticalText;
};
let base = state.create_base_display_item(
@@ -1963,7 +1963,7 @@ impl FragmentDisplayListBuilding for Fragment {
&stacking_relative_content_box,
build_local_clip(&self.style),
self.node,
- self.style.get_cursor(Cursor::Default),
+ self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
let item = DisplayItem::Iframe(Box::new(IframeDisplayItem {
@@ -1989,7 +1989,7 @@ impl FragmentDisplayListBuilding for Fragment {
&stacking_relative_content_box,
build_local_clip(&self.style),
self.node,
- self.style.get_cursor(Cursor::Default),
+ self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Image(Box::new(ImageDisplayItem {
@@ -2025,7 +2025,7 @@ impl FragmentDisplayListBuilding for Fragment {
&stacking_relative_content_box,
build_local_clip(&self.style),
self.node,
- self.style.get_cursor(Cursor::Default),
+ self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
let display_item = DisplayItem::Image(Box::new(ImageDisplayItem {
@@ -2128,9 +2128,9 @@ impl FragmentDisplayListBuilding for Fragment {
let (orientation, cursor) = if self.style.writing_mode.is_vertical() {
// TODO: Distinguish between 'sideways-lr' and 'sideways-rl' writing modes in CSS
// Writing Modes Level 4.
- (TextOrientation::SidewaysRight, Cursor::VerticalText)
+ (TextOrientation::SidewaysRight, CursorKind::VerticalText)
} else {
- (TextOrientation::Upright, Cursor::Text)
+ (TextOrientation::Upright, CursorKind::Text)
};
// Compute location of the baseline.
@@ -2256,7 +2256,7 @@ impl FragmentDisplayListBuilding for Fragment {
&stacking_relative_box,
LocalClip::from(clip.to_layout()),
self.node,
- self.style.get_cursor(Cursor::Default),
+ self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
@@ -3158,7 +3158,7 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
}
trait ComputedValuesCursorUtility {
- fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor>;
+ fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind>;
}
impl ComputedValuesCursorUtility for ComputedValues {
@@ -3166,14 +3166,14 @@ impl ComputedValuesCursorUtility for ComputedValues {
/// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for
/// text display items it may be `TextCursor` or `VerticalTextCursor`.
#[inline]
- fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor> {
+ fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> {
match (
self.get_pointing().pointer_events,
self.get_pointing().cursor,
) {
(PointerEvents::None, _) => None,
- (PointerEvents::Auto, cursor::Keyword::Auto) => Some(default_cursor),
- (PointerEvents::Auto, cursor::Keyword::Cursor(cursor)) => Some(cursor),
+ (PointerEvents::Auto, Cursor(CursorKind::Auto)) => Some(default_cursor),
+ (PointerEvents::Auto, Cursor(cursor)) => Some(cursor),
}
}
}
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 3159de3a5c2..e330c49d441 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -68,7 +68,7 @@ use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, RecvTimeoutError};
use style_traits::CSSPixel;
use style_traits::SpeculativePainter;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
use webrender_api::{ClipId, DevicePixel, DocumentId, ImageKey};
use webvr_traits::{WebVREvent, WebVRMsg};
@@ -807,7 +807,7 @@ pub enum ConstellationMsg {
/// Forward an event to the script task of the given pipeline.
ForwardEvent(PipelineId, CompositorEvent),
/// Requesting a change to the onscreen cursor.
- SetCursor(Cursor),
+ SetCursor(CursorKind),
}
/// Resources required by workerglobalscopes
diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs
index a9b5f86d8fe..6ff47b5e004 100644
--- a/components/script_traits/script_msg.rs
+++ b/components/script_traits/script_msg.rs
@@ -25,7 +25,7 @@ use net_traits::storage_thread::StorageType;
use servo_url::ImmutableOrigin;
use servo_url::ServoUrl;
use style_traits::CSSPixel;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use style_traits::viewport::ViewportConstraints;
/// Messages from the layout to the constellation.
@@ -39,7 +39,7 @@ pub enum LayoutMsg {
/// the time when the frame with the given ID (epoch) is painted.
PendingPaintMetric(PipelineId, Epoch),
/// Requests that the constellation inform the compositor of the a cursor change.
- SetCursor(Cursor),
+ SetCursor(CursorKind),
/// Notifies the constellation that the viewport has been constrained in some manner
ViewportConstrained(PipelineId, ViewportConstraints),
}
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index f21f33bfd63..687701245e7 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -5302,53 +5302,50 @@ clip-path
<%self:impl_trait style_struct_name="Pointing"
skip_longhands="cursor caret-color">
pub fn set_cursor(&mut self, v: longhands::cursor::computed_value::T) {
- use properties::longhands::cursor::computed_value::Keyword;
- use style_traits::cursor::Cursor;
+ use style_traits::cursor::CursorKind;
self.gecko.mCursor = match v.keyword {
- Keyword::Auto => structs::NS_STYLE_CURSOR_AUTO,
- Keyword::Cursor(cursor) => match cursor {
- Cursor::None => structs::NS_STYLE_CURSOR_NONE,
- Cursor::Default => structs::NS_STYLE_CURSOR_DEFAULT,
- Cursor::Pointer => structs::NS_STYLE_CURSOR_POINTER,
- Cursor::ContextMenu => structs::NS_STYLE_CURSOR_CONTEXT_MENU,
- Cursor::Help => structs::NS_STYLE_CURSOR_HELP,
- Cursor::Progress => structs::NS_STYLE_CURSOR_SPINNING,
- Cursor::Wait => structs::NS_STYLE_CURSOR_WAIT,
- Cursor::Cell => structs::NS_STYLE_CURSOR_CELL,
- Cursor::Crosshair => structs::NS_STYLE_CURSOR_CROSSHAIR,
- Cursor::Text => structs::NS_STYLE_CURSOR_TEXT,
- Cursor::VerticalText => structs::NS_STYLE_CURSOR_VERTICAL_TEXT,
- Cursor::Alias => structs::NS_STYLE_CURSOR_ALIAS,
- Cursor::Copy => structs::NS_STYLE_CURSOR_COPY,
- Cursor::Move => structs::NS_STYLE_CURSOR_MOVE,
- Cursor::NoDrop => structs::NS_STYLE_CURSOR_NO_DROP,
- Cursor::NotAllowed => structs::NS_STYLE_CURSOR_NOT_ALLOWED,
- Cursor::Grab => structs::NS_STYLE_CURSOR_GRAB,
- Cursor::Grabbing => structs::NS_STYLE_CURSOR_GRABBING,
- Cursor::EResize => structs::NS_STYLE_CURSOR_E_RESIZE,
- Cursor::NResize => structs::NS_STYLE_CURSOR_N_RESIZE,
- Cursor::NeResize => structs::NS_STYLE_CURSOR_NE_RESIZE,
- Cursor::NwResize => structs::NS_STYLE_CURSOR_NW_RESIZE,
- Cursor::SResize => structs::NS_STYLE_CURSOR_S_RESIZE,
- Cursor::SeResize => structs::NS_STYLE_CURSOR_SE_RESIZE,
- Cursor::SwResize => structs::NS_STYLE_CURSOR_SW_RESIZE,
- Cursor::WResize => structs::NS_STYLE_CURSOR_W_RESIZE,
- Cursor::EwResize => structs::NS_STYLE_CURSOR_EW_RESIZE,
- Cursor::NsResize => structs::NS_STYLE_CURSOR_NS_RESIZE,
- Cursor::NeswResize => structs::NS_STYLE_CURSOR_NESW_RESIZE,
- Cursor::NwseResize => structs::NS_STYLE_CURSOR_NWSE_RESIZE,
- Cursor::ColResize => structs::NS_STYLE_CURSOR_COL_RESIZE,
- Cursor::RowResize => structs::NS_STYLE_CURSOR_ROW_RESIZE,
- Cursor::AllScroll => structs::NS_STYLE_CURSOR_ALL_SCROLL,
- Cursor::ZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
- Cursor::ZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
- // note: the following properties are gecko-only.
- Cursor::MozGrab => structs::NS_STYLE_CURSOR_GRAB,
- Cursor::MozGrabbing => structs::NS_STYLE_CURSOR_GRABBING,
- Cursor::MozZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
- Cursor::MozZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
- }
+ CursorKind::Auto => structs::NS_STYLE_CURSOR_AUTO,
+ CursorKind::None => structs::NS_STYLE_CURSOR_NONE,
+ CursorKind::Default => structs::NS_STYLE_CURSOR_DEFAULT,
+ CursorKind::Pointer => structs::NS_STYLE_CURSOR_POINTER,
+ CursorKind::ContextMenu => structs::NS_STYLE_CURSOR_CONTEXT_MENU,
+ CursorKind::Help => structs::NS_STYLE_CURSOR_HELP,
+ CursorKind::Progress => structs::NS_STYLE_CURSOR_SPINNING,
+ CursorKind::Wait => structs::NS_STYLE_CURSOR_WAIT,
+ CursorKind::Cell => structs::NS_STYLE_CURSOR_CELL,
+ CursorKind::Crosshair => structs::NS_STYLE_CURSOR_CROSSHAIR,
+ CursorKind::Text => structs::NS_STYLE_CURSOR_TEXT,
+ CursorKind::VerticalText => structs::NS_STYLE_CURSOR_VERTICAL_TEXT,
+ CursorKind::Alias => structs::NS_STYLE_CURSOR_ALIAS,
+ CursorKind::Copy => structs::NS_STYLE_CURSOR_COPY,
+ CursorKind::Move => structs::NS_STYLE_CURSOR_MOVE,
+ CursorKind::NoDrop => structs::NS_STYLE_CURSOR_NO_DROP,
+ CursorKind::NotAllowed => structs::NS_STYLE_CURSOR_NOT_ALLOWED,
+ CursorKind::Grab => structs::NS_STYLE_CURSOR_GRAB,
+ CursorKind::Grabbing => structs::NS_STYLE_CURSOR_GRABBING,
+ CursorKind::EResize => structs::NS_STYLE_CURSOR_E_RESIZE,
+ CursorKind::NResize => structs::NS_STYLE_CURSOR_N_RESIZE,
+ CursorKind::NeResize => structs::NS_STYLE_CURSOR_NE_RESIZE,
+ CursorKind::NwResize => structs::NS_STYLE_CURSOR_NW_RESIZE,
+ CursorKind::SResize => structs::NS_STYLE_CURSOR_S_RESIZE,
+ CursorKind::SeResize => structs::NS_STYLE_CURSOR_SE_RESIZE,
+ CursorKind::SwResize => structs::NS_STYLE_CURSOR_SW_RESIZE,
+ CursorKind::WResize => structs::NS_STYLE_CURSOR_W_RESIZE,
+ CursorKind::EwResize => structs::NS_STYLE_CURSOR_EW_RESIZE,
+ CursorKind::NsResize => structs::NS_STYLE_CURSOR_NS_RESIZE,
+ CursorKind::NeswResize => structs::NS_STYLE_CURSOR_NESW_RESIZE,
+ CursorKind::NwseResize => structs::NS_STYLE_CURSOR_NWSE_RESIZE,
+ CursorKind::ColResize => structs::NS_STYLE_CURSOR_COL_RESIZE,
+ CursorKind::RowResize => structs::NS_STYLE_CURSOR_ROW_RESIZE,
+ CursorKind::AllScroll => structs::NS_STYLE_CURSOR_ALL_SCROLL,
+ CursorKind::ZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
+ CursorKind::ZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
+ // note: the following properties are gecko-only.
+ CursorKind::MozGrab => structs::NS_STYLE_CURSOR_GRAB,
+ CursorKind::MozGrabbing => structs::NS_STYLE_CURSOR_GRABBING,
+ CursorKind::MozZoomIn => structs::NS_STYLE_CURSOR_ZOOM_IN,
+ CursorKind::MozZoomOut => structs::NS_STYLE_CURSOR_ZOOM_OUT,
} as u8;
unsafe {
@@ -5390,47 +5387,47 @@ clip-path
}
pub fn clone_cursor(&self) -> longhands::cursor::computed_value::T {
- use properties::longhands::cursor::computed_value::{Keyword, Image};
- use style_traits::cursor::Cursor;
+ use values::computed::pointing::CursorImage;
+ use style_traits::cursor::CursorKind;
use values::specified::url::SpecifiedUrl;
let keyword = match self.gecko.mCursor as u32 {
- structs::NS_STYLE_CURSOR_AUTO => Keyword::Auto,
- structs::NS_STYLE_CURSOR_NONE => Keyword::Cursor(Cursor::None),
- structs::NS_STYLE_CURSOR_DEFAULT => Keyword::Cursor(Cursor::Default),
- structs::NS_STYLE_CURSOR_POINTER => Keyword::Cursor(Cursor::Pointer),
- structs::NS_STYLE_CURSOR_CONTEXT_MENU => Keyword::Cursor(Cursor::ContextMenu),
- structs::NS_STYLE_CURSOR_HELP => Keyword::Cursor(Cursor::Help),
- structs::NS_STYLE_CURSOR_SPINNING => Keyword::Cursor(Cursor::Progress),
- structs::NS_STYLE_CURSOR_WAIT => Keyword::Cursor(Cursor::Wait),
- structs::NS_STYLE_CURSOR_CELL => Keyword::Cursor(Cursor::Cell),
- structs::NS_STYLE_CURSOR_CROSSHAIR => Keyword::Cursor(Cursor::Crosshair),
- structs::NS_STYLE_CURSOR_TEXT => Keyword::Cursor(Cursor::Text),
- structs::NS_STYLE_CURSOR_VERTICAL_TEXT => Keyword::Cursor(Cursor::VerticalText),
- structs::NS_STYLE_CURSOR_ALIAS => Keyword::Cursor(Cursor::Alias),
- structs::NS_STYLE_CURSOR_COPY => Keyword::Cursor(Cursor::Copy),
- structs::NS_STYLE_CURSOR_MOVE => Keyword::Cursor(Cursor::Move),
- structs::NS_STYLE_CURSOR_NO_DROP => Keyword::Cursor(Cursor::NoDrop),
- structs::NS_STYLE_CURSOR_NOT_ALLOWED => Keyword::Cursor(Cursor::NotAllowed),
- structs::NS_STYLE_CURSOR_GRAB => Keyword::Cursor(Cursor::Grab),
- structs::NS_STYLE_CURSOR_GRABBING => Keyword::Cursor(Cursor::Grabbing),
- structs::NS_STYLE_CURSOR_E_RESIZE => Keyword::Cursor(Cursor::EResize),
- structs::NS_STYLE_CURSOR_N_RESIZE => Keyword::Cursor(Cursor::NResize),
- structs::NS_STYLE_CURSOR_NE_RESIZE => Keyword::Cursor(Cursor::NeResize),
- structs::NS_STYLE_CURSOR_NW_RESIZE => Keyword::Cursor(Cursor::NwResize),
- structs::NS_STYLE_CURSOR_S_RESIZE => Keyword::Cursor(Cursor::SResize),
- structs::NS_STYLE_CURSOR_SE_RESIZE => Keyword::Cursor(Cursor::SeResize),
- structs::NS_STYLE_CURSOR_SW_RESIZE => Keyword::Cursor(Cursor::SwResize),
- structs::NS_STYLE_CURSOR_W_RESIZE => Keyword::Cursor(Cursor::WResize),
- structs::NS_STYLE_CURSOR_EW_RESIZE => Keyword::Cursor(Cursor::EwResize),
- structs::NS_STYLE_CURSOR_NS_RESIZE => Keyword::Cursor(Cursor::NsResize),
- structs::NS_STYLE_CURSOR_NESW_RESIZE => Keyword::Cursor(Cursor::NeswResize),
- structs::NS_STYLE_CURSOR_NWSE_RESIZE => Keyword::Cursor(Cursor::NwseResize),
- structs::NS_STYLE_CURSOR_COL_RESIZE => Keyword::Cursor(Cursor::ColResize),
- structs::NS_STYLE_CURSOR_ROW_RESIZE => Keyword::Cursor(Cursor::RowResize),
- structs::NS_STYLE_CURSOR_ALL_SCROLL => Keyword::Cursor(Cursor::AllScroll),
- structs::NS_STYLE_CURSOR_ZOOM_IN => Keyword::Cursor(Cursor::ZoomIn),
- structs::NS_STYLE_CURSOR_ZOOM_OUT => Keyword::Cursor(Cursor::ZoomOut),
+ structs::NS_STYLE_CURSOR_AUTO => CursorKind::Auto,
+ structs::NS_STYLE_CURSOR_NONE => CursorKind::None,
+ structs::NS_STYLE_CURSOR_DEFAULT => CursorKind::Default,
+ structs::NS_STYLE_CURSOR_POINTER => CursorKind::Pointer,
+ structs::NS_STYLE_CURSOR_CONTEXT_MENU => CursorKind::ContextMenu,
+ structs::NS_STYLE_CURSOR_HELP => CursorKind::Help,
+ structs::NS_STYLE_CURSOR_SPINNING => CursorKind::Progress,
+ structs::NS_STYLE_CURSOR_WAIT => CursorKind::Wait,
+ structs::NS_STYLE_CURSOR_CELL => CursorKind::Cell,
+ structs::NS_STYLE_CURSOR_CROSSHAIR => CursorKind::Crosshair,
+ structs::NS_STYLE_CURSOR_TEXT => CursorKind::Text,
+ structs::NS_STYLE_CURSOR_VERTICAL_TEXT => CursorKind::VerticalText,
+ structs::NS_STYLE_CURSOR_ALIAS => CursorKind::Alias,
+ structs::NS_STYLE_CURSOR_COPY => CursorKind::Copy,
+ structs::NS_STYLE_CURSOR_MOVE => CursorKind::Move,
+ structs::NS_STYLE_CURSOR_NO_DROP => CursorKind::NoDrop,
+ structs::NS_STYLE_CURSOR_NOT_ALLOWED => CursorKind::NotAllowed,
+ structs::NS_STYLE_CURSOR_GRAB => CursorKind::Grab,
+ structs::NS_STYLE_CURSOR_GRABBING => CursorKind::Grabbing,
+ structs::NS_STYLE_CURSOR_E_RESIZE => CursorKind::EResize,
+ structs::NS_STYLE_CURSOR_N_RESIZE => CursorKind::NResize,
+ structs::NS_STYLE_CURSOR_NE_RESIZE => CursorKind::NeResize,
+ structs::NS_STYLE_CURSOR_NW_RESIZE => CursorKind::NwResize,
+ structs::NS_STYLE_CURSOR_S_RESIZE => CursorKind::SResize,
+ structs::NS_STYLE_CURSOR_SE_RESIZE => CursorKind::SeResize,
+ structs::NS_STYLE_CURSOR_SW_RESIZE => CursorKind::SwResize,
+ structs::NS_STYLE_CURSOR_W_RESIZE => CursorKind::WResize,
+ structs::NS_STYLE_CURSOR_EW_RESIZE => CursorKind::EwResize,
+ structs::NS_STYLE_CURSOR_NS_RESIZE => CursorKind::NsResize,
+ structs::NS_STYLE_CURSOR_NESW_RESIZE => CursorKind::NeswResize,
+ structs::NS_STYLE_CURSOR_NWSE_RESIZE => CursorKind::NwseResize,
+ structs::NS_STYLE_CURSOR_COL_RESIZE => CursorKind::ColResize,
+ structs::NS_STYLE_CURSOR_ROW_RESIZE => CursorKind::RowResize,
+ structs::NS_STYLE_CURSOR_ALL_SCROLL => CursorKind::AllScroll,
+ structs::NS_STYLE_CURSOR_ZOOM_IN => CursorKind::ZoomIn,
+ structs::NS_STYLE_CURSOR_ZOOM_OUT => CursorKind::ZoomOut,
_ => panic!("Found unexpected value in style struct for cursor property"),
};
@@ -5448,8 +5445,8 @@ clip-path
None
};
- Image { url, hotspot }
- }).collect();
+ CursorImage { url, hotspot }
+ }).collect::<Vec<_>>().into_boxed_slice();
longhands::cursor::computed_value::T { images, keyword }
}
diff --git a/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/pointing.mako.rs
index 75731428a26..6361e394a09 100644
--- a/components/style/properties/longhand/pointing.mako.rs
+++ b/components/style/properties/longhand/pointing.mako.rs
@@ -6,142 +6,12 @@
<% data.new_style_struct("Pointing", inherited=True, gecko_name="UserInterface") %>
-<%helpers:longhand name="cursor" boxed="${product == 'gecko'}" animation_value_type="discrete"
- spec="https://drafts.csswg.org/css-ui/#cursor">
- pub use self::computed_value::T as SpecifiedValue;
- #[cfg(feature = "gecko")]
- use values::specified::url::SpecifiedUrl;
-
- pub mod computed_value {
- #[cfg(feature = "gecko")]
- use std::fmt;
- #[cfg(feature = "gecko")]
- use style_traits::ToCss;
- use style_traits::cursor::Cursor;
- #[cfg(feature = "gecko")]
- use values::specified::url::SpecifiedUrl;
-
- #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
- pub enum Keyword {
- Auto,
- Cursor(Cursor),
- }
-
- #[cfg(not(feature = "gecko"))]
- pub type T = Keyword;
-
- #[cfg(feature = "gecko")]
- #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
- pub struct Image {
- pub url: SpecifiedUrl,
- pub hotspot: Option<(f32, f32)>,
- }
-
- #[cfg(feature = "gecko")]
- #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
- pub struct T {
- pub images: Vec<Image>,
- pub keyword: Keyword,
- }
-
- #[cfg(feature = "gecko")]
- impl ToCss for Image {
- fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- self.url.to_css(dest)?;
- if let Some((x, y)) = self.hotspot {
- dest.write_str(" ")?;
- x.to_css(dest)?;
- dest.write_str(" ")?;
- y.to_css(dest)?;
- }
- Ok(())
- }
- }
-
- #[cfg(feature = "gecko")]
- impl ToCss for T {
- fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- for url in &self.images {
- url.to_css(dest)?;
- dest.write_str(", ")?;
- }
- self.keyword.to_css(dest)
- }
- }
- }
-
- #[cfg(not(feature = "gecko"))]
- #[inline]
- pub fn get_initial_value() -> computed_value::T {
- computed_value::Keyword::Auto
- }
-
- #[cfg(feature = "gecko")]
- #[inline]
- pub fn get_initial_value() -> computed_value::T {
- computed_value::T {
- images: vec![],
- keyword: computed_value::Keyword::Auto
- }
- }
-
- impl Parse for computed_value::Keyword {
- fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
- -> Result<computed_value::Keyword, ParseError<'i>> {
- #[allow(unused_imports)] use std::ascii::AsciiExt;
- use style_traits::cursor::Cursor;
- let location = input.current_source_location();
- let ident = input.expect_ident()?;
- if ident.eq_ignore_ascii_case("auto") {
- Ok(computed_value::Keyword::Auto)
- } else {
- Cursor::from_css_keyword(&ident)
- .map(computed_value::Keyword::Cursor)
- .map_err(|()| location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
- }
- }
- }
-
- #[cfg(feature = "gecko")]
- fn parse_image<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
- -> Result<computed_value::Image, ParseError<'i>> {
- Ok(computed_value::Image {
- url: SpecifiedUrl::parse(context, input)?,
- hotspot: match input.try(|input| input.expect_number()) {
- Ok(number) => Some((number, input.expect_number()?)),
- Err(_) => None,
- },
- })
- }
-
- #[cfg(not(feature = "gecko"))]
- pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
- -> Result<SpecifiedValue, ParseError<'i>> {
- computed_value::Keyword::parse(context, input)
- }
-
- /// cursor: [<url> [<number> <number>]?]# [auto | default | ...]
- #[cfg(feature = "gecko")]
- pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
- -> Result<SpecifiedValue, ParseError<'i>> {
- let mut images = vec![];
- loop {
- match input.try(|input| parse_image(context, input)) {
- Ok(mut image) => {
- image.url.build_image_value();
- images.push(image)
- }
- Err(_) => break,
- }
- input.expect_comma()?;
- }
-
- Ok(computed_value::T {
- images: images,
- keyword: computed_value::Keyword::parse(context, input)?,
- })
- }
-</%helpers:longhand>
+${helpers.predefined_type("cursor",
+ "Cursor",
+ "computed::Cursor::auto()",
+ initial_specified_value="specified::Cursor::auto()",
+ animation_value_type="discrete",
+ spec="https://drafts.csswg.org/css-ui/#cursor")}
// NB: `pointer-events: auto` (and use of `pointer-events` in anything that isn't SVG, in fact)
// is nonstandard, slated for CSS4-UI.
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 050d101a16b..20bcefc655b 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -20,7 +20,7 @@ use std::cell::RefCell;
#[cfg(feature = "servo")]
use std::sync::Arc;
use style_traits::ToCss;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use super::{CSSFloat, CSSInteger};
use super::generics::{GreaterThanOrEqualToOne, NonNegative};
use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth};
@@ -61,6 +61,9 @@ pub use self::list::ListStyleType;
pub use self::outline::OutlineStyle;
pub use self::percentage::Percentage;
pub use self::position::{Position, GridAutoFlow, GridTemplateAreas};
+pub use self::pointing::Cursor;
+#[cfg(feature = "gecko")]
+pub use self::pointing::CursorImage;
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::svg::MozContextProperties;
@@ -90,6 +93,7 @@ pub mod length;
pub mod list;
pub mod outline;
pub mod percentage;
+pub mod pointing;
pub mod position;
pub mod rect;
pub mod svg;
@@ -404,7 +408,7 @@ trivial_to_computed_value!(u16);
trivial_to_computed_value!(u32);
trivial_to_computed_value!(Atom);
trivial_to_computed_value!(BorderStyle);
-trivial_to_computed_value!(Cursor);
+trivial_to_computed_value!(CursorKind);
trivial_to_computed_value!(Namespace);
trivial_to_computed_value!(String);
trivial_to_computed_value!(Box<str>);
diff --git a/components/style/values/computed/pointing.rs b/components/style/values/computed/pointing.rs
new file mode 100644
index 00000000000..9b108dbcfc2
--- /dev/null
+++ b/components/style/values/computed/pointing.rs
@@ -0,0 +1,138 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//! Computed values for Pointing properties.
+//!
+//! https://drafts.csswg.org/css-ui/#pointing-keyboard
+
+use cssparser::Parser;
+use parser::{Parse, ParserContext};
+use selectors::parser::SelectorParseErrorKind;
+#[cfg(feature = "gecko")]
+use std::fmt;
+use style_traits::ParseError;
+#[cfg(feature = "gecko")]
+use style_traits::ToCss;
+use style_traits::cursor::CursorKind;
+
+/// The computed value for the `cursor` property.
+///
+/// https://drafts.csswg.org/css-ui/#cursor
+pub use values::specified::pointing::Cursor;
+#[cfg(feature = "gecko")]
+pub use values::specified::pointing::CursorImage;
+#[cfg(feature = "gecko")]
+use values::specified::url::SpecifiedUrl;
+
+impl Cursor {
+ /// Set `cursor` to `auto`
+ #[cfg(feature = "servo")]
+ #[inline]
+ pub fn auto() -> Self {
+ Cursor(CursorKind::Auto)
+ }
+
+ /// Set `cursor` to `auto`
+ #[cfg(feature = "gecko")]
+ #[inline]
+ pub fn auto() -> Self {
+ Self {
+ images: vec![].into_boxed_slice(),
+ keyword: CursorKind::Auto
+ }
+ }
+}
+
+impl Parse for Cursor {
+ /// cursor: [auto | default | ...]
+ #[cfg(feature = "servo")]
+ fn parse<'i, 't>(
+ context: &ParserContext,
+ input: &mut Parser<'i, 't>
+ ) -> Result<Self, ParseError<'i>> {
+ Ok(Cursor(CursorKind::parse(context, input)?))
+ }
+
+ /// cursor: [<url> [<number> <number>]?]# [auto | default | ...]
+ #[cfg(feature = "gecko")]
+ fn parse<'i, 't>(
+ context: &ParserContext,
+ input: &mut Parser<'i, 't>
+ ) -> Result<Self, ParseError<'i>> {
+ let mut images = vec![];
+ loop {
+ match input.try(|input| CursorImage::parse_image(context, input)) {
+ Ok(mut image) => {
+ image.url.build_image_value();
+ images.push(image)
+ }
+ Err(_) => break,
+ }
+ input.expect_comma()?;
+ }
+ Ok(Self {
+ images: images.into_boxed_slice(),
+ keyword: CursorKind::parse(context, input)?,
+ })
+ }
+}
+
+#[cfg(feature = "gecko")]
+impl ToCss for Cursor {
+ fn to_css<W>(&self, dest: &mut W) -> fmt::Result
+ where W: fmt::Write
+ {
+ for url in &*self.images {
+ url.to_css(dest)?;
+ dest.write_str(", ")?;
+ }
+ self.keyword.to_css(dest)
+ }
+}
+
+impl Parse for CursorKind {
+ fn parse<'i, 't>(
+ _context: &ParserContext,
+ input: &mut Parser<'i, 't>
+ ) -> Result<Self, ParseError<'i>> {
+ let location = input.current_source_location();
+ let ident = input.expect_ident()?;
+ CursorKind::from_css_keyword(&ident)
+ .map_err(|_| location.new_custom_error(
+ SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
+ }
+}
+
+#[cfg(feature = "gecko")]
+impl CursorImage {
+ fn parse_image<'i, 't>(
+ context: &ParserContext,
+ input: &mut Parser<'i, 't>
+ ) -> Result<Self, ParseError<'i>> {
+ Ok(Self {
+ url: SpecifiedUrl::parse(context, input)?,
+ // FIXME(emilio): Should use Number::parse to handle calc() correctly.
+ hotspot: match input.try(|input| input.expect_number()) {
+ Ok(number) => Some((number, input.expect_number()?)),
+ Err(_) => None,
+ },
+ })
+ }
+}
+
+#[cfg(feature = "gecko")]
+impl ToCss for CursorImage {
+ fn to_css<W>(&self, dest: &mut W) -> fmt::Result
+ where W: fmt::Write
+ {
+ self.url.to_css(dest)?;
+ if let Some((x, y)) = self.hotspot {
+ dest.write_str(" ")?;
+ x.to_css(dest)?;
+ dest.write_str(" ")?;
+ y.to_css(dest)?;
+ }
+ Ok(())
+ }
+}
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index 40f463f26b0..c8bd26f1490 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -57,6 +57,9 @@ pub use self::outline::OutlineStyle;
pub use self::rect::LengthOrNumberRect;
pub use self::percentage::Percentage;
pub use self::position::{Position, PositionComponent, GridAutoFlow, GridTemplateAreas};
+pub use self::pointing::Cursor;
+#[cfg(feature = "gecko")]
+pub use self::pointing::CursorImage;
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::svg::MozContextProperties;
@@ -90,6 +93,7 @@ pub mod length;
pub mod list;
pub mod outline;
pub mod percentage;
+pub mod pointing;
pub mod position;
pub mod rect;
pub mod source_size_list;
diff --git a/components/style/values/specified/pointing.rs b/components/style/values/specified/pointing.rs
new file mode 100644
index 00000000000..8c8b34d93e9
--- /dev/null
+++ b/components/style/values/specified/pointing.rs
@@ -0,0 +1,40 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//! Specified values for Pointing properties.
+//!
+//! https://drafts.csswg.org/css-ui/#pointing-keyboard
+
+use style_traits::cursor::CursorKind;
+#[cfg(feature = "gecko")]
+use values::specified::url::SpecifiedUrl;
+
+/// The specified value for the `cursor` property.
+///
+/// https://drafts.csswg.org/css-ui/#cursor
+#[cfg(feature = "servo")]
+#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
+pub struct Cursor(pub CursorKind);
+
+/// The specified value for the `cursor` property.
+///
+/// https://drafts.csswg.org/css-ui/#cursor
+#[cfg(feature = "gecko")]
+#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
+pub struct Cursor {
+ /// The parsed images for the cursor.
+ pub images: Box<[CursorImage]>,
+ /// The kind of the cursor [default | help | ...].
+ pub keyword: CursorKind,
+}
+
+/// The specified value for the `image cursors`.
+#[cfg(feature = "gecko")]
+#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
+pub struct CursorImage {
+ /// The url to parse images from.
+ pub url: SpecifiedUrl,
+ /// The <x> and <y> coordinates.
+ pub hotspot: Option<(f32, f32)>,
+}
diff --git a/components/style_traits/cursor.rs b/components/style_traits/cursor.rs
index 28a575f1cca..ca40c4aed79 100644
--- a/components/style_traits/cursor.rs
+++ b/components/style_traits/cursor.rs
@@ -20,43 +20,42 @@ macro_rules! define_cursor {
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[repr(u8)]
#[allow(missing_docs)]
- pub enum Cursor {
+ pub enum CursorKind {
$( $c_variant = $c_value, )+
$( #[cfg(feature = "gecko")] $g_variant = $g_value, )+
}
- impl Cursor {
+ impl CursorKind {
/// Given a CSS keyword, get the corresponding cursor enum.
- pub fn from_css_keyword(keyword: &str) -> Result<Cursor, ()> {
+ pub fn from_css_keyword(keyword: &str) -> Result<Self, ()> {
match_ignore_ascii_case! { &keyword,
- $( $c_css => Ok(Cursor::$c_variant), )+
- $( #[cfg(feature = "gecko")] $g_css => Ok(Cursor::$g_variant), )+
+ $( $c_css => Ok(CursorKind::$c_variant), )+
+ $( #[cfg(feature = "gecko")] $g_css => Ok(CursorKind::$g_variant), )+
_ => Err(())
}
}
/// From the C u8 value, get the corresponding Cursor enum.
- pub fn from_u8(value: u8) -> Result<Cursor, ()> {
+ pub fn from_u8(value: u8) -> Result<Self, ()> {
match value {
- $( $c_value => Ok(Cursor::$c_variant), )+
- $( #[cfg(feature = "gecko")] $g_value => Ok(Cursor::$g_variant), )+
+ $( $c_value => Ok(CursorKind::$c_variant), )+
+ $( #[cfg(feature = "gecko")] $g_value => Ok(CursorKind::$g_variant), )+
_ => Err(())
}
}
}
- impl ToCss for Cursor {
+ impl ToCss for CursorKind {
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
match *self {
- $( Cursor::$c_variant => dest.write_str($c_css), )+
- $( #[cfg(feature = "gecko")] Cursor::$g_variant => dest.write_str($g_css), )+
+ $( CursorKind::$c_variant => dest.write_str($c_css), )+
+ $( #[cfg(feature = "gecko")] CursorKind::$g_variant => dest.write_str($g_css), )+
}
}
}
}
}
-
define_cursor! {
common properties = [
"none" => None = 0,
@@ -94,12 +93,13 @@ define_cursor! {
"all-scroll" => AllScroll = 32,
"zoom-in" => ZoomIn = 33,
"zoom-out" => ZoomOut = 34,
+ "auto" => Auto = 35,
]
// gecko only properties
gecko properties = [
- "-moz-grab" => MozGrab = 35,
- "-moz-grabbing" => MozGrabbing = 36,
- "-moz-zoom-in" => MozZoomIn = 37,
- "-moz-zoom-out" => MozZoomOut = 38,
+ "-moz-grab" => MozGrab = 36,
+ "-moz-grabbing" => MozGrabbing = 37,
+ "-moz-zoom-in" => MozZoomIn = 38,
+ "-moz-zoom-out" => MozZoomOut = 39,
]
}
diff --git a/ports/cef/window.rs b/ports/cef/window.rs
index 58e7507dff3..05b98e6dca9 100644
--- a/ports/cef/window.rs
+++ b/ports/cef/window.rs
@@ -33,7 +33,7 @@ use std::os::raw::{c_char, c_void};
use std::ptr;
use std::rc::Rc;
use servo_url::ServoUrl;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
use style_traits::DevicePixel;
#[cfg(target_os="linux")]
extern crate x11;
@@ -104,69 +104,68 @@ impl Window {
vec![WindowEvent::Idle]
}
- fn cursor_type_for_cursor(&self, cursor: Cursor) -> cef_cursor_type_t {
+ fn cursor_type_for_cursor(&self, cursor: CursorKind) -> cef_cursor_type_t {
match cursor {
- Cursor::None => return cef_cursor_type_t::CT_NONE,
- Cursor::ContextMenu => return cef_cursor_type_t::CT_CONTEXTMENU,
- Cursor::Grabbing => return cef_cursor_type_t::CT_GRABBING,
- Cursor::Crosshair => return cef_cursor_type_t::CT_CROSS,
- Cursor::Copy => return cef_cursor_type_t::CT_COPY,
- Cursor::Alias => return cef_cursor_type_t::CT_ALIAS,
- Cursor::Text => return cef_cursor_type_t::CT_IBEAM,
- Cursor::Grab | Cursor::AllScroll =>
- return cef_cursor_type_t::CT_GRAB,
- Cursor::NoDrop => return cef_cursor_type_t::CT_NODROP,
- Cursor::NotAllowed => return cef_cursor_type_t::CT_NOTALLOWED,
- Cursor::Pointer => return cef_cursor_type_t::CT_POINTER,
- Cursor::SResize => return cef_cursor_type_t::CT_SOUTHRESIZE,
- Cursor::WResize => return cef_cursor_type_t::CT_WESTRESIZE,
- Cursor::EwResize => return cef_cursor_type_t::CT_EASTWESTRESIZE,
- Cursor::ColResize => return cef_cursor_type_t::CT_COLUMNRESIZE,
- Cursor::EResize => return cef_cursor_type_t::CT_EASTRESIZE,
- Cursor::NResize => return cef_cursor_type_t::CT_NORTHRESIZE,
- Cursor::NsResize => return cef_cursor_type_t::CT_NORTHSOUTHRESIZE,
- Cursor::RowResize => return cef_cursor_type_t::CT_ROWRESIZE,
- Cursor::VerticalText => return cef_cursor_type_t::CT_VERTICALTEXT,
- _ => return cef_cursor_type_t::CT_POINTER,
+ CursorKind::None => cef_cursor_type_t::CT_NONE,
+ CursorKind::ContextMenu => cef_cursor_type_t::CT_CONTEXTMENU,
+ CursorKind::Grabbing => cef_cursor_type_t::CT_GRABBING,
+ CursorKind::Crosshair => cef_cursor_type_t::CT_CROSS,
+ CursorKind::Copy => cef_cursor_type_t::CT_COPY,
+ CursorKind::Alias => cef_cursor_type_t::CT_ALIAS,
+ CursorKind::Text => cef_cursor_type_t::CT_IBEAM,
+ CursorKind::Grab | CursorKind::AllScroll => cef_cursor_type_t::CT_GRAB,
+ CursorKind::NoDrop => cef_cursor_type_t::CT_NODROP,
+ CursorKind::NotAllowed => cef_cursor_type_t::CT_NOTALLOWED,
+ CursorKind::Pointer => cef_cursor_type_t::CT_POINTER,
+ CursorKind::SResize => cef_cursor_type_t::CT_SOUTHRESIZE,
+ CursorKind::WResize => cef_cursor_type_t::CT_WESTRESIZE,
+ CursorKind::EwResize => cef_cursor_type_t::CT_EASTWESTRESIZE,
+ CursorKind::ColResize => cef_cursor_type_t::CT_COLUMNRESIZE,
+ CursorKind::EResize => cef_cursor_type_t::CT_EASTRESIZE,
+ CursorKind::NResize => cef_cursor_type_t::CT_NORTHRESIZE,
+ CursorKind::NsResize => cef_cursor_type_t::CT_NORTHSOUTHRESIZE,
+ CursorKind::RowResize => cef_cursor_type_t::CT_ROWRESIZE,
+ CursorKind::VerticalText => cef_cursor_type_t::CT_VERTICALTEXT,
+ _ => cef_cursor_type_t::CT_POINTER,
}
}
/// Returns the Cocoa cursor for a CSS cursor. These match Firefox, except where Firefox
/// bundles custom resources (which we don't yet do).
#[cfg(target_os="macos")]
- fn cursor_handle_for_cursor(&self, cursor: Cursor) -> cef_cursor_handle_t {
+ fn cursor_handle_for_cursor(&self, cursor: CursorKind) -> cef_cursor_handle_t {
use cocoa::base::class;
unsafe {
match cursor {
- Cursor::None => return 0 as cef_cursor_handle_t,
- Cursor::ContextMenu => msg_send![class("NSCursor"), contextualMenuCursor],
- Cursor::Grabbing => msg_send![class("NSCursor"), closedHandCursor],
- Cursor::Crosshair => msg_send![class("NSCursor"), crosshairCursor],
- Cursor::Copy => msg_send![class("NSCursor"), dragCopyCursor],
- Cursor::Alias => msg_send![class("NSCursor"), dragLinkCursor],
- Cursor::Text => msg_send![class("NSCursor"), IBeamCursor],
- Cursor::Grab | Cursor::AllScroll =>
+ CursorKind::None => return 0 as cef_cursor_handle_t,
+ CursorKind::ContextMenu => msg_send![class("NSCursor"), contextualMenuCursor],
+ CursorKind::Grabbing => msg_send![class("NSCursor"), closedHandCursor],
+ CursorKind::Crosshair => msg_send![class("NSCursor"), crosshairCursor],
+ CursorKind::Copy => msg_send![class("NSCursor"), dragCopyCursor],
+ CursorKind::Alias => msg_send![class("NSCursor"), dragLinkCursor],
+ CursorKind::Text => msg_send![class("NSCursor"), IBeamCursor],
+ CursorKind::Grab | CursorKind::AllScroll =>
msg_send![class("NSCursor"), openHandCursor],
- Cursor::NoDrop | Cursor::NotAllowed =>
+ CursorKind::NoDrop | CursorKind::NotAllowed =>
msg_send![class("NSCursor"), operationNotAllowedCursor],
- Cursor::Pointer => msg_send![class("NSCursor"), pointingHandCursor],
- Cursor::SResize => msg_send![class("NSCursor"), resizeDownCursor],
- Cursor::WResize => msg_send![class("NSCursor"), resizeLeftCursor],
- Cursor::EwResize | Cursor::ColResize =>
+ CursorKind::Pointer => msg_send![class("NSCursor"), pointingHandCursor],
+ CursorKind::SResize => msg_send![class("NSCursor"), resizeDownCursor],
+ CursorKind::WResize => msg_send![class("NSCursor"), resizeLeftCursor],
+ CursorKind::EwResize | CursorKind::ColResize =>
msg_send![class("NSCursor"), resizeLeftRightCursor],
- Cursor::EResize => msg_send![class("NSCursor"), resizeRightCursor],
- Cursor::NResize => msg_send![class("NSCursor"), resizeUpCursor],
- Cursor::NsResize | Cursor::RowResize =>
+ CursorKind::EResize => msg_send![class("NSCursor"), resizeRightCursor],
+ CursorKind::NResize => msg_send![class("NSCursor"), resizeUpCursor],
+ CursorKind::NsResize | CursorKind::RowResize =>
msg_send![class("NSCursor"), resizeUpDownCursor],
- Cursor::VerticalText => msg_send![class("NSCursor"), IBeamCursorForVerticalLayout],
+ CursorKind::VerticalText => msg_send![class("NSCursor"), IBeamCursorForVerticalLayout],
_ => msg_send![class("NSCursor"), arrowCursor],
}
}
}
#[cfg(not(target_os="macos"))]
- fn cursor_handle_for_cursor(&self, _: Cursor) -> cef_cursor_handle_t {
+ fn cursor_handle_for_cursor(&self, _: CursorKind) -> cef_cursor_handle_t {
0
}
@@ -488,7 +487,7 @@ impl WindowMethods for Window {
// TODO(negge)
}
- fn set_cursor(&self, cursor: Cursor) {
+ fn set_cursor(&self, cursor: CursorKind) {
use types::{CefCursorInfo,cef_point_t,cef_size_t};
let browser = self.cef_browser.borrow();
if let Some(ref browser) = *browser {
diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs
index cea115d6f89..1d34713923a 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -42,7 +42,7 @@ use std::rc::Rc;
use std::thread;
use std::time;
use style_traits::DevicePixel;
-use style_traits::cursor::Cursor;
+use style_traits::cursor::CursorKind;
#[cfg(target_os = "windows")]
use user32;
use webrender_api::{DeviceUintRect, DeviceUintSize, ScrollLocation};
@@ -1190,47 +1190,48 @@ impl WindowMethods for Window {
}
/// Has no effect on Android.
- fn set_cursor(&self, c: Cursor) {
+ fn set_cursor(&self, cursor: CursorKind) {
match self.kind {
WindowKind::Window(ref window) => {
use glutin::MouseCursor;
- let glutin_cursor = match c {
- Cursor::None => MouseCursor::NoneCursor,
- Cursor::Default => MouseCursor::Default,
- Cursor::Pointer => MouseCursor::Hand,
- Cursor::ContextMenu => MouseCursor::ContextMenu,
- Cursor::Help => MouseCursor::Help,
- Cursor::Progress => MouseCursor::Progress,
- Cursor::Wait => MouseCursor::Wait,
- Cursor::Cell => MouseCursor::Cell,
- Cursor::Crosshair => MouseCursor::Crosshair,
- Cursor::Text => MouseCursor::Text,
- Cursor::VerticalText => MouseCursor::VerticalText,
- Cursor::Alias => MouseCursor::Alias,
- Cursor::Copy => MouseCursor::Copy,
- Cursor::Move => MouseCursor::Move,
- Cursor::NoDrop => MouseCursor::NoDrop,
- Cursor::NotAllowed => MouseCursor::NotAllowed,
- Cursor::Grab => MouseCursor::Grab,
- Cursor::Grabbing => MouseCursor::Grabbing,
- Cursor::EResize => MouseCursor::EResize,
- Cursor::NResize => MouseCursor::NResize,
- Cursor::NeResize => MouseCursor::NeResize,
- Cursor::NwResize => MouseCursor::NwResize,
- Cursor::SResize => MouseCursor::SResize,
- Cursor::SeResize => MouseCursor::SeResize,
- Cursor::SwResize => MouseCursor::SwResize,
- Cursor::WResize => MouseCursor::WResize,
- Cursor::EwResize => MouseCursor::EwResize,
- Cursor::NsResize => MouseCursor::NsResize,
- Cursor::NeswResize => MouseCursor::NeswResize,
- Cursor::NwseResize => MouseCursor::NwseResize,
- Cursor::ColResize => MouseCursor::ColResize,
- Cursor::RowResize => MouseCursor::RowResize,
- Cursor::AllScroll => MouseCursor::AllScroll,
- Cursor::ZoomIn => MouseCursor::ZoomIn,
- Cursor::ZoomOut => MouseCursor::ZoomOut,
+ let glutin_cursor = match cursor {
+ CursorKind::Auto => MouseCursor::Default,
+ CursorKind::None => MouseCursor::NoneCursor,
+ CursorKind::Default => MouseCursor::Default,
+ CursorKind::Pointer => MouseCursor::Hand,
+ CursorKind::ContextMenu => MouseCursor::ContextMenu,
+ CursorKind::Help => MouseCursor::Help,
+ CursorKind::Progress => MouseCursor::Progress,
+ CursorKind::Wait => MouseCursor::Wait,
+ CursorKind::Cell => MouseCursor::Cell,
+ CursorKind::Crosshair => MouseCursor::Crosshair,
+ CursorKind::Text => MouseCursor::Text,
+ CursorKind::VerticalText => MouseCursor::VerticalText,
+ CursorKind::Alias => MouseCursor::Alias,
+ CursorKind::Copy => MouseCursor::Copy,
+ CursorKind::Move => MouseCursor::Move,
+ CursorKind::NoDrop => MouseCursor::NoDrop,
+ CursorKind::NotAllowed => MouseCursor::NotAllowed,
+ CursorKind::Grab => MouseCursor::Grab,
+ CursorKind::Grabbing => MouseCursor::Grabbing,
+ CursorKind::EResize => MouseCursor::EResize,
+ CursorKind::NResize => MouseCursor::NResize,
+ CursorKind::NeResize => MouseCursor::NeResize,
+ CursorKind::NwResize => MouseCursor::NwResize,
+ CursorKind::SResize => MouseCursor::SResize,
+ CursorKind::SeResize => MouseCursor::SeResize,
+ CursorKind::SwResize => MouseCursor::SwResize,
+ CursorKind::WResize => MouseCursor::WResize,
+ CursorKind::EwResize => MouseCursor::EwResize,
+ CursorKind::NsResize => MouseCursor::NsResize,
+ CursorKind::NeswResize => MouseCursor::NeswResize,
+ CursorKind::NwseResize => MouseCursor::NwseResize,
+ CursorKind::ColResize => MouseCursor::ColResize,
+ CursorKind::RowResize => MouseCursor::RowResize,
+ CursorKind::AllScroll => MouseCursor::AllScroll,
+ CursorKind::ZoomIn => MouseCursor::ZoomIn,
+ CursorKind::ZoomOut => MouseCursor::ZoomOut,
};
window.set_cursor(glutin_cursor);
}