2014-12-18 10:24:49 +03:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
//! A list of common mouse cursors per CSS3-UI § 8.1.1.
|
|
|
|
|
2018-01-23 21:03:41 +03:00
|
|
|
use super::{CssWriter, ToCss};
|
2014-12-30 02:33:41 +03:00
|
|
|
|
|
|
|
macro_rules! define_cursor {
|
2017-05-05 06:27:44 +03:00
|
|
|
(
|
|
|
|
common properties = [
|
|
|
|
$( $c_css: expr => $c_variant: ident = $c_value: expr, )+
|
|
|
|
]
|
|
|
|
gecko properties = [
|
|
|
|
$( $g_css: expr => $g_variant: ident = $g_value: expr, )+
|
|
|
|
]
|
|
|
|
) => {
|
2017-10-18 00:04:10 +03:00
|
|
|
/// <https://drafts.csswg.org/css-ui/#cursor>
|
servo: Merge #18938 - Replace all uses of the `heapsize` crate with `malloc_size_of` (from nnethercote:bug-1409255); r=SimonSapin
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.
This patch makes the following changes to the `malloc_size_of` crate.
- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
(e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).
- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
support that operation.
- For `HashSet`/`HashMap`, falls back to a computed estimate when
`enclosing_size_of_op` isn't available.
- Adds an extern "C" `malloc_size_of` function that does the actual heap
measurement; this is based on the same functions from the `heapsize` crate.
This patch makes the following changes elsewhere.
- Converts all the uses of `heapsize` to instead use `malloc_size_of`.
- Disables the "heapsize"/"heap_size" feature for the external crates that
provide it.
- Removes the `HeapSizeOf` implementation from `hashglobe`.
- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
doesn't derive those types, unlike `heapsize`.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1409255
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because testing is on the Gecko side.
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: 4c538b642e4bdfbf42c522c5a59c258a6d14546e
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : f9a6feed1088d0b0be2b55d7f0c2ec9c594ac33b
2017-10-18 21:56:05 +03:00
|
|
|
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)]
|
|
|
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
2014-12-30 02:33:41 +03:00
|
|
|
#[repr(u8)]
|
2016-12-31 14:19:02 +03:00
|
|
|
#[allow(missing_docs)]
|
2018-01-20 21:10:58 +03:00
|
|
|
pub enum CursorKind {
|
2017-05-05 06:27:44 +03:00
|
|
|
$( $c_variant = $c_value, )+
|
|
|
|
$( #[cfg(feature = "gecko")] $g_variant = $g_value, )+
|
2014-12-30 02:33:41 +03:00
|
|
|
}
|
|
|
|
|
2018-01-20 21:10:58 +03:00
|
|
|
impl CursorKind {
|
2016-12-31 14:19:02 +03:00
|
|
|
/// Given a CSS keyword, get the corresponding cursor enum.
|
2018-01-20 21:10:58 +03:00
|
|
|
pub fn from_css_keyword(keyword: &str) -> Result<Self, ()> {
|
2017-02-26 13:19:32 +03:00
|
|
|
match_ignore_ascii_case! { &keyword,
|
2018-01-20 21:10:58 +03:00
|
|
|
$( $c_css => Ok(CursorKind::$c_variant), )+
|
|
|
|
$( #[cfg(feature = "gecko")] $g_css => Ok(CursorKind::$g_variant), )+
|
2014-12-30 02:33:41 +03:00
|
|
|
_ => Err(())
|
|
|
|
}
|
|
|
|
}
|
2017-10-18 01:09:25 +03:00
|
|
|
|
|
|
|
/// From the C u8 value, get the corresponding Cursor enum.
|
2018-01-20 21:10:58 +03:00
|
|
|
pub fn from_u8(value: u8) -> Result<Self, ()> {
|
2017-10-18 01:09:25 +03:00
|
|
|
match value {
|
2018-01-20 21:10:58 +03:00
|
|
|
$( $c_value => Ok(CursorKind::$c_variant), )+
|
|
|
|
$( #[cfg(feature = "gecko")] $g_value => Ok(CursorKind::$g_variant), )+
|
2017-10-18 01:09:25 +03:00
|
|
|
_ => Err(())
|
|
|
|
}
|
|
|
|
}
|
2014-12-30 02:33:41 +03:00
|
|
|
}
|
|
|
|
|
2018-01-20 21:10:58 +03:00
|
|
|
impl ToCss for CursorKind {
|
2018-01-23 21:03:41 +03:00
|
|
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
2015-10-13 03:33:30 +03:00
|
|
|
match *self {
|
2018-01-23 21:03:41 +03:00
|
|
|
$(CursorKind::$c_variant => {
|
|
|
|
::std::fmt::Write::write_str(dest, $c_css)
|
|
|
|
})+
|
|
|
|
$(#[cfg(feature = "gecko")] CursorKind::$g_variant => {
|
|
|
|
::std::fmt::Write::write_str(dest, $g_css)
|
|
|
|
})+
|
2014-12-30 02:33:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-18 10:24:49 +03:00
|
|
|
}
|
|
|
|
|
2014-12-30 02:33:41 +03:00
|
|
|
define_cursor! {
|
2017-05-05 06:27:44 +03:00
|
|
|
common properties = [
|
|
|
|
"none" => None = 0,
|
|
|
|
"default" => Default = 1,
|
|
|
|
"pointer" => Pointer = 2,
|
|
|
|
"context-menu" => ContextMenu = 3,
|
|
|
|
"help" => Help = 4,
|
|
|
|
"progress" => Progress = 5,
|
|
|
|
"wait" => Wait = 6,
|
|
|
|
"cell" => Cell = 7,
|
|
|
|
"crosshair" => Crosshair = 8,
|
|
|
|
"text" => Text = 9,
|
|
|
|
"vertical-text" => VerticalText = 10,
|
|
|
|
"alias" => Alias = 11,
|
|
|
|
"copy" => Copy = 12,
|
|
|
|
"move" => Move = 13,
|
|
|
|
"no-drop" => NoDrop = 14,
|
|
|
|
"not-allowed" => NotAllowed = 15,
|
|
|
|
"grab" => Grab = 16,
|
|
|
|
"grabbing" => Grabbing = 17,
|
|
|
|
"e-resize" => EResize = 18,
|
|
|
|
"n-resize" => NResize = 19,
|
|
|
|
"ne-resize" => NeResize = 20,
|
|
|
|
"nw-resize" => NwResize = 21,
|
|
|
|
"s-resize" => SResize = 22,
|
|
|
|
"se-resize" => SeResize = 23,
|
|
|
|
"sw-resize" => SwResize = 24,
|
|
|
|
"w-resize" => WResize = 25,
|
|
|
|
"ew-resize" => EwResize = 26,
|
|
|
|
"ns-resize" => NsResize = 27,
|
|
|
|
"nesw-resize" => NeswResize = 28,
|
|
|
|
"nwse-resize" => NwseResize = 29,
|
|
|
|
"col-resize" => ColResize = 30,
|
|
|
|
"row-resize" => RowResize = 31,
|
|
|
|
"all-scroll" => AllScroll = 32,
|
|
|
|
"zoom-in" => ZoomIn = 33,
|
|
|
|
"zoom-out" => ZoomOut = 34,
|
2018-01-20 21:10:58 +03:00
|
|
|
"auto" => Auto = 35,
|
2017-05-05 06:27:44 +03:00
|
|
|
]
|
|
|
|
// gecko only properties
|
|
|
|
gecko properties = [
|
2018-01-20 21:10:58 +03:00
|
|
|
"-moz-grab" => MozGrab = 36,
|
|
|
|
"-moz-grabbing" => MozGrabbing = 37,
|
|
|
|
"-moz-zoom-in" => MozZoomIn = 38,
|
|
|
|
"-moz-zoom-out" => MozZoomOut = 39,
|
2017-05-05 06:27:44 +03:00
|
|
|
]
|
2014-12-30 02:33:41 +03:00
|
|
|
}
|