Difference between revisions of "Gecko:DeCOMtamination"

From MozillaWiki
Jump to: navigation, search
m (s/lxr/mxr)
Line 9: Line 9:
 
# Figure out what the cleaned-up function and method signatures will be, taking into account the hints in the [[Gecko:Interface Style Guide]].
 
# Figure out what the cleaned-up function and method signatures will be, taking into account the hints in the [[Gecko:Interface Style Guide]].
 
# Find an [https://bugzilla.mozilla.org/buglist.cgi?query_format=&short_desc_type=allwordssubstr&short_desc=decomtam&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0= existing bug] for the deCOMtamination task, or create a new bug for it, CCing roc@ocallahan.org, and attach a patch file showing what the new signatures will look like. Get feedback to make sure you're on the right track.
 
# Find an [https://bugzilla.mozilla.org/buglist.cgi?query_format=&short_desc_type=allwordssubstr&short_desc=decomtam&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0= existing bug] for the deCOMtamination task, or create a new bug for it, CCing roc@ocallahan.org, and attach a patch file showing what the new signatures will look like. Get feedback to make sure you're on the right track.
# Finish the task by updating all callers and implementations of the functions and methods to be consistent with the new signatures. Always use  http://lxr.mozilla.org/mozilla to search for users of the method. There may be code that uses the method that's not built by your build configuration.
+
# Finish the task by updating all callers and implementations of the functions and methods to be consistent with the new signatures. Always use  http://mxr.mozilla.org/mozilla to search for users of the method. There may be code that uses the method that's not built by your build configuration.
 
# Make sure you can build and run Mozilla with your changes. Test it thoroughly.
 
# Make sure you can build and run Mozilla with your changes. Test it thoroughly.
 
# Make a patch with CVS diff -utp8, and submit it as an attachment in the bug. Request review, e.g. from roc.
 
# Make a patch with CVS diff -utp8, and submit it as an attachment in the bug. Request review, e.g. from roc.

Revision as of 20:52, 29 May 2008

For more information about Gecko:DeCOMtamination contact roc@ocallahan.org.

The basic idea is to refactor interfaces to remove unnecessary "XPCOM style" ugliness and other interface design errors. Check the Gecko:Interface Style Guide for information about how to design these clean interfaces.

If you want to get started, follow these steps. If you get stuck, don't give up, mail roc for help!

  1. Make sure you have successfully built a Mozilla product from source (preferably Mozilla Suite or Firefox). Official instructions can be found on MDC. You will want to change your configure options to include "ac_add_options --enable-debug" and "ac_add_options --disable-optimize".
  2. Choose one of the deCOMtamination problems below, or email roc for suggestions.
  3. Note in this wiki page that you are working on the task.
  4. Figure out what the cleaned-up function and method signatures will be, taking into account the hints in the Gecko:Interface Style Guide.
  5. Find an existing bug for the deCOMtamination task, or create a new bug for it, CCing roc@ocallahan.org, and attach a patch file showing what the new signatures will look like. Get feedback to make sure you're on the right track.
  6. Finish the task by updating all callers and implementations of the functions and methods to be consistent with the new signatures. Always use http://mxr.mozilla.org/mozilla to search for users of the method. There may be code that uses the method that's not built by your build configuration.
  7. Make sure you can build and run Mozilla with your changes. Test it thoroughly.
  8. Make a patch with CVS diff -utp8, and submit it as an attachment in the bug. Request review, e.g. from roc.

Here are some places known to need deCOMtamination or general interface cleanup:

  • Box methods in nsIFrame: bug 243370 See the section under "// BOX LAYOUT METHODS" in nsIFrame.h. GetBorderAndPadding, GetBorder, GetPadding, GetMargin, GetLayoutManager and GetClientRect probably can all return their results directly instead of via an out parameter. GetClientRect should be renamed to GetContentRect and return the rect directly. Some methods may only have one implementation in which case we can make them non-virtual or even inline.
  • Not really deCOMtamination, but anyway: many frames have an mPresContext field. This should be removed, and uses of that field can just call GetPresContext on the frame. (Some work on this in bug 301313)
  • Lots of the non-Box methods of nsIFrame could be cleaned up too. We can remove the nsPresContext parameter from almost all of them. Many of them return their result in an 'out' parameter and should just return the result directly. Understanding the best way to do this for various methods will require some more creativity and understanding of the existing code.
  • in many cases we have a singleton interface like nsIComboboxControlFrame that is only implemented by one class, is not defined in IDL (and is therefore not scriptable), and is not visible outside Gecko. In these cases we can save code and data size by eliminating the interface, moving its methods to the concrete class and devirtualizing them, and casting to the class directly, like we just did with nsGfxButtonControlFrame. We can even assign the class an IID so you can get to it with QueryInterface. For example you can QI to nsBlockFrame this way.(bug 326944)
  • Not really deCOMtamination, but we have new methods nsIContent::AttrValueIs and nsIContent::FindAttrValueIn that can be used in many many places where nsIContent::GetAttr is currently used. The new methods reduce code size and are faster. We need to convert GetAttr calls to use the new methods.(bug 333896)
  • Access to nsISupports* objects could be improved by using direct access to the nsSupports*Impl implementation classes from C++ (bug 399237).