~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/layout/doc/obsolete/line-layout.html

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

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