Last modified: 2014-02-28 23:03:35 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T57448, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 55448 - VisualEditor: Clean up phantom mouse event code in ve.ce.ProtectedNode
VisualEditor: Clean up phantom mouse event code in ve.ce.ProtectedNode
Status: ASSIGNED
Product: VisualEditor
Classification: Unclassified
ContentEditable (Other open bugs)
unspecified
All All
: High normal
: ---
Assigned To: Editing team bugs – take if you're interested!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-07 22:46 UTC by Roan Kattouw
Modified: 2014-02-28 23:03 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Roan Kattouw 2013-10-07 22:46:39 UTC
Currently, the mouse event handling in phantoms is:

// mouseenter on the protectednode
ve.ce.ProtectedNode.prototype.onProtectedMouseEnter = function () {
	if ( !this.root.getSurface().dragging ) {
		this.createPhantoms();
	}
};

// mousemove on the surface, bound by createPhantoms and unbound by clearPhantoms
ve.ce.ProtectedNode.prototype.onSurfaceMouseMove = function ( e ) {
	var $target = $( e.target );
	if (
		!$target.hasClass( 've-ce-protectedNode-phantom' ) &&
		$target.closest( '.ve-ce-protectedNode' ).length === 0
	) {
		this.clearPhantoms();
	}
};

// mouseout on the surface, bound by createPhantoms and unbound by clearPhantoms
ve.ce.ProtectedNode.prototype.onSurfaceMouseOut = function ( e ) {
	if ( e.toElement === null ) {
		this.clearPhantoms();
	}
};

Issues:
* the mousemove handler seems to permit moving the mouse directly to a different ProtectedNode without causing the phantoms to be cleared
* the mouseout handler uses e.toElement, which is a poorly documented property that's allegedly IE-only
* it's generally very difficult to reason about what this code does or convince oneself that it does something reasonable
Comment 1 Roan Kattouw 2013-10-07 22:51:40 UTC
What's even worse is that if somehow another ProtectedNode does manage to show other phantoms, they will replace the first node's phantoms (because of the way ce.Surface manages phantoms), but if for some reason clearPhantoms() isn't called, the first node will continue to track the now-detached phantoms and reposition them when a transaction occurs.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links