Bug 1596296 - Stop supporting XUL [dir="reverse"] attribute value. r=dholbert
authorTim Nguyen <ntim.bugs@gmail.com>
Fri, 15 Nov 2019 23:03:40 +0000
changeset 502300 4c41a3b36c68de9abaf195c7a1cca4b87895ba5d
parent 502299 b9737a17de366f287072fec20ae5dcbc14bfad50
child 502301 6b5e8d8a9ff16e7bf08f130b8c0780f6a92e45a8
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,40 +668,40 @@
           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 = "";
         if (position.indexOf("_end") > 0) {
           arrowbox.pack = "end";
         } else {
           arrowbox.pack = "start";
         }
         arrowbox.style.transform = "translate(" + -offset + "px, 0)";
 
         if (position.indexOf("before_") == 0) {
-          container.dir = "reverse";
+          container.style.MozBoxDirection = "reverse";
           this.setAttribute("side", "bottom");
         } else {
-          container.dir = "";
+          container.style.removeProperty("-moz-box-direction");
           this.setAttribute("side", "top");
         }
       }
 
       arrow.hidden = false;
     }
 
     on_popupshowing(event) {
--- 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,40 +131,40 @@
           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 = "";
         if (position.indexOf("_end") > 0) {
           arrowbox.pack = "end";
         } else {
           arrowbox.pack = "start";
         }
         arrowbox.style.transform = "translate(" + -offset + "px, 0)";
 
         if (position.indexOf("before_") == 0) {
-          container.dir = "reverse";
+          container.style.MozBoxDirection = "reverse";
           this.setAttribute("side", "bottom");
         } else {
-          container.dir = "";
+          container.style.removeProperty("-moz-box-direction");
           this.setAttribute("side", "top");
         }
       }
     }
 
     on_popupshowing(event) {
       if (this.isArrowPanel && event.target == this) {
         var arrow = this.shadowRoot.querySelector(".panel-arrow");
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -562,18 +562,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; }