Closed Bug 184719 Opened 22 years ago Closed 22 years ago

midas needs a command for toggling read-only/writable

Categories

(Core :: DOM: Editor, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.3beta

People

(Reporter: Brade, Assigned: Brade)

Details

(Whiteboard: midas)

Attachments

(3 obsolete files)

Midas needs a command for toggling read-only and writeable modes
Status: NEW → ASSIGNED
Whiteboard: midas
Target Milestone: --- → mozilla1.3beta
Charley reminds me of these things:
>be sure to implement it as another "nsSetDocumentStateCommand" command if it
>supports setting a state param. and use nsDocumentStateCommand if it simply
>reports state

I would guess that this is setting a state rather than reporting a state.
Comment on attachment 111432 [details] [diff] [review]
split document commands off into a separate file; add readonly cmd

sfraser--can you look this over and give me some feedback?  Note: much of the
new file is copy/pasted from old file so some cleanup may be needed.
Attachment #111432 - Flags: superreview?(sfraser)
+    // Should we fail if this param wasn't set?
+    // I'm not sure we should be that strict
+    if (NS_FAILED(rv))
+      return NS_OK;

I think if you're going to not do what the user asked, then you should return an
error value.

+    if (NS_SUCCEEDED(aParams->GetBooleanValue(STATE_ATTRIBUTE, &isReadOnly)))
+    {
+      PRUint32 flags;
+      editor->GetFlags(&flags);
+      if (isReadOnly)
+        flags |= nsIPlaintextEditor::eEditorReadonlyMask;
+      else
+        flags &= ~(nsIPlaintextEditor::eEditorReadonlyMask);
+
+      return NS_OK;
+    }
+
+    return NS_ERROR_FAILURE;

Don't you need to set the flags back on the editor? An early return would be
cleaner here too (return failure if GetBooleanValue() fails).

+  {
+
+    PRUint32 editorStatus = nsIEditingSession::eEditorErrorUnknown;

extra line.

+  nsCOMPtr<nsIEditingSession> editingSession = do_QueryInterface(refCon);

Need to say why the refcon for this command is an editingSession, and for the
other commands is an nsIEditor (see below).

+      // refCon is initially set to nsIEditingSession until editor
+      //  is successfully created and source doc is loaded

Oh, there it is. Move the
+  nsCOMPtr<nsIEditingSession> editingSession = do_QueryInterface(refCon);
inside that scope.

Attachment #111432 - Attachment is obsolete: true
Attachment #111432 - Flags: superreview?(sfraser)
Attachment #111627 - Flags: review?(mkaply)
Comment on attachment 111627 [details] [diff] [review]
revised diff with fixes suggested by smfr

mkaply--please review.

note: commented out ifdefs will be removed once I've confirmed they build on
windows/linux.
Comment on attachment 111627 [details] [diff] [review]
revised diff with fixes suggested by smfr

fyi this builds on windows with a Makefile.in change
Attachment #111627 - Flags: superreview?(sfraser)
Attachment #111627 - Flags: review?(mkaply)
Attachment #111627 - Flags: review+
Attachment #111627 - Flags: superreview?(sfraser) → superreview+
Attached patch add command registration (obsolete) — Splinter Review
obsoleting previous patch because it was checked in
Attachment #111627 - Attachment is obsolete: true
Comment on attachment 111792 [details] [diff] [review]
add command registration

seek reviews for missing command registration
Attachment #111792 - Flags: superreview?(sfraser)
Attachment #111792 - Flags: review?(mkaply)
Attachment #111792 - Flags: superreview?(sfraser) → superreview+
Attachment #111792 - Flags: review?(mkaply) → review+
Comment on attachment 111792 [details] [diff] [review]
add command registration

obsoleting patch which is now checked in
Attachment #111792 - Attachment is obsolete: true
fixed
Status: ASSIGNED → RESOLVED
Closed: 22 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: