layout/doc/obsolete/layout.xml

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5
michael@0 6 <?xml-stylesheet href="layout.css" type="text/css"?>
michael@0 7 <!DOCTYPE Documentation>
michael@0 8
michael@0 9 <Documentation xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 10 xmlns:xlink="http://www.w3.org/1999/xlink">
michael@0 11
michael@0 12 <Title>Gecko Layout Engine</Title>
michael@0 13 <Author xlink:type="simple" xlink:show="new" xlink:href="mailto:troy@netscape.com">Troy Chevalier</Author>
michael@0 14 <UpdateDate>8 August 1999</UpdateDate>
michael@0 15
michael@0 16 <SectionHeading>Overview</SectionHeading>
michael@0 17 <Body>Gecko is Mozilla's new layout engine. It is based on the HTML4, CSS1, XML 1.0,
michael@0 18 and DOM Internet standards, and it is built using a modular XPCOM-based
michael@0 19 architecture.</Body>
michael@0 20
michael@0 21 <Body>When we talk about layout, we're referring to the formatting process that applies
michael@0 22 presentation styles to a source document. The formatting process is controlled
michael@0 23 by the style specification.</Body>
michael@0 24
michael@0 25 <SectionHeading>Components</SectionHeading>
michael@0 26 <Body>Here are a list of components and terms that will be referenced by this document.</Body>
michael@0 27
michael@0 28 <Components>
michael@0 29 <Term>Parser</Term>
michael@0 30 <Definition>Either the <A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/parser.html">HTML</A>
michael@0 31 or XML parser. Processes the document and makes calls to the content sink.</Definition>
michael@0 32
michael@0 33 <Term>Content sink</Term>
michael@0 34 <Definition>Called by the parser. Responsible for building the content model.</Definition>
michael@0 35
michael@0 36 <Term><A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/contentmodel.html">Content model</A></Term>
michael@0 37 <Definition>Consists of document object and a tree of content objects. Changes to the
michael@0 38 content model result in modifications of the frame model.</Definition>
michael@0 39
michael@0 40 <Term>Frame model</Term>
michael@0 41 <Definition><A xlink:type="simple" xlink:show="replace" xlink:href="#Frames">Frames</A> are formatting
michael@0 42 objects. Each frame defines a particular set of formatting characteristics.</Definition>
michael@0 43
michael@0 44 <Term><A xlink:type="simple" xlink:show="replace" xlink:href="#Reflow">Reflow</A></Term>
michael@0 45 <Definition>The formatting process. Reflow of the frame model defines the visual appearance
michael@0 46 of the formatted document.</Definition>
michael@0 47
michael@0 48 <Term><A xlink:type="simple" xlink:show="replace" xlink:href="#FrameConstruction">Frame construction</A></Term>
michael@0 49 <Definition>Initial creation and updating of the frame model in response to changes to the
michael@0 50 content model and changes to the style data.</Definition>
michael@0 51
michael@0 52 <Term><A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/style.html">Style system</A></Term>
michael@0 53 <Definition>Provide the mapping and management of style data onto document content in a given
michael@0 54 presentation. Major components are style set, style sheets, style sheet and
michael@0 55 rules, style context, and style sheet loader.</Definition>
michael@0 56
michael@0 57 <Term>Presentation shell</Term>
michael@0 58 <Definition>Controlling point for managing the presentation of a document.</Definition>
michael@0 59
michael@0 60 <Term><A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/viewsystem.html">View system</A></Term>
michael@0 61 <Definition>Consists of a view manager and view objects arranged in a tree hierarchy.
michael@0 62 Views support overlapped positioning, z-order sorting, and opacity levels.</Definition>
michael@0 63 </Components>
michael@0 64
michael@0 65 <SectionHeading>Document Loading</SectionHeading>
michael@0 66 <Body>The basic flow of control is as follows: as the parser encounters tokens it notifies
michael@0 67 the content sink that a new node (or child node) is encountered. The content sink
michael@0 68 creates the appropriate type content object and inserts it into the content model.</Body>
michael@0 69
michael@0 70 <Body>Whenever the content model changes the document's observers are notified. The presentation
michael@0 71 shell is one of the document observers. The presentation shell forwards the document
michael@0 72 change notification to the style set object</Body>
michael@0 73
michael@0 74 <Body>The style set passes the notification to the frame construction code, the
michael@0 75 frame construction code creates new frames and inserts them into the frame model. The
michael@0 76 document is reflowed, and the formatted changes are displayed.
michael@0 77 </Body>
michael@0 78
michael@0 79 <Body>
michael@0 80 The actual interfaces involved are:
michael@0 81 <Interfaces>
michael@0 82 <Interface>nsIDocument</Interface>
michael@0 83 <Interface>nsIDocumentObserver</Interface>
michael@0 84 <Interface>nsIPresShell</Interface>
michael@0 85 <Interface>nsIStyleSet</Interface>
michael@0 86 <Interface>nsIStyleFrameConstruction</Interface>
michael@0 87 <Interface>nsIFrame</Interface>
michael@0 88 </Interfaces>
michael@0 89 </Body>
michael@0 90
michael@0 91 <Body>All of the interface files are located in the mozilla/layout/base/public
michael@0 92 directory.</Body>
michael@0 93
michael@0 94 <SectionHeading>Object Lifetimes</SectionHeading>
michael@0 95 <Body>Gecko supports multiple views of the same document. This means you can print the
michael@0 96 same document that you're viewing on the screen, and there's only one content
michael@0 97 model. Because there's just a single content model, each of the content objects
michael@0 98 is referenced counted. The document holds a reference to the root content object,
michael@0 99 and each content node holds a reference to its child content nodes.</Body>
michael@0 100
michael@0 101 <Body>Each view of the document has a separate presentation shell, style manager,
michael@0 102 style set, and frame hierarchy. The presentation shell is the controlling point for
michael@0 103 the presentation of a document, and it holds a reference to the document object.</Body>
michael@0 104
michael@0 105 <Body>Frames and views are not referenced counted. The lifetime of the frame hierarchy
michael@0 106 is bounded by the lifetime of the presentation shell which owns the frames. The
michael@0 107 lifetime of the view hierarchy is bounded by the lifetime of the view manager
michael@0 108 that owns the views.</Body>
michael@0 109
michael@0 110 <SectionHeading><html:a name="Frames">Frames</html:a></SectionHeading>
michael@0 111 <Body>Each frame defines a particular set of formatting characteristics. Frames have
michael@0 112 the opportunity to:
michael@0 113 <Characteristics>
michael@0 114 <Characteristic>reflow (format) their child frames</Characteristic>
michael@0 115 <Characteristic>render their appearance</Characteristic>
michael@0 116 <Characteristic>handle mouse and keyboard events</Characteristic>
michael@0 117 <Characteristic>display a cursor</Characteristic>
michael@0 118 <Characteristic>have an associated view object</Characteristic>
michael@0 119 </Characteristics>
michael@0 120 </Body>
michael@0 121
michael@0 122 <Body>Frames can have multiple child lists, the default unnamed child list
michael@0 123 (referred to as the principal child list) and additional named child lists.
michael@0 124 There is an ordering of frames within a child list, but no ordering
michael@0 125 between frames in different child lists of the same parent frame.</Body>
michael@0 126
michael@0 127 <Body>The principal child list contains the flowed children, and the additional
michael@0 128 child lists are for out-of-flow frames like floated elements and absolutely
michael@0 129 positioned elements.</Body>
michael@0 130
michael@0 131 <Body>Child frames are linked together in a singly linked list. Each frame
michael@0 132 defines its own local coordinate space. Frame bounding rects are in twips,
michael@0 133 and the origin is relative to the upper-left corner of its parent frame.
michael@0 134 The bounding rect includes the content area, borders, and padding.</Body>
michael@0 135
michael@0 136 <SectionHeading><html:a name="FrameConstruction">Frame Construction</html:a></SectionHeading>
michael@0 137 <Body>The frame construction process begins with a notification that content
michael@0 138 has been added or removed or that style has changed.</Body>
michael@0 139
michael@0 140 <Body>The first step is to resolve style information for the content element.
michael@0 141 This process creates a style context that is stored in the frame (see
michael@0 142 nsIStyleContext).</Body>
michael@0 143
michael@0 144 <Body>Once style is resolved construction rules are used to decide the type of
michael@0 145 frame to create. First we look at the element's tag and special case some
michael@0 146 things like IMG elements. If we don't create a frame that way, then we use
michael@0 147 the 'display' property to dictate what type of frame to create. Typically
michael@0 148 it's a block or inline frame.</Body>
michael@0 149
michael@0 150 <Body>For a 'display' value of 'none' no frame is created. For elements that are
michael@0 151 out of the flow (for example, a floated element or an absolutely positioned
michael@0 152 element), a placeholder frame is also created. The placeholder frame is inserted
michael@0 153 into the flow exactly where the out-of-flow frame would have been inserted.
michael@0 154 The out-of-flow frame is then inserted as a child of its containing block in
michael@0 155 one of the additional child lists. Floated frames are inserted into the
michael@0 156 "Float-list" and absolutely positioned frames are inserted into the
michael@0 157 "Absolute-list".</Body>
michael@0 158
michael@0 159 <SectionHeading>Frame Manager</SectionHeading>
michael@0 160 <Body>The frame manager is owned by the presentation shell and used by both the
michael@0 161 presentation shell and the frame construction code. It serves two main
michael@0 162 purposes:
michael@0 163 <Purposes>
michael@0 164 <Purpose>provides a service for mapping from content object to frame and from out-of-flow
michael@0 165 frame to placeholder frame</Purpose>
michael@0 166 <Purpose>coordinates structural modifications to the frame model</Purpose>
michael@0 167 </Purposes>
michael@0 168 </Body>
michael@0 169
michael@0 170 <Body>In many places in the frame code we need to find the frame associated with
michael@0 171 a particular content object. In order to quickly implement this operation we
michael@0 172 maintain a mapping from content objects to frames. The frame construction adds
michael@0 173 and removes entries from the map as frames are created and destroyed.</Body>
michael@0 174
michael@0 175 <Body>When creating new frames and removing existing frames, the frame construction
michael@0 176 code doesn't directly modify the frame hierarchy. Instead if informs the frame
michael@0 177 manager and has it coordinate the request. If the frame model lock is available,
michael@0 178 the change is processed immediately; otherwise, the request is queued and
michael@0 179 processed later.</Body>
michael@0 180
michael@0 181 <Body>The frame manager also coordinates processing of replaced elements that can't
michael@0 182 be rendered (for example, an IMG or OBJECT element), and it allows client to
michael@0 183 register to be notified when a particular frame is being destroyed. This is
michael@0 184 needed because frames are not reference counted. It's used by the event manager
michael@0 185 and other clients to ensure that any outstanding references to the frame are
michael@0 186 cleaned up.</Body>
michael@0 187
michael@0 188 <SectionHeading><html:a name="Reflow">Reflow</html:a> Process</SectionHeading>
michael@0 189 <Note>The fact that are two reflow interfaces reflects an early
michael@0 190 goal of having core layout and HTML specific layout. The core reflow process would
michael@0 191 be the same for all frames, and each class of formatting objects (for
michael@0 192 example, CSS and DSSSL) would have their own reflow additions.</Note>
michael@0 193
michael@0 194 <Body>The reflow process is a top-down protocol where a frame is given some
michael@0 195 available space and asked to reflow its child frames and return a desired
michael@0 196 size.</Body>
michael@0 197
michael@0 198 <Body>The reflow process is not part of the nsIFrame interface. The generic reflow
michael@0 199 interface is defined in the nsIFrameReflow interface, and the HTML/CSS specific
michael@0 200 reflow interface is defined in the nsIHTMLReflow interface.</Body>
michael@0 201
michael@0 202 <Body>An important part of the reflow process is the calculation of the computed
michael@0 203 values for the CSS properties. This includes things like 'width', 'height',
michael@0 204 and 'margin', and involves calculation of the containing block width and height
michael@0 205 and percentage based values and properties whose value is inherited.</Body>
michael@0 206
michael@0 207 <Body>This process is encapsulated in the HTML specific reflow state struct
michael@0 208 (struct nsHTMLReflowState) that is passed in as part of reflow. The reflow
michael@0 209 states are linked together with the reflow state for a child frame pointing
michael@0 210 to its parent frame's reflow state. This allows us to walk up the reflow state
michael@0 211 structures and calculate containing block width and height and percentage
michael@0 212 based values.</Body>
michael@0 213
michael@0 214 <Body>In addition to the computed values for the CSS box model properties, the
michael@0 215 following items are also included:
michael@0 216 <Items>
michael@0 217 <Item>reflow reason that indicates why the frame is being reflowed</Item>
michael@0 218 <Item>a rendering context that can be used to measure text</Item>
michael@0 219 <Item>reflow command (only used for incremental reflow)</Item>
michael@0 220 <Item>space manager</Item>
michael@0 221 </Items>
michael@0 222 </Body>
michael@0 223
michael@0 224 <Body>The most common reflow reasons are 'eReflowReason_Resize' (the viewport
michael@0 225 has changed size) and 'eReflowReason_Incremental' (processing of an incremental
michael@0 226 reflow command).</Body>
michael@0 227
michael@0 228 <Body>Reflow commands (see nsHTMLReflowCommand in mozilla/layout/html/base/src) are used
michael@0 229 to kick off an incremental reflow. They're generated either by the style system
michael@0 230 (in response to a style change) or by a frame itself (for example, if a frame has
michael@0 231 dirty child frames that need to be reflowed it will generate a reflow command).</Body>
michael@0 232
michael@0 233 <Body>Reflow commands are queued by the presentation shell and then dispatched. Reflow
michael@0 234 commands have a target frame, which is the frame for which the reflow command
michael@0 235 is destined. In the example above the target frame is the frame with dirty child
michael@0 236 frames that need to be reflowed. Reflow command processing follows a path from
michael@0 237 the root frame down to the target frame.</Body>
michael@0 238
michael@0 239 <Body>The space manager (see nsISpaceManager in mozilla/layout/base/public) is used
michael@0 240 when flowing text around floated elements. It has an API for managing bands of
michael@0 241 unavailable space (space that is reserved for a floated element). Internally it
michael@0 242 organizes the band data similar to how a region data structure works.</Body>
michael@0 243
michael@0 244 <SectionHeading>Frame Classes</SectionHeading>
michael@0 245 <Body>There are four main categories of frame classes, all of which are located
michael@0 246 in mozilla/layout/html/src:
michael@0 247
michael@0 248 <Categories>
michael@0 249 <Category>core frame classes</Category>
michael@0 250 <Category>table frame classes</Category>
michael@0 251 <Category>form frame classes</Category>
michael@0 252 <Category>frameset frame classes</Category>
michael@0 253 </Categories>
michael@0 254 </Body>
michael@0 255
michael@0 256 <Body><RunIn>The core frame classes</RunIn> implement the CSS viewport abstraction, scrolling,
michael@0 257 block and inline display of flowed elements, floats, and absolute positioning.</Body>
michael@0 258
michael@0 259 <Body>For more information on block layout, click
michael@0 260 <A xlink:type="simple" xlink:show="replace" xlink:href="block.html">here</A>. For more information about
michael@0 261 line layout, click <A xlink:type="simple" xlink:show="replace" xlink:href="line-layout.html">here</A>.</Body>
michael@0 262
michael@0 263 <Body><RunIn>The table frame classes</RunIn> correspond to the HTML4 table spec, and in addition
michael@0 264 to the table frame there are row group frames, row frames, column group frames,
michael@0 265 column frames, and cell frames. There is an "outer" table frame as well that's
michael@0 266 really an anonymous frame that contains the caption frame and the table frame
michael@0 267 itself.</Body>
michael@0 268
michael@0 269 <Body>Table layout is determined in a 3-step process. In the first step, the table
michael@0 270 is flowed into an infinitely wide and tall space. This gives us the minimum and
michael@0 271 desired sizes for every cell in the table. In the second step, the table constraints
michael@0 272 are factored in and widths are assigned to every cell. In the third step, heights are
michael@0 273 assigned to every cell based on the computed width constraint. The results of the first
michael@0 274 step are cached and only need to be recomputed when content or constraints are changed.</Body>
michael@0 275
michael@0 276 <SectionHeading>Event Manager</SectionHeading>
michael@0 277 <Body>To be written</Body>
michael@0 278
michael@0 279 </Documentation>

mercurial