WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
80159
Content with -webkit-user-select: none should be skipped during copy
https://bugs.webkit.org/show_bug.cgi?id=80159
Summary
Content with -webkit-user-select: none should be skipped during copy
ultr
Reported
2012-03-02 06:55:12 PST
Created
attachment 129896
[details]
testcase "-webkit-user-select:none" CSS property is not respected when copying content. Testcase: <span>one</span> <span style="-webkit-user-select:none; -moz-user-select:none;">two</span> <span>three</span> When you select the above text and copy it, your clipboard will contain "one two three" instead of "one three". It works OK in Mozilla Firefox - only elements with no -webkit-user-select:none set are copied.
Attachments
testcase
(376 bytes, text/html)
2012-03-02 06:55 PST
,
ultr
no flags
Details
Test case
(1.48 KB, text/html)
2022-12-08 21:17 PST
,
Ryosuke Niwa
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Shane Stephens
Comment 1
2012-03-21 20:54:33 PDT
Firefox has the same behavior, and even documents this (
https://developer.mozilla.org/en/CSS/user-select
). In the absence of an explicit specification suggesting the correct behavior is to respect the property when copying content, this doesn't seem to be a bug.
ultr
Comment 2
2012-05-26 03:52:23 PDT
> Firefox has the same behavior
This is not true. I have just tested it and it does NOT copy -moz-user-select:none fragments into the clipboard. Tested on: - Iceweasel 10.0.4 on Debian - Firefox 12.0 on Windows (there seems to be a bug: -moz-user-select:none fragment can be selected, but it is still NOT copied into the clipboard) There should at least be an option to change this behavior in Qt Webkit, so that this feature can be used in programs.
Alexey Proskuryakov
Comment 3
2012-07-01 10:57:57 PDT
***
Bug 90348
has been marked as a duplicate of this bug. ***
Ryosuke Niwa
Comment 4
2012-07-02 11:27:51 PDT
(In reply to
comment #1
)
> Firefox has the same behavior, and even documents this (
https://developer.mozilla.org/en/CSS/user-select
). In the absence of an explicit specification suggesting the correct behavior is to respect the property when copying content, this doesn't seem to be a bug.
This is not true at all.
Mr Maier
Comment 5
2013-01-16 06:23:03 PST
My system does not copy the text which is effected by "-webkit-user-select:none", too. Tested with Chrome 24.0.1312.52, Firefox 16.0.1 & WebKit
r139829
on Mac OS
Mr Maier
Comment 6
2013-01-16 06:26:04 PST
(In reply to
comment #5
)
> My system does not copy the text which is effected by "-webkit-user-select:none", too. Tested with Chrome 24.0.1312.52, Firefox 16.0.1 & WebKit
r139829
on Mac OS
Sorry I wanted to say it DOES COPY
Chris Peterson
Comment 7
2013-01-17 18:31:49 PST
Two interesting differences between -webkit-user-select:none and -moz-user-select:none (and the related -moz-user-select:-moz-none) is the highlighting and copying of text: * WebKit: CMD+A (or dragging a selection) will highlight the text surrounding a `none` span, but NOT the `none` text. * Gecko: CMD+A (or dragging a selection) will highlight all text, INCLUDING the `none` text. * WebKit: CMD+C will copy all text, INCLUDING the `none` text. * Gecko: CMD+C will copy the text surrounding a `none` span, but NOT the `none` text.
Ryosuke Niwa
Comment 8
2013-01-18 12:11:14 PST
(In reply to
comment #7
)
> Two interesting differences between -webkit-user-select:none and -moz-user-select:none (and the related -moz-user-select:-moz-none) is the highlighting and copying of text: > > * WebKit: CMD+A (or dragging a selection) will highlight the text surrounding a `none` span, but NOT the `none` text. > * Gecko: CMD+A (or dragging a selection) will highlight all text, INCLUDING the `none` text.
Gecko's behavior is counter-intuitive here. Isn't the whole point of user-select: none so that the text is never selected/highlighted?
> * WebKit: CMD+C will copy all text, INCLUDING the `none` text. > * Gecko: CMD+C will copy the text surrounding a `none` span, but NOT the `none` text.
Gecko's behavior makes sense here. I previously said that I'm afraid there might be a compat. issue but I think it makes sense to match Gecko's behavior on the basis that the user wouldn't expect unhighlighted text to be included when they hit cmd/ctl+c.
Chris Peterson
Comment 9
2013-01-18 12:47:40 PST
(In reply to
comment #8
)
> > * WebKit: CMD+A (or dragging a selection) will highlight the text surrounding a `none` span, but NOT the `none` text. > > * Gecko: CMD+A (or dragging a selection) will highlight all text, INCLUDING the `none` text. > > Gecko's behavior is counter-intuitive here. Isn't the whole point of user-select: none so that the text is never selected/highlighted?
I agree; I feel that highlighting text that is not going to copied is misleading.
> > * WebKit: CMD+C will copy all text, INCLUDING the `none` text. > > * Gecko: CMD+C will copy the text surrounding a `none` span, but NOT the `none` text. > > Gecko's behavior makes sense here. I previously said that I'm afraid there might be a compat. issue but I think it makes sense to match Gecko's behavior on the basis that the user wouldn't expect unhighlighted text to be included when they hit cmd/ctl+c.
I think part of the confusion is whether -*-user-select:none (which is not standard CSS) intends "selection" to means text highlight or copying. I think the user-select:none use case is to prevent users from highlighting and copying elements of a web page that are "not content", such as header or footer text. Unfortunately, I can imagine news websites marking their articles' text as user-select:none as weak "copy protection" (like websites that use JS to prevent right-clicking on images).
ultr
Comment 10
2013-01-18 13:28:10 PST
> * Gecko: CMD+A (or dragging a selection) will highlight all text, INCLUDING the `none` text.
That was working fine (-moz-user-select:none text was not highlighted nor copied) in Mozilla Firefox when I submitted this bug. But I confirm this is broken now (Iceweasel 18.0).
Ryosuke Niwa
Comment 11
2013-01-18 13:32:45 PST
(In reply to
comment #9
)
> > > * WebKit: CMD+C will copy all text, INCLUDING the `none` text. > > > * Gecko: CMD+C will copy the text surrounding a `none` span, but NOT the `none` text. > > > > Gecko's behavior makes sense here. I previously said that I'm afraid there might be a compat. issue but I think it makes sense to match Gecko's behavior on the basis that the user wouldn't expect unhighlighted text to be included when they hit cmd/ctl+c. > > I think part of the confusion is whether -*-user-select:none (which is not standard CSS) intends "selection" to means text highlight or copying. I think the user-select:none use case is to prevent users from highlighting and copying elements of a web page that are "not content", such as header or footer text. Unfortunately, I can imagine news websites marking their articles' text as user-select:none as weak "copy protection" (like websites that use JS to prevent right-clicking on images).
Yeah, that'll be very annoying for users.
Chris Peterson
Comment 12
2013-01-18 14:17:51 PST
(In reply to
comment #10
)
> That was working fine (-moz-user-select:none text was not highlighted nor copied) in Mozilla Firefox when I submitted this bug. But I confirm this is broken now (Iceweasel 18.0).
ultr, in
comment #2
, you said that I that Iceweasel 10 on Debian did NOT highlight the "none" text, but Firefox 12 on Windows did. I just tested Firefox 10 and 12 on Mac OS X. Firefox 12 does highlight the "none" text, but Firefox 10 does NOT! So the text highlight bug is a Gecko regression in Firefox 11 or 12. Thanks for pointing this regression. I'm going to file a Firefox bug now. :)
Deirdre Saoirse Moen
Comment 13
2013-04-18 18:06:54 PDT
<
rdar://problem/13689646
>
Han
Comment 14
2015-01-02 08:44:15 PST
FYI Firefox's misleading behavior of highlighting text that is not going to copied has been fixed in Firefox 35 (currently in beta):
https://bugzilla.mozilla.org/show_bug.cgi?id=739396
So -moz-user-select:none is pretty much perfect now in Firefox. Also, just to link this stuff together, the corresponding Chromium issue:
https://code.google.com/p/chromium/issues/detail?id=147490
Cory Duncan
Comment 15
2019-07-25 11:54:50 PDT
I'm seeing this working as expected in Chrome, Firefox and Edge. Is there any hope this might get fixed for Safari at some point?
Dougal Graham
Comment 16
2020-02-25 22:03:43 PST
It would be nice for this to be consistent across all browsers. It is even mentioned in the spec now:
https://drafts.csswg.org/css-ui-4/#content-selection
"UAs are encouraged to keep the visual selection consistent with what would get copied to the clipboard when copying. Copying text that does not appear to be selected, or vice versa, is highly confusing to users."
Tim Nguyen (:ntim)
Comment 17
2022-04-20 01:28:57 PDT
Comment hidden (obsolete)
getSelection() seems to return the correct selection without the user-select: none content. Not sure what the manual copy process uses, but it should use something similar.
Tim Nguyen (:ntim)
Comment 18
2022-04-20 02:20:07 PDT
(In reply to Tim Nguyen (:ntim) from
comment #17
)
> getSelection() seems to return the correct selection without the > user-select: none content. Not sure what the manual copy process uses, but > it should use something similar.
I stand corrected, getSelection() is wrong, it returns one range instead of two!
Tim Nguyen (:ntim)
Comment 19
2022-04-20 02:22:45 PDT
Chrome returns the one range (like WebKit) for getSelection() as well, and getSelection().toString() is "one two three" like WebKit. Gecko returns "one three"...
Ryosuke Niwa
Comment 20
2022-04-20 09:53:39 PDT
WebKit doesn't support multi-range selection. We need to adjust the behavior of StyledMarkupAccumulator in Markup.cpp. We probably also need to add a mode of TextIterator which skips content with this style applied as well, and use that in copy operation.
Ryosuke Niwa
Comment 21
2022-12-08 21:17:11 PST
Created
attachment 463953
[details]
Test case Based on this test case, Chrome includes the content with -webkit-user-select: none in the clipboard content.
tellowkrinkle
Comment 22
2022-12-10 12:45:49 PST
It seems to only include it in the html clipboard content, if you paste with "paste and match formatting" (shift-cmd-option-v) it pastes without the unselectable text. This happens to match my specific use case (marking <rp> and <rt> tags as unselectable), where I would want the tags copied in html but not in plain text, but I don't think that's what user-select was really meant for.
Ryosuke Niwa
Comment 23
2022-12-11 23:21:24 PST
Pull request:
https://github.com/WebKit/WebKit/pull/7467
EWS
Comment 24
2022-12-12 11:40:58 PST
Committed
257749@main
(166aef896770): <
https://commits.webkit.org/257749@main
> Reviewed commits have been landed. Closing PR #7467 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug