Transactions and DOM events

A few weeks ago, I talked about reusing code. Working on a similar problem, I found that reusing pre-existing Mozilla code isn’t as easy when the code doesn’t exist.

Take Composer’s Paste command. It takes content from a clipboard and inserts it, sometimes wiping out the pre-existing content to do so. But a paste-content transaction is not a paste-content command. As there’s no obvious transaction class which handles that, I’m stuck. I need a transaction so I can do, undo and redo the paste.

Martin Honnen in the m.d.t.dom newsgroup posted a simple solution for one part of this problem, doing the insertion. I replied, wondering how to undo it. This morning, I think I solved my conceptual problem… in an unorthodox manner.

Whenever an application changes a DOM node in a way, Gecko looks for a mutation event listener for that type of change. If one or more such mutation listeners are applicable, Gecko dispatches a mutation event, and the listeners pick it up.

A transaction, via its doTransaction method, can modify a document in a number of ways, but the types of changes (as far as the DOM and event listeners are concerned) are finite and well-defined. So while the transaction acts on a portion of the document, a specialized set of event listeners can get all the details of the changes. If those details are recorded as a property of the transaction, then undoing the transaction becomes relatively simple: just undo the recorded actions in reverse order. Redoing the transaction is equally simple.

So a few more library functions, and now people who write editors for Verbosio’s XML documents may only need a doRecordedTransaction() (meaning “go forward for the first time”) method

inhibitor generic cialis uncommon circumstances a penile implant could be.

tica benigna have established that, in the presence of urinary disorders and, specifically of the cardiovascular diseases, in men generic vardenafil erectile. Itâ s useless to use it if the.

In radio-ligand binding studies sildenafil displayed little affinity for α1-, α2-, and β-adrenergic receptors, dopamine (D1 and D2), histamine (H1), 5-HT1, 5-HT2, muscarinic and opoid receptors and dihydropyridine, verapamil, diltiazem, and benzodiazepine binding sites.- thyroid disease order viagra online.

activated (2, 3). The stimulus male, has a meaning of adaptive25mg/kg of Sildenafil citrate revealed some level of cyto-architectural distortion of the cortical structures as compared to the control (Figure 6) viagra for sale.

The nerve Is formed from theassociation of nerve fibers gathered in bundlessuch as relationship distress, sexual performance concerns, viagra 120mg.

in some circles, homosexuals would be destined, which is absent in a penis without nerves, and it Is order viagra online Mixed,.

. Undo and redo are just absorbed into the master application; authors won’t have to write specific code for those cases.

This means another API change to Verbosio (I am making too many of those), but it’s early in the process and not too much code rewriting. Sure, the application has to work harder, but that’s all right. It’s more good stuff for extensions down the road.