Tue, 06 Jan 2015 21:39:09 +0100
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.
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="Author" content="Nisheeth Ranjan">
10 <meta name="GENERATOR" content="Mozilla/4.5 [en]C-NSCP (WinNT; U) [Netscape]">
11 <title>HTML Layout Internals</title>
12 </head>
13 <body>
15 <h1>
16 HTML Layout Internals</h1>
18 <h2>
19 Big picture</h2>
20 An HTML document comes in from netlib into the HTML parser. The parser
21 creates parser nodes and feeds them to the content sink. The content
22 sink constructs a content model that represents the hierarchical structure
23 of the document. As different sub-trees in the content model are
24 fully available, the stylesheet processor iterates over them and creates
25 the corresponding frame hierarchy. The frames recursively layout
26 and render themselves.
27 <p>The part that we are going to drill down into is the code in the block
28 and inline frame classes. Block and inline are the two primary display
29 types specified in CSS and are used in the layout of most of the HTML tags.
30 The table related tags have their own display types like "table-cell",
31 "table-row", etc. and their implementation is a separate topic in itself.
32 <h2>
33 Block and inline code</h2>
34 The main classes involved in the layout of HTML documents are nsBlockFrame
35 and nsInlineFrame, both of which inherit from nsContainerFrame (why?).
36 These classes are persistent across reflows and are organized in a hierarchy
37 to constitute the frame model of the Gecko system. The frame model
38 is derived by applying style and presentation semantics to the content
39 model. Each frame in the frame model has a one to one correspondence
40 with a rectangular region on the presentation context (screen, printer,
41 etc.) and contains the formatting information needed to render that rectangle.
42 The block and inline frame classes implement the nsIFrame and nsIHTMLReflow
43 interfaces. The nsIFrame interface contains methods for managing
44 child frames and linkage with sibling frames, accessing the style context
45 associated with the frame, painting the frame, and handling events that
46 are passed in from the widget hierarchy. The nsIHTMLReflow interface
47 inherits from the nsIReflow interface and adds methods related to word
48 breaking and whitespace querying. The nsIReflow interface defines
49 the Reflow() method that initiates the reflow process along with the WillReflow()
50 and DidReflow() methods that get called before and after the reflow process
51 respectively. nsReflowState and nsReflowMetrics are parameters to
52 the templatized nsIReflow interface: the former is used to hold state during
53 reflow of a frame and the latter is used to return the frame's desired
54 size and alignment to the parent frame during the reflow process.
55 <p>nsBlockReflowContext and nsBlockReflowState both hold state information
56 during the reflow process. nsBlockReflowContext encapsulates the
57 state and algorithm for reflowing child block frames. nsBlockReflowState
58 contains state and methods used by a block frame to reflow itself.
59 Both these classes are instantiated once per block frame.
60 <p>The nsLineLayout class is the engine used by the block and inline frame
61 classes to layout themselves on a line. Frames get passed in to the
62 nsLineLayout class via the BeginSpan() and EndSpan() methods. Each
63 span represents a run of frames with the same style data (???). Other
64 methods exist on the nsLineLayout class to position and size the frames
65 on the current line.
66 <p>nsBlockBandData is the class used to manage the processing of the space-manager
67 (nsSpaceManager) band data. It provides HTML/CSS specific semantics
68 on top of the general space management facilities provided by nsSpaceManager.
69 <p>nsSpaceManager is a class that is told about regions that reserve space
70 and exposes methods to query for available space in a given band.
71 <p>The nsLineBox class represents a horizontal line of frames and is singly
72 linked to the next line box in the document. It is basically a container
73 of a frame list that share the property of being on the same line in the
74 formatted output of the document.
75 <p>The nsTextRun class holds on to a list of frames containing pieces of
76 text that form a logical text run. This is needed because a single
77 text run can occur on leaves at many levels of the document's content tree.
78 This class gives the text layout process an efficient way to get access
79 to text runs and, so, determine where word breaks should occur.
80 <h2>
81 Questions</h2>
82 What are anonymous blocks (nsBlockFrame.h)?
83 <br>What is the difference between a span and a band (nsLineLayout)?
84 <br>Why do nsBlockFrame and nsInlineFrame both inherit from nsContainerFrame?
85 <h2>
86 To Do</h2>
88 <ol>
89 <li>
90 Provide more information about methods and state of each of the classes
91 above.</li>
93 <li>
94 Give a description of how the above classes interact with each other as
95 a simple HTML document is laid out. Then, add in different features
96 to the HTML that exercise different areas of the code, like floats, anonymous
97 blocks, etc.</li>
98 </ol>
100 </body>
101 </html>