mediawiki-extensions-Visual.../modules/ve/dm
Trevor Parscal 2419f7638c Death and/or destruction
So. It turns out that the design of SurfaceFragment is a little -
shall we say - wonky.

One of the best things about ve.dm.SurfaceFragment is its magical
ability to retain the intention of its range, even as transactions
are being processed. This ability is granted by each fragment
listening to the surface's change event, and responding by using
translateRange for each transaction that gets processed. Surface
fragments also have these clever methods that allow you to get a
fragment based on another, which makes adjusting the range easy to do
inline without having to manually store multiple fragments or
modifying the original.

This sounded good, and we seemed to all be convinced it was well
designed. But if you add a console.log( 'hello' ); to the first line
of ve.dm.SurfaceFragment.prototype.onTransact, and then start using
the bold tool on various selections of text, you will find that there
may indeed be a flaw. What you will probably realize is that the
number of times that particular line of code is being called is
disturbingly large, and increases each time you do just about anything
in the editor. What's going on? How did we get here? Read on…

It turns out that fragments are immortal. We create them, they listen
to the surface's transact event, we are done with them, but the
surface keeps on emitting events to the now long forgotten about
fragments. They continue to build up over time, never go out of scope,
and bloat the hell out of our program.

The same ended up being true of toolbars - and each time the context
menu fired up a new one the old one was left in limbo, still
responding to events, still taking up memory, but not being visible to
the user.

All of this immortality was causing strange and difficult to track
down problems. This patch fixes this by introducing a destroy method.
This method unbinds events, allowing the object to finally fall out of
scope and die - and more importantly stop receiving notifications of
changes.

This is a hack, but Ed will no doubt get this situation sorted out
properly by making fragments lazy-evaluate their selections by only
storing an identifier of the most recent transaction they were based
on, see bug 47343.

Change-Id: I18bb986001a44732a7871b9d79dc3015eedfb168
2013-04-18 13:56:20 -07:00
..
annotations Actually use the doc parameter in toDomElements() 2013-04-09 23:48:03 +00:00
lineardata Merge "Implement next/prevBreakOffset and word skipping" 2013-04-09 22:24:41 +00:00
metaitems Fixes to DM metaList stuff under Roan's guidance. 2013-04-11 14:49:17 -07:00
nodes Hybridise MWTemplateNode 2013-04-14 02:34:18 +00:00
ve.dm.Annotation.js Actually use the doc parameter in toDomElements() 2013-04-09 23:48:03 +00:00
ve.dm.AnnotationFactory.js Convert AnnotationFactory and MetaItemFactory to NamedClassFactories 2013-04-09 12:05:05 -07:00
ve.dm.AnnotationSet.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.BranchNode.js Fix documentation to place @emits in the correct place 2013-03-25 21:06:05 +00:00
ve.dm.Converter.js Whitespace preservation was broken after the first run 2013-04-17 11:28:05 +00:00
ve.dm.DataString.js UnicodeJS library to implement Unicode standards 2013-03-27 17:44:22 +00:00
ve.dm.Document.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.DocumentSlice.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.dm.DocumentSynchronizer.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.dm.IndexValueStore.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.dm.LeafNode.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.LinearData.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.MetaItem.js Add ve.ce.View as a common base class for ce.Node and ce.Annotation 2013-04-09 12:05:05 -07:00
ve.dm.MetaItemFactory.js Convert AnnotationFactory and MetaItemFactory to NamedClassFactories 2013-04-09 12:05:05 -07:00
ve.dm.MetaList.js Fixes to DM metaList stuff under Roan's guidance. 2013-04-11 14:49:17 -07:00
ve.dm.Model.js Fix annotation breakage 2013-04-15 17:04:50 -07:00
ve.dm.ModelRegistry.js Convert AnnotationFactory and MetaItemFactory to NamedClassFactories 2013-04-09 12:05:05 -07:00
ve.dm.Node.js Hybridise MWTemplateNode 2013-04-14 02:34:18 +00:00
ve.dm.NodeFactory.js Allow nodes to handle their own children 2013-04-11 22:41:18 +00:00
ve.dm.Surface.js Fixes to DM metaList stuff under Roan's guidance. 2013-04-11 14:49:17 -07:00
ve.dm.SurfaceFragment.js Death and/or destruction 2013-04-18 13:56:20 -07:00
ve.dm.Transaction.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.TransactionProcessor.js TransactionProcessor: Fix offset bug 2013-04-12 23:16:51 +00:00