DXR will be turned off on Tuesday, December 29th. It will redirect to Searchfox.
See the announcement on Discourse.

DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (cdf352f02ac4)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        align="start">
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script><![CDATA[
var is = window.arguments[0].SimpleTest.is;
window.onerror = window.arguments[0].onerror;

const anchorPositions =
  [ "before_start", "before_end", "after_start", "after_end",
    "start_before", "start_after", "end_before", "end_after", "overlap", "screen"];
var currentPosition;

function testResizer(resizerid, noShrink, hResize, vResize, testid)
{
  var rect = document.getElementById(resizerid + "-container").getBoundingClientRect();
  var resizer = document.getElementById(resizerid);
  var resizerrect = resizer.getBoundingClientRect();

  var originalX = resizerrect.left;
  var originalY = resizerrect.top;

  const scale = 20;
  for (var mouseX = -1; mouseX <= 1; ++mouseX) {
    for (var mouseY = -1; mouseY <= 1; ++mouseY) {
      var expectedWidth = rect.width + hResize * mouseX * scale;
      var expectedHeight = rect.height + vResize * mouseY * scale;

      if (noShrink) {
        if (mouseX == -1)
          expectedWidth = rect.width;
        if (mouseY == -1)
          expectedHeight = rect.height;
      }

      synthesizeMouse(document.documentElement, originalX + 5, originalY + 5, { type:"mousedown" });
      synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
                      originalY + 5 + mouseY * scale, { type:"mousemove" });

      var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
      is(Math.round(newrect.width), Math.round(expectedWidth), "resize element " + resizerid +
         " " + testid + " width moving " + mouseX + "," + mouseY + ",,," + hResize);
      is(Math.round(newrect.height), Math.round(expectedHeight), "resize element " + resizerid +
         " " + testid + " height moving " + mouseX + "," + mouseY);
      // release
      synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
                      originalY + 5 + mouseY * scale, { type:"mouseup" });
      // return to the original size
      synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
                      originalY + 5 + mouseY * scale, { type:"dblclick" });
      var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
      is(Math.round(newrect.width), Math.round(rect.width), "resize element " + resizerid +
         " " + testid + " doubleclicking to restore original size");
      is(Math.round(newrect.height), Math.round(rect.height), "resize element " + resizerid +
         " " + testid + " doubleclicking to restore original size");
    }
  }
}

function doTest() {
  // first, check if a resizer with a element attribute set to an element that
  // does not exist does not cause a problem
  var resizer = document.getElementById("notfound");
  synthesizeMouse(resizer, 5, 5, { type:"mousedown" });
  synthesizeMouse(resizer, 10, 10, { type:"mousemove" });
  synthesizeMouse(resizer, 5, 5, { type:"mouseup" });

  testResizer("outside", true, 1, 1, "");
  testResizer("html", true, 1, 1, "");
  testResizer("inside", true, 1, 1, "");
  testResizer("inside-large", false, 1, 1, "");
  testResizer("inside-with-border", true, 1, 1, "");

  document.getElementById("inside-popup-container").
    openPopupAtScreen(Math.ceil(window.mozInnerScreenX) + 100, Math.ceil(window.mozInnerScreenY) + 100);
}

function popupShown(event)
{
  testResizer("inside-popup", false, 1, 1, "");
  document.getElementById("inside-popup-container").id = "outside-popup-container";
  testResizer("outside-popup", false, 1, 1, "");

  var resizerrect = document.getElementById("inside-popup").getBoundingClientRect();
  synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mousedown" });
  synthesizeMouse(document.documentElement, resizerrect.left + 2000, resizerrect.top + 2000, { type:"mousemove" });

  var isMac = (navigator.platform.includes("Mac"));
  var popuprect = document.getElementById("outside-popup-container").getBoundingClientRect();
  // subtract 3 due to space left for panel dropshadow
  is(Math.ceil(window.mozInnerScreenX) + popuprect.right,
     (isMac ? screen.availLeft + screen.availWidth : screen.left + screen.width) - 3, "resized to edge width");
  is(Math.ceil(window.mozInnerScreenY) + popuprect.bottom,
     (isMac ? screen.availTop + screen.availHeight : screen.top + screen.height) - 3, "resized to edge height");

  resizerrect = document.getElementById("inside-popup").getBoundingClientRect();
  synthesizeMouse(document.documentElement, resizerrect.left + 5, resizerrect.top + 5, { type:"mouseup" });

  event.target.hidePopup();
}

function popupHidden()
{
  if (anchorPositions.length == 0) {
    window.close();
    window.arguments[0].SimpleTest.finish();
    return;
  }

  currentPosition = anchorPositions.shift();
  var anchor = document.getElementById("anchor");
  var popup = document.getElementById("anchored-panel-container");

  if (currentPosition == "screen")
    popup.openPopupAtScreen(window.screenX + 100, window.screenY + 100);
  else
    popup.openPopup(anchor, currentPosition);
}

function anchoredPopupShown(event)
{
  var leftAllowed = (!currentPosition.includes("end_") && !currentPosition.includes("_start"));
  var rightAllowed = (!currentPosition.includes("start_") && !currentPosition.includes("_end"));
  var topAllowed = (!currentPosition.includes("after_") && !currentPosition.includes("_before"));
  var bottomAllowed = (!currentPosition.includes("before_") && !currentPosition.includes("_after"));

  if (currentPosition == "overlap") {
    leftAllowed = topAllowed = false;
    rightAllowed = bottomAllowed = true;
  }

  var resizerTypes = [ "topleft", "top", "topright", "left", "right",
                       "bottomleft", "bottom", "bottomright", "bottomend" ];
  for (var r = 0; r < resizerTypes.length; r++) {
    var resizerType = resizerTypes[r];
    var horiz = 0, vert = 0;
    if (leftAllowed && resizerType.includes("left")) horiz = -1;
    else if (rightAllowed && (resizerType.includes("right") || resizerType == "bottomend")) horiz = 1;

    if (topAllowed && resizerType.includes("top")) vert = -1;
    else if (bottomAllowed && resizerType.includes("bottom")) vert = 1;

    document.getElementById("anchored-panel").dir = resizerType;
    testResizer("anchored-panel", false, horiz, vert, currentPosition + " " + resizerType);
  }

  event.target.hidePopup();
}

window.arguments[0].SimpleTest.waitForFocus(doTest, window);
]]></script>

<resizer id="outside" dir="bottomend" element="outside-container"/>
<resizer id="notfound" dir="bottomend" element="nothing"/>
<hbox id="outside-container">
  <hbox minwidth="46" minheight="39"/>
</hbox>
<html:div id="html-container" xmlns:html="http://www.w3.org/1999/xhtml">
  <html:button>One</html:button><html:br/>
  <resizer id="html" dir="bottomend" element="_parent"/>
</html:div>
<hbox id="anchor" align="start" style="margin-left: 100px;">
  <hbox id="inside-container" align="start">
    <hbox minwidth="45" minheight="41"/>
    <resizer id="inside" dir="bottomend" element="_parent"/>
  </hbox>
  <hbox id="inside-large-container" width="70" height="70" align="start">
    <resizer id="inside-large" dir="bottomend" element="_parent"/>
  </hbox>
  <hbox id="inside-with-border-container" style="border: 5px solid red; padding: 2px; margin: 2px;" align="start">
    <hbox minwidth="35" minheight="30"/>
    <resizer id="inside-with-border" dir="bottomend" element="_parent"/>
  </hbox>
</hbox>

<panel id="inside-popup-container" align="start" onpopupshown="popupShown(event)" onpopuphidden="popupHidden()">
  <resizer id="inside-popup" dir="bottomend"/>
  <hbox width="50" height="50" flex="1"/>
</panel>
<resizer id="outside-popup" dir="bottomend" element="outside-popup-container"/>

<panel id="anchored-panel-container" align="start" onpopupshown="anchoredPopupShown(event)"
       onpopuphidden="popupHidden()">
  <hbox width="50" height="50" flex="1"/>
  <resizer id="anchored-panel" width="20" height="20"/>
</panel>

</window>