1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/doc/obsolete/layout-internals.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.5 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.7 + 1.8 +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> 1.9 +<html> 1.10 +<head> 1.11 + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 1.12 + <meta name="Author" content="Nisheeth Ranjan"> 1.13 + <meta name="GENERATOR" content="Mozilla/4.5 [en]C-NSCP (WinNT; U) [Netscape]"> 1.14 + <title>HTML Layout Internals</title> 1.15 +</head> 1.16 +<body> 1.17 + 1.18 +<h1> 1.19 +HTML Layout Internals</h1> 1.20 + 1.21 +<h2> 1.22 +Big picture</h2> 1.23 +An HTML document comes in from netlib into the HTML parser. The parser 1.24 +creates parser nodes and feeds them to the content sink. The content 1.25 +sink constructs a content model that represents the hierarchical structure 1.26 +of the document. As different sub-trees in the content model are 1.27 +fully available, the stylesheet processor iterates over them and creates 1.28 +the corresponding frame hierarchy. The frames recursively layout 1.29 +and render themselves. 1.30 +<p>The part that we are going to drill down into is the code in the block 1.31 +and inline frame classes. Block and inline are the two primary display 1.32 +types specified in CSS and are used in the layout of most of the HTML tags. 1.33 +The table related tags have their own display types like "table-cell", 1.34 +"table-row", etc. and their implementation is a separate topic in itself. 1.35 +<h2> 1.36 +Block and inline code</h2> 1.37 +The main classes involved in the layout of HTML documents are nsBlockFrame 1.38 +and nsInlineFrame, both of which inherit from nsContainerFrame (why?). 1.39 +These classes are persistent across reflows and are organized in a hierarchy 1.40 +to constitute the frame model of the Gecko system. The frame model 1.41 +is derived by applying style and presentation semantics to the content 1.42 +model. Each frame in the frame model has a one to one correspondence 1.43 +with a rectangular region on the presentation context (screen, printer, 1.44 +etc.) and contains the formatting information needed to render that rectangle. 1.45 +The block and inline frame classes implement the nsIFrame and nsIHTMLReflow 1.46 +interfaces. The nsIFrame interface contains methods for managing 1.47 +child frames and linkage with sibling frames, accessing the style context 1.48 +associated with the frame, painting the frame, and handling events that 1.49 +are passed in from the widget hierarchy. The nsIHTMLReflow interface 1.50 +inherits from the nsIReflow interface and adds methods related to word 1.51 +breaking and whitespace querying. The nsIReflow interface defines 1.52 +the Reflow() method that initiates the reflow process along with the WillReflow() 1.53 +and DidReflow() methods that get called before and after the reflow process 1.54 +respectively. nsReflowState and nsReflowMetrics are parameters to 1.55 +the templatized nsIReflow interface: the former is used to hold state during 1.56 +reflow of a frame and the latter is used to return the frame's desired 1.57 +size and alignment to the parent frame during the reflow process. 1.58 +<p>nsBlockReflowContext and nsBlockReflowState both hold state information 1.59 +during the reflow process. nsBlockReflowContext encapsulates the 1.60 +state and algorithm for reflowing child block frames. nsBlockReflowState 1.61 +contains state and methods used by a block frame to reflow itself. 1.62 +Both these classes are instantiated once per block frame. 1.63 +<p>The nsLineLayout class is the engine used by the block and inline frame 1.64 +classes to layout themselves on a line. Frames get passed in to the 1.65 +nsLineLayout class via the BeginSpan() and EndSpan() methods. Each 1.66 +span represents a run of frames with the same style data (???). Other 1.67 +methods exist on the nsLineLayout class to position and size the frames 1.68 +on the current line. 1.69 +<p>nsBlockBandData is the class used to manage the processing of the space-manager 1.70 +(nsSpaceManager) band data. It provides HTML/CSS specific semantics 1.71 +on top of the general space management facilities provided by nsSpaceManager. 1.72 +<p>nsSpaceManager is a class that is told about regions that reserve space 1.73 +and exposes methods to query for available space in a given band. 1.74 +<p>The nsLineBox class represents a horizontal line of frames and is singly 1.75 +linked to the next line box in the document. It is basically a container 1.76 +of a frame list that share the property of being on the same line in the 1.77 +formatted output of the document. 1.78 +<p>The nsTextRun class holds on to a list of frames containing pieces of 1.79 +text that form a logical text run. This is needed because a single 1.80 +text run can occur on leaves at many levels of the document's content tree. 1.81 +This class gives the text layout process an efficient way to get access 1.82 +to text runs and, so, determine where word breaks should occur. 1.83 +<h2> 1.84 +Questions</h2> 1.85 +What are anonymous blocks (nsBlockFrame.h)? 1.86 +<br>What is the difference between a span and a band (nsLineLayout)? 1.87 +<br>Why do nsBlockFrame and nsInlineFrame both inherit from nsContainerFrame? 1.88 +<h2> 1.89 +To Do</h2> 1.90 + 1.91 +<ol> 1.92 +<li> 1.93 +Provide more information about methods and state of each of the classes 1.94 +above.</li> 1.95 + 1.96 +<li> 1.97 +Give a description of how the above classes interact with each other as 1.98 +a simple HTML document is laid out. Then, add in different features 1.99 +to the HTML that exercise different areas of the code, like floats, anonymous 1.100 +blocks, etc.</li> 1.101 +</ol> 1.102 + 1.103 +</body> 1.104 +</html>