michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: Space Manager High Level Design michael@0: michael@0: michael@0: michael@0: michael@0:

Gecko Layout High Level Design Document

michael@0: michael@0:

Space Manager High Level Design

michael@0:
michael@0: michael@0:

Overview

michael@0: The Space Manager and associated classes and strructures are used by Block michael@0: and Line layout to manage rectangular regions that are occupied and available, michael@0: for correct handling of floated elements and the elements that flow around michael@0: them.  When elements are floated to the left or right in a layout, they michael@0: take up space and influence where other elements can be placed.  The michael@0: Space Manager is responsible for keeping track of where space is taken up michael@0: and where it is available. This information is used by block layout to correctly michael@0: compute where other floated elements should be placed, and how much space michael@0: is available to normal in-flow elements that flow around the floated bits.
michael@0:
michael@0: The Space Manager works in concert with several other classes to do its michael@0: job. The classes that are considered part of the Space Manager are:
michael@0: michael@0: michael@0: Outside of the Space Manager itself, the clients of the Space Manager also michael@0: play an inportant part in the management of he available and used space. michael@0:  The primary classes that interact with the Space Manager are:
michael@0: michael@0: michael@0: The general interaction model is to create a Space Manager for a block michael@0: frame in the context of a Reflow, and to associate it with the BlockReflowState michael@0: so it is passed down to child frames' reflow methods. After reflow, the michael@0: Space Manager is destroyed.  During reflow, the space manager stores michael@0: the space taken up by floats (UpdateSpaceManager in nsBlockFrame) and michael@0: provides information about the space available for other elements (GetAvailableSpace michael@0: in nsBlockReflowState).  
michael@0:
michael@0: Additionally, there is a need to manage impacts to lines caused by michael@0: changes to floated elements.  This is referred to as Propagation michael@0: of Float Damage and is handled by the Block Frame, making use of the michael@0: Space Manager. When a float is incrementally reflowed, the Space michael@0: Manager is notified if the float's region has changed. If so, the michael@0: vertical space that has been affected (including both the float's old michael@0: region and the float's new region) is noted in the internal michael@0: nsIntervalSet as potential float damage (the method is michael@0: IncludeInDamage). During the incremental reflow of dirty lines the michael@0: block frame may encounter lines that are NOT dirty. In this case the michael@0: Space Manager is also asked if  there is any float damage, and michael@0: if there is then the block further checks to see if that damage michael@0: intersects the area of the non-dirty line, marking it dirty if there michael@0: is intersection.  Thus, changes to floats on other lines may michael@0: cause impact to otherwise clean lines, and the Space Manager michael@0: facilitates the detection of this.

Data Model

michael@0: michael@0:

Class/Component Diagram

michael@0: michael@0:
michael@0:
SpaceManager Class Diagram michael@0:
michael@0:
michael@0:
michael@0: michael@0: michael@0: michael@0:

Use Case

michael@0: michael@0:

Use Case 1: Space Manager is Created / Destroyed

michael@0: Space Manager instances are created in the nsBlockFrame's Reflow method. michael@0:  
michael@0: michael@0: michael@0: If the BlockReflowState already had a Space Manager instance associated michael@0: with it, it is stored off before being replaced, and the returned to the michael@0: BlockReflowState instance after the new one has been destroyed.  Thus, michael@0: Space Managers are effectively 'nested' during reflow, with each new block michael@0: introducing its own Space Manager. michael@0: michael@0:

Use Case 2: Float is added to the Space Manager

After a Space Manager is created for a block context's reflow chain, a michael@0: floated block may be added to it.  This happens in the method nsBlockReflowState::RecoverFloats and michael@0: nsBlockReflowState::FlowAndPlaceFloat (formerly this was done in nsBlockFrame::UpdateSpaceManager).  
michael@0:
michael@0: The general algorightm in nsBlockReflowState::RecoverFloats is:
michael@0: michael@0:
michael@0: michael@0: The general algorightm in nsBlockReflowState::FlowAndPlaceFloat is:
michael@0: michael@0:

Use Case 3: Space Manager is used to find available space to reflow michael@0: into

michael@0: The nsBlockFrame makes use of the Space Manager indirectly to get the available michael@0: space to reflow a child block or inline frame into. The block frame uses michael@0: a helper method on the nsBlockReflowState class to do the actual computation michael@0: of available space based on the data in the Space Manager. Here is how it michael@0: works for reflowing an inline frame within a block (this also occurs for michael@0: reflowing a block frame and, partially, for preparing for a resize reflow).
michael@0: michael@0: michael@0: michael@0:

Use Case 4: Propagation of Float Damage: detecting and handling float michael@0: damage

michael@0: This process is driven by the Block Frame.
michael@0: michael@0: michael@0:
michael@0: michael@0:

michael@0: michael@0:

Problems / bugs found during documentation:

michael@0: michael@0: michael@0:
michael@0:
michael@0: michael@0: michael@0: