downloads: break downloads.js into more classes/files.
chrome://downloads' code has gotten less flexible than we'd like over
the years and needs a little TLC.
This CL heavily refactors chrome://downloads code by ripping apart
downloads.js into:
downloads.{
Item: a light data wrapper that has-an ItemView
ItemView: responsible for beautiful downloads
Manager: owns and manages all the items
}
as well as moving large portions of programmatic DOM creation (i.e. tons
of document.createElement() calls) into an HTML template that's cloned.
The JS refactor loosens the coupling between various layers, more
clearly show responsibilities, and makes the code easier to understand,
test, and maintain (in theory).
The new way C++ => JS communication works is:
- if an item will be hidden or shown (e.g. remove, undo, new)
- C++ sends a whole new list to the JS
- the JS is now much smarter about re-using DOM nodes
- this preserves focus and has better performance
- if an item is simply updated (e.g. downloading in progress)
- C++ sends an update to that specific item
R=asanka@chromium.org
BUG=446412
Review URL: https://codereview.chromium.org/
977473002
Cr-Commit-Position: refs/heads/master@{#320204}