Neil's Place

Archive for May, 2007

Tasks to Complete

Tuesday, May 29th, 2007

There’s lots of changes to XUL in Mozilla 1.9. Some of these are documented already in the XUL element reference, but expect some more documentation in the future. But there’s still some things I want to get done for Mozilla 1.9:

  • The XUL Popup reworking fixes a pile of bugs, makes popups less crash prone, and avoids the issue of popups that seem to hang around on the screen. It adds a <panel> element which is a type of popup designed for non-menu content so the keyboard works properly within it. Also, the API for opening popups is modified to be more useful and well defined. Much XPCOM overhead is removed too.
  • Template with XML Sources support is almost ready. After that, a couple of fairly simple improvements to support reading other types of data (currently being worked on by Laurent Jouanneau), and logging so that debugging a template is possible. However, the last feature I have in mind, nested templates, will likely have to wait.
  • Robert O’Callahan is almost finished up his patch for supporting getBoundingClientRect and getClientRects. These two functions allow one to get the area of an element as well as the rectangles used for text. I’d also like to support the offset and scroll properties in XUL. This allows us to move away from using the underspecified Mozilla specific box object APIs and move towards the er, um, underspecified Microsoft APIs. But the latter is at least being working on as a specification.
  • I have a working WHAT-WG drag and drop implementation in bug 356295 with a few extra features needed for XUL use. However, this probably won’t be able to be in 1.9.
  • After adding support for optional arguments in IDL to make things easier, the Scriptable IO support will be almost finished. This will make it easier to handle files and other streams from extensions. Unfortunately, the existing APIs were really designed for asynchronous network usage, so I may end up needing to reimplement some of the text reading and writing code so that things make more sense.
  • No additional XUL elements are planned besides the ones aready checked in, but there is some polish still to go, along with lots of XUL tests.

Scriptable IO

Wednesday, May 9th, 2007

So one thing that is hard to do in Mozilla is read and write to files. This invoves a lot of creating of XPCOM components, initializing them and wrapping them in various other streams components. Or, you could use a library like jslib or similar. But it doesn’t have to be that way. What if an easier method was built-in:

// write a string to the file stuff.txt from the Home directory.
var file = IO.newFile("Home", "stuff.txt");
var stream = IO.newOutputStream(file, "text");
stream.writeString("This is a file\n");
stream.close();

And what if a similar technique could be used for reading and writing from files, sockets or other streams? What if this was reality?

See Scriptable IO for more details. Comments very welcome, especially on the API.