This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27626 - Specify Document.caretRangeFromPoint()?
Summary: Specify Document.caretRangeFromPoint()?
Status: NEW
Alias: None
Product: CSS
Classification: Unclassified
Component: CSSOM View (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Simon Pieters
QA Contact: public-css-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-16 13:07 UTC by Philip Jägenstedt
Modified: 2014-12-18 15:59 UTC (History)
3 users (show)

See Also:


Attachments

Description Philip Jägenstedt 2014-12-16 13:07:49 UTC
This is a WebKit invention, and still in Blink. Usage is high enough that removal isn't trivial, but could work out if deemed necessary:
https://www.chromestatus.com/metrics/feature/timeline/popularity/387

The caretPositionFromPoint() in the spec seems to be a Gecko-only API. I'm not sure which of these can be implemented in terms of the other, or if having both makes any sense.
Comment 1 Simon Pieters 2014-12-16 13:38:56 UTC
https://github.com/search?utf8=✓&q=caretrangefrompoint+NOT+shouldBe+NOT+test+NOT+expected&type=Code&ref=searchresults

https://github.com/search?utf8=✓&q=caretpositionfrompoint+NOT+shouldBe+NOT+test+NOT+expected&type=Code&ref=searchresults

It seems there are some uses that does not fall back to the other API, and I didn't see any obvious use that is browser sniffing (it could exist though). As far as I can tell they are redundant with each other, but possibly having both is slightly better for Web compat.
Comment 2 Philip Jägenstedt 2014-12-17 13:40:18 UTC
I've grepped the 20141115 httparchive data, finding 160 instances of caretPositionFromPoint and 219 instances of caretRangeFromPoint. There's some overlap, as these combined are only 220 unique resources.

There is only one resource which has caretPositionFromPoint but not caretRangeFromPoint:
http://www.elenasmodels.com/JavaScriptSpellCheck/include.js

That's inside livespell.test.FireFox() :(

There are 60 resources with caretRangeFromPoint but not caretPositionFromPoint. Because of a bug <https://github.com/HTTPArchive/httparchive/issues/41>, here are the top-level documents that requested those resources:
http://diadiemanuong.com/
http://kroogi.com/explore?locale=en
http://ldpr.ru/
http://loot.com/
http://loot.com/user/registration/
http://mmmos.com/
http://nashrenovin.ir/
http://oak.scout.com/forums
http://paleohacks.com/
http://pfc-cska.com/
http://pressaboutus.com/
http://pubslush.com/
http://rakftz.com/
https://app.careerplug.com/user/sign_in
https://edpuzzle.com/
https://fabrily.com/
http://sozi.vn/
https://topvisor.ru/
https://trueability.com/
https://www.crowdforangels.com/
https://www.healthtrioconnect.com/app/index.page?
https://www.onewire.com/
https://www.realestate.com.ng/
https://www.reverbcity.com/
https://www.upinside.com.br/
https://www.wellnessliving.com/
http://www.1stopsocial.com/
http://www.adultfax.com/
http://www.appdata.com/
http://www.areamembri.it/login
http://www.babyfrance.com/fr
http://www.comicbook.com/
http://www.deepakchopra.it/
http://www.dnngo.net/
http://www.elfwood.com/
http://www.espguitars.com/
http://www.europeanvoice.com/
http://www.fanbacked.com/
http://www.flamengorj.com.br/
http://www.getsmarter.co.za/
http://www.gradesaver.com/
http://www.klagemauer.tv/
http://www.kla.tv/
http://www.kosmas.cz/
http://www.noomii.com/
http://www.opinionstage.com/
http://www.platfor.ma/
http://www.prnob.com/
http://www.runelocus.com/
http://www.siteprice.org/
http://www.sos-lettre.fr/
http://www.upshare.co/
http://www.valueinvestorsclub.com/
http://www.webforcepro.net/
http://www.whenathome.com/
http://www.womaninreallife.com/
http://www.worldpackers.com/
http://www.yigg.de/

Most of these seem to be TinyMCE, and a few CKEditor cases. I haven't investigated what functionality is missing without caretRangeFromPoint.
Comment 4 Simon Pieters 2014-12-18 09:51:46 UTC
The page with only caretPositionFromPoint uses it after checking for "firefox" in navigator.userAgent, so it would start breaking in Firefox if it was removed, but it wouldn't break for Blink to support it.

TinyMCE and CKEditor feature-check for caretRangeFromPoint before using it. They don't use any other "WebKit-specific" code in that code-path. So it wouldn't break for other browsers to support it.

To me this suggests the best path forward is to support both. The main risk I think is that there are pages on the long tail that use other browser-specific APIs depending on whether caretRangeFromPoint or caretPositionFromPoint is supported, but it is encouraging that it appears to not be present in the httparchive data.
Comment 5 Philip Jägenstedt 2014-12-18 10:07:14 UTC
If caretPositionFromPoint() can be trivially expressed in terms of caretRangeFromPoint() that would be a good start. Some like use counter data from Firefox for caretPositionFromPoint() would also be very nice, since if it's a lot lower than the ~0.04% we're seeing for caretRangeFromPoint() them simply removing it seems like the fastest way to converge.