I think it's high time we reorganized files within layout.  I think the
current directory structure is so convoluted that it may well scare off
contributors -- people who are interested in fixing one thing, and may
later come back to help more -- because they can't find what they want.

I think the most important goals of the new directory structure are:
 * related files should be nearby, for easy editing
 * it should be relatively easy for somebody new, who wants to know how
   we do X, to find the code that does X.
I think both of these point toward a shallower tree structure than the
one we currently have.

What follows is a proposal that I just wrote, without looking at (or
even finding, but it's in a bug somewhere) a proposal that I wrote a
year or so ago.

I propose to reorganize all of the files in the following directories:
    content/html/style/
    content/shared/
    layout/base/
    layout/html/   (except layout/html/tests/, to save CVS)
    layout/xul/
plus the following files within content/base/:
    content/base/public/nsIStyleRule.h
    content/base/public/nsIStyleSheet.h
    content/base/public/nsIStyleRuleProcessor.h
    content/base/public/nsIPrintProgress.idl
    content/base/public/nsIPrintProgressParams.idl
    content/base/public/nsIPrintStatusFeedback.idl
    content/base/src/nsDocumentViewer.cpp
    content/base/src/nsPrintData.cpp
    content/base/src/nsPrintData.h
    content/base/src/nsPrintEngine.cpp
    content/base/src/nsPrintEngine.h
    content/base/src/nsPrintObject.cpp
    content/base/src/nsPrintObject.h
    content/base/src/nsPrintPreviewListener.cpp
    content/base/src/nsPrintPreviewListener.h
    content/base/src/nsSelection.cpp
    content/base/src/nsPagePrintTimer.cpp
    content/base/src/nsPagePrintTimer.h
    content/base/src/nsStyleSet.cpp
    content/base/src/nsRuleNode.cpp
    content/base/src/nsStyleContext.cpp

I propose that we eliminate the "public" and "src" distinction.  It's
been inconsistently used:  we sometimes put all EXPORTS in public,
sometimes only those that are intended to be used by other modules, and
sometimes even put exports for other modules in src directories.  It
also tends to make things more difficult to read and edit.

The overall structure would yield the following subdirectories of layout
(in addition to the ones excluded above):

    layout/base/  [ Central objects and things that don't go anywhere else. ]
    layout/style/sheets/ [ Style sheet objects and supporting code ]
    layout/style/data/   [ Style data computation ]
    layout/corenodes/    [ roughly what's now in layout/html/base/src/  -
                                looking for a better name (*) ]
    layout/forms/
    layout/tables/
    layout/printing/     [ or should this just be within base ? ]
    layout/xul/
    layout/xulgrid/
    layout/xultree/

(*) Why "nodes"?  I don't want to use "frames" because it's a confusing
    term to people looking for code that does something.  I don't want
    "boxes" because that has a specific meaning in XUL (nsIBox), although it
    would otherwise be the right term.  I originally had corenodes, forms,
    tables, and xul* all as subdirectories of layout/nodes/, but that
    hides the depth of the structure.  I'd rather have a flatter
    structure, since it's much easier to find things, and I can't think of
    a clear name that says "lots of stuff will be in this subdirectory"
    (like netwerk/protocols/).


Here's how I would move files around to get to the structure above (ignoring
jar.mn, Makefile.in, and .cvsignore files):

I propose the following mass-moves:
    layout/html/forms/{public,src}/ -> layout/forms/
    layout/html/table/{public,src}/ -> layout/tables/
    layout/xul/base/{public,src}/ -> layout/xul/
    layout/xul/base/src/grid/ -> layout/xulgrid/
    layout/xul/base/src/tree/{public,src}/ -> layout/xultree/

Furthermore, of the enumerated files within content/base/ above:
    the ones containing "Print" in the filename -> layout/printing/
    nsIStyle* -> layout/style/sheets/
    nsRuleNode.cpp and nsStyleContext.cpp -> layout/style/data/
    nsDocumentViewer.cpp, nsSelection.cpp, and nsStyleSet.cpp -> layout/base/

Further, I propose the following mass-moves (roughly):
    layout/html/style/src/ -> layout/base/
    layout/base/{public,src}/ -> layout/base/
    layout/html/base/src/ -> layout/corenodes/
with the following exceptions:
    layout/base/public/nsHTML* -> layout/corenodes/
    layout/base/public/ns*Frame.h -> layout/corenodes/
    layout/base/src/nsIntervalSet* -> layout/corenodes/
    layout/base/src/nsSpaceManager* -> layout/corenodes/
    layout/html/base/src/nsFrameManager.cpp -> layout/base/
    layout/html/base/src/nsPresShell.cpp -> layout/base/
    layout/html/style/src/nsIHTMLStyleSheet.h -> layout/style/sheets/

That leaves the files in the following directories to be handled
individually:
    content/html/style/
    content/shared/
Listing them only by their leaf name, I propose they end up in the
following locations:

    layout/style/sheets/nsICSSLoader.h
    layout/style/sheets/nsICSSLoaderObserver.h
    layout/style/sheets/nsICSSParser.h
    layout/style/sheets/nsICSSPseudoComparator.h
    layout/style/sheets/nsICSSStyleSheet.h
    layout/style/data/nsIComputedDOMStyle.h                  ? (maybe sheets?)
    layout/style/sheets/nsIMediaList.h
    layout/style/sheets/css.properties
    layout/style/sheets/nsCSSDataBlock.cpp
    layout/style/sheets/nsCSSDataBlock.h
    layout/style/sheets/nsCSSDeclaration.cpp
    layout/style/sheets/nsCSSDeclaration.h
    layout/style/sheets/nsCSSLoader.cpp
    layout/style/sheets/nsCSSLoader.h
    layout/style/sheets/nsCSSOMFactory.cpp
    layout/style/sheets/nsCSSOMFactory.h
    layout/style/sheets/nsCSSParser.cpp
    layout/style/sheets/nsCSSRule.cpp
    layout/style/sheets/nsCSSRule.h
    layout/style/sheets/nsCSSRules.cpp
    layout/style/sheets/nsCSSScanner.cpp
    layout/style/sheets/nsCSSScanner.h
    layout/style/sheets/nsCSSStruct.cpp
    layout/style/sheets/nsCSSStruct.h
    layout/style/sheets/nsCSSStyleRule.cpp
    layout/style/sheets/nsCSSStyleSheet.cpp
    layout/style/sheets/nsCSSValue.cpp
    layout/style/sheets/nsCSSValue.h
    layout/style/data/nsComputedDOMStyle.cpp                ? (maybe sheets?)
    layout/style/data/nsComputedDOMStyle.h                  ? (maybe sheets?)
    layout/style/sheets/nsDOMCSSAttrDeclaration.cpp
    layout/style/sheets/nsDOMCSSAttrDeclaration.h
    layout/style/sheets/nsDOMCSSDeclaration.cpp
    layout/style/sheets/nsDOMCSSDeclaration.h
    layout/style/sheets/nsDOMCSSRGBColor.cpp
    layout/style/sheets/nsDOMCSSRGBColor.h
    layout/style/sheets/nsDOMCSSRect.cpp
    layout/style/sheets/nsDOMCSSRect.h
    layout/style/sheets/nsDOMCSSValueList.cpp
    layout/style/sheets/nsDOMCSSValueList.h
    layout/style/sheets/nsHTMLAttributes.cpp                ? (maybe content?)
    layout/style/sheets/nsHTMLAttributes.h                  ? (maybe content?)
    layout/style/sheets/nsHTMLValue.cpp                     ? (maybe content?)
    layout/style/sheets/nsHTMLValue.h                       ? (maybe content?)
    layout/style/sheets/nsHTMLCSSStyleSheet.cpp
    layout/style/sheets/nsHTMLStyleSheet.cpp
    layout/style/sheets/nsICSSGroupRule.h
    layout/style/sheets/nsICSSImportRule.h
    layout/style/sheets/nsICSSMediaRule.h
    layout/style/sheets/nsICSSNameSpaceRule.h
    layout/style/sheets/nsICSSOMFactory.h
    layout/style/sheets/nsICSSRule.h
    layout/style/sheets/nsICSSStyleRule.h
    layout/style/sheets/nsICSSStyleRuleDOMWrapper.h
    layout/style/sheets/nsICSSStyleRuleProcessor.h
    layout/style/sheets/nsIHTMLCSSStyleSheet.h
    layout/style/data/nsIInspectorCSSUtils.h
    layout/style/data/nsInspectorCSSUtils.cpp
    layout/style/data/nsInspectorCSSUtils.h
    layout/style/sheets/nsROCSSPrimitiveValue.cpp
    layout/style/sheets/nsROCSSPrimitiveValue.h
    layout/style/sheets/nsStyleUtil.h
    layout/style/sheets/nsStyleUtil.cpp
    layout/base/nsBidiUtils.cpp                       ?
    layout/base/nsBidiUtils.h                         ?

    layout/style/sheets/nsCSSKeywordList.h
    layout/style/sheets/nsCSSKeywords.cpp
    layout/style/sheets/nsCSSKeywords.h
    layout/style/sheets/nsCSSPropList.h
    layout/style/sheets/nsCSSProperty.h
    layout/style/sheets/nsCSSProps.cpp
    layout/style/sheets/nsCSSProps.h
    layout/base/nsChangeHint.h
    content/html/content/src/nsImageMapUtils.cpp                ?
    content/html/content/src/nsImageMapUtils.h                  ?
    layout/style/data/nsRuleNode.h
    layout/style/data/nsRuleWalker.h
    layout/style/data/nsStyleContext.h
    layout/style/data/nsStyleCoord.cpp
    layout/style/data/nsStyleCoord.h
    layout/style/data/nsStyleStruct.cpp
    layout/style/data/nsStyleStruct.h
    layout/style/data/nsStyleStructList.h
    content/base/src/nsTextFragment.cpp
    content/base/public/nsTextFragment.h

The following should probably all go in layout/base/, but that might make
it a bit crowded.  Any better ideas?

    nsAtomListUtils.cpp
    nsAtomListUtils.h
    nsHTMLAtomList.h
    nsHTMLAtoms.cpp
    nsHTMLAtoms.h
    nsLayoutAtomList.h
    nsLayoutAtoms.cpp
    nsLayoutAtoms.h
    nsSVGAtomList.h
    nsSVGAtoms.cpp
    nsSVGAtoms.h
    nsXBLAtomList.h
    nsXBLAtoms.cpp
    nsXBLAtoms.h
    nsXULAtomList.h
    nsXULAtoms.cpp
    nsXULAtoms.h
    nsCSSAnonBoxList.h
    nsCSSAnonBoxes.cpp
    nsCSSAnonBoxes.h
    nsCSSPseudoClassList.h
    nsCSSPseudoClasses.cpp
    nsCSSPseudoClasses.h
    nsCSSPseudoElementList.h
    nsCSSPseudoElements.cpp
    nsCSSPseudoElements.h

I realize a reorganization is painful, but I think we need to do it, and
now's as good a time as any (and better than many).

Thoughts?

-David

-- 
L. David Baron                                <URL: http://dbaron.org/ >

Reply via email to