Last modified: 2013-12-12 01:01:29 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 T34186, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 32186 - Remove weird user-agent sniffing from jquery.textSelection scrolling
Remove weird user-agent sniffing from jquery.textSelection scrolling
Status: NEW
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.20.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-03 19:04 UTC by Brion Vibber
Modified: 2013-12-12 01:01 UTC (History)
5 users (show)

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


Attachments

Description Brion Vibber 2011-11-03 19:04:01 UTC
jquery.textSelection's scrollToCaretPosition() function has some weird-looking UA sniffing bits:

	function getLineLength( e ) {
		return Math.floor( e.scrollWidth / ( $.client.profile().platform == 'linux' ? 7 : 8 ) );
	}

What's that even mean? Why would being on Linux specifically mean the magic 7 number comes in? This looks like some awful magic code which is totally undocumented.

Then a bit later similar:
		return ( $.client.profile().platform == 'mac' ? 13 : ( $.client.profile().platform == 'linux' ? 15 : 16 ) ) * row;

What is this? Is it assuming that certain font sizes are always in use? This shouldn't fly...
Comment 1 Trevor Parscal 2011-11-03 20:20:32 UTC
This is code we don't use anymore, so it can really just be dropped. The code was originally borrowed from somewhere else (I think a Wikia extension but I don't recall details).

It's fundamentally broken and the approach is very inaccurate.
Comment 2 Brion Vibber 2011-11-04 18:13:28 UTC
WikiEditor's search-replace dialog appears to actively call $textarea.textSelection('scrollToCaretPosition') when selecting the next match.

LiquidThreads seems to have a partial copy of the search-replace in lqt.toolbar.js which also does this. (WTF?)


The getCaretScrollPosition() subfunction (with the 13 / 15 / 16 pixel hardcoding) appears to be used for 'Mozilla'-style browsers, and the getLineLength() is used by that.
Comment 3 Matthew Flaschen 2013-12-12 01:00:49 UTC
Do you mean dropping scrollToCaretPosition, or the whole jquery.textSelection library?

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


Navigation
Links