layout/doc/obsolete/line-layout.html

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

mercurial