Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 <!-- This Source Code Form is subject to the terms of the Mozilla Public
2 - License, v. 2.0. If a copy of the MPL was not distributed with this
3 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
5 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
6 <html>
7 <head>
8 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9 <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.5-22 i686) [Netscape]">
10 </head>
11 <body>
13 <h1>
14 <u>Line Layout</u></h1>
15 Line layout is the process of placing inline frames horizontally (left
16 to right or right to left depending on the CSS direction property value).
17 An attempt is made to describe how it works.
18 <p>nsLineLayout is the class that provides support for line layout. The
19 container frames nsBlockFrame and nsInlineFrame use nsLineLayout to perform
20 line layout and span layout. Span layout is a subset of line layout used
21 for inline container classes - for example, the HTML "B" element). Because
22 of spans, nsLineLayout handles the nested nature of line layout.
23 <p>Line layout as a process contains the following steps:
24 <ol>
25 <li>
26 Initialize the nsLineLayout object (done in nsBlockFrame). This prepares
27 the line layout engine for reflow by initializing its internal data structures.</li>
29 <br>
30 <li>
31 Reflowing of inline frames. The block code uses nsLineLayout's <b>ReflowFrame</b>
32 method to reflow each inline frame in a line. This continues until the
33 line runs out of room or the block runs out of frames. The block may be
34 reflowing a span (an instance of nsInlineFrame) which will recursively
35 use nsLineLayout for reflow and placement of the frames in the span.</li>
37 <p><br>Note that the container frames (nsBlockFrame/nsInlineFrame) call
38 nsLineLayout's ReflowFrame method instead of having the line layout code
39 process a list of children. This is done so that the container frames can
40 handle the issues of "pushing" and "pulling" of frames across continuations.
41 Because block and inline maintain different data structures for their child
42 lists, and because we don't want to mandate a common base class, the line
43 layout code doesn't control the "outer loop" of frame reflow.
44 <br>
45 <li>
46 Finish line layout by vertically aligning the frames, horizontally aligning
47 the frames and relatively positioning the frames on the line.</li>
48 </ol>
49 nsLineLayout is also used by nsBlockFrame to construct text-run information;
50 this process is independent of normal line layout is pretty much a hack.
51 <p>When frames are reflowed they return a reflow status. During line layout,
52 there are several additions to the basic reflow status used by most frames:
53 <ul>
54 <li>
55 NS_FRAME_COMPLETE - this is a normal reflow status and indicates that the
56 frame is complete and doesn't need to be continued.</li>
58 <li>
59 NS_FRAME_NOT_COMPLETE - this is another normal reflow status and indicates
60 that the frame is not complete and will need a continuation frame created
61 for it (if it doesn't already have one).</li>
63 <li>
64 NS_INLINE_BREAK - some kind of break has been requested. Breaks types include
65 simple line breaks (like the BR tag in html sometime does) and more complex
66 breaks like page breaks, float breaks, etc. Currently, we only support
67 line breaks, and float clearing breaks. Breaks can occur before the frame
68 (NS_INLINE_IS_BREAK_BEFORE) or after the frame (NS_INLINE_IS_BREAK_AFTER)</li>
69 </ul>
70 The handling of the reflow status is done by the container frame using
71 nsLineLayout.
72 <h3>
73 <u>Line Breaking</u></h3>
74 Another aspect of nsLineLayout is that it supports line breaking. At the
75 highest level, line breaking consists of identifying where it is appropriate
76 to break a line that doesn't fit in the available horizontal space. At
77 a lower level, some frames are breakable (e.g. text) and some frames are
78 not (e.g. images).
79 <p>In order to break text properly, some out-of-band information is needed
80 by the text frame code (nsTextFrame). In particular, because a "word" (a
81 non-breakable unit of text) may span several frames (for example: <b>"<B>H</B>ello
82 there"</b> is breakable after the <b>"o"</b> in "<b>ello</b>" but not after
83 the <b>"H"</b>), text-run information is used to allow the text frame to
84 find adjacent text and look at them to determine where the next breakable
85 point is. nsLineLayout supports this by keeping track of the text-runs
86 as well as both storing and interrogating "word" state.
87 <h3>
88 <u>White-space</u></h3>
89 To support the white-space property, the line layout logic keeps track
90 of the presence of white-space in the line as it told to reflow each inline
91 frame. This allows for the compression of leading whitespace and the compression
92 of adjacent whitespace that is in separate inline elements.
93 <p>As a post-processing step, the TrimTrailingWhiteSpace logic is used
94 to remove those pesky pices of white-space that end up being placed at
95 the end of a line, that shouldn't really be seen.
96 <p>To support pre-formatted text that contains tab characters, the line
97 layout class keeps track of the current column on behalf of the text frame
98 code.
99 <h3>
100 <u>Vertical Alignment</u></h3>
101 Vertical alignment is peformed as a two and a half pass process. The first
102 pass is done during nsInlineFrame reflow: the child frames of the nsInlineFrame
103 are vertically aligned as best as can be done at the time. There are certain
104 values for the vertical-align property that require the alignment be done
105 after the lines entire height is known; those frames are placed during
106 the last half pass.
107 <p>The second pass is done by the block frame when all of the frames for
108 a line are known. This is where the final height of the line
109 <br>(not the line-height property) is known and where the final half pass
110 can be done to place all of the top and bottom aligned elements.
111 <br>
112 <h3>
113 <u>Horizontal Alignment</u></h3>
114 After all frames on a line have been placed vertically, the block code
115 will use nsLineLayout to perform horizontal alignment within the extra
116 space.
117 </body>
118 </html>