Bug 1570182 - Fix cursor prefixed aliases to do the right thing. r=boris a=RyanVM
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 31 Jul 2019 18:18:21 +0000
changeset 544895 27c6f94fdb170b8713aca8227e9f0f572faee5b0
parent 544894 a547b44c0ec3629502767bb2480c4b67a3b75cba
child 544896 03b028ae464bb042d8141ba0f45f5bd99ab81833
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris, RyanVM
bugs1570182, 1520154
milestone69.0
Bug 1570182 - Fix cursor prefixed aliases to do the right thing. r=boris a=RyanVM This was an oversight in bug 1520154. We kept the -moz- version in the specified value but not the computed value. That's a very peculiar way of making aliases work. This makes them work consistently as many other aliases instead. Also, add an assert that would've caught this much much earlier. Differential Revision: https://phabricator.services.mozilla.com/D40063
dom/events/EventStateManager.cpp
layout/style/test/mochitest.ini
layout/style/test/test_moz_prefixed_cursor.html
servo/components/style/values/specified/ui.rs
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -3921,29 +3921,27 @@ void EventStateManager::ClearCachedWidge
 nsresult EventStateManager::SetCursor(StyleCursorKind aCursor,
                                       imgIContainer* aContainer,
                                       const Maybe<gfx::IntPoint>& aHotspot,
                                       nsIWidget* aWidget, bool aLockCursor) {
   EnsureDocument(mPresContext);
   NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
   sMouseOverDocument = mDocument.get();
 
-  nsCursor c;
-
   NS_ENSURE_TRUE(aWidget, NS_ERROR_FAILURE);
   if (aLockCursor) {
     if (StyleCursorKind::Auto != aCursor) {
       mLockCursor = aCursor;
     } else {
       // If cursor style is set to auto we unlock the cursor again.
       mLockCursor = kInvalidCursorKind;
     }
   }
+  nsCursor c;
   switch (aCursor) {
-    default:
     case StyleCursorKind::Auto:
     case StyleCursorKind::Default:
       c = eCursor_standard;
       break;
     case StyleCursorKind::Pointer:
       c = eCursor_hyperlink;
       break;
     case StyleCursorKind::Crosshair:
@@ -4040,16 +4038,20 @@ nsresult EventStateManager::SetCursor(St
       c = eCursor_ns_resize;
       break;
     case StyleCursorKind::EwResize:
       c = eCursor_ew_resize;
       break;
     case StyleCursorKind::None:
       c = eCursor_none;
       break;
+    default:
+      MOZ_ASSERT_UNREACHABLE("Unknown cursor kind");
+      c = eCursor_standard;
+      break;
   }
 
   int32_t x = aHotspot ? aHotspot->x : 0;
   int32_t y = aHotspot ? aHotspot->y : 0;
   aWidget->SetCursor(c, aContainer, x, y);
   return NS_OK;
 }
 
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -272,16 +272,17 @@ skip-if = (verify || android_version == 
 [test_media_queries_dynamic.html]
 [test_media_query_list.html]
 [test_media_query_serialization.html]
 [test_mq_any_hover_and_any_pointer.html]
 [test_mq_hover_and_pointer.html]
 [test_mq_prefers_reduced_motion_dynamic.html]
 run-if = (os == 'mac' || toolkit == 'android')
 [test_moz_device_pixel_ratio.html]
+[test_moz_prefixed_cursor.html]
 [test_namespace_rule.html]
 [test_non_content_accessible_properties.html]
 [test_non_content_accessible_pseudos.html]
 [test_non_content_accessible_values.html]
 [test_of_type_selectors.xhtml]
 [test_overscroll_behavior_pref.html]
 [test_page_parser.html]
 [test_parse_eof.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_moz_prefixed_cursor.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>Cursor aliases compute to the unprefixed keyword</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div></div>
+<script>
+test(function() {
+  let div = document.querySelector("div");
+  for (const kw of ["grab", "grabbing", "zoom-in", "zoom-out"]) {
+    div.style.cursor = "-moz-" + kw;
+    assert_equals(getComputedStyle(div).cursor, kw);
+  }
+}, "-moz- prefixed cursor keywords compute to its unprefixed version");
+</script>
--- a/servo/components/style/values/specified/ui.rs
+++ b/servo/components/style/values/specified/ui.rs
@@ -194,37 +194,33 @@ pub enum CursorKind {
     Crosshair,
     Text,
     VerticalText,
     Alias,
     Copy,
     Move,
     NoDrop,
     NotAllowed,
+    #[parse(aliases = "-moz-grab")]
     Grab,
+    #[parse(aliases = "-moz-grabbing")]
     Grabbing,
     EResize,
     NResize,
     NeResize,
     NwResize,
     SResize,
     SeResize,
     SwResize,
     WResize,
     EwResize,
     NsResize,
     NeswResize,
     NwseResize,
     ColResize,
     RowResize,
     AllScroll,
+    #[parse(aliases = "-moz-zoom-in")]
     ZoomIn,
+    #[parse(aliases = "-moz-zoom-out")]
     ZoomOut,
     Auto,
-    #[cfg(feature = "gecko")]
-    MozGrab,
-    #[cfg(feature = "gecko")]
-    MozGrabbing,
-    #[cfg(feature = "gecko")]
-    MozZoomIn,
-    #[cfg(feature = "gecko")]
-    MozZoomOut,
 }