Frames
Author: Chris Karnaze
Updated: 12 Oct 1998
| Overview |
Frames consits of the content and layout classes supporting <FRAMESET>, <FRAME> and <IFRAME> tags. A document with a <FRAMESET> does not contain a body tag and the <FRAMESET> specifies how the layout will divided into rows and columns. Each cell of this division can contain a <FRAME> (leaf cell) or another <FRAMESET>. Leaf cells are rendered with the contents of the document specified by the <FRAME>s src attribute. The only rendering associated with non-leaf cells is contributed by the leaf cells that they contain (1 or more levels below).
An <IFRAME> is like a <FRAME> without a containing <FRAMESET>. They define complete documents that are rendered inline within the box they define by their width and height attributes.
An nsIWebShell (and nsWebShell implementation) provides the document
support to <FRAME>s and <IFRAME>s.
| Major Components |
<FRAMESET>s and <IFRAME>s are comprised of content classes (including nsHTMFramesetElement, nsHTMLFrameElement, nsHTMLIFrameElement) and layout/frame classes including nsFrameSetFrame, nsFrameSetBorderFrame, nsFrameSetBlankFrame, nsHTMLFrameOuterFrame, nsHTMLFrameInnerFrame. The content classes are fairly light weight and provide basic getters and setters on their attributes. The layout are a bit more involved and provide the needed layout capabilities in addition to user draggable frame borders in the case of <FRAMESET>s.
A <FRAMESET> layout consists of a single nsFrameSetFrame which can contain one or more nsFrameSetBorderFrames, nsFrameSetBlankFrames. An nsFrameSetBorderFrame defines a border between two adjacent cells within its containing nsFrameSetFrame. By being a separate frame, it can support user dragging to resize the adjacent cells. nsFrameSetBlankFrame provides minimal support in the case where a <FRAMESET> specifies more leaf cells than <FRAME>s. It renders as just a blank white box.
The layout for both a <FRAME> and an <IFRAME> consists of a single nsHTMLFrameOuterFrame which contains a single nsHTMLFrameInnerFrame. The outer frame provides the border for the <IFRAME> layout (the border for the <FRAME> layout is provided by the nsFrameSetFrame, so consequently at some point, the outer frame might go away in this case). The inner frame contains an nsIWebShell which is associated with the sub document to be rendered.
| Implementation |
nsFrameSetFrame's ParseRowColSpec takes the rows and cols attributes and builds an array of nsFramesetSpecs specifying the units (pixel, percentage, proportional) and the values. Reflow passes this spec to CalculateRowCol which calculates the cells dimensions. Reflow lays out its children nsFrameSetFrames, nsHTMLFrameOuterFrames, nsFrameSetBlankFrames from left to right and top to bottom (based on the matrix of cells defined) and subtracting out the width of nsFrameSetBorderFrames. It next lays out the nsFrameSetBorderFrames.
There are a couple of cases where the layout process becomes more complicated. First, since border widths can be specified at the <FRAMESET> and/or <FRAME> level and <FRAMESET>s can be arbitrarily nested, border width calculations need to take this into account. Second, since borders are parented by an nsFrameSetFrame yet they can be specified to be not mouse sensitive (noresize attribute) possibly many levels below that in an nsHTMLFrameSetFrame, this causes some extra recursive logic.
nsHTMLFrameOuterFrame's Reflow subtracts the space for its borders
and reflows its single nsHTMLFrameInnerFrame. In the case of <FRAME>
layout the border has width 0 since the nsFrameSetFrame parent handles
all borders. The inner frame makes a link to the nsIWebShell which is responsible
for laying out the sub document.
| Roadmap |
Frames are complete except for outstanding bugs.
| Known Bugs |
Cell calculation when absolute pixel values are specified are not always right. Dragging a border outside the causes the view system to hang.
| Schedule |