- From: Aryeh Gregor <Simetrical+w3c@gmail.com>
- Date: Fri, 22 Jul 2011 11:44:38 -0400
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: Ryosuke Niwa <rniwa@webkit.org>, David Flanagan <dflanagan@mozilla.com>, public-webapps@w3.org
On Thu, Jul 21, 2011 at 4:21 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote: > I'd really like numbers. Having looked at the Gecko editor code in the > past, I don't share your assurance that this is how it works.... > > That said, if you point to a workload, I (or anyone else; it's open source!) > can probably generate some numbers by instrumenting the Gecko DOM. But I > need a workload. Pretty much any formatting command is going to involve adding and removing wrapper elements. To add a wrapper element, say adding a <b> around some text to make it bold, you first have to insert the wrapper before or after the thing you want to wrap, then move all the nodes to wrap into the wrapper. Likewise, to remove a wrapper, you have to first move all its contents adjacent to it, then actually remove it from its parent. Likewise, for instance, suppose you delete some text that spans blocks, like: <p>foo[bar</p><div>baz]quz</div>. The result will be something like <p>foo[]quz</p>. How do you do that? First delete "bar" and "baz", then move "quz" to the <p>, then remove the <div>. Or let's say you have <p>foo[]bar</p> and the user hits Enter -- you first create an empty <p> after the existing one, then you move "bar" into it. Of the 37 execCommand()s I've defined, every single one will commonly move at least one node within the DOM, except for insertHorizontalRule and the ones that don't actually change the DOM (copy, selectAll, styleWithCSS, useCSS). I defined an algorithm "move preserving ranges" to handle this because of the range mutation problem: http://aryeh.name/spec/editcommands/editcommands.html#preserving-ranges It's invoked in 17 places in my draft currently, and nearly all of those are in general algorithms that are themselves invoked in multiple places. So I don't have any numbers, but anecdotally, editing things definitely does a lot of moving. If you want numbers, though, you probably don't want to look at my implementation -- you want some real-world software that actually uses mutation events.
Received on Friday, 22 July 2011 15:45:27 UTC