XULSortService: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 9: Line 9:
Thus, some work will be done to improve the sort service.
Thus, some work will be done to improve the sort service.


1. Move the sort inserting code directly into the content builder. Eventually, it may be possible to sort results first and then insert them all sorted.
#Move the sort inserting code directly into the content builder. Eventually, it may be possible to sort results first and then insert them all sorted.
2. Make the sort inserting code and the container sort algorithms use the query processor for sorting such that they work on all datasources.
#Make the sort inserting code and the container sort algorithms use the query processor for sorting such that they work on all datasources.
3. Make how one specifies the sort info consistent, as described below.
#Make how one specifies the sort info consistent, as described below.
4. Simplify the sort code
#Simplify the sort code


===Attributes===
===Attributes===

Revision as of 01:25, 23 April 2006

XUL Sort Service Improvements

The XUL Sort Service is used for sorting content built by a content template builder, although not a tree builder. It has two purposes, figure out where to insert a new generated item into a existing container, and change the sort key and/or direction of an existing container.

The code is large and complex, considering that the tree sorting built into the tree builder has about 90% of the same functionality, but with only 10% as much code.

The sort service also only works with RDF datasources.

Thus, some work will be done to improve the sort service.

  1. Move the sort inserting code directly into the content builder. Eventually, it may be possible to sort results first and then insert them all sorted.
  2. Make the sort inserting code and the container sort algorithms use the query processor for sorting such that they work on all datasources.
  3. Make how one specifies the sort info consistent, as described below.
  4. Simplify the sort code

Attributes

The following attributes will be involved in sorting:

sort="?key1 ?key2 ..."

Specifies the sort keys to be used. One or more may be specified. For template-built content, the keys are expected to be identifiers used in the template, either of the variable form such as ?name, or a predicate such as rdf:http://www.example.com/name. A query processor may also support other values. In the case of RDF, keys that are RDF predicates without the rdf: prefix may be used also.

sortResource=""

This is obsolete but is equivalent to specifing one sort key.

sortResource2=""

This is obsolete but is equivalent to specifing the second sort key. Thus, sortResource and sortResource2 are the same as sort="sortResource sortResource2".

sortDirection="ascending|descending|natural"

The direction of the sort.

sortSeparators="true|false"

Indicates if sorting is done separately between separators.

staticHint="integer"

Set automatically to determine how many static children there are. These static children are not sorted.

sortStaticsLast="true|false"

True if static content is placed after generated content, and false is static content should be placed before generated content. I don't think this actually works currently anyway, so no need to support it necessarily in the future.

Tree Content

There is some code to set attributes on columns for trees built with the content builder, it doesn't seem to have any real use as far as I can tell. Some code appears to rely on the behaviour but implements much of the sort attribute handling manually since the sort service is fairly inconsistent ith how it uses the attributes.

Special Sort Resources

  • The form resource?sort=true can be handled directly in the query processor.
  • The form resource?collation=true isn't used anywhere so it will be removed.

Sorting Non-Templates

For an element that doesn't have a template, support will be added to allow it to be sorted using the sort service's Sort method. If the element implements nsIDOMXULSelectControlElement, its items will be sorted. Otherwise, the children of the element will be sorted. The sort key is an attribute on those items to sort by.