Closed
Bug 865654
Opened 12 years ago
Closed 12 years ago
Coordinates near text input boundaries passed to caretPositionFromPoint product wrong offsets
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla24
People
(Reporter: jimm, Assigned: jwir3)
References
(Blocks 1 open bug)
Details
(Whiteboard: [selection] )
Attachments
(3 files, 1 obsolete file)
STR:
If you attempt to use caretPositionFromPoint with coordinates that aren't in the very center of text inputs the resulting offsets can be off, usually near at the beginning or end of the control.
This can play havoc with touch input / selection on mobile devices that rely on caretPositionFromPoint for setting selection or caret position.
STR:
1) open test case
2) open web console
3) click the mouse in the center of the text in the control
you should see a valid offset value.
4) move the mouse down to the white space below text and click again.
the caret will move to the end of the control and in the console you should see an offset of 924.
Reporter | ||
Comment 1•12 years ago
|
||
If you tweak the test case by setting a higher height value on the input it's easier to see the problem.
Comment 2•12 years ago
|
||
Thanks for filing this, jimm! This sounds like the issue I was seeing with bug 864582.
Blocks: 864582
Reporter | ||
Updated•12 years ago
|
Whiteboard: [selection]
Assignee | ||
Comment 3•12 years ago
|
||
Hm, so the problem here is that we have nested frames. If you open the testcase I am attaching with this comment (same testcase as Jim posted, just edited to make the height of the input larger) with the layout debugger setup to enable Visual Debugging, you'll see that there is a frame inside of the input element that contains the actual text.
In order for caretPositionFromPoint to work, we get the offset from a point within a given frame. This works by first detecting which frame the point resides in. In the case of text inputs, though, we don't want to expose the anonymous content in the text control, so a decision was made to always utilize the inner frame of the text control (which contains the content), hence the situation we have here.
One thing I might ask, though, is "What would it be expected to do?". I guess it seems like this should probably find the offset in the content that's vertically aligned with the click point in the text control, which we might be able to do in this case. For textareas, though, if you were to click in the whitespace at the bottom of the control element like this, I would argue that the behavior should do what is happening with the input element right now.
So, it seems like what we need to do is specialize between textareas and input elements, which are apparently using the same codepaths right now...
Assignee | ||
Comment 4•12 years ago
|
||
Attachment #741820 -
Attachment is obsolete: true
Assignee | ||
Comment 5•12 years ago
|
||
This patch adds a test for the problem seen in this bug, and fixes the problem by only adjusting offsets (the cause of the problem) for text areas. Other input elements don't need their offsets adjusted.
Assignee: nobody → sjohnson
Attachment #752597 -
Flags: review?(blassey.bugs)
Assignee | ||
Updated•12 years ago
|
OS: Windows 8 → All
Hardware: x86_64 → All
Updated•12 years ago
|
Attachment #752597 -
Flags: review?(blassey.bugs) → review+
Assignee | ||
Comment 6•12 years ago
|
||
Target Milestone: --- → mozilla24
Comment 7•12 years ago
|
||
Outbound: http://hg.mozilla.org/integration/mozilla-inbound/rev/7480571fa34e for https://tbpl.mozilla.org/php/getParsedLog.php?id=23298138&tree=Mozilla-Inbound
Target Milestone: mozilla24 → ---
Assignee | ||
Comment 8•12 years ago
|
||
Comment 9•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Reporter | ||
Comment 10•12 years ago
|
||
This is still a little broken with text area boundaries, should I file a follow up?
Assignee | ||
Comment 11•12 years ago
|
||
(In reply to Jim Mathies [:jimm] from comment #10)
> Created attachment 761418 [details]
> textarea
>
> This is still a little broken with text area boundaries, should I file a
> follow up?
Jim:
Are you talking about if you expand the text area and then move the mouse over an area of whitespace to the right of a given line? If so, then I thought there was a bug on this already... let me see if I can find it.
Reporter | ||
Comment 12•12 years ago
|
||
(In reply to Scott Johnson (:jwir3) from comment #11)
> (In reply to Jim Mathies [:jimm] from comment #10)
> > Created attachment 761418 [details]
> > textarea
> >
> > This is still a little broken with text area boundaries, should I file a
> > follow up?
>
> Jim:
>
> Are you talking about if you expand the text area and then move the mouse
> over an area of whitespace to the right of a given line? If so, then I
> thought there was a bug on this already... let me see if I can find it.
That's one problem, here are two test cases:
1) move your mouse to the lower edge of the textarea, you'll notice there is a ~3 pixel inner boundary where cpfp returns 2 rather than a correct text offset.
2) move your mouse to any text line and move right to the end of the text. You'll notice that after the cursor moves past the last character, cpfp will return an offset equal to the last character in the textarea, rather than the offset at the end of the line.
Assignee | ||
Comment 13•12 years ago
|
||
(In reply to Jim Mathies [:jimm] from comment #12)
> (In reply to Scott Johnson (:jwir3) from comment #11)
> > (In reply to Jim Mathies [:jimm] from comment #10)
> > > Created attachment 761418 [details]
> > > textarea
> > >
> > > This is still a little broken with text area boundaries, should I file a
> > > follow up?
> >
> > Jim:
> >
> > Are you talking about if you expand the text area and then move the mouse
> > over an area of whitespace to the right of a given line? If so, then I
> > thought there was a bug on this already... let me see if I can find it.
>
> That's one problem, here are two test cases:
>
> 1) move your mouse to the lower edge of the textarea, you'll notice there is
> a ~3 pixel inner boundary where cpfp returns 2 rather than a correct text
> offset.
>
> 2) move your mouse to any text line and move right to the end of the text.
> You'll notice that after the cursor moves past the last character, cpfp will
> return an offset equal to the last character in the textarea, rather than
> the offset at the end of the line.
Ok, so these problems and the above mentioned problem in comment 11 are basically the same thing. What is happening is that the frame for a given point is being incorrectly returned (since there's an anonymous document structure inside of the text area). I thought there was a bug for this already, but a precursory search didn't turn anything up. So, yes, I think this should be a followup bug.
As an aside, I think what we need to do for textareas is, given a point, find the nearest text frame to that point under certain conditions. I'm not 100% sure how this will work yet, though, since it's unclear that this will always return the correct frame.
Assignee | ||
Comment 14•12 years ago
|
||
Thanks, Jim!
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•