Skip to content

Commit

Permalink
style: Move cursor property out of mako
Browse files Browse the repository at this point in the history
  • Loading branch information
gootorov committed Jan 20, 2018
1 parent 671b69c commit 4ee9eb8
Show file tree
Hide file tree
Showing 17 changed files with 413 additions and 360 deletions.
4 changes: 2 additions & 2 deletions components/compositing/compositor.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions components/compositing/compositor_thread.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/compositing/windowing.rs
Expand Up @@ -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)]
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions components/constellation/constellation.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
}

Expand Down
4 changes: 2 additions & 2 deletions components/gfx/display_list/mod.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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.
Expand Down
50 changes: 25 additions & 25 deletions components/layout/display_list/builder.rs
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -3158,22 +3158,22 @@ 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 {
/// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies
/// 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),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/script_traits/lib.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/script_traits/script_msg.rs
Expand Up @@ -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.
Expand All @@ -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),
}
Expand Down

0 comments on commit 4ee9eb8

Please sign in to comment.