Closed
Bug 128903
Opened 23 years ago
Closed 23 years ago
nsIEditor.idl and nsIHTMLEditor.idl methods need to return out params correctly
Categories
(SeaMonkey :: Composer, defect)
SeaMonkey
Composer
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla1.0
People
(Reporter: cmanske, Assigned: akkzilla)
References
Details
Attachments
(4 files, 5 obsolete files)
1.15 KB,
patch
|
bugzilla
:
review+
sfraser_bugs
:
superreview+
|
Details | Diff | Splinter Review |
151.30 KB,
patch
|
cmanske
:
review+
sfraser_bugs
:
superreview+
|
Details | Diff | Splinter Review |
35.67 KB,
patch
|
dbaron
:
approval+
|
Details | Diff | Splinter Review |
1.14 KB,
patch
|
Brade
:
review+
kinmoz
:
superreview+
dbaron
:
approval+
|
Details | Diff | Splinter Review |
During the IDLizing of editor interfaces, the IDL methods return out params
that make it much harder to use in JavaScript:
Methods that have just one return param should be attributes: E.g.:
void GetSelection(out nsISelection selection);
should be:
readonly attribute nsISelection selection;
Methods with in params or multiple out params should return the last out param:
void CreateNode(in DOMString tag,
in nsIDOMNode parent,
in long position,
out nsIDOMNode newNode);
should be:
nsIDOMNode newNode CreateNode(in DOMString tag,
in nsIDOMNode parent,
in long position);
Reporter | ||
Comment 1•23 years ago
|
||
In last example, it should be:
nsIDOMNode CreateNode(in DOMString tag,
in nsIDOMNode parent,
in long position);
Assignee | ||
Comment 2•23 years ago
|
||
Assignee | ||
Comment 3•23 years ago
|
||
Patch attached. I changed all the nsIEditor and nsIHTMLEditor methods which
returned one out parameter, except for one case, SplitNode, where it wouldn't be
obvious what the return value was without a named out param.
It would be nice to make CSSEnabled at the end of nsIHTMLEditor a read/write
parameter, but I was trying to stick to changes that wouldn't affect any code,
for safety, and making it a parameter would change the name of IsCSSEnabled().
Seeking review (ideally from both cmanske and brade). Also cc'ing Simon and Kin
in case they have any comments (and so they know what's going on when I hit one
of them up for an sr).
Status: NEW → ASSIGNED
OS: Windows 2000 → All
Target Milestone: --- → mozilla1.0
Reporter | ||
Comment 4•23 years ago
|
||
I would suggest converting these methods in nsIHTMLEditor.idl:
void GetParagraphState(out boolean aMixed,out DOMString outState);
void GetFontFaceState(out boolean aMixed,out DOMString outFont);
void GetFontColorState(out boolean aMixed,out DOMString outColor);
void GetBackgroundColorState(out boolean aMixed,out DOMString outColor);
void GetAlignment(out boolean aMixed, out short aAlign);
so they all return the last out param.
Doesn't seem like we need both of these:
void GetHighlightColorState(out boolean aMixed,out DOMString outColor);
wstring GetHighlightColor(out boolean mixed);
GetHighlightColor() is used in editor.js. Can we eliminate it?
Comment 5•23 years ago
|
||
Comment on attachment 72464 [details] [diff] [review]
Changes to nsIEditor.idl and nsIHTMLEditor.idl
+ boolean ShouldTxnSetSelection();
+ boolean CanCut();
+ boolean CanCopy();
+ boolean CanPaste(in long aSelectionType);
+ boolean CanDrag(in nsIDOMEvent aEvent);
+ nsIDOMNode CreateNode(in DOMString tag,
...
iirc, these should all begin with lowercase letters:
canCopy, canPaste, canDrag, createNode, ...
It'd be great if we could all jump in and help Akkana get some real comments in
these files (explain each parameter, return values, etc.). However, I don't
think that should hold up this patch.
Assignee | ||
Comment 6•23 years ago
|
||
Attachment #72464 -
Attachment is obsolete: true
Reporter | ||
Comment 7•23 years ago
|
||
Comment on attachment 72487 [details] [diff] [review]
Better patch
Don't include
void Shutdown()
for this fix. It depends
on other remove editorShell work.
I wonder if you should return boolean for nsIEditor::GetAttributeValue()
Reporter | ||
Comment 8•23 years ago
|
||
Comment on attachment 72487 [details] [diff] [review]
Better patch
r=cmanske with suggested changes.
Attachment #72487 -
Flags: review+
Comment 9•23 years ago
|
||
Ideally, all the methods should have leading lower case names. Now would be a
good time to fix that, before they start being used in JS.
Assignee | ||
Comment 10•23 years ago
|
||
At Simon's request, I have renamed all the editor IDL methods in the files I
was touching to be lower-case, and have changed the JS cases I found which were
using those methods in their upper-cased incarnations. And as long as we're
trying to make the editor IDL right, it turns out that nsITableEditor,
nsIEditorMailSupport and nsIEditorStyleSheets were never IDL-ified; two of them
were put in the idl directory but they were only partially converted and were
not being built. We need all those interfaces if we're going to make people
stop using the editor shell. So I've converted those three, and made the
necessary changes to editor files. Unfortunately, that results in a huge
patch, primarily because most of the table editor methods were nonscriptable
(passing references) and had to be changed to pass pointers. While I was in
there I fixed some warnings, cleaned up or improved some of the javadoc
comments (we still have quite a few methods that aren't documented, though),
and a lot of formatting problems (lines too long, random spacing).
Charley: need review.
Simon: need super-review.
Attachment #72487 -
Attachment is obsolete: true
Assignee | ||
Comment 11•23 years ago
|
||
I didn't mean to include EdReplace.js and EdReplace.xul in that patch; they are
part of bug 80805, dependant on this bug and are also awaiting review and sr.
Assignee | ||
Comment 12•23 years ago
|
||
Kathy, I'd appreciate it if you could also look this over and see if I missed
anything or if there's something you think should be done differently.
Comment 13•23 years ago
|
||
Comment on attachment 72878 [details] [diff] [review]
big patch: fix all the problems in our idl files
extra space after 'attribute' on this line:
+ readonly attribute nsIDOMElement rootElement;
I'd remove this line altogether (we can always add it later if we want to
implement that):
+ //readonly attribute nsIPresShell presShell;
in the following block, you *could* (but not really necessary) rearrange code:
-nsHTMLEditor::GetCellIndexes(nsIDOMElement *aCell, PRInt32 &aRowIndex, PRInt32
&aColIndex)
+nsHTMLEditor::GetCellIndexes(nsIDOMElement *aCell,
+ PRInt32 *aRowIndex, PRInt32 *aColIndex)
{
+ NS_ENSURE_ARG_POINTER(aRowIndex);
+ NS_ENSURE_ARG_POINTER(aColIndex);
nsresult res=NS_ERROR_NOT_INITIALIZED;
- aColIndex=0; // initialize out params
- aRowIndex=0;
+ *aColIndex=0; // initialize out params
+ *aRowIndex=0;
NS_ENSURE_ARG_POINTER(aRowIndex);
*aRowIndex = 0;
NS_ENSURE_ARG_POINTER(aColIndex);
*aColIndex = 0;
This line could be moved up with the other NS_ENSURE_ARG_POINTER lines in
GetCellDataAt:
if (!aCell) return NS_ERROR_NULL_POINTER;
publish.js should be cvs removed; no one should be using it
looks great!
I'll let Charley check the checkbox but you have my r=brade :-)
Assignee | ||
Comment 14•23 years ago
|
||
Charley pointed out that I missed changing composer's use of flags (now an
editor attribute rather than methods). Here's a new patch just for
MsgComposeCommands.js. It overrides MsgComposeCommands.js in the big patch.
Reporter | ||
Comment 15•23 years ago
|
||
Comment on attachment 72878 [details] [diff] [review]
big patch: fix all the problems in our idl files
Wow!
Ignoring Replace dialog stuff and msgComposer,
r=cmanske
Attachment #72878 -
Flags: review+
Reporter | ||
Comment 16•23 years ago
|
||
Comment on attachment 73014 [details] [diff] [review]
new MsgComposeCommands.js diff
needs work.
Comment 17•23 years ago
|
||
do we need to make any changes to Netscape's commercial tree? If so, what is
the corresponding bugscape bug #?
Assignee | ||
Comment 18•23 years ago
|
||
Cc ducarroz for the MsgComposeCommands.js change. J-F, can you review this
small change?
Kathy, good point! It turns out there are a couple of lines in that have to
change in the commercial build: bugscape bug 12419 now tracks that.
Assignee | ||
Comment 19•23 years ago
|
||
Cleaner way of handling the flags in MsgComposeCommands.js, suggested by
Charley.
Attachment #73014 -
Attachment is obsolete: true
Comment 20•23 years ago
|
||
Comment on attachment 73019 [details] [diff] [review]
Improved MsgComposeCommands.js
R=ducarroz
Attachment #73019 -
Flags: review+
Comment 21•23 years ago
|
||
Index: editor/idl/nsIHTMLEditor.idl
+ void Align(in AString aAlign);
You missed a lowercasing.
- void SetCSSEnabled(in boolean aIsCSSPrefChecked);
+ void setCSSEnabled(in boolean aIsCSSPrefChecked);
- /** IsCSSEnabled answers a boolean which is true is the HTMLEditor has been
+ /** isCSSEnabled answers a boolean which is true is the HTMLEditor has been
* instantiated with CSS knowledge and if the CSS pref is currently checked
*
- * @param aIsCSSEnabled [OUT] true if CSS handled and enabled
+ * @return true if CSS handled and enabled
*/
- void IsCSSEnabled(out boolean aIsCSSEnabled);
+ boolean isCSSEnabled();
Change to a read/write attribute?
- nsIDOMCSSStyleRule ParseStyleAttrIntoCSSRule(in wstring aString);
+ nsIDOMCSSStyleRule parseStyleAttrIntoCSSRule(in wstring aString);
wstring -> AString?
+ * Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
+ * (passes NS_SUCCEEDED macro)
* You can scan for all cells in a row or column
* by iterating through the appropriate indexes
* until the returned aCell is null
*/
- void GetCellAt(in nsIDOMElement aTable, in long aRowIndex, in long
aColIndex, out nsIDOMElement aCell);
+ nsIDOMElement getCellAt(in nsIDOMElement aTable,
+ in long aRowIndex, in long aColIndex);
This return error will be inaccessible from JS. Do we need to fix that? Same for
other methods that do this.
+ void getFirstRow(in nsIDOMElement aTableElement, out nsIDOMNode aRow);
+ void getNextRow(in nsIDOMNode aTableElement, out nsIDOMNode aRow);
Return the row?
+ void GetFirstSelectedCell(out nsIDOMElement aCell, out nsIDOMRange aRange);
lowercase.
Index: editor/ui/dialogs/content/EdReplace.js
Some changes in here that look unrelated.
Fix those, and sr=sfraser
Assignee | ||
Comment 22•23 years ago
|
||
Assignee | ||
Updated•23 years ago
|
Attachment #72878 -
Attachment is obsolete: true
Comment 23•23 years ago
|
||
Comment on attachment 73751 [details] [diff] [review]
Big patch incorporating Simon's suggestions
sr=sfraser
Attachment #73751 -
Flags: superreview+
Reporter | ||
Comment 24•23 years ago
|
||
Comment on attachment 73751 [details] [diff] [review]
Big patch incorporating Simon's suggestions
r=cmanske
Attachment #73751 -
Flags: review+
The final "big patch" doesn't seem to incorporate the second to last
patch. Is that needed as well? Doesn't it need super-review?
How extensively has this been tested? Did you search the whole tree in
some way (LXR?) looking for the case changes that you needed to make?
It seems there's a lot of potential for JS errors resulting from missed
case changes in JS for this type of change.
(I also noticed a bunch of style nits I'd pick if I were reviewing the
patch. I've been trying to restrain myself from reviewing as part of
the approval process, so feel free to ignore these or fix them sometime
in the future, but:
* There are bunch of what I consider to be bogus NS_ENSURE_ARG_POINTER
statements -- I think callers deserve to crash if they pass null for
something declared in IDL as |out| or as a return value, although I
don't object to assertions.
* I *think* the [const] on |in nsAString| is extraneous -- the |in|
should get you the C++ |const|.
* In nsIEditorStyleSheets.idl:
* I think you should be using |[ptr] native| and a forward declaration
in a C++ block for nsICSSStyleSheet, since nsICSSStyleSheet isn't in
IDL (although it might be that it should be based on whether it's
XPCOM).
* There are a bunch of final |out nsICSSStyleSheet| that should be
return types.
And, FWIW (in response to comment 21), there is a way of accessing
success return values from JS, although I forget what it is.)
Comment 26•23 years ago
|
||
Comment on attachment 73019 [details] [diff] [review]
Improved MsgComposeCommands.js
sr=sfraser
Attachment #73019 -
Flags: superreview+
Assignee | ||
Comment 27•23 years ago
|
||
Simon has now explicitly sr'ed the mail and IM files.
Re NS_ENSURE_ARG_POINTER: I've gotten burned before when a reviewer told me "It
should never happen that this is called with a null argument," and then for the
next year I got blamed every time there was a crash in that code. Please allow
maintainers the option of checking arguments so their components can be robust
no matter what callers do.
Re searching: I searched using both lxr and recursive grep for patterns like
"hell.ed (i.e. catching editorShell.editor but with flexibility in
capitalization). Previously the only way to get the nsIEditor interface from JS
was via the "editor" member of the editor shell. I also searched for
"editor.getflags" to see if that would turn up anything additional, but it didn't.
New patch addressing the other concerns coming.
Assignee | ||
Comment 28•23 years ago
|
||
1. Removes all the [const]s from in AString declarations.
2. Makes a C++ block as requested for nsICSSStyleSheet.
3. Makes those out nsICSSStyleSheet arguments into return parameters.
This small patch only includes files changed vs. the previous patch:
nsIEditorStyleSheets.idl, nsIEditorMailSupport.idl, nsIEditor.idl.
Comment on attachment 74158 [details] [diff] [review]
Three files changed re dbaron's comments
I pinged sfraser on IRC and he seemed happy with these changes, so a=dbaron.
Attachment #74158 -
Flags: approval+
Assignee | ||
Comment 30•23 years ago
|
||
Fix is in!
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Akkana : you removed GetHighlightColor() but did not change the calls in
editor.js
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 33•23 years ago
|
||
Comment on attachment 74332 [details] [diff] [review]
new patch for getHighlightColorState()
r=brade
Attachment #74332 -
Flags: review+
Comment 34•23 years ago
|
||
Comment on attachment 74332 [details] [diff] [review]
new patch for getHighlightColorState()
sr=kin@netscape.com
Attachment #74332 -
Flags: superreview+
Comment on attachment 74332 [details] [diff] [review]
new patch for getHighlightColorState()
If getHighlightColor doesn't exist anymore, why does the second of the two
changes in this patch still use it?
baahh, glazou gets a knock-knock on his head because he did not attach the right
file...
Attachment #74332 -
Attachment is obsolete: true
Comment 38•23 years ago
|
||
Comment on attachment 74347 [details] [diff] [review]
new patch for getHighlightColorState() v2.0
r=brade
Attachment #74347 -
Flags: review+
Comment 39•23 years ago
|
||
Comment on attachment 74347 [details] [diff] [review]
new patch for getHighlightColorState() v2.0
sr=kin@netscape.com
Attachment #74347 -
Flags: superreview+
Comment on attachment 74347 [details] [diff] [review]
new patch for getHighlightColorState() v2.0
a=dbaron for trunk checkin
Attachment #74347 -
Flags: approval+
Assignee | ||
Comment 41•23 years ago
|
||
The tree didn't open at a reasonable time for Daniel or Kathy, so I've checked
in the fix for them. Thanks all!
Status: REOPENED → RESOLVED
Closed: 23 years ago → 23 years ago
Resolution: --- → FIXED
Comment 42•23 years ago
|
||
Would someone mind explaining why some code in EdFieldSetProps.js was changed?
Assignee | ||
Comment 43•23 years ago
|
||
Neil: The editor API IDL files were cleaned up (that's what this bug was about)
to follow the JS convention that function names should begin with lower-case.
EdFieldSetProps.js had references to editor.DeleteNode and editor.InsertNode,
which needed to be lowercased.
Comment 44•23 years ago
|
||
Sorry, I confused this patch with another change.
Comment 45•23 years ago
|
||
Charley/Akkana, can one of you please verify this and mark verified-fixed..?
thanks.
Updated•20 years ago
|
Product: Browser → Seamonkey
You need to log in
before you can comment on or make changes to this bug.
Description
•