Closed
Bug 602130
Opened 14 years ago
Closed 14 years ago
Caret positioned incorrectly in input[type=text] when hidden and redisplayed
Categories
(Core :: DOM: Editor, defect)
Core
DOM: Editor
Tracking
()
RESOLVED
FIXED
mozilla2.0b7
Tracking | Status | |
---|---|---|
blocking2.0 | --- | final+ |
People
(Reporter: cers, Assigned: ehsan.akhgari)
References
()
Details
Attachments
(3 files, 1 obsolete file)
9.40 KB,
image/png
|
Details | |
2.81 KB,
patch
|
Details | Diff | Splinter Review | |
3.42 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b7pre) Gecko/20101005 Firefox/4.0b7pre
Build Identifier: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b7pre) Gecko/20101005 Firefox/4.0b7pre
If an input[type=text] is hidden via display="none" and redisplayed via display="block" or display="inline-block" (and possibly other values), the caret is displayed too low in the input. This only occurs if the input has been focused before the first time it is hidden, and the bug disappears as soon as text is entered.
It is not triggered if the input is redisplayed via display="" or display="inline". If the input is wrapped in a div, and the div is hidden, display="block" no longer triggers the bug, yet display="inline-block" still does.
Reproducible: Always
Steps to Reproduce:
1. Go to http://www.geeksbynature.dk/bugs/cursorPosition
2. focus topmost text input
3. click trigger next to it
Actual Results:
caret positioned about half a line down, showing only top part
Expected Results:
caret positioned as before input was hidden
Reporter | ||
Comment 1•14 years ago
|
||
Screenshot of the bug as it appears on OSX
Updated•14 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
![]() |
||
Comment 2•14 years ago
|
||
Seems likely the fix for bug 536421 will fix this. Need to retest once that lands...
Depends on: 536421
Comment 3•14 years ago
|
||
Bug 536421 will not fix this. This bug only seems to occur when the
text input is empty. Maybe Ehsan's work on caret placement in bug 389321
will help?
Assignee | ||
Comment 4•14 years ago
|
||
(In reply to comment #3)
> Bug 536421 will not fix this.
Why? It seems to me that this is actually a dupe of that bug, isn't it?
Assignee | ||
Comment 5•14 years ago
|
||
Also, bug 389321 is about contenteditable elements, and it shouldn't affect caret positioning in input elements at all.
Reporter | ||
Comment 6•14 years ago
|
||
(In reply to comment #4)
> (In reply to comment #3)
> > Bug 536421 will not fix this.
>
> Why? It seems to me that this is actually a dupe of that bug, isn't it?
In bug 536421 the caret is not displayed at all, here it is displayed in a weird position (and this bug only affects empty elements). While it is a reasonable guess that the fix for that bug might also solve this problem, I do not think it is a dupe.
Assignee | ||
Comment 7•14 years ago
|
||
(In reply to comment #6)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > Bug 536421 will not fix this.
> >
> > Why? It seems to me that this is actually a dupe of that bug, isn't it?
>
> In bug 536421 the caret is not displayed at all, here it is displayed in a
> weird position (and this bug only affects empty elements). While it is a
> reasonable guess that the fix for that bug might also solve this problem, I do
> not think it is a dupe.
The cause of the problem (reframing of the text control) is the same, however...
Reporter | ||
Comment 8•14 years ago
|
||
(In reply to comment #7)
>
> The cause of the problem (reframing of the text control) is the same,
> however...
On that note, I've tested the patch from bug 536421, but it does not appear to
affect this bug. I do agree that the over all cause for the two are the same
though.
Additionally, I've tried replicating what happens in Panorama (bug 5948044),
but it doesn't seem to trigger with those circumstances in HTML. iQ hides and
shows by setting "opacity:0;display:none" and "opacity:1;display:''"
respectively, and Panorama applies this to a wrapper div. It seems that the bug
behaves slightly differently in chrome context, though it might just be other
contributing factors in the Panorama code.
I've added a test for the iQ way of hiding/showing to the HTML testcase.
Comment 11•14 years ago
|
||
Given that bug 553097 depends on that bug and is a blocker, it would be nice to
have this bug being explicitly a blocker.
blocking2.0: --- → ?
Assignee | ||
Comment 12•14 years ago
|
||
I set a breakpoint on nsCaret::DisplayAtPositionWithHint, and verified that the caret rectangle is correctly calculated (a 1x14 rectangle). I think this should be debugged by someone familiar with display list stuff. roc: do we have anybody to take a look at this?
No longer blocks: 553097
blocking2.0: ? → ---
Comment 13•14 years ago
|
||
I can take a look.
Assignee | ||
Comment 14•14 years ago
|
||
(In reply to comment #13)
> I can take a look.
Thanks!
Comment 15•14 years ago
|
||
So the caret is ok. The textframe inside the anonymous div is shifted down, and the caret is drawn at the correct position inside the textframe and is just clipped. So the textframe being at the wrong place is the problem.
Comment 16•14 years ago
|
||
Hmm, so '<input>' and '<input style="display: block;">' both create an anonymous div that contains only a br node, but setting display block when onfocus the anonymous div only contains a text node.
Comment 17•14 years ago
|
||
Setting to display: block causes us to reconstruct the frame. We follow this path
nsCSSFrameConstructor::ProcessChildren
nsCSSFrameConstructor::GetAnonymousContent
nsTextControlFrame::CreateAnonymousContent
nsHTMLInputElement::BindToFrame
nsTextEditorState::BindToFrame
nsTextEditorState::GetRootNode
nsTextEditorState::CreateRootNode
nsTextControlFrame::UpdateValueDisplay
and in UpdateValueDisplay we create the text node under the anonymous div. Then the next time it is safe to run script the PrepareEditorEvent runs and when it tries to nsTextEditRules::CreateBogusNodeIfNeeded it does not create the br node because it finds the textnode already there.
So I'm guessing we still want to create a br node in this case? And UpdateValueDisplay should handle this? I'm not sure here.
![]() |
||
Updated•14 years ago
|
Assignee | ||
Comment 18•14 years ago
|
||
Good catch, Timothy.
The problem here is that UpdateValueDisplay can be potentially called before editor init with aBeforeEditorInit equal to false (or not called at all, which is even worse).
This patch should fix this issue.
Assignee | ||
Comment 19•14 years ago
|
||
I also verified that this patch fixes the duplicates, as well as bug 585967 and bug 594804.
![]() |
||
Comment 20•14 years ago
|
||
Comment on attachment 482868 [details] [diff] [review]
Patch (v1)
r=me
Attachment #482868 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Updated•14 years ago
|
Attachment #482868 -
Flags: approval2.0?
Attachment #482868 -
Flags: approval2.0? → approval2.0+
blocking2.0: ? → final+
Assignee | ||
Updated•14 years ago
|
Whiteboard: [needs landing]
Updated•14 years ago
|
Whiteboard: [needs landing]
Updated•14 years ago
|
Whiteboard: [needs landing]
Assignee | ||
Comment 21•14 years ago
|
||
I added the display:block style to the reference file in order to make sure that the layout is consistent on all platforms.
Attachment #482868 -
Attachment is obsolete: true
Assignee | ||
Comment 22•14 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [needs landing]
Target Milestone: --- → mozilla2.0b8
Version: unspecified → Trunk
Assignee | ||
Comment 23•14 years ago
|
||
I backed this out because of test failures:
http://hg.mozilla.org/mozilla-central/rev/8567b73400e8
Sample failure log:
http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1287087223.1287088014.28248.gz
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 24•14 years ago
|
||
The test failure happened because under some situations, the transaction manager was not correctly cleared when we re-initialized the editor for a text control. This patch fixes this problem as well.
Attachment #483339 -
Flags: review?(roc)
Attachment #483339 -
Flags: review?(roc) → review+
Assignee | ||
Updated•14 years ago
|
Status: REOPENED → ASSIGNED
Whiteboard: [needs landing]
Assignee | ||
Comment 25•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/26f3aecd3d79
http://hg.mozilla.org/mozilla-central/rev/2ad78af5ae6b
Status: ASSIGNED → RESOLVED
Closed: 14 years ago → 14 years ago
Resolution: --- → FIXED
Whiteboard: [needs landing]
Updated•14 years ago
|
Target Milestone: mozilla2.0b8 → mozilla2.0b7
You need to log in
before you can comment on or make changes to this bug.
Description
•