Closed Bug 263060 Opened 21 years ago Closed 21 years ago

bookmarklet select stopped working (editor not initialized correctly)

Categories

(Core :: Layout, defect)

1.7 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Peter6, Assigned: shaver)

Details

(Keywords: fixed1.7.5, regression)

Attachments

(1 file)

bookmarklet: javascript:(function() { var title = document.title; function htmlEscape(s){return s;}; var OS=document.getElementById(%22op_sys%22).value.substring(0,3) ; document.write(%22<form name=f><textarea name=ta cols=120 rows=5></textarea></form>%22); document.close(); document.f.ta.value = %22[*][url=%22 + location.href + %22]BRANCH:#%22 + /\d+/(title)[0] + %22 [/url]%22 + htmlEscape(/-.*/(title)[0].slice(2)) +%22 [%22+OS +%22]%22+ %22%22; document.f.ta.select(); })() (original can be found on Jesse's website) repro: 1. make this bookmarklet 2. open a random bug 3. press on the bookmarklet 4. it will create a textfile I use for forums 5. notice, that despite "document.f.ta.select();" , the text is not selected regression happened between 20041004 14PDT and 20041005 07PDT (Sweetlou builds) Prime suspect bug 241625 "Open in tabs" doesn't focus content area in first tab CC jruderman@gmail.com and vladimir@pobox.com
It's not bug 241625; I just tested both with and without it (it's a one-line bookmarks.js change), and the bookmarklet worked fine in both cases.
I just rechecked the sweetlou build downloaded 20041004 21:37 utc (14:37 pdt) shows the text SELECTED. the sweetlou build downloaded 20041005 14:02 utc (07:02 pdt) doesn't show the text selected. checked in (roughly in that period) bug 228557 This one maybe bug 256218 bug 241625 bug 237204 bug 259039 bug 260591 bug 258787 bug 262750 bug 260704 bug 255572 Could bug 228557 have caused this Vlad ?
description in tinderbox for this was : bug 228557 asynchronously initialize editor to avoid re-entering frame construction. checkin shaver 2004-10-04 14:10 PDT patches in : mozilla/ layout/ html/ forms/ src/ nsTextControlFrame.h mozilla/ layout/ html/ forms/ src/ nsTextControlFrame.cpp
> Could bug 228557 have caused this Vlad ? It almost certainly did. We need to force editor init on select() and other operations that need an editor. Those shouldn't be happening during frame construction anyway.
I guess I should fix this, then, but I'll need to dig a bit and make sure I understand why I broke this case.
Assignee: firefox → shaver
Shaver, calling select() calls through to nsHTMLInputElement::SelectAll, which calls nsTextControlFrame::SetProperty for the nsHTMLAtoms::select property. This calls SelectAllContents(), which bails because mEditor is null. So we either need to force editor creation there or set a flag to re-call SelectAllContents() once we have an editor...
In general, there are various selection-related functions in nsTextControlFrame that have similar issues (eg SetSelectionRange, SetSelectionStart, SetSelectionEnd, GetSelectionRange, etc, etc).
OK, I think I'll just ReallyInitEditor there, since it can't happen during frame construction (can it? can some XBL constructor do something unpleasant to access the selection?).
An XBL constructor can call select()....
So does that mean that they _can_ happen during frame construction? Or does comment 4 still hold. Sorry, just want to be completely sure here.
To be frank, I'm not sure. Constructor processing happens late, but not quite _after_ frame construction. So I don't know what will happen if it forces editor init...
But in general, constructor processing can do all sorts of weird shit; we have bugs on it already (eg remove nodes that have had frames already created but not yet inserted....)
OK, so I'm going to ReallyInitEditor here and we can fix this when we fix the other stuff. Patch coming up.
Status: NEW → ASSIGNED
Of course, if mEditor is null we will also bail out of ReallyInitEditor. I think I need to spend some time in a debugger learning how this path is supposed to work here. Patch still coming, just not as _right_ up.
Summary: bookmarklet select stopped working → bookmarklet select stopped working (editor not initialized correctly)
So looking at this code, not yet in the debugger, I'm wondering if the problem is that we get through frame construction and call PostCreateFrames, which _used_to_ synchronously initialize the editor, but now returns before editor initialization is complete. This means that when we get into select() we may not have completed frame construction. I'm not sure what the best way to fix this is. We could just spin the event loop in SelectAllContents() until we're initialized, I guess, but that feels pretty gross. To be perfectly honest, this whole thing feels pretty gross and non-deterministic and fragile, but I still think it might be better than crashing due to flashblock.
> Of course, if mEditor is null we will also bail out of ReallyInitEditor. mEditor is set in CreateAnonymousContent, no? That happens before XBL constructors and before any JS could possibly execute.
If that's the case, then how does what you describe in comment 6 (SelectAllContents finding a null mEditor) occur? It seems like this access is happening after before frame construction, but I guess I need to get into the debugger after all.
Consensus: mEditor is not null, it just has no contents because it hasn't been initialized. On it, as the kids say.
Comment on attachment 161508 [details] [diff] [review] Force editor initialization for selection-access methods. r+sr=bzbarsky.
Attachment #161508 - Flags: superreview+
Attachment #161508 - Flags: review+
Comment on attachment 161508 [details] [diff] [review] Force editor initialization for selection-access methods. Requesting aviary approval for regression fix.
Attachment #161508 - Flags: approval-aviary?
Comment on attachment 161508 [details] [diff] [review] Force editor initialization for selection-access methods. a=brendan@mozilla.org for aviary1.0, and where's the 1.7 approval? Ah, wrong product.... /be
Attachment #161508 - Flags: approval-aviary? → approval-aviary+
Tidying. /be
Component: General → Layout
Flags: blocking-aviary1.0+
OS: Windows 2000 → All
Product: Firefox → Browser
Hardware: PC → All
Fixed on branch, closing.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
QA Contact: firefox.general → core.layout
per bug 228557, this got checked in to 1.7 too (2004-10-08 15:01). adding fixed1.7.x. also fixed on aviary branch 2004-10-08 14:52
This was backed out from the aviary branch, see bug 228557 for details.
Flags: blocking-aviary1.0+
Keywords: fixed-aviary1.0
This was backed out from the 1.7 branch too, see bug 228557 comment 55 for details. So it is not fixed on 1.7 branch anymore, right? Reopen?
Flags: review+
Version: 1.0 Branch → 1.7 Branch
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20050218 Firefox/1.0 (FF1.0.1) This WFM in FF 1.0.1 (sweetlou-aviary1.0.1 branch)
ostgote@gmx.net, you seem to be laboring under a fundamental misunderstanding of the situation. This bug was a regression caused by the fix for bug 228557. Both this fix and the fix in bug 228557 were backed out. So this bug still doesn't exist (since the changes causing it were backed out).
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: