Closed Bug 14617 Opened 25 years ago Closed 24 years ago

calling GetAnchor/GetFocus from editor code

Categories

(Core :: DOM: Editor, defect, P3)

Other
Other
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: buster, Assigned: mozeditor)

Details

From Joe's posting:
We shouldn't ever be calling GetFocusNode()/GetAnchorNode() in the
editor.  I
wasn't going to say anything about it until I found an actual
example of code
that was broken because of this approach.  Well, I've
found it: the old
nsTextEditRules::DidUndo()/DidRedo() code didn't work
at all and caused
flurries of bogus nodes to start populating the
document.  There are 6
(remaining) places where we call GetFocusNode()
and 17 places where we call
GetAnchorNode() and I consider them all
guilty until proven innocent.  The
editor never cares, as far as I can
tell, what the selection code considers
anchor or focus, and our
operations should instead just operate on selection
ranges.
Summary: calling GetAnchor/GetFocus from editor code
Status: NEW → ASSIGNED
Target Milestone: M12
I will review all uses of this, although I don't understand how it affects
undo.
kin or I can help with any undo questions.
Can someone explain more about how using it generates "bogus nodes"?
The cases that use GetFocusNode() seem to be valid:
E.g., nsAutoSelectionReset uses them to save the current selection endpoints.
Steve: Do you want me to evaluate their use in code I didn't write?
Their use in SetTextPropertiesForNodeWithDifferentParents looks suspicious to
me.
Steve: Please evaluate SetTextPropertiesForNodeWithDifferentParents as
requested above.
Summary: calling GetAnchor/GetFocus from editor code → [CODE cleanup]calling GetAnchor/GetFocus from editor code
Whiteboard: [CODE general cleanup]
Target Milestone: M12 → M17
setting out to M17, general code cleanup
Assignee: cmanske → jfrancis
Status: ASSIGNED → NEW
The instances in my code are Ok.
I'm not sure about those in other people's code.
Joe: please review uses in your code.
accepting bug
removing whiteboard status text
Summary: [CODE cleanup]calling GetAnchor/GetFocus from editor code → calling GetAnchor/GetFocus from editor code
Whiteboard: [CODE general cleanup]
All this stuff has been reviewed, so I'm closing it out.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
verified in 4/25 build.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.