Bug 1425356 - remove various dead XUL sort attributes, r?florian,bz draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 20 Dec 2017 15:08:27 +0000
changeset 715366 66e52eb18406fef8258297e2203db23db8643d30
parent 715365 43154ae3bfb3c6c50a9e914d0aa19e2f61472f57
child 744788 5294af5ef575684472fef780e26bbef7146cd3c5
push id94155
push usergijskruitbosch@gmail.com
push dateWed, 03 Jan 2018 20:55:16 +0000
reviewersflorian, bz
bugs1425356
milestone59.0a1
Bug 1425356 - remove various dead XUL sort attributes, r?florian,bz - sort-statics-last is no longer meaningful now non-static (ie template) items don't exist - we don't use the 'resource' attribute anywhere in XUL. - sortResource/sortResource2 are unused. - we don't have meaningful consumers for sortSeparators MozReview-Commit-ID: C31vC9MCrDo
browser/base/content/pageinfo/pageInfo.xul
devtools/client/shared/node-attribute-parser.js
dom/base/nsGkAtomList.h
dom/xul/nsXULSortService.cpp
dom/xul/nsXULSortService.h
--- a/browser/base/content/pageinfo/pageInfo.xul
+++ b/browser/base/content/pageinfo/pageInfo.xul
@@ -163,33 +163,33 @@
       </hbox>
     </vbox>
 
     <!-- Media information -->
     <vbox id="mediaPanel">
       <tree id="imagetree" onselect="onImageSelect();" contextmenu="picontext"
             ondragstart="onBeginLinkDrag(event,'image-address','image-alt')">
         <treecols>
-          <treecol sortSeparators="true" primary="true" persist="width" flex="10"
+          <treecol primary="true" persist="width" flex="10"
                         width="10" id="image-address" label="&mediaAddress;"
                         onclick="gImageView.onPageMediaSort('image-address');"/>
           <splitter class="tree-splitter"/>
-          <treecol sortSeparators="true" persist="hidden width" flex="2"
+          <treecol persist="hidden width" flex="2"
                         width="2"  id="image-type"    label="&mediaType;"
                         onclick="gImageView.onPageMediaSort('image-type');"/>
           <splitter class="tree-splitter"/>
-          <treecol sortSeparators="true" hidden="true" persist="hidden width" flex="2"
+          <treecol hidden="true" persist="hidden width" flex="2"
                         width="2"  id="image-size"  label="&mediaSize;" value="size"
                         onclick="gImageView.onPageMediaSort('image-size');"/>
           <splitter class="tree-splitter"/>
-          <treecol sortSeparators="true" hidden="true" persist="hidden width" flex="4"
+          <treecol hidden="true" persist="hidden width" flex="4"
                         width="4"  id="image-alt"    label="&mediaAltHeader;"
                         onclick="gImageView.onPageMediaSort('image-alt');"/>
           <splitter class="tree-splitter"/>
-          <treecol sortSeparators="true" hidden="true" persist="hidden width" flex="1"
+          <treecol hidden="true" persist="hidden width" flex="1"
                         width="1"  id="image-count"    label="&mediaCount;"
                         onclick="gImageView.onPageMediaSort('image-count');"/>
         </treecols>
         <treechildren id="imagetreechildren" flex="1"/>
       </tree>
       <splitter orient="vertical" id="mediaSplitter"/>
       <vbox flex="1" id="mediaPreviewBox" collapsed="true">
         <grid id="mediaGrid">
--- a/devtools/client/shared/node-attribute-parser.js
+++ b/devtools/client/shared/node-attribute-parser.js
@@ -107,18 +107,16 @@ const ATTRIBUTE_TYPES = [
   {namespaceURI: XUL_NS, attributeName: "datasources", tagName: "*", type: TYPE_URI_LIST},
   {namespaceURI: XUL_NS, attributeName: "insertafter", tagName: "*", type: TYPE_IDREF},
   {namespaceURI: XUL_NS, attributeName: "insertbefore", tagName: "*", type: TYPE_IDREF},
   {namespaceURI: XUL_NS, attributeName: "menu", tagName: "*", type: TYPE_IDREF},
   {namespaceURI: XUL_NS, attributeName: "observes", tagName: "*", type: TYPE_IDREF},
   {namespaceURI: XUL_NS, attributeName: "popup", tagName: "*", type: TYPE_IDREF},
   {namespaceURI: XUL_NS, attributeName: "ref", tagName: "*", type: TYPE_URI},
   {namespaceURI: XUL_NS, attributeName: "removeelement", tagName: "*", type: TYPE_IDREF},
-  {namespaceURI: XUL_NS, attributeName: "sortResource", tagName: "*", type: TYPE_URI},
-  {namespaceURI: XUL_NS, attributeName: "sortResource2", tagName: "*", type: TYPE_URI},
   {namespaceURI: XUL_NS, attributeName: "src", tagName: "stringbundle", type: TYPE_URI},
   {namespaceURI: XUL_NS, attributeName: "template", tagName: "*", type: TYPE_IDREF},
   {namespaceURI: XUL_NS, attributeName: "tooltip", tagName: "*", type: TYPE_IDREF},
   /* eslint-enable */
   // SVG links aren't handled yet, see bug 1158831.
   // {namespaceURI: SVG_NS, attributeName: "fill", tagName: "*", type: },
   // {namespaceURI: SVG_NS, attributeName: "stroke", tagName: "*", type: },
   // {namespaceURI: SVG_NS, attributeName: "markerstart", tagName: "*", type: },
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -1172,17 +1172,16 @@ GK_ATOM(replace, "replace")
 GK_ATOM(requestcontextid, "requestcontextid")
 GK_ATOM(required, "required")
 GK_ATOM(reserved, "reserved")
 GK_ATOM(reset, "reset")
 GK_ATOM(resizeafter, "resizeafter")
 GK_ATOM(resizebefore, "resizebefore")
 GK_ATOM(resizer, "resizer")
 GK_ATOM(resolution, "resolution")
-GK_ATOM(resource, "resource")
 GK_ATOM(resources, "resources")
 GK_ATOM(result, "result")
 GK_ATOM(resultPrefix, "result-prefix")
 GK_ATOM(retargetdocumentfocus, "retargetdocumentfocus")
 GK_ATOM(rev, "rev")
 GK_ATOM(reverse, "reverse")
 GK_ATOM(reversed, "reversed")
 GK_ATOM(richlistbox, "richlistbox")
@@ -1259,20 +1258,16 @@ GK_ATOM(small, "small")
 GK_ATOM(smooth, "smooth")
 GK_ATOM(snap, "snap")
 GK_ATOM(sort, "sort")
 GK_ATOM(sortActive, "sortActive")
 GK_ATOM(sortDirection, "sortDirection")
 GK_ATOM(sorted, "sorted")
 GK_ATOM(sorthints, "sorthints")
 GK_ATOM(sortLocked, "sortLocked")
-GK_ATOM(sortResource, "sortResource")
-GK_ATOM(sortResource2, "sortResource2")
-GK_ATOM(sortSeparators, "sortSeparators")
-GK_ATOM(sortStaticsLast, "sortStaticsLast")
 GK_ATOM(source, "source")
 GK_ATOM(space, "space")
 GK_ATOM(spacer, "spacer")
 GK_ATOM(span, "span")
 GK_ATOM(spellcheck, "spellcheck")
 GK_ATOM(spinner, "spinner")
 GK_ATOM(split, "split")
 GK_ATOM(splitter, "splitter")
--- a/dom/xul/nsXULSortService.cpp
+++ b/dom/xul/nsXULSortService.cpp
@@ -60,19 +60,16 @@ XULSortServiceImpl::SetSortColumnHints(n
   for (nsIContent* child = content->GetFirstChild();
        child;
        child = child->GetNextSibling()) {
     if (child->IsXULElement(nsGkAtoms::treecols)) {
       SetSortColumnHints(child, sortResource, sortDirection);
     } else if (child->IsXULElement(nsGkAtoms::treecol)) {
       nsAutoString value;
       child->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, value);
-      // also check the resource attribute for older code
-      if (value.IsEmpty())
-        child->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::resource, value);
       if (value == sortResource) {
         child->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::sortActive,
                                     NS_LITERAL_STRING("true"), true);
 
         child->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection,
                                     sortDirection, true);
         // Note: don't break out of loop; want to set/unset
         // attribs on ALL sort columns
@@ -160,51 +157,23 @@ XULSortServiceImpl::SortContainer(nsICon
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t numResults = items.Length();
   if (!numResults)
     return NS_OK;
 
   uint32_t i;
 
-  // inbetweenSeparatorSort sorts the items between separators independently
-  if (aSortState->inbetweenSeparatorSort) {
-    uint32_t startIndex = 0;
-    for (i = 0; i < numResults; i++) {
-      if (i > startIndex + 1) {
-        nsAutoString type;
-        items[i].result->GetType(type);
-        if (type.EqualsLiteral("separator")) {
-          if (aSortState->invertSort)
-            InvertSortInfo(items, startIndex, i - startIndex);
-          else
-            NS_QuickSort((void *)(items.Elements() + startIndex), i - startIndex,
-                         sizeof(contentSortInfo), testSortCallback, (void*)aSortState);
-
-          startIndex = i + 1;
-        }
-      }
-    }
-
-    if (i > startIndex + 1) {
-      if (aSortState->invertSort)
-        InvertSortInfo(items, startIndex, i - startIndex);
-      else
-        NS_QuickSort((void *)(items.Elements() + startIndex), i - startIndex,
-                     sizeof(contentSortInfo), testSortCallback, (void*)aSortState);
-    }
-  } else {
-    // if the items are just being inverted, that is, just switching between
-    // ascending and descending, just reverse the list.
-    if (aSortState->invertSort)
-      InvertSortInfo(items, 0, numResults);
-    else
-      NS_QuickSort((void *)items.Elements(), numResults,
-                   sizeof(contentSortInfo), testSortCallback, (void*)aSortState);
-  }
+  // if the items are just being inverted, that is, just switching between
+  // ascending and descending, just reverse the list.
+  if (aSortState->invertSort)
+    InvertSortInfo(items, 0, numResults);
+  else
+    NS_QuickSort((void *)items.Elements(), numResults,
+                 sizeof(contentSortInfo), testSortCallback, (void*)aSortState);
 
   // first remove the items from the old positions
   for (i = 0; i < numResults; i++) {
     nsIContent* child = items[i].content;
     nsIContent* parent = child->GetParent();
 
     if (parent) {
       // remember the parent so that it can be reinserted back
@@ -274,56 +243,33 @@ XULSortServiceImpl::InitializeSortState(
 {
   // used as an optimization for the content builder
   if (aContainer != aSortState->lastContainer.get()) {
     aSortState->lastContainer = aContainer;
     aSortState->lastWasFirst = false;
     aSortState->lastWasLast = false;
   }
 
-  // The attributes allowed are either:
-  //    sort="key1 key2 ..."
-  // or sortResource="key1" sortResource2="key2"
-  // The latter is for backwards compatibility, and is equivalent to concatenating
-  // both values in the sort attribute
+  // The sort attribute is of the form: sort="key1 key2 ..."
   nsAutoString sort(aSortKey);
   aSortState->sortKeys.Clear();
-  if (sort.IsEmpty()) {
-    nsAutoString sortResource, sortResource2;
-    aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortResource, sortResource);
-    if (!sortResource.IsEmpty()) {
-      RefPtr<nsAtom> sortkeyatom = NS_Atomize(sortResource);
-      aSortState->sortKeys.AppendElement(sortkeyatom);
-      sort.Append(sortResource);
-
-      aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortResource2, sortResource2);
-      if (!sortResource2.IsEmpty()) {
-        RefPtr<nsAtom> sortkeyatom2 = NS_Atomize(sortResource2);
-        aSortState->sortKeys.AppendElement(sortkeyatom2);
-        sort.Append(' ');
-        sort.Append(sortResource2);
-      }
-    }
-  }
-  else {
-    nsWhitespaceTokenizer tokenizer(sort);
-    while (tokenizer.hasMoreTokens()) {
-      RefPtr<nsAtom> keyatom = NS_Atomize(tokenizer.nextToken());
-      NS_ENSURE_TRUE(keyatom, NS_ERROR_OUT_OF_MEMORY);
-      aSortState->sortKeys.AppendElement(keyatom);
-    }
+  nsWhitespaceTokenizer tokenizer(sort);
+  while (tokenizer.hasMoreTokens()) {
+    RefPtr<nsAtom> keyatom = NS_Atomize(tokenizer.nextToken());
+    NS_ENSURE_TRUE(keyatom, NS_ERROR_OUT_OF_MEMORY);
+    aSortState->sortKeys.AppendElement(keyatom);
   }
 
   aSortState->sort.Assign(sort);
   aSortState->direction = nsSortState_natural;
 
   bool noNaturalState = false;
-  nsWhitespaceTokenizer tokenizer(aSortHints);
-  while (tokenizer.hasMoreTokens()) {
-    const nsDependentSubstring& token(tokenizer.nextToken());
+  nsWhitespaceTokenizer hintsTokenizer(aSortHints);
+  while (hintsTokenizer.hasMoreTokens()) {
+    const nsDependentSubstring& token(hintsTokenizer.nextToken());
     if (token.EqualsLiteral("comparecase"))
       aSortState->sortHints |= nsIXULSortService::SORT_COMPARECASE;
     else if (token.EqualsLiteral("integer"))
       aSortState->sortHints |= nsIXULSortService::SORT_INTEGER;
     else if (token.EqualsLiteral("descending"))
       aSortState->direction = nsSortState_descending;
     else if (token.EqualsLiteral("ascending"))
       aSortState->direction = nsSortState_ascending;
@@ -352,26 +298,16 @@ XULSortServiceImpl::InitializeSortState(
         aSortState->invertSort = true;
     }
     else if (aSortState->direction == nsSortState_ascending &&
              existingsortDirection.EqualsLiteral("descending")) {
       aSortState->invertSort = true;
     }
   }
 
-  // sort items between separators independently
-  aSortState->inbetweenSeparatorSort =
-    aRootElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::sortSeparators,
-                              nsGkAtoms::_true, eCaseMatters);
-
-  // sort static content (non template generated nodes) after generated content
-  aSortState->sortStaticsLast = aRootElement->AttrValueIs(kNameSpaceID_None,
-                                  nsGkAtoms::sortStaticsLast,
-                                  nsGkAtoms::_true, eCaseMatters);
-
   aSortState->initialized = true;
 
   return NS_OK;
 }
 
 int32_t
 XULSortServiceImpl::CompareValues(const nsAString& aLeft,
                                   const nsAString& aRight,
--- a/dom/xul/nsXULSortService.h
+++ b/dom/xul/nsXULSortService.h
@@ -23,18 +23,16 @@ enum nsSortState_direction {
   nsSortState_natural
 };
 
 // the sort state holds info about the current sort
 struct nsSortState
 {
   bool initialized;
   MOZ_INIT_OUTSIDE_CTOR bool invertSort;
-  MOZ_INIT_OUTSIDE_CTOR bool inbetweenSeparatorSort;
-  MOZ_INIT_OUTSIDE_CTOR bool sortStaticsLast;
 
   uint32_t sortHints;
 
   MOZ_INIT_OUTSIDE_CTOR nsSortState_direction direction;
   nsAutoString sort;
   nsTArray<RefPtr<nsAtom>> sortKeys;
 
   nsCOMPtr<nsIContent> lastContainer;