Closed Bug 1032090 Opened 10 years ago Closed 10 years ago

Bounding Issue for CSS -moz-user-select

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 739396

People

(Reporter: howie, Unassigned)

References

()

Details

Considering a DOM structure:
<body>
 <p>Foobar1</p>
 <div>Some dummy here</div>
 <p>Foobar2</p>
</body>

Assuming we want to make the div not selectable, the CSS would be
div {-moz-user-select: none}

When selecting the div alone, it can’t be done, which is correct.

But, when the selection starts from Foobar1:
Actual Result -- It's easily to drag through the div and all the way down to Foobar2, making everything selected.

Expected Result -- The div to be skipped since it's moz-user-select: none.
See the hierarchy of user-select here:
http://dxr.mozilla.org/mozilla-central/source/layout/generic/nsFrame.cpp#2584

It seems like we only check for selection flags on frames on mousedown and not during the drag when extending the selection range across multiple frames.

A good place to hook this up may be in the DOM selection range code. eg.: 
http://dxr.mozilla.org/mozilla-central/source/content/base/src/nsRange.h#142

...but I don't know how expensive it would be to map nsINodes back to nsFrames to check for their selectability bits. This could be a performance issue while we're in the middle of a drag loop. Rob might know.
Component: Layout → Plug-ins
Flags: needinfo?(roc)
Component: Plug-ins → Layout
I'm not really sure how this should work, to be honest. Based on MDN, it sounds like our current behavior is intentional:
https://developer.mozilla.org/en-US/docs/Web/CSS/user-select
There is no spec, so we can't refer to that.

Mats knows more about this than I do. I can see that a value like Howie wants is useful, but it's difficult to implement since we'd have to create a multi-range selection. Other browsers don't support multi-range selection at all so we probably would never be able to standardize it.
Flags: needinfo?(roc) → needinfo?(mats)
Jet, Roc, another use case we are interested in is like this:

<body style="-moz-user-select: none;">
  <p>hi</p>
  <div style="-moz-user-select: element;">hello world</div>
</body>

and selecting the <div> and move up the cursor will also select the <p>.

Should I file another bug on this? This *maybe* is easier to implement than comment 0.
From what I can remember, 'user-select:none' means that *user actions*
that select content should exclude these elements.  We used to do that
by clearing a "selected" bit on the frame, but this broke when we
moved that bit to content.

I think the "Selection can contain these elements" on the MDN page is
a warning that the 'user-select:none' element may appear in the
Selection range, i.e. window.getSelection().getRangeAt(0).toString()
would include it.

This is a dupe of bug 739396, let's continue the discussion there...
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(mats)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.