Go to file
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
.docs docgen: Disable parallel processing, suspected cause of Ruby segfaults 2013-04-15 22:32:26 +00:00
demos Hybridise MWTemplateNode 2013-04-14 02:34:18 +00:00
maintenance Fix 404 on iframe styles by standardizing get and set modules methods. 2013-04-10 10:18:39 -07:00
modules Death and/or destruction 2013-04-18 13:56:20 -07:00
.gitignore Ignore Eclipse files 2013-01-11 10:58:47 -08:00
.gitreview Set defaultrebase=0 2012-06-20 16:27:40 -07:00
.jshintignore UnicodeJS library to implement Unicode standards 2013-03-27 17:44:22 +00:00
.jshintrc JSHint: Re-order jshintrc options to split common from project settings 2013-04-13 08:53:11 +02:00
ApiVisualEditor.php Pass through error message to VE if Parsoid is unreachable. 2013-03-11 18:01:36 +00:00
AUTHORS.txt Add Ed 2013-02-12 16:06:21 -08:00
CODING.md Document and clean up events in all the things 2013-03-20 09:58:27 -07:00
LICENSE.txt Bump copyright year range to 2013 in the licence file 2013-03-18 09:55:57 -07:00
README.txt Remove the parser from the VE repo 2012-07-30 13:19:09 -07:00
VisualEditor.hooks.php Fix missing global in 116321afe5 2013-04-17 15:29:58 -07:00
VisualEditor.i18n.php Localisation updates from http://translatewiki.net. 2013-04-16 19:47:52 +00:00
VisualEditor.php Make the "Report problem" POST URL configurable 2013-04-17 17:05:58 +00:00
VisualEditorMessagesModule.php Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00

VisualEditor provides a visual editor for wiki pages. It is written in
JavaScript and runs in a web browser. 

It uses the Parsoid parser to convert wikitext documents to annotated HTML
which the VisualEditor is able to load, modify and emit back to Parsoid at
which point it is converted back into wikitext.

For more information about these projects, check out the wiki:

	* http://www.mediawiki.org/wiki/VisualEditor
	* http://www.mediawiki.org/wiki/Parsoid