Bug 1450017 - Part V, Remove rtl="true" attribute from resizer draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Tue, 10 Apr 2018 21:25:15 +0800
changeset 788004 911890504cebc8913a01e14b52f181088a34764e
parent 788003 c8230db29d175e372eceade1ed73bc4c8c6197f8
child 788005 60f81c52cdefd4b0c79eb2e7643bdbc09645dd6e
push id107872
push usertimdream@gmail.com
push dateWed, 25 Apr 2018 20:44:34 +0000
bugs1450017
milestone61.0a1
Bug 1450017 - Part V, Remove rtl="true" attribute from resizer This patch changes the direction context the dir=bottomend/bottomstart value from the CSS direction property value to locale dir, with the help from :-moz-locale-dir(rtl) selector. The change is justified because: - In the web content, we have since rely on the nsScrollFrame to set the direction explicity. - XUL window should always render in the application locale; it should be fine to disregard direction property set in the local document DOM teee, as it is unlikely to be differ than the locale dir. This remove the one last bit of JavaScript from the resizer binding. MozReview-Commit-ID: AweJ5GARNUE
layout/xul/test/window_resizer.xul
toolkit/content/widgets/resizer.xml
toolkit/themes/osx/global/resizer.css
toolkit/themes/windows/global/resizer.css
--- a/layout/xul/test/window_resizer.xul
+++ b/layout/xul/test/window_resizer.xul
@@ -76,17 +76,17 @@ function doTest() {
   Array.forEach(resizers, function (element) {
     is(getComputedStyle(element, "").cursor,
        element.getAttribute("expectedcursor"),
        "cursor for " + element.dir);
   });
 
   // now check the cursors in rtl. The bottomend resizer
   // should be reversed
-  document.getElementById("bottomend").setAttribute("rtl", "true");
+  document.documentElement.setAttribute("localedir", "rtl");
   Array.forEach(resizers, function (element) {
     is(getComputedStyle(element, "").cursor,
        element.dir == "bottomend" ? "sw-resize" :
          element.getAttribute("expectedcursor"),
        "cursor for " + element.dir);
   });
 
   window.close();
--- a/toolkit/content/widgets/resizer.xml
+++ b/toolkit/content/widgets/resizer.xml
@@ -6,34 +6,11 @@
 
 <bindings id="resizerBindings"
    xmlns="http://www.mozilla.org/xbl">
 
   <binding id="resizer">
     <resources>
       <stylesheet src="chrome://global/skin/resizer.css"/>
     </resources>
-    <implementation>
-      <constructor>
-      <![CDATA[
-        // don't do this for viewport resizers; causes a crash related to
-        // bugs 563665 and 581536 otherwise
-        if (this.parentNode == this.ownerDocument.documentElement)
-          return;
-
-        // if the direction is rtl, set the rtl attribute so that the
-        // stylesheet can use this to make the cursor appear properly
-        var cs = window.getComputedStyle(this);
-        if (cs.writingMode === undefined || cs.writingMode == "horizontal-tb") {
-          if (cs.direction == "rtl") {
-            this.setAttribute("rtl", "true");
-          }
-        } else if (cs.writingMode.endsWith("-rl")) {
-          // writing-modes 'vertical-rl' and 'sideways-rl' want rtl resizers,
-          // as they will appear at the bottom left of the element
-          this.setAttribute("rtl", "true");
-        }
-      ]]>
-      </constructor>
-    </implementation>
   </binding>
 
 </bindings>
--- a/toolkit/themes/osx/global/resizer.css
+++ b/toolkit/themes/osx/global/resizer.css
@@ -20,38 +20,36 @@ resizer {
     background-size: 100% 100%;
   }
 }
 
 resizer[type="window"] {
   display: none;
 }
 
-resizer[rtl="true"],
-resizer[dir="bottomend"]:-moz-locale-dir(rtl) {
+resizer:-moz-locale-dir(rtl) {
   background: url("chrome://global/skin/icons/resizer-rtl.png") no-repeat;
 }
 @media (min-resolution: 2dppx) {
-  resizer[rtl="true"],
-  resizer[dir="bottomend"]:-moz-locale-dir(rtl) {
+  resizer:-moz-locale-dir(rtl) {
     background-image: url("chrome://global/skin/icons/resizer-rtl@2x.png");
     background-size: 100% 100%;
   }
 }
 
 
 resizer[dir="left"],
 resizer[dir="bottomleft"],
 resizer[dir="bottomstart"] {
   transform: scaleX(-1);
 }
 
 resizer[dir="bottomleft"],
-resizer[dir="bottomstart"]:not([rtl="true"]):not(:-moz-locale-dir(rtl)),
-resizer[dir="bottomend"][rtl="true"] {
+resizer[dir="bottomstart"]:not(:-moz-locale-dir(rtl)),
+resizer[dir="bottomend"]:-moz-locale-dir(rtl) {
   cursor: sw-resize;
 }
 
 resizer[dir="top"],
 resizer[dir="bottom"] {
   cursor: ns-resize;
 }
 
--- a/toolkit/themes/windows/global/resizer.css
+++ b/toolkit/themes/windows/global/resizer.css
@@ -8,30 +8,29 @@ resizer {
   -moz-appearance: resizer;
   background: url("chrome://global/skin/icons/resizer.png") no-repeat;
   background-size: 100% 100%;
   cursor: se-resize;
   width: 15px;
   height: 15px;
 }
 
-resizer[rtl="true"],
-resizer[dir="bottomend"]:-moz-locale-dir(rtl) {
+resizer:-moz-locale-dir(rtl) {
   background: url("chrome://global/skin/icons/resizer-rtl.png") no-repeat;
 }
 
 resizer[dir="left"],
 resizer[dir="bottomleft"],
 resizer[dir="bottomstart"] {
   transform: scaleX(-1);
 }
 
 resizer[dir="bottomleft"],
-resizer[dir="bottomstart"]:not([rtl="true"]):not(:-moz-locale-dir(rtl)),
-resizer[dir="bottomend"][rtl="true"] {
+resizer[dir="bottomstart"]:not(:-moz-locale-dir(rtl)),
+resizer[dir="bottomend"]:-moz-locale-dir(rtl) {
   cursor: sw-resize;
 }
 
 resizer[dir="top"],
 resizer[dir="bottom"] {
   cursor: ns-resize;
 }