HTML::Renderer::Box Class Reference

#include <GenericRenderer.hpp>

List of all members.


Detailed Description

The box class store the W3C box model definition as defined in CSS2.1 Please refer to : http://www.w3.org/TR/REC-CSS2/box.html.

Said simply, an HTML renderable element is split in boxes (usually one box for each HTML element, but might be more for list element / TD / etc...) Each box is compound of a content area (whose width and height can be fixed, or automatically processed), and a used area (this area is made of the content area + padding + border + margin) While rendering each box must have a width and height, and a 3D position. While the width and height of each part (content, padding, border, margin) can be explicitely specified, it is usually computed by the layout processor.

The layout computation process is described in http://www.w3.org/TR/REC-CSS2/

The class below simply implement the properties for such a box


Public Types

typedef CSS::Colour Colour
 The colors.
enum  ContentType {
  Text = 0, Image = 1, Object = 2, Input = 3,
  TextArea = 4, Select = 5, Button = 6, Table = 7,
  Other = 8
}
 The box content type. More...
typedef CSS::DisplayMode::Type DisplayMode
 The display mode.
typedef CSS::Font Font
 The font used for this box.
typedef CSS::Length Length
 The units.
typedef CSS::LineHeight LineHeight
 The line height.
typedef CSS::TextAlign TextAlign
 The text alignment.
typedef CSS::TextDecoration::Type TextDecoration
 The text decoration.
typedef CSS::VerticalAlign VerticalAlign
 The vertical alignment.

Public Member Functions

void assignWidthToTable (const uint32 type, TableLayout *tableLayout, const uint32 currentIteration, const uint32 width, uint32 &bottom)
 Assign a specified width to a table.
 Box (Mapper &_mapper, const BoxHierarchy *boxHierarchy, const CSS::StyleImplement &style, const ContentType ct=Text, const Strings::FastString &text="")
 Constructor with style implement.
uint32 computeHeightFromAvailableWidth (const uint32 width, const uint32 currentIteration)
 Compute the required height to render this box in the given width.
bool computeRenderingSize (const uint32 currentIteration, const uint32 top=0)
 Compute the box size from the declaration.
void computeTableWidths (TableLayout::Cell *cellPtr, int32 &previousMaxWidth)
 Compute the widths for a box cell in a table.
bool displayedAsBlock () const
 This is box displayed as block ?
bool displayedAsInline () const
 This is box displayed as inline ?
void findContainingBlock ()
 Find the container block depending on the model as expected in http://www.w3.org/TR/REC-CSS2/visudet.html#containing-block-details.
void findFirstBlockContainer ()
 Find the first container which is displayed as block and extract the split position from it.
BoxfindFirstChildOf (Box *container)
 Helper method in order to get the first child of a given box.
BoxfindLastChildOf (Box *container)
 Helper method in order to get the last child of a given box.
BoxfindPreviousBox () const
 Find the previous box (depend on box display mode).
uint32 getBlockHeight () const
 Get block height in pixels.
uint32 getBlockWidth () const
 Get block width in pixels.
const Border::SidegetBorderSide (uint32 whichOne) const
 Get the border side.
uint32 getContainedBlockHeight () const
 Get containing block height in pixel.
uint32 getContainedBlockWidth () const
 Get containing block width in pixel.
void getContentPosition (ComputedPosition &box) const
 Get the content position.
uint32 getReplacedHeight ()
 Get the replaced element height (this code depends on the element and is implementation dependent).
uint32 getReplacedWidth ()
 Get the replaced element width (this code depends on the element and is implementation dependent).
int32 getSplitLeftPosition () const
 Get the split left position.
int32 getSplitRightPosition () const
 Get the split right position.
uint32 getWidthFromConstraint (const uint32 type, TableLayout::Column &col, const int32 availableWidthLessTableMinWidth, const int32 maxWidthLessMinWidth)
 Get a column width with the given declaration.
bool hasBackground () const
 Does this box has a background (color or picture).
bool isCleared () const
 Is the block clear from a side ?
bool isFloating () const
 Is the block floating ?
bool isSplit () const
 Is this inline box split ?
uint32 max (const uint32 a, const uint32 b) const
 Helper max method.
bool replacedElement () const
 Is this block element a replaced element as defined in http://www.w3.org/TR/REC-CSS2/conform.html#replaced-element.
void returnAllLengths (volatile const HTML::Renderer::Allocators::BaseAllocator *alloc)
 Return all the declared length to the allocator.
void setComputedHeightValues ()
 Set the computed value for width so inherited length can use it.
void setComputedPosValues (const int32 left, const int32 right)
 Set the computed value for left and right position.
void setComputedValues ()
 Helper method to call both method for width and height.
void setComputedWidthValues ()
 Set the computed value for width so inherited length can use it.
void solveAbsoluteBlockLevelWidth (uint32 width)
 Solve width equation for absolute block level Please refer to 10.3.7.
void solveBlockLevelWidth (uint32 width)
 Solve the block level width equation.
void transferDeclaredValues (bool content=true, bool margin1=true, bool margin2=true, bool border1=true, bool border2=true, bool padding1=true, bool padding2=true)
 Helper method to call both method for width and height.
void transferHeightDeclaredValues (bool content=true, bool marginTop=true, bool marginBottom=true, bool borderTop=true, bool borderBottom=true, bool paddingTop=true, bool paddingBottom=true)
 Transfert all known width value from declaration to cache.
void transferWidthDeclaredValues (bool content=true, bool marginLeft=true, bool marginRight=true, bool borderLeft=true, bool borderRight=true, bool paddingLeft=true, bool paddingRight=true)
 Transfers all known width values from declaration to cache.
void zeroIfAuto (Length *len) const
 Zero the computed value for the given length, if auto.

Public Attributes

Boxancestor
 The container box (this is the box that contains us).
FontboxFont
 The current font.
Boxchild
 The first child (if any).
ClearAndFloat clearAndFloat
 The clear and float properties.
ComputedBoxSizes computedBox
 The computed box.
ComputedPosition computedPos
 The computed position.
Boxcontainer
 The container box (this is the box that contains us).
Strings::FastString contentText
 The box content, as a UTF8 string.
enum HTML::Renderer::Box::ContentType contentType
 The box content type.
DisplayMode displayMode
 The display mode.
uint32 iteration
 The current rendering iteration.
bool leftToRight
 The direction for this box.
LineHeight lineHeight
 The line height.
Mappermapper
 The mapper reference.
Boxnext
 The next box (this is the next box on the same level as us).
Boxprevious
 The previous box (this is the previous box on the same level as us).
bool renderAsAnonymousBlock
 Do we need to render this box as an anonymous block ?
SplitLimit splitLimit
 The split limit (if set).
TextAligntextAlign
 The text horizontal alignment.
TextDecoration textDecoration
 The text decoration (if any).
const BoxHierarchyUID
 This box identifier (used by the mapper).
VerticalAlignverticalAlign
 The text vertical alignment.

Friends

class Mapper


Member Typedef Documentation

typedef CSS::Colour HTML::Renderer::Box::Colour

The colors.

typedef CSS::DisplayMode::Type HTML::Renderer::Box::DisplayMode

The display mode.

typedef CSS::Font HTML::Renderer::Box::Font

The font used for this box.

typedef CSS::Length HTML::Renderer::Box::Length

The units.

typedef CSS::LineHeight HTML::Renderer::Box::LineHeight

The line height.

typedef CSS::TextAlign HTML::Renderer::Box::TextAlign

The text alignment.

typedef CSS::TextDecoration::Type HTML::Renderer::Box::TextDecoration

The text decoration.

typedef CSS::VerticalAlign HTML::Renderer::Box::VerticalAlign

The vertical alignment.


Member Enumeration Documentation

enum HTML::Renderer::Box::ContentType

The box content type.

Enumerator:
Text  The text inside this box.
Image  This box display an image.
Object  This box display a foreign object (whose size if already known).
Input  This box display an input box.
TextArea  This box display a text area input box (multiline text box).
Select  This box display a select box (also known as combobox).
Button  This box display a button.
Table  This box is a table.
Other  This box display an unknown object.


Constructor & Destructor Documentation

HTML::Renderer::Box::Box ( Mapper _mapper,
const BoxHierarchy boxHierarchy,
const CSS::StyleImplement style,
const ContentType  ct = Text,
const Strings::FastString text = "" 
) [inline]

Constructor with style implement.

This is very heavy constructor, but it's the only constructor that can build a true box


Member Function Documentation

void HTML::Renderer::Box::assignWidthToTable ( const uint32  type,
TableLayout tableLayout,
const uint32  currentIteration,
const uint32  width,
uint32 &  bottom 
) [inline]

Assign a specified width to a table.

uint32 HTML::Renderer::Box::computeHeightFromAvailableWidth ( const uint32  width,
const uint32  currentIteration 
) [inline]

Compute the required height to render this box in the given width.

bool HTML::Renderer::Box::computeRenderingSize ( const uint32  currentIteration,
const uint32  top = 0 
) [inline]

Compute the box size from the declaration.

A box is considered computed when all these steps are done:

  1. Box::computedBox is filled, which also means that:
    1. Box::computedBox.content.width & height are set
    2. Box::computedBox.padding.top & left & right & bottom are set
    3. Box::computedBox.margin.top & left & right & bottom are set
    4. Box::computedBox.border.top & left & right & bottom are set
  2. Box::computedPos is filled, which also means that:
    1. Box::computedPos.top & left & right & bottom are set
  3. Box::iteration is set to currentIteration
  4. Box::setComputedValues is called (this will transfer computed values above in CSS cache, so it can be refered later by 'inherit' or '' CSS dependents)

void HTML::Renderer::Box::computeTableWidths ( TableLayout::Cell cellPtr,
int32 &  previousMaxWidth 
) [inline]

Compute the widths for a box cell in a table.

bool HTML::Renderer::Box::displayedAsBlock (  )  const [inline]

This is box displayed as block ?

bool HTML::Renderer::Box::displayedAsInline (  )  const [inline]

This is box displayed as inline ?

void HTML::Renderer::Box::findContainingBlock (  )  [inline]

Find the container block depending on the model as expected in http://www.w3.org/TR/REC-CSS2/visudet.html#containing-block-details.

void HTML::Renderer::Box::findFirstBlockContainer (  )  [inline]

Find the first container which is displayed as block and extract the split position from it.

Box* HTML::Renderer::Box::findFirstChildOf ( Box container  )  [inline]

Helper method in order to get the first child of a given box.

Box* HTML::Renderer::Box::findLastChildOf ( Box container  )  [inline]

Helper method in order to get the last child of a given box.

Box* HTML::Renderer::Box::findPreviousBox (  )  const [inline]

Find the previous box (depend on box display mode).

uint32 HTML::Renderer::Box::getBlockHeight (  )  const [inline]

Get block height in pixels.

uint32 HTML::Renderer::Box::getBlockWidth (  )  const [inline]

Get block width in pixels.

const Border::Side& HTML::Renderer::Box::getBorderSide ( uint32  whichOne  )  const [inline]

Get the border side.

Parameters:
whichOne Either (0:Top, 1:Left, 2:Right, 3:Bottom)
Returns:
a constant reference on the declared border side

uint32 HTML::Renderer::Box::getContainedBlockHeight (  )  const [inline]

Get containing block height in pixel.

uint32 HTML::Renderer::Box::getContainedBlockWidth (  )  const [inline]

Get containing block width in pixel.

void HTML::Renderer::Box::getContentPosition ( ComputedPosition &  box  )  const [inline]

Get the content position.

uint32 HTML::Renderer::Box::getReplacedHeight (  )  [inline]

Get the replaced element height (this code depends on the element and is implementation dependent).

uint32 HTML::Renderer::Box::getReplacedWidth (  )  [inline]

Get the replaced element width (this code depends on the element and is implementation dependent).

int32 HTML::Renderer::Box::getSplitLeftPosition (  )  const [inline]

Get the split left position.

int32 HTML::Renderer::Box::getSplitRightPosition (  )  const [inline]

Get the split right position.

uint32 HTML::Renderer::Box::getWidthFromConstraint ( const uint32  type,
TableLayout::Column col,
const int32  availableWidthLessTableMinWidth,
const int32  maxWidthLessMinWidth 
) [inline]

Get a column width with the given declaration.

bool HTML::Renderer::Box::hasBackground (  )  const [inline]

Does this box has a background (color or picture).

Todo:
Implement the CSS background code too

bool HTML::Renderer::Box::isCleared (  )  const [inline]

Is the block clear from a side ?

bool HTML::Renderer::Box::isFloating (  )  const [inline]

Is the block floating ?

bool HTML::Renderer::Box::isSplit (  )  const [inline]

Is this inline box split ?

uint32 HTML::Renderer::Box::max ( const uint32  a,
const uint32  b 
) const [inline]

Helper max method.

bool HTML::Renderer::Box::replacedElement (  )  const [inline]

Is this block element a replaced element as defined in http://www.w3.org/TR/REC-CSS2/conform.html#replaced-element.

void HTML::Renderer::Box::returnAllLengths ( volatile const HTML::Renderer::Allocators::BaseAllocator alloc  )  [inline]

Return all the declared length to the allocator.

void HTML::Renderer::Box::setComputedHeightValues (  )  [inline]

Set the computed value for width so inherited length can use it.

void HTML::Renderer::Box::setComputedPosValues ( const int32  left,
const int32  right 
) [inline]

Set the computed value for left and right position.

void HTML::Renderer::Box::setComputedValues (  )  [inline]

Helper method to call both method for width and height.

void HTML::Renderer::Box::setComputedWidthValues (  )  [inline]

Set the computed value for width so inherited length can use it.

void HTML::Renderer::Box::solveAbsoluteBlockLevelWidth ( uint32  width  )  [inline]

Solve width equation for absolute block level Please refer to 10.3.7.

void HTML::Renderer::Box::solveBlockLevelWidth ( uint32  width  )  [inline]

Solve the block level width equation.

See also:
http://www.w3.org/TR/REC-CSS2/visudet.html#q6

void HTML::Renderer::Box::transferDeclaredValues ( bool  content = true,
bool  margin1 = true,
bool  margin2 = true,
bool  border1 = true,
bool  border2 = true,
bool  padding1 = true,
bool  padding2 = true 
) [inline]

Helper method to call both method for width and height.

void HTML::Renderer::Box::transferHeightDeclaredValues ( bool  content = true,
bool  marginTop = true,
bool  marginBottom = true,
bool  borderTop = true,
bool  borderBottom = true,
bool  paddingTop = true,
bool  paddingBottom = true 
) [inline]

Transfert all known width value from declaration to cache.

void HTML::Renderer::Box::transferWidthDeclaredValues ( bool  content = true,
bool  marginLeft = true,
bool  marginRight = true,
bool  borderLeft = true,
bool  borderRight = true,
bool  paddingLeft = true,
bool  paddingRight = true 
) [inline]

Transfers all known width values from declaration to cache.

void HTML::Renderer::Box::zeroIfAuto ( Length len  )  const [inline]

Zero the computed value for the given length, if auto.


Friends And Related Function Documentation

friend class Mapper [friend]


Member Data Documentation

Box* HTML::Renderer::Box::ancestor

The container box (this is the box that contains us).

Font* HTML::Renderer::Box::boxFont

The current font.

Box* HTML::Renderer::Box::child

The first child (if any).

ClearAndFloat HTML::Renderer::Box::clearAndFloat

The clear and float properties.

ComputedBoxSizes HTML::Renderer::Box::computedBox

The computed box.

ComputedPosition HTML::Renderer::Box::computedPos

The computed position.

Box* HTML::Renderer::Box::container

The container box (this is the box that contains us).

Strings::FastString HTML::Renderer::Box::contentText

The box content, as a UTF8 string.

enum HTML::Renderer::Box::ContentType HTML::Renderer::Box::contentType

The box content type.

DisplayMode HTML::Renderer::Box::displayMode

The display mode.

uint32 HTML::Renderer::Box::iteration

The current rendering iteration.

bool HTML::Renderer::Box::leftToRight

The direction for this box.

LineHeight HTML::Renderer::Box::lineHeight

The line height.

Mapper& HTML::Renderer::Box::mapper

The mapper reference.

Box* HTML::Renderer::Box::next

The next box (this is the next box on the same level as us).

Box* HTML::Renderer::Box::previous

The previous box (this is the previous box on the same level as us).

bool HTML::Renderer::Box::renderAsAnonymousBlock

Do we need to render this box as an anonymous block ?

SplitLimit HTML::Renderer::Box::splitLimit

The split limit (if set).

TextAlign* HTML::Renderer::Box::textAlign

The text horizontal alignment.

TextDecoration HTML::Renderer::Box::textDecoration

The text decoration (if any).

const BoxHierarchy* HTML::Renderer::Box::UID

This box identifier (used by the mapper).

VerticalAlign* HTML::Renderer::Box::verticalAlign

The text vertical alignment.


The documentation for this class was generated from the following file:

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is