Currently, the Clipboard class is used for both drag-and-drop data and for copy-and-paste operations. There are several limitations to the Clipboard class; you cannot use arbitrary types, and the system pasteboard is always cleared prior to dispatching cut/copy events to the page ( http://www.quirksmode.org/dom/events/cutcopypaste.html).
I propose refactoring Clipboard and pulling more code into the base implementation. At a high-level, I'd like to change it so: - Clipboard has an internal HashMap cache mapping formats to data. Calling getData() and clearData() will only result in changes to the internal cache. - Clipboard can take an optional ClipboardDataSource in its constructor, which wraps access to the system pasteboard or native drag and drop data. This data source is read-only; data is never written back through the data source. If this data source is supplied, calls to getData() will only refer to the supplied data source. - Clipboard has one method to write back data in its cache back to the system pasteboard. > If setData() and clearData() were never called, this will be a no-op. This allows pages to prevent the default action from occurring on cut/copy without clearing the clipboard. > If setData() or clearData() were called, the system pasteboard will be cleared before the contents of the cache are written in. Not all types in the cache will necessarily be serialized to the system pasteboard; on Windows, application/x-my-crazy-mime-type won't be visible to other native apps. - Clipboard has one method to write back data in its cache to a native drag and drop object. Similar restrictions apply on types, depending on the platform. - All the types set by Javascript using setData() will magically work within WebKit. For drag and drop, this is simple. For copy and paste, it's a little more involved; WebKit will need to keep the Clipboard cache around globally, and install a clipboard listener to invalidate the cache if the clipboard changes outside of WebKit. With this change, the example snippets in the HTML5 draft for drag-and-drop should work out of the box. Doing this will greatly simplify platform implementations of Clipboard, and move access checks into a central location. It can be done in several patches alongside the existing code; the Clipboard functions affected by this change are virtual so base implementations can be added, and the original platform implementations removed as each platform implementation is updated.. Thoughts or comments? Daniel
_______________________________________________ webkit-dev mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

