Places:Design Overview: Difference between revisions
Comrade693 (talk | contribs) (→Models) |
|||
Line 100: | Line 100: | ||
http://people.mozilla.com/~dietrich/places-erd.png | http://people.mozilla.com/~dietrich/places-erd.png | ||
A detailed database schema complete with associations between the various tables within places.sqlite: | |||
https://wiki.mozilla.org/images/d/d5/Places.sqlite.schema3.pdf | https://wiki.mozilla.org/images/d/d5/Places.sqlite.schema3.pdf | ||
Source code: | Source code: |
Revision as of 17:53, 27 January 2009
Design Overview
Implement a new back-end for Bookmarks, History and related components using the mozStorage wrapper for SQLite. Develop newer, more usable front-end components to display results, emphasizing simple search and categorization.
Related Documents:
- Places:User Interface
- Places:URL Store
- Places:Bookmarks
- Places:place URIs
- Places:Results
- Places:Controller
- Browser History
- Places:AutoComplete
- Places:Transactions
- Places:Drag & Drop
- Places:Manager
- Places:Bookmarks Containers
- Places:Live Bookmarks
Objectives
The primary objectives:
- Improve access to History and Bookmarks
- Make it easier for people to Bookmark pages
Secondary objectives:
- Consolidating user data formats
- Providing a platform for using interesting per-URL metadata
- Improving the capabilities of Live Bookmarks
- Providing a solid architecture for bookmark sync and remote storage
- Extensible Bookmark Providers for customization
- Flexible Query System
- Clean Architecture for ease of code reuse and maintainability
Background
Studies from the late 1990s show that while revisitations of pages previously seen counted for roughly 39% of all page navigations (see Google Scholar), Bookmarks and History usage was low (1-3%), despite the fact that roughly 20% of those revisitations were to pages seen > 10 URLs ago (and thus outside the usefulness range of the Back button or menu).
Autocomplete in the URL bar is a useful tool but fails to address some common desires when looking up visited pages. There is a gulf between the capabilities of that tool, the capabilities of the Bookmarks and History systems today, and the desired capabilities of those systems.
Use Cases
- Places:History Use Cases
- Bookmarks Use Cases (not specific to places)
Functional Requirements
The original requirements for Places in Firefox 3 are detailed in the Firefox 3 PRD
Front End Architecture
The Front End Architecture utilizes a MVC (model-view-controller) design. This calls for clean separation between each of the three components. The benefits of this approach are improved maintainability, stability and extensibility.
Within the Places code, the Model can be considered to be the SQL tables and the code that creates them, the query system to access them, and the simple manipulation pathways provided through services like nsINavHistoryService and nsINavBookmarksService.
The View is the piece that displays information from the Model in one way or another. In code, these are menu.xml, toolbar.xml and tree.xml.
The Controller is the piece that interprets user actions on a selection and carries them out - basically linking the Model and the View. In code, this is controller.js.
The extent to which these services are kept independent can be seen in the following details:
- The Model does not in general deal with presentation.
- The Controller knows of "selection" only as a concept abstract from the details of the selected View (e.g. a complex tree selection versus a selected toolbar button or menu item). As far as the Controller is concerned, the selection is a list of Result Nodes, there are no View-specific selection ranges, etc.
- The Views know nothing about the functions performed when the user interacts with their content, since that is instance specific. The Views implement a View Interface which handle translating their unique selection characteristics into an agnostic form the Controller can deal with.
The idea is that someone can instantiate a View, attach a Controller, and define the behavioral characteristics that suit their use, in very little code. Examples:
Bookmarks Menu
- instantiate a Menu View, attached to the top level Browser Bookmarks Menu.
- attach the Controller
- attach a command event listener that handles user clicks in the menu
by loading the associated URL, if any, in a browser tab
- root the View on a Model query result, and tell it to populate itself
Folder Selector
- instantiate a Menu View, attached to a menulist in the Places Search popup.
- attach the Controller
- attach a command event listener that handles user clicks in the menu by re-rooting a Tree View elsewhere in the UI
- root the View on a Model query result, and tell it to populate itself.
As you can see, this careful distinction between each allows us to rapidly build new user interface components by connecting the same Views and Controller with different application specific functionality.

Details
Models
Data storage is implemented via a collection of SQLite tables:
A detailed database schema complete with associations between the various tables within places.sqlite: https://wiki.mozilla.org/images/d/d5/Places.sqlite.schema3.pdf
Source code:
- Browser front-end:
mozilla/browser/components/places
- Toolkit Services:
mozilla/toolkit/components/places
Views
There are three primary types of view for Places:
- Tree/List view - Can show flat lists or hierarchical structures. e.g. the panes in the Places Organizer window.
- Toolbar view - Shows folders as buttons that have dropdown menus. e.g. the Bookmarks Toolbar in the browser window.
- Menu view - Shows folders as sub menus. e.g. the Bookmarks Menu in the browser window.
Each of these views implement a Places View interface which provides view-agnostic means for obtaining the current selection and other information. The Views themselves take on no controller-like responsibilities. They are not responsible for handling user clicks and opening links, etc - just presenting a list of places.
XXXben - fill in details!
Source code: mozilla/browser/components/places/content/tree|menu|toolbar.xml
Controller
The Controller connects the Views to the Model. It is responsible for telling the UI what commands are available, enabled and executing them on the back end services.
Source code: mozilla/browser/components/places/content/controller.js
Querying History

To display results in a PlacesView, the following steps are performed:
Query Creation
Any list of items is the result of a query. e.g. the contents of a particular bookmark folder is a request for all URLs with the bookmark flag set that are contained by a named folder. Or all pages in a specific date range. And so on. Queries are represented as strings (which can be Bookmarked - "saved searches" or "virtual folders") containing all the parameters. -->brettw - fill in details!
Query Execution
The contents of the query string are deserialized and a series of Query objects are constructed. The query objects are executed.
Result Gathering
The results of the execution are gathered. --> brettw - fill in details! Not all queries produce results in the form of rows from the main URL table. Some produce results dynamically by consulting the contents of a directory on the user's file system (e.g. a new implementation of the old File System Datasource), for example. There are potentially other examples of remote data sources being used to feed data into the places view. Data sources like the Feed handler and the Bonjour listener would work slightly differently however. They would have their own timeout/notification based system by which they would detect new content, and then push URLs/rows into the main URL table whenever there was new data, so that when their containers were opened static content from the last dump is shown.
Result Organization
The results object is passed to a "Grouper" which organizes the results into a hierarchy based on a set of rules specified by the user interface. These rules form a kind of filter, for example: show all bookmarks organized into their appropriate folders; show history from last week, grouped by site; show all URLs matching the string "goats" in a flat, ungrouped list.
View Creation
The grouped results object is passed to the View implementation which supplies the necessary structure for the user interface.
Other Components
Dynamic Containers
The following are some example dynamic containers:
- Feed Container - ping and parse RSS/Atom feeds and fill containers with their posts
- File System Container - show folders and files from the local hard disk
- Bonjour Container - fill a container with available network resources discovered by Bonjour Zero-Configuration Networking.
- Address Book URLs Container - fill a container with URLs mentioned in the system address book
Data Migration
Migrating data from Netscape-bookmarks-file-1, Mork, etc, to the storage format.
- HTML Import/Export API
- JSON Import/Export API (XXX bug 384370)
Observer API
Observer APIs for extensions and other components that want to listen to backend activity: