W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2012

[UndoManager] Re-introduce DOMTransaction interface?

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Wed, 4 Jul 2012 15:38:21 -0700
Message-ID: <CABNRm63M+kBaNLKEy-zmOPF8Ra0Z+v1rpBpZW5dAc1mFZ8vdNw@mail.gmail.com>
To: public-webapps <public-webapps@w3.org>
Cc: Ojan Vafai <ojan@chromium.org>, Jonas Sicking <jonas@sicking.cc>, Olli Pettay <Olli.Pettay@helsinki.fi>, Ehsan Akhgari <ehsan@mozilla.com>, Erik Arvidsson <arv@chromium.org>, Adam Barth <w3c@adambarth.com>, Sukolsak Sakshuwong <sukolsak@gmail.com>, Aryeh Gregor <ayg@aryeh.name>
Hi all,

Sukolsak has been implementing the Undo Manager API in WebKit but the fact
undoManager.transact() takes a pure JS object with callback functions is
making it very challenging.  The problem is that this object needs to be
kept alive by either JS reference or DOM but doesn't have a backing C++
object.  Also, as far as we've looked, there are no other specification
that uses the same mechanism.

Since I want to make the API consistent with the rest of the platform and
the implementation maintainable in WebKit, I propose the following changes:

   - Re-introduce DOMTransaction interface so that scripts can instantiate
   new DOMTransaction().
   - Introduce AutomaticDOMTransaction that inherits from DOMTransaction
   and has a constructor that takes two arguments: a function and an optional

After this change, authors can write:
scope.undoManager.transact(new AutomaticDOMTransaction{function () {
}, 'append "foo"'));

instead of:

scope.undoManager.transact({executeAutomatic: function () {
}, label: 'append "foo"'});


document.undoManager.transact(new DOMTransaction({function () {
        // Draw a line on canvas
    }, function () {
        // Undraw a line
    }, function () { this.execute(); },
    'Draw a line'

instead of:

document.undoManager.transact({ execute: function () {
        // Draw a line on canvas
    }, undo: function () {
        // Undraw a line
    }, redo: function () { this.execute(); },
    label: 'Draw a line'

Ryosuke Niwa
Software Engineer
Google Inc.
Received on Wednesday, 4 July 2012 22:39:10 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:37 UTC