Closed Bug 245133 Opened 21 years ago Closed 21 years ago

[FIX]bad focus behaviour when moving a text input and immediately focus on it in the same function

Categories

(Core :: Layout: Form Controls, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha2

People

(Reporter: nirvn.asia, Assigned: bzbarsky)

References

()

Details

Attachments

(2 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040530 Firefox/0.8.0+ Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040530 Firefox/0.8.0+ If you call a function (say 'openMoveDiv()') that will move a text input in a div to a new location on the page where you mouse clicked, and that you focus on the input in the same function, the browser will scroll back to the old div/input location. Reproducible: Always Steps to Reproduce: 1.Open proofofbug.html; 2.Go to the end of the page, click on 'Open div container here'; 3. you can reproduce the behaviour infinitly by using the link at the beginning of the page when your div is at the bottom, and vice-versa. Actual Results: the page scrolls back to the old text input position Expected Results: focus on the text using its new position
Attached file Testcase for this bug
use this file to test the bug
I forgot to mention that there's an easy workaround: simply set a timeout function (like 200ms later) that will focus the text input ...
Not at all related to the JS engine. The JS engine knows nothing about focus, positions, etc.
Assignee: general → nobody
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → Layout: Form Controls
Ever confirmed: true
QA Contact: pschwartau → core.layout.form-controls
So the point is that we should be flushing reflows before trying to scroll frames into view. Not sure whether the flush should be in nsPresShell::ScrollFrameIntoView or in its callers.... Putting it in ScrollFrameIntoView makes the most sense to me -- I don't really see a reasonable situation where we'd want to ScrollFrameIntoView _without_ flushing.
Agreed.
Actually, this is a little tough... The problem is that we really need to flush out both style and layout before scrolling. But we don't want to be flushing out style while inside a frame impl, since the style change can tear down the frame. So I think the right thing to do is to fix form control content impls to flush before scrolling (like anchors and areas do).
On second thought, the right fix is to make Flush_Frames flush out style reresolves (so that any frame reconstructs get flushed) and then have ScrollFrameIntoView flush just reflow.
Attached patch PatchSplinter Review
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment on attachment 149702 [details] [diff] [review] Patch jst, what do you think? Note that the GetPrimaryFrame code in nsGenericHTMLElement flushes Flush_Frames, which is why this is happy.
Attachment #149702 - Flags: superreview?(jst)
Attachment #149702 - Flags: review?(jst)
OS: Windows XP → All
Priority: -- → P3
Hardware: PC → All
Summary: bad focus behaviour when moving a text input and immediately focus on it in the same function → [FIX]bad focus behaviour when moving a text input and immediately focus on it in the same function
Target Milestone: --- → mozilla1.8alpha2
Comment on attachment 149702 [details] [diff] [review] Patch Looks good. r+sr=jst
Attachment #149702 - Flags: superreview?(jst)
Attachment #149702 - Flags: superreview+
Attachment #149702 - Flags: review?(jst)
Attachment #149702 - Flags: review+
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: