@@ -26,6 +26,67 @@ namespace mozilla {
2626class PresShell ;
2727} // namespace mozilla
2828
29+ /* *
30+ * nsView's serve two main purposes: 1) a bridge between nsIFrame's and
31+ * nsIWidget's, 2) linking the frame tree of a(n) (in-process) subdocument with
32+ * its parent document frame tree. Historically views were used for more things,
33+ * but their role has been reduced, and could be reduced to nothing in the
34+ * future (bug 337801 tracks removing views). Views are generally associated
35+ * with a frame. A view that does not have a frame is called an anonymous view.
36+ * Some frames also have associated widgets (think os level windows). If a frame
37+ * has a widget it must also have a view, but not all frames with views will
38+ * have widgets.
39+ *
40+ * Only five types of frames can have a view: root frames (ViewportFrame),
41+ * subdocument frames (nsSubDocumentFrame), plugin frames (nsPluginFrame),
42+ * menu popup frames (nsMenuPopupFrame), and list control frames
43+ * (nsListControlFrame). Root frames and subdocument frames have views to link
44+ * the two documents together (the frame trees do not link up otherwise).
45+ * Plugin frames, menu popup frames, and list control frames have views because
46+ * they (sometimes) need to create widgets (although plugins with widgets might
47+ * be going away/gone?). Menu popup frames handles xul popups, which is anything
48+ * where we need content to go over top the main window at an os level. List
49+ * control frames handle select popups/dropdowns in non-e10s mode.
50+ *
51+ * The term "root view" refers to the root view of a document. Just like root
52+ * frames, root views can have parent views. Only the root view of the root
53+ * document in the process will not have a parent.
54+ *
55+ * All views are created by their frames except root views. Root views are
56+ * special. Root views are created in nsDocumentViewer::MakeWindow before the
57+ * root frame is created, so the root view will not have a frame very early in
58+ * document creation.
59+ *
60+ * Subdocument frames and plugin frames have an anonymous (no frame associated
61+ * with it) inner view that is a child of their "outer" view. On a plugin frame
62+ * with a widget the inner view would be associated with the widget (as opposed
63+ * to the outer view).
64+ *
65+ * On a subdocument frame the inner view serves as the parent of the
66+ * root view of the subdocument. The outer and inner view of the subdocument
67+ * frame belong to the subdocument frame and hence to the parent document. The
68+ * root view of the subdocument belongs to the subdocument.
69+ * nsLayoutUtils::GetCrossDocParentFrame and nsPresContext::GetParentPresContext
70+ * depend on this view structure and are the main way that we traverse across
71+ * the document boundary in layout.
72+ *
73+ * When the load of a new document is started in the subdocument, the creation
74+ * of the new subdocument and destruction of the old subdocument are not
75+ * linked. (This creation and destruction is handled in nsDocumentViewer.cpp.)
76+ * This means that the old and new document will both exist at the same time
77+ * during the loading of the new document. During this period the inner view of
78+ * the subdocument parent will be the parent of two root views. This means that
79+ * during this period there is a choice for which subdocument we draw,
80+ * nsSubDocumentFrame::GetSubdocumentPresShellForPainting is what makes that
81+ * choice. Note that this might not be a totally free choice, ie there might be
82+ * hidden dependencies and bugs if the way we choose is changed.
83+ *
84+ * One thing that is special about the root view of a chrome window is that
85+ * instead of creating a widget for the view, they can "attach" to the
86+ * existing widget that was created by appshell code or something else. (see
87+ * nsDocumentViewer::ShouldAttachToTopLevel)
88+ */
89+
2990// Enumerated type to indicate the visibility of a layer.
3091// hide - the layer is not shown.
3192// show - the layer is shown irrespective of the visibility of
0 commit comments