diff options
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | components/compositing/Cargo.toml | 1 | ||||
-rw-r--r-- | components/compositing/compositor.rs | 5 | ||||
-rw-r--r-- | components/constellation/constellation.rs | 5 | ||||
-rw-r--r-- | components/embedder_traits/Cargo.toml | 2 | ||||
-rw-r--r-- | components/embedder_traits/lib.rs | 47 | ||||
-rw-r--r-- | components/layout/Cargo.toml | 1 | ||||
-rw-r--r-- | components/layout/display_list/builder.rs | 79 | ||||
-rw-r--r-- | components/script/dom/webidls/CSSStyleDeclaration.webidl | 46 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 4 | ||||
-rw-r--r-- | components/script_traits/script_msg.rs | 5 | ||||
-rw-r--r-- | components/style/gecko/conversions.rs | 4 | ||||
-rw-r--r-- | components/style/logical_geometry.rs | 29 | ||||
-rw-r--r-- | components/style/values/animated/length.rs | 11 | ||||
-rw-r--r-- | components/style/values/animated/svg.rs | 18 | ||||
-rw-r--r-- | components/style/values/computed/length.rs | 12 | ||||
-rw-r--r-- | components/style/values/generics/ui.rs | 2 | ||||
-rw-r--r-- | components/style/values/specified/ui.rs | 5 | ||||
-rw-r--r-- | ports/servo/glutin_app/window.rs | 74 |
19 files changed, 243 insertions, 111 deletions
diff --git a/Cargo.lock b/Cargo.lock index 1a0d1643205..de63ba40dfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -602,6 +602,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "pixels 0.0.1", "profile_traits 0.0.1", "script_traits 0.0.1", @@ -1041,6 +1042,8 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", + "num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "servo_url 0.0.1", "style_traits 0.0.1", @@ -2059,6 +2062,7 @@ dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "canvas_traits 0.0.1", "crossbeam-channel 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "embedder_traits 0.0.1", "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 1d48cd68794..90edfbe0d6b 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -28,6 +28,7 @@ keyboard-types = "0.4.3" log = "0.4" msg = {path = "../msg"} net_traits = {path = "../net_traits"} +num-traits = "0.2" pixels = {path = "../pixels", optional = true} profile_traits = {path = "../profile_traits"} script_traits = {path = "../script_traits"} diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 365cb8219ed..89f185beadb 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -13,6 +13,7 @@ use crate::windowing::{ use crate::CompositionPipeline; use crate::SendableFrameTree; use crossbeam_channel::Sender; +use embedder_traits::Cursor; use euclid::{TypedPoint2D, TypedScale, TypedVector2D}; use gfx_traits::Epoch; #[cfg(feature = "gl")] @@ -21,6 +22,7 @@ use ipc_channel::ipc; use libc::c_void; use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId}; use net_traits::image::base::Image; +use num_traits::FromPrimitive; #[cfg(feature = "gl")] use pixels::PixelFormat; use profile_traits::time::{self as profile_time, profile, ProfilerCategory}; @@ -36,7 +38,6 @@ use std::fs::{create_dir_all, File}; use std::io::Write; use std::num::NonZeroU32; use std::rc::Rc; -use style_traits::cursor::CursorKind; use style_traits::viewport::ViewportConstraints; use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor}; use time::{now, precise_time_ns, precise_time_s}; @@ -742,7 +743,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { warn!("Sending event to constellation failed ({:?}).", e); } - if let Some(cursor) = CursorKind::from_u8(item.tag.1 as _).ok() { + if let Some(cursor) = Cursor::from_u8(item.tag.1 as _) { 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/constellation/constellation.rs b/components/constellation/constellation.rs index ec4c1f94273..01d2df699f2 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -113,7 +113,7 @@ use compositing::compositor_thread::Msg as ToCompositorMsg; use compositing::SendableFrameTree; use crossbeam_channel::{unbounded, Receiver, Sender}; use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg}; -use embedder_traits::{EmbedderMsg, EmbedderProxy}; +use embedder_traits::{Cursor, EmbedderMsg, EmbedderProxy}; use euclid::{Size2D, TypedScale, TypedSize2D}; use gfx::font_cache_thread::FontCacheThread; use gfx_traits::Epoch; @@ -164,7 +164,6 @@ use std::process; use std::rc::{Rc, Weak}; use std::sync::Arc; use std::thread; -use style_traits::cursor::CursorKind; use style_traits::viewport::ViewportConstraints; use style_traits::CSSPixel; use webvr_traits::{WebVREvent, WebVRMsg}; @@ -2135,7 +2134,7 @@ where .send(ToCompositorMsg::PendingPaintMetric(pipeline_id, epoch)) } - fn handle_set_cursor_msg(&mut self, cursor: CursorKind) { + fn handle_set_cursor_msg(&mut self, cursor: Cursor) { self.embedder_proxy .send((None, EmbedderMsg::SetCursor(cursor))) } diff --git a/components/embedder_traits/Cargo.toml b/components/embedder_traits/Cargo.toml index ab6d5e36229..1b67089b2f6 100644 --- a/components/embedder_traits/Cargo.toml +++ b/components/embedder_traits/Cargo.toml @@ -17,6 +17,8 @@ keyboard-types = "0.4.3" lazy_static = "1" log = "0.4" msg = {path = "../msg"} +num-traits = "0.2" +num-derive = "0.2" serde = "1.0" servo_url = {path = "../url"} style_traits = {path = "../style_traits", features = ["servo"]} diff --git a/components/embedder_traits/lib.rs b/components/embedder_traits/lib.rs index e25ad11d13e..fbf1102dec3 100644 --- a/components/embedder_traits/lib.rs +++ b/components/embedder_traits/lib.rs @@ -7,6 +7,8 @@ extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] +extern crate num_derive; +#[macro_use] extern crate serde; pub mod resources; @@ -17,9 +19,50 @@ use keyboard_types::KeyboardEvent; use msg::constellation_msg::{InputMethodType, PipelineId, TopLevelBrowsingContextId}; use servo_url::ServoUrl; use std::fmt::{Debug, Error, Formatter}; -use style_traits::cursor::CursorKind; use webrender_api::{DeviceIntPoint, DeviceIntSize}; +/// A cursor for the window. This is different from a CSS cursor (see +/// `CursorKind`) in that it has no `Auto` value. +#[repr(u8)] +#[derive(Copy, Clone, FromPrimitive, PartialEq, Eq, Deserialize, Serialize)] +pub enum Cursor { + None, + Default, + Pointer, + ContextMenu, + Help, + Progress, + Wait, + Cell, + Crosshair, + Text, + VerticalText, + Alias, + Copy, + Move, + NoDrop, + NotAllowed, + Grab, + Grabbing, + EResize, + NResize, + NeResize, + NwResize, + SResize, + SeResize, + SwResize, + WResize, + EwResize, + NsResize, + NeswResize, + NwseResize, + ColResize, + RowResize, + AllScroll, + ZoomIn, + ZoomOut, +} + /// Used to wake up the event loop, provided by the servo port/embedder. pub trait EventLoopWaker: 'static + Send { fn clone(&self) -> Box<EventLoopWaker + Send>; @@ -90,7 +133,7 @@ pub enum EmbedderMsg { /// Sends an unconsumed key event back to the embedder. Keyboard(KeyboardEvent), /// Changes the cursor. - SetCursor(CursorKind), + SetCursor(Cursor), /// A favicon was detected NewFavicon(ServoUrl), /// <head> tag finished parsing diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index ccda6a62867..423d5ac9326 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -18,6 +18,7 @@ atomic_refcell = "0.1" bitflags = "1.0" canvas_traits = {path = "../canvas_traits"} crossbeam-channel = "0.3" +embedder_traits = {path = "../embedder_traits"} euclid = "0.19" fnv = "1.0" fxhash = "0.2" diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index a6e77fe78b8..17cdd5cdc1a 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -31,6 +31,7 @@ use crate::model::MaybeAuto; use crate::table_cell::CollapsedBordersForCell; use app_units::{Au, AU_PER_PX}; use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg}; +use embedder_traits::Cursor; use euclid::{rect, Point2D, Rect, SideOffsets2D, Size2D, TypedRect, TypedSize2D, Vector2D}; use fnv::FnvHashMap; use gfx::text::glyph::ByteIndex; @@ -60,8 +61,8 @@ use style::values::computed::image::Image as ComputedImage; use style::values::computed::Gradient; use style::values::generics::background::BackgroundSize; use style::values::generics::image::{GradientKind, Image, PaintWorklet}; +use style::values::specified::ui::CursorKind; use style::values::{Either, RGBA}; -use style_traits::cursor::CursorKind; use style_traits::ToCss; use webrender_api::{ self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ColorU, @@ -379,7 +380,7 @@ impl<'a> DisplayListBuildState<'a> { bounds: Rect<Au>, clip_rect: Rect<Au>, node: OpaqueNode, - cursor: Option<CursorKind>, + cursor: Option<Cursor>, section: DisplayListSection, ) -> BaseDisplayItem { let clipping_and_scrolling = if self.is_background_or_border_of_clip_scroll_node(section) { @@ -691,7 +692,7 @@ impl Fragment { bounds, bounds, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), display_list_section, ); state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( @@ -822,7 +823,7 @@ impl Fragment { placement.bounds, placement.clip_rect, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), display_list_section, ); @@ -937,7 +938,7 @@ impl Fragment { placement.bounds, placement.clip_rect, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), display_list_section, ); @@ -1003,7 +1004,7 @@ impl Fragment { bounds, clip, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), display_list_section, ); let border_radius = border::radii(absolute_bounds, style.get_border()); @@ -1087,7 +1088,7 @@ impl Fragment { bounds, clip, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), display_list_section, ); @@ -1286,7 +1287,7 @@ impl Fragment { bounds, clip, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), DisplayListSection::Outlines, ); state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data( @@ -1317,7 +1318,7 @@ impl Fragment { stacking_relative_border_box, clip, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), DisplayListSection::Content, ); state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data( @@ -1346,7 +1347,7 @@ impl Fragment { baseline, clip, self.node, - get_cursor(&style, CursorKind::Default), + get_cursor(&style, Cursor::Default), DisplayListSection::Content, ); // TODO(gw): Use a better estimate for wavy line thickness. @@ -1374,7 +1375,7 @@ impl Fragment { stacking_relative_border_box, clip, self.node, - get_cursor(&self.style, CursorKind::Default), + get_cursor(&self.style, Cursor::Default), DisplayListSection::Content, ); state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data( @@ -1416,7 +1417,7 @@ impl Fragment { stacking_relative_border_box, clip, self.node, - get_cursor(&self.style, CursorKind::Default), + get_cursor(&self.style, Cursor::Default), display_list_section, ); state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( @@ -1447,7 +1448,7 @@ impl Fragment { INSERTION_POINT_LOGICAL_WIDTH, stacking_relative_border_box.size.height, ); - cursor = CursorKind::Text; + cursor = Cursor::Text; } else { insertion_point_bounds = rect( stacking_relative_border_box.origin.x, @@ -1455,7 +1456,7 @@ impl Fragment { stacking_relative_border_box.size.width, INSERTION_POINT_LOGICAL_WIDTH, ); - cursor = CursorKind::VerticalText; + cursor = Cursor::VerticalText; }; let base = state.create_base_display_item( @@ -1644,7 +1645,8 @@ impl Fragment { content_size, content_size, self.node, - get_cursor(&self.style, CursorKind::Default).or(Some(CursorKind::Default)), + // FIXME(emilio): Why does this ignore pointer-events? + get_cursor(&self.style, Cursor::Default).or(Some(Cursor::Default)), DisplayListSection::Content, ); state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( @@ -1695,7 +1697,7 @@ impl Fragment { stacking_relative_content_box, stacking_relative_border_box, self.node, - get_cursor(&self.style, CursorKind::Default), + get_cursor(&self.style, Cursor::Default), DisplayListSection::Content, ) }; @@ -1952,9 +1954,9 @@ impl 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, CursorKind::VerticalText) + (TextOrientation::SidewaysRight, Cursor::VerticalText) } else { - (TextOrientation::Upright, CursorKind::Text) + (TextOrientation::Upright, Cursor::Text) }; // Compute location of the baseline. @@ -2096,7 +2098,7 @@ impl Fragment { stacking_relative_box, clip, self.node, - get_cursor(&self.style, CursorKind::Default), + get_cursor(&self.style, Cursor::Default), DisplayListSection::Content, ); @@ -2830,14 +2832,49 @@ impl BaseFlow { /// 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(values: &ComputedValues, default_cursor: CursorKind) -> Option<CursorKind> { +fn get_cursor(values: &ComputedValues, default_cursor: Cursor) -> Option<Cursor> { let inherited_ui = values.get_inherited_ui(); if inherited_ui.pointer_events == PointerEvents::None { return None; } + Some(match inherited_ui.cursor.keyword { CursorKind::Auto => default_cursor, - keyword => keyword, + CursorKind::None => Cursor::None, + CursorKind::Default => Cursor::Default, + CursorKind::Pointer => Cursor::Pointer, + CursorKind::ContextMenu => Cursor::ContextMenu, + CursorKind::Help => Cursor::Help, + CursorKind::Progress => Cursor::Progress, + CursorKind::Wait => Cursor::Wait, + CursorKind::Cell => Cursor::Cell, + CursorKind::Crosshair => Cursor::Crosshair, + CursorKind::Text => Cursor::Text, + CursorKind::VerticalText => Cursor::VerticalText, + CursorKind::Alias => Cursor::Alias, + CursorKind::Copy => Cursor::Copy, + CursorKind::Move => Cursor::Move, + CursorKind::NoDrop => Cursor::NoDrop, + CursorKind::NotAllowed => Cursor::NotAllowed, + CursorKind::Grab => Cursor::Grab, + CursorKind::Grabbing => Cursor::Grabbing, + CursorKind::EResize => Cursor::EResize, + CursorKind::NResize => Cursor::NResize, + CursorKind::NeResize => Cursor::NeResize, + CursorKind::NwResize => Cursor::NwResize, + CursorKind::SResize => Cursor::SResize, + CursorKind::SeResize => Cursor::SeResize, + CursorKind::SwResize => Cursor::SwResize, + CursorKind::WResize => Cursor::WResize, + CursorKind::EwResize => Cursor::EwResize, + CursorKind::NsResize => Cursor::NsResize, + CursorKind::NeswResize => Cursor::NeswResize, + CursorKind::NwseResize => Cursor::NwseResize, + CursorKind::ColResize => Cursor::ColResize, + CursorKind::RowResize => Cursor::RowResize, + CursorKind::AllScroll => Cursor::AllScroll, + CursorKind::ZoomIn => Cursor::ZoomIn, + CursorKind::ZoomOut => Cursor::ZoomOut, }) } diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl index 7fab2481468..ef75f29501a 100644 --- a/components/script/dom/webidls/CSSStyleDeclaration.webidl +++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl @@ -127,6 +127,18 @@ partial interface CSSStyleDeclaration { [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockEndWidth; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-end-style; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockEndStyle; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-color; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockColor; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-style; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockStyle; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-width; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockWidth; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-end; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-start; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockStart; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlock; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-start-color; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineStartColor; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-start-width; @@ -139,14 +151,18 @@ partial interface CSSStyleDeclaration { [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineEndWidth; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-end-style; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineEndStyle; - [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-start; - [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockStart; - [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-block-end; - [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBlockEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-color; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineColor; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-style; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineStyle; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-width; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineWidth; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-start; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineStart; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline-end; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInlineEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-inline; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderInline; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString content; @@ -300,10 +316,14 @@ partial interface CSSStyleDeclaration { [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginBlockStart; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-block-end; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginBlockEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-block; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginBlock; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-inline-start; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginInlineStart; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-inline-end; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginInlineEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-inline; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginInline; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingBottom; @@ -318,10 +338,14 @@ partial interface CSSStyleDeclaration { [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingBlockStart; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-block-end; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingBlockEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-block; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingBlock; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-inline-start; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingInlineStart; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-inline-end; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingInlineEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-inline; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingInline; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString outline; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString outlineColor; @@ -354,10 +378,14 @@ partial interface CSSStyleDeclaration { [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString insetBlockStart; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString inset-block-end; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString insetBlockEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString inset-block; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString insetBlock; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString inset-inline-start; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString insetInlineStart; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString inset-inline-end; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString insetInlineEnd; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString inset-inline; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString insetInline; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString height; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString minHeight; @@ -454,4 +482,14 @@ partial interface CSSStyleDeclaration { [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationFillMode; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-delay; [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationDelay; + + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-end-end-radius; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderEndEndRadius; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-start-end-radius; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderStartEndRadius; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-start-start-radius; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderStartStartRadius; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-end-start-radius; + [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderEndStartRadius; + }; diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index c033b491e35..e2bc5c4d1ed 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -24,6 +24,7 @@ use bluetooth_traits::BluetoothRequest; use canvas_traits::webgl::WebGLPipeline; use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; +use embedder_traits::Cursor; use euclid::{Length, Point2D, Rect, TypedScale, TypedSize2D, Vector2D}; use gfx_traits::Epoch; use http::HeaderMap; @@ -50,7 +51,6 @@ use servo_url::ServoUrl; use std::collections::HashMap; use std::fmt; use std::sync::Arc; -use style_traits::cursor::CursorKind; use style_traits::CSSPixel; use style_traits::SpeculativePainter; use webrender_api::{ @@ -775,7 +775,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(CursorKind), + SetCursor(Cursor), } impl fmt::Debug for ConstellationMsg { diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 7d5ce79e2f6..2ad62849c68 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -14,7 +14,7 @@ use crate::WorkerGlobalScopeInit; use crate::WorkerScriptLoadOrigin; use canvas_traits::canvas::{CanvasId, CanvasMsg}; use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; -use embedder_traits::EmbedderMsg; +use embedder_traits::{Cursor, EmbedderMsg}; use euclid::{Size2D, TypedSize2D}; use gfx_traits::Epoch; use ipc_channel::ipc::{IpcReceiver, IpcSender}; @@ -26,7 +26,6 @@ use net_traits::CoreResourceMsg; use servo_url::ImmutableOrigin; use servo_url::ServoUrl; use std::fmt; -use style_traits::cursor::CursorKind; use style_traits::viewport::ViewportConstraints; use style_traits::CSSPixel; use webrender_api::{DeviceIntPoint, DeviceIntSize}; @@ -60,7 +59,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(CursorKind), + SetCursor(Cursor), /// Notifies the constellation that the viewport has been constrained in some manner ViewportConstrained(PipelineId, ViewportConstraints), } diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index 365e53f6251..0f6ac89c9f2 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -36,9 +36,7 @@ use style_traits::values::specified::AllowedNumericType; impl From<LengthPercentage> for nsStyleCoord_CalcValue { fn from(other: LengthPercentage) -> nsStyleCoord_CalcValue { debug_assert!( - other.was_calc || - !other.has_percentage || - other.unclamped_length() == Length::zero() + other.was_calc || !other.has_percentage || other.unclamped_length() == Length::zero() ); nsStyleCoord_CalcValue { mLength: other.unclamped_length().to_i32_au(), diff --git a/components/style/logical_geometry.rs b/components/style/logical_geometry.rs index 63aa5f138a4..dc6bae55461 100644 --- a/components/style/logical_geometry.rs +++ b/components/style/logical_geometry.rs @@ -172,17 +172,22 @@ impl WritingMode { } #[inline] - fn physical_sides_to_corner(block_side: PhysicalSide, inline_side: PhysicalSide) -> PhysicalCorner { + fn physical_sides_to_corner( + block_side: PhysicalSide, + inline_side: PhysicalSide, + ) -> PhysicalCorner { match (block_side, inline_side) { - (PhysicalSide::Top, PhysicalSide::Left) | - (PhysicalSide::Left, PhysicalSide::Top) => PhysicalCorner::TopLeft, - (PhysicalSide::Top, PhysicalSide::Right) | - (PhysicalSide::Right, PhysicalSide::Top) => PhysicalCorner::TopRight, + (PhysicalSide::Top, PhysicalSide::Left) | (PhysicalSide::Left, PhysicalSide::Top) => { + PhysicalCorner::TopLeft + }, + (PhysicalSide::Top, PhysicalSide::Right) | (PhysicalSide::Right, PhysicalSide::Top) => { + PhysicalCorner::TopRight + }, (PhysicalSide::Bottom, PhysicalSide::Right) | (PhysicalSide::Right, PhysicalSide::Bottom) => PhysicalCorner::BottomRight, (PhysicalSide::Bottom, PhysicalSide::Left) | (PhysicalSide::Left, PhysicalSide::Bottom) => PhysicalCorner::BottomLeft, - _ => unreachable!("block and inline sides must be orthogonal") + _ => unreachable!("block and inline sides must be orthogonal"), } } @@ -190,28 +195,32 @@ impl WritingMode { pub fn start_start_physical_corner(&self) -> PhysicalCorner { WritingMode::physical_sides_to_corner( self.block_start_physical_side(), - self.inline_start_physical_side()) + self.inline_start_physical_side(), + ) } #[inline] pub fn start_end_physical_corner(&self) -> PhysicalCorner { WritingMode::physical_sides_to_corner( self.block_start_physical_side(), - self.inline_end_physical_side()) + self.inline_end_physical_side(), + ) } #[inline] pub fn end_start_physical_corner(&self) -> PhysicalCorner { WritingMode::physical_sides_to_corner( self.block_end_physical_side(), - self.inline_start_physical_side()) + self.inline_start_physical_side(), + ) } #[inline] pub fn end_end_physical_corner(&self) -> PhysicalCorner { WritingMode::physical_sides_to_corner( self.block_end_physical_side(), - self.inline_end_physical_side()) + self.inline_end_physical_side(), + ) } #[inline] diff --git a/components/style/values/animated/length.rs b/components/style/values/animated/length.rs index 569d9888862..dd678f5c395 100644 --- a/components/style/values/animated/length.rs +++ b/components/style/values/animated/length.rs @@ -26,13 +26,10 @@ impl Animate for LengthPercentage { let length = self .unclamped_length() .animate(&other.unclamped_length(), procedure)?; - let percentage = animate_percentage_half( - self.specified_percentage(), - other.specified_percentage(), - )?; - let is_calc = self.was_calc || - other.was_calc || - self.has_percentage != other.has_percentage; + let percentage = + animate_percentage_half(self.specified_percentage(), other.specified_percentage())?; + let is_calc = + self.was_calc || other.was_calc || self.has_percentage != other.has_percentage; Ok(Self::with_clamping_mode( length, percentage, diff --git a/components/style/values/animated/svg.rs b/components/style/values/animated/svg.rs index 947e4135ae3..4564b787c6d 100644 --- a/components/style/values/animated/svg.rs +++ b/components/style/values/animated/svg.rs @@ -32,16 +32,14 @@ fn to_number_or_percentage( value: &SvgLengthPercentageOrNumber<LengthPercentage, Number>, ) -> Result<NumberOrPercentage, ()> { Ok(match *value { - SvgLengthPercentageOrNumber::LengthPercentage(ref l) => { - match l.specified_percentage() { - Some(p) => { - if l.unclamped_length().px() != 0. { - return Err(()); - } - NumberOrPercentage::Percentage(p) - }, - None => NumberOrPercentage::Number(l.length().px()), - } + SvgLengthPercentageOrNumber::LengthPercentage(ref l) => match l.specified_percentage() { + Some(p) => { + if l.unclamped_length().px() != 0. { + return Err(()); + } + NumberOrPercentage::Percentage(p) + }, + None => NumberOrPercentage::Number(l.length().px()), }, SvgLengthPercentageOrNumber::Number(ref n) => NumberOrPercentage::Number(*n), }) diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 012c2e076f2..1fd42301e3b 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -102,7 +102,8 @@ pub struct LengthPercentage { // like calc(0px + 5%) and such. impl PartialEq for LengthPercentage { fn eq(&self, other: &Self) -> bool { - self.length == other.length && self.percentage == other.percentage && + self.length == other.length && + self.percentage == other.percentage && self.has_percentage == other.has_percentage } } @@ -115,7 +116,8 @@ impl ComputeSquaredDistance for LengthPercentage { Ok(self .unclamped_length() .compute_squared_distance(&other.unclamped_length())? + - self.percentage.compute_squared_distance(&other.percentage)?) + self.percentage + .compute_squared_distance(&other.percentage)?) } } @@ -216,7 +218,8 @@ impl LengthPercentage { /// percentages. pub fn maybe_to_pixel_length(&self, container_len: Option<Au>) -> Option<Length> { if self.has_percentage { - let length = self.unclamped_length().px() + container_len?.scale_by(self.percentage.0).to_f32_px(); + let length = self.unclamped_length().px() + + container_len?.scale_by(self.percentage.0).to_f32_px(); return Some(Length::new(self.clamping_mode.clamp(length))); } Some(self.length()) @@ -431,8 +434,7 @@ impl ToComputedValue for specified::LengthPercentage { return specified::LengthPercentage::Percentage(p); } - if !computed.has_percentage && - computed.clamping_mode.clamp(length.px()) == length.px() { + if !computed.has_percentage && computed.clamping_mode.clamp(length.px()) == length.px() { return specified::LengthPercentage::Length(ToComputedValue::from_computed_value( &length, )); diff --git a/components/style/values/generics/ui.rs b/components/style/values/generics/ui.rs index 2d8e87e56d5..2a984b915a0 100644 --- a/components/style/values/generics/ui.rs +++ b/components/style/values/generics/ui.rs @@ -5,8 +5,8 @@ //! Generic values for UI properties. use std::fmt::{self, Write}; -use values::specified::ui::CursorKind; use style_traits::{CssWriter, ToCss}; +use values::specified::ui::CursorKind; /// A generic value for the `cursor` property. /// diff --git a/components/style/values/specified/ui.rs b/components/style/values/specified/ui.rs index 37f055f91d6..2290ac06d6d 100644 --- a/components/style/values/specified/ui.rs +++ b/components/style/values/specified/ui.rs @@ -163,6 +163,7 @@ pub enum UserSelect { Copy, Debug, Eq, + FromPrimitive, MallocSizeOf, Parse, PartialEq, @@ -208,8 +209,12 @@ pub enum CursorKind { ZoomIn, ZoomOut, Auto, + #[cfg(feature = "gecko")] MozGrab, + #[cfg(feature = "gecko")] MozGrabbing, + #[cfg(feature = "gecko")] MozZoomIn, + #[cfg(feature = "gecko")] MozZoomOut, } diff --git a/ports/servo/glutin_app/window.rs b/ports/servo/glutin_app/window.rs index 3e82677dbd9..c9ab4a0ab6f 100644 --- a/ports/servo/glutin_app/window.rs +++ b/ports/servo/glutin_app/window.rs @@ -10,12 +10,11 @@ use glutin::{Api, ContextBuilder, GlContext, GlRequest, GlWindow}; use keyboard_types::{Key, KeyboardEvent, KeyState}; use servo::compositing::windowing::{AnimationState, MouseWindowEvent, WindowEvent}; use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods}; -use servo::embedder_traits::EventLoopWaker; +use servo::embedder_traits::{Cursor, EventLoopWaker}; use servo::script_traits::TouchEventType; use servo::servo_config::opts; use servo::servo_geometry::DeviceIndependentPixel; use servo::style_traits::DevicePixel; -use servo::style_traits::cursor::CursorKind; use servo::webrender_api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, ScrollLocation}; use std::cell::{Cell, RefCell}; #[cfg(any(target_os = "linux", target_os = "macos"))] @@ -617,47 +616,46 @@ impl Window { } } - pub fn set_cursor(&self, cursor: CursorKind) { + pub fn set_cursor(&self, cursor: Cursor) { match self.kind { WindowKind::Window(ref window, ..) => { use winit::MouseCursor; let winit_cursor = match cursor { - CursorKind::Auto => MouseCursor::Default, - 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, + 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, _ => MouseCursor::Default, }; window.set_cursor(winit_cursor); |