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

Re: [UndoManager] Re-introduce DOMTransaction interface?

From: Jonas Sicking <jonas@sicking.cc>
Date: Fri, 6 Jul 2012 15:53:58 -0700
Message-ID: <CA+c2ei_FOAqkJ82k5FvNtm=UU-tVX8_MXqGfDL3gDoQ1XT-A_A@mail.gmail.com>
To: Ryosuke Niwa <rniwa@webkit.org>
Cc: olli@pettay.fi, Erik Arvidsson <arv@chromium.org>, Ehsan Akhgari <ehsan@mozilla.com>, Aryeh Gregor <ayg@aryeh.name>, Adam Barth <w3c@adambarth.com>, public-webapps <public-webapps@w3.org>, Ojan Vafai <ojan@chromium.org>, Sukolsak Sakshuwong <sukolsak@gmail.com>
On Wed, Jul 4, 2012 at 5:39 PM, Ryosuke Niwa <rniwa@webkit.org> wrote:
> On Jul 4, 2012 5:26 PM, "Olli Pettay" <Olli.Pettay@helsinki.fi> wrote:
>> On 07/05/2012 03:11 AM, Ryosuke Niwa wrote:
>>> On Wed, Jul 4, 2012 at 5:00 PM, Olli Pettay <Olli.Pettay@helsinki.fi
>>> <mailto:Olli.Pettay@helsinki.fi>> wrote:
>>>     On 07/05/2012 01:38 AM, Ryosuke Niwa wrote:
>>>         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.
>>>     I don't understand what is difficult.
>>>     How is that any different to
>>>     target.addEventListener("foo", { handleEvent: function() {}})
>>> It will be very similar to that except this object is going to have 3
>>> callbacks instead of one.
>>> The problem is that the event listener is a very special object in WebKit
>>> for which we have a lot of custom binding code. We don't want to implement a
>>> similar behavior for the DOM transaction because it's very error prone.
>> So, it is very much implementation detail.
>> (And I still don't understand how a callback can be so hard in this case.
>> There are plenty of different kinds of callback objects.
>>  new MutationObserver(some_callback_function_object) )
> Yes. It's an implementation feedback. The mutation observer callback is
> implemented as a special event handler in WebKit.

This seems like an implementation specific limitation that you
probably should fix. Given that WebIDL supports callback interfaces
with multiple functions on them, and that the resulting JS code is
very easy to write and is very understandable, I suspect that this is
something that we will see in more APIs.

For example we did something very similar in the Idle API [1] (which
we are hoping to propose in the System Level APIs WG). Likewise the
jQuery.ajax [2] API supports passing in an object with both data and
multiple callbacks on it.

[1] https://wiki.mozilla.org/WebAPI/IdleAPI
[2] http://api.jquery.com/jQuery.ajax/

/ Jonas
Received on Friday, 6 July 2012 22:54:56 UTC

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