Closed
Bug 164054
Opened 23 years ago
Closed 23 years ago
Place selection at first visible content on editor doc load
Categories
(Core :: DOM: Editor, defect)
Core
DOM: Editor
Tracking
()
VERIFIED
FIXED
M1
People
(Reporter: mozeditor, Assigned: mozeditor)
Details
(Whiteboard: EDITORBASE+; fixinhand; need r=,sr=)
Attachments
(1 file)
|
10.28 KB,
patch
|
Brade
:
review+
kinmoz
:
superreview+
|
Details | Diff | Splinter Review |
This is to partially hide bug 98619. I need to place the selection at doc load
time at the first editable content.
| Assignee | ||
Updated•23 years ago
|
Status: NEW → ASSIGNED
Whiteboard: EDITORBASE+
| Assignee | ||
Updated•23 years ago
|
Target Milestone: --- → M1
| Assignee | ||
Comment 1•23 years ago
|
||
Well, this started out as a really simple patch to make
nsHTMLEditor::CollapseSelectionToStart() simply call
nsEditor::BeginningOfDocument(). That fixed the normal document load case for
most docs.
Then I noticed switching back from source mode still didn't set selection
properly. Turned out there were two reasons. 1)
nsEditor::BeginningOfDocument() lacks the sophistication to really tell
formatting text nodes from visible text nodes. 2) When switch from source
view, the composer commands js was explicitly setting the selection to {body,0}
after nsHTMLEditor::CollapseSelectionToStart() had done' it's thing.
So the js cal to set selection is gone, BegginingOfDocument() is now overridden
in nsHTMLEditor where it can be smarter, CollapseSelectionToStart() calls it,
and for giggles I shortened nsEditor::BegginingOfDocument() because it was such
a mess. It's semantics are unchanged.
I also had to initialize the dtd in nsHTMLEditor::Init() a little earlier so
that it would be around in time for the whitespace code to use in
nsHTMLEditor::BegginingOfDocument().
| Assignee | ||
Updated•23 years ago
|
Whiteboard: EDITORBASE+ → EDITORBASE+; fixinhand; need r=,sr=
Comment 2•23 years ago
|
||
Comment on attachment 101526 [details] [diff] [review]
patch to editor
r=brade
Attachment #101526 -
Flags: review+
Comment on attachment 101526 [details] [diff] [review]
patch to editor
sr=kin@netscape.com
==== I see different error check styles in nsEditor and
nsHTMLEditor::BeginningOfDocument():
+ if (NS_FAILED(res))
+ return res;
+ if (!selection)
+ return NS_ERROR_NOT_INITIALIZED;
...
+ if (NS_FAILED(res)) return res;
+ if (!rootElement) return NS_ERROR_NULL_POINTER;
...
+ if (NS_FAILED(result)) { return result; }
+ if (!parentNode) { return NS_ERROR_NULL_POINTER; }
==== In |nsHTMLEditor::BeginningOfDocument()| should we initialize |selNode|
and |selOffset| to (body, 0)? My concern is if it's possible to go through the
while loop and keep hitting |visType==nsWSRunObject::eOtherBlock| until we exit
the loop?
==== Just curious, why do we have |CollapseSelectionToStart()| and
|BeginningOfDocument()|:
nsEditor::BeginningOfDocument()
nsPlaintextEditor::CollapseSelectionToStart()
nsHTMLEditor::BeginningOfDocument()
nsHTMLEditor::CollapseSelectionToStart()
Attachment #101526 -
Flags: superreview+
| Assignee | ||
Comment 4•23 years ago
|
||
Kin, I don't know why we have the two different routines. I think Charlie added
CollapseSelectionToStart(), and it used to call some code that would not look
inside tables. Perhaps he wanted that distinction in behavior.
Or perhaps he didn't notice BeginningOfDocument(), which is an odd name anyway.
I wouldn't guess that would touch my selection from the name.
| Assignee | ||
Comment 5•23 years ago
|
||
kin: you can't exit the loop untikl done==PR_TRUE, and that only happens where
selNode is set.
| Assignee | ||
Comment 6•23 years ago
|
||
fixed on trunk
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Comment 7•23 years ago
|
||
This commit have added a "might be used uninitialized" warning on Brad TBox:
+editor/libeditor/html/nsHTMLEditor.cpp:494
+ `PRInt32 selOffset' might be used uninitialized in this function
While this appears to be a case of compiler not being smart enough, it would be
nice to have fewer warnings anyway (especially since these "might be used
uninitialized" warnings occasionally do indicate nasty bugs) .
P.S. See bug 59652 for more on "might be used uninitialized" warnings.
Updated•22 years ago
|
QA Contact: sujay → sairuh
You need to log in
before you can comment on or make changes to this bug.
Description
•