mediawiki-extensions-Visual.../modules/ve
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
..
actions Death and/or destruction 2013-04-18 13:56:20 -07:00
ce Merge "Inside ve.ce.Document.getRelativeOffset fallback to 'character' mode if 'word' mode returns the same offset as was passed originally" 2013-04-16 22:54:27 +00:00
dm Death and/or destruction 2013-04-18 13:56:20 -07:00
init Partly fix the "Report problem" button 2013-04-17 23:04:56 +00:00
styles Toolbar style fixes 2013-03-15 12:48:49 -07:00
test Death and/or destruction 2013-04-18 13:56:20 -07:00
ui Death and/or destruction 2013-04-18 13:56:20 -07:00
ve.Action.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.ActionFactory.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.BranchNode.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.CommandRegistry.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.debug.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.Document.js Emit a transact event on the ve.dm.Document when a transaction occurs 2013-03-14 23:35:50 -07:00
ve.EventEmitter.js Fix documentation to place @emits in the correct place 2013-03-25 21:06:05 +00:00
ve.Factory.js Remove more periods 2013-03-20 22:55:50 +00:00
ve.js Fix for custom hash with keys in different order 2013-04-09 00:20:44 +01:00
ve.LeafNode.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.NamedClassFactory.js Rename ve.NodeFactory to ve.NamedClassFactory 2013-04-09 12:05:05 -07:00
ve.Node.js Move common Node/Annotation/MetaItem code into ve.dm.Model 2013-04-09 12:05:05 -07:00
ve.Range.js Clickable inline images 2013-04-08 17:58:46 -07:00
ve.Registry.js Document and clean up events in all the things 2013-03-20 09:58:27 -07:00
ve.Surface.js Death and/or destruction 2013-04-18 13:56:20 -07:00
ve.Trigger.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.TriggerRegistry.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00