Bug 1596296 - Stop supporting XUL [dir="reverse"] attribute value. r=dholbert
☠☠ backed out by 53c096b278f5 ☠ ☠
authorTim Nguyen <ntim.bugs@gmail.com>
Fri, 15 Nov 2019 02:20:10 +0000
changeset 502158 f03a850e3f537a33d65889797230222b305f7f7f
parent 502157 27a1fb60c2863d29755521c69d6fceb1f2be18d7
child 502159 d215b3534e043455cad3bf14a90e5f80e9f8cdd0
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1596296
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1596296 - Stop supporting XUL [dir="reverse"] attribute value. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D52946
browser/components/places/content/places-menupopup.js
layout/xul/nsBoxFrame.cpp
toolkit/content/tests/chrome/test_richlistbox.xhtml
toolkit/content/widgets/panel.js
toolkit/content/xul.css
--- a/browser/components/places/content/places-menupopup.js
+++ b/browser/components/places/content/places-menupopup.js
@@ -668,20 +668,20 @@
           arrowbox.pack = "start";
         }
         arrowbox.style.transform = "translate(0, " + -offset + "px)";
 
         // The assigned side stays the same regardless of direction.
         let isRTL = this.matches(":-moz-locale-dir(rtl)");
 
         if (position.indexOf("start_") == 0) {
-          container.dir = "reverse";
+          container.style.mozBoxDirection = "reverse";
           this.setAttribute("side", isRTL ? "left" : "right");
         } else {
-          container.dir = "";
+          container.style.removeProperty("-moz-box-direction");
           this.setAttribute("side", isRTL ? "right" : "left");
         }
       } else if (
         position.indexOf("before_") == 0 ||
         position.indexOf("after_") == 0
       ) {
         container.orient = "";
         arrowbox.orient = "";
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -410,46 +410,39 @@ void nsBoxFrame::GetInitialDirection(boo
   if (!GetContent()) return;
 
   if (IsXULHorizontal()) {
     // For horizontal boxes only, we initialize our value based off the CSS
     // 'direction' property. This means that BiDI users will end up with
     // horizontally inverted chrome.
     aIsNormal = (StyleVisibility()->mDirection ==
                  NS_STYLE_DIRECTION_LTR);  // If text runs RTL then so do we.
-  } else
+    if (GetContent()->IsElement()) {
+      Element* element = GetContent()->AsElement();
+
+      // Now see if we have an attribute. The attribute overrides
+      // the style system 'direction' property.
+      static Element::AttrValuesArray strings[] = {nsGkAtoms::ltr,
+                                                   nsGkAtoms::rtl, nullptr};
+      int32_t index = element->FindAttrValueIn(
+          kNameSpaceID_None, nsGkAtoms::dir, strings, eCaseMatters);
+      if (index >= 0) {
+        bool values[] = {true, false};
+        aIsNormal = values[index];
+      }
+    }
+  } else {
     aIsNormal = true;  // Assume a normal direction in the vertical case.
+  }
 
   // Now check the style system to see if we should invert aIsNormal.
   const nsStyleXUL* boxInfo = StyleXUL();
   if (boxInfo->mBoxDirection == StyleBoxDirection::Reverse) {
     aIsNormal = !aIsNormal;  // Invert our direction.
   }
-
-  if (!GetContent()->IsElement()) {
-    return;
-  }
-
-  Element* element = GetContent()->AsElement();
-
-  // Now see if we have an attribute.  The attribute overrides
-  // the style system value.
-  if (IsXULHorizontal()) {
-    static Element::AttrValuesArray strings[] = {
-        nsGkAtoms::reverse, nsGkAtoms::ltr, nsGkAtoms::rtl, nullptr};
-    int32_t index = element->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::dir,
-                                             strings, eCaseMatters);
-    if (index >= 0) {
-      bool values[] = {!aIsNormal, true, false};
-      aIsNormal = values[index];
-    }
-  } else if (element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
-                                  nsGkAtoms::reverse, eCaseMatters)) {
-    aIsNormal = !aIsNormal;
-  }
 }
 
 /* Returns true if it was set.
  */
 bool nsBoxFrame::GetInitialEqualSize(bool& aEqualSize) {
   // see if we are a vertical or horizontal box.
   if (!GetContent() || !GetContent()->IsElement()) return false;
 
--- a/toolkit/content/tests/chrome/test_richlistbox.xhtml
+++ b/toolkit/content/tests/chrome/test_richlistbox.xhtml
@@ -38,17 +38,17 @@ function test_richlistbox()
   richListBox.firstChild.nextSibling.id = "list-box-first";
   richListBox.lastChild.previousSibling.id = "list-box-last";
 
   var count = richListBox.itemCount;
   richListBox.focus();
 
   // Test that dir="reverse" is ignored and behaves the same as dir="normal".
   for (let dir of ["reverse", "normal"]) {
-    richListBox.dir = dir;
+    richListBox.style.mozBoxDirection = dir;
     richListBox.selectedIndex = 0;
     sendKey("DOWN");
     is(richListBox.currentIndex, 1, "Selection should move to the next item");
     sendKey("UP");
     is(richListBox.currentIndex, 0, "Selection should move to the previous item");
     sendKey("END");
     is(richListBox.currentIndex, count - 1, "Selection should move to the last item");
     sendKey("HOME");
--- a/toolkit/content/widgets/panel.js
+++ b/toolkit/content/widgets/panel.js
@@ -131,20 +131,20 @@
           arrowbox.pack = "start";
         }
         arrowbox.style.transform = "translate(0, " + -offset + "px)";
 
         // The assigned side stays the same regardless of direction.
         var isRTL = window.getComputedStyle(this).direction == "rtl";
 
         if (position.indexOf("start_") == 0) {
-          container.dir = "reverse";
+          container.style.mozBoxDirection = "reverse";
           this.setAttribute("side", isRTL ? "left" : "right");
         } else {
-          container.dir = "";
+          container.style.removeProperty("-moz-box-direction");
           this.setAttribute("side", isRTL ? "right" : "left");
         }
       } else if (
         position.indexOf("before_") == 0 ||
         position.indexOf("after_") == 0
       ) {
         container.orient = "";
         arrowbox.orient = "";
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -561,18 +561,16 @@ tabmodalprompt {
 
 @supports -moz-bool-pref("layout.css.emulate-moz-box-with-flex") {
   /* Support common XUL attributes in the emulated flex mode so we can
      test the browser in this configuration without mass-changing existing
      markup and CSS. */
   [orient="vertical"] { -moz-box-orient: vertical; }
   [orient="horizontal"] { -moz-box-orient: horizontal; }
 
-  [dir="reverse"] { -moz-box-direction: reverse; }
-
   [align="start"] { -moz-box-align: start; }
   [align="center"] { -moz-box-align: center; }
   [align="end"] { -moz-box-align: end; }
   [align="baseline"] { -moz-box-align: baseline; }
   [align="stretch"] { -moz-box-align: stretch; }
 
   [pack="start"] { -moz-box-pack: start; }
   [pack="center"] { -moz-box-pack: center; }