About the recent Places refactorings

Recently we have made some refactoring to Places source files in Minefield, the final scope is to have a smaller browser-only part and share more code in Toolkit for various Places implementers. Some of these changes are relevant for Add-on authors, thus i will try to drive you through them.

Note: this does not cover all of recent changes, just the more "breaking" ones.

PlacesUtils

PlacesUtils were living in a utils.js module, since the name was a poor choice with high conflicts risks, we moved them to a better PlacesUtils.jsm file. The old file is still present to avoid breaking extensions, but when imported it will put a nice warning in the Error Console. If you extension relies on importing PlacesUtils you should update your code to this backwards compatible one, notice that a future version will remove the old utils.js file.

Try {
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
} catch(ex) {
Components.utils.import("resource://gre/modules/utils.js");
}

PlacesUIUtils

PlacesUIUtils was an object living in window scope for those windows having a Places view (or better, importing PlacesOverlay.xul). Now it is a Javascript module, and you can import it through Cu.import("resource:///modules/PlacesUIUtils.jsm"). It contains various utils we use in the UI, will most likely get some love and more code sharing in near future (so, don't rely too much on it being immutable for now). Notice this module exists only in Minefield and only in Firefox so far.

Microsummaries

Microsummaries Service is being moved to toolkit, but you can still use it as usual. You can now also access it through PlacesUtils.microsummaries (Minefield only). Notice that we are evaluating a Microsummaries feature resize, so if you are interested in the argument, let us know (mozilla.dev.apps.firefox is a nice place to do so). Even if someone feels like we could completely remove the support, we feel like it could be possible to retain basic livetitles functionality to avoid breaking websites using them. The component is too large though, so don't rely too much on its most exotic features since it could be put on a diet.

Toolbar, Menu, Tree views

The bindings are being removed from toolbar and menu views for performance reasons and code reuse, they will merge into a common script, this has not landed still. The treeview has been partly rewritten instead, for performance reasons, while all views were put on a diet. Drag&Drop is now relying only on the new API. We would like (and are trying) to remove all dependencies to nsDragAndDrop.js in browser, and to stop using it completely, you should not rely on it, use the new D&D API instead.

Shutdown

Places will now shutdown at profile-before-change, any database change should be committed before this notification, and you should not rely on any Places service after it.

Results

Results will now have the possibility to add more than one observer. While the previous implementation was mostly based on treeviews, and you could have just one treeviewer, now you can add as many nsINavHistoryResultsObserver as you wish. We also added to it a new containerStateChanged notification for nsINavHistoryResult that in future will replace containerOpened and containerClosed.

ImportExport

Places import-export service has been moved to toolkit, you can still use it as usual. We plan to merge all import-export-backup-restore needs into a js module or service in future.

Transactions

Places transactions service is being killed, and replaced with a Toolkit Javascript module. This has not yet landed. In future we'll change some implementation of it, to make it faster.

Tests

If you are going to write a Places xpcshell-test you should know that you can use PlacesUtils, Services, NetUtil in any Places toolkit test, and also PlacesUIUtils in Places browser tests.  There are also other shared utils in toolkit's head_common.js file.

MaK | Mercoledì 28 Aprile 2010 at 06:03 am | | Mozilla-EN
Tag usati: , ,

Nessun commento

(optional field)
(optional field)

In questo sito si attua la moderazione dei commenti. Questo significa che il tuo commento non è visibile finché non viene approvato da un moderatore.

Mantenere le informazioni personali?
Nota: Tutti i tag HTML eccetto <b> e <i> saranno rimossi dal commento. Puoi inserire collegamenti semplicemente scrivendo un URL o un indirizzo e-mail.