#include <GenericRenderer.hpp>
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. | |
Box * | findFirstChildOf (Box *container) |
Helper method in order to get the first child of a given box. | |
Box * | findLastChildOf (Box *container) |
Helper method in order to get the last child of a given box. | |
Box * | findPreviousBox () 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::Side & | getBorderSide (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 | |
Box * | ancestor |
The container box (this is the box that contains us). | |
Font * | boxFont |
The current font. | |
Box * | child |
The first child (if any). | |
ClearAndFloat | clearAndFloat |
The clear and float properties. | |
ComputedBoxSizes | computedBox |
The computed box. | |
ComputedPosition | computedPos |
The computed position. | |
Box * | container |
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. | |
Mapper & | mapper |
The mapper reference. | |
Box * | next |
The next box (this is the next box on the same level as us). | |
Box * | previous |
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). | |
TextAlign * | textAlign |
The text horizontal alignment. | |
TextDecoration | textDecoration |
The text decoration (if any). | |
const BoxHierarchy * | UID |
This box identifier (used by the mapper). | |
VerticalAlign * | verticalAlign |
The text vertical alignment. | |
Friends | |
class | Mapper |
The colors.
The display mode.
typedef CSS::Font HTML::Renderer::Box::Font |
The font used for this box.
The units.
The line height.
The text alignment.
The text decoration.
The vertical alignment.
The box content type.
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
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:
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.
Helper method in order to get the first child of a given box.
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.
whichOne | Either (0:Top, 1:Left, 2:Right, 3:Bottom) |
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] |
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] |
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.
friend class Mapper [friend] |
The container box (this is the box that contains us).
The current font.
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.
The container box (this is the box that contains us).
The box content, as a UTF8 string.
The box content type.
The display mode.
The current rendering iteration.
The direction for this box.
The line height.
The mapper reference.
The next box (this is the next box on the same level as us).
The previous box (this is the previous box on the same level as us).
Do we need to render this box as an anonymous block ?
SplitLimit HTML::Renderer::Box::splitLimit |
The split limit (if set).
The text horizontal alignment.
The text decoration (if any).
This box identifier (used by the mapper).
The text vertical alignment.