本文整理汇总了PHP中GenericFormattedBox::reflow方法的典型用法代码示例。如果您正苦于以下问题:PHP GenericFormattedBox::reflow方法的具体用法?PHP GenericFormattedBox::reflow怎么用?PHP GenericFormattedBox::reflow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericFormattedBox
的用法示例。
在下文中一共展示了GenericFormattedBox::reflow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reflow
function reflow(&$parent, &$context)
{
// Check if there are any boxes in parent's line box
if ($parent->line_box_empty()) {
// The very first whitespace in the line box should not affect neither height nor baseline of the line box;
// because following boxes can be smaller that assumed whitespace height
// Example: <br>[whitespace]<img height="2" width="2"><br>; whitespace can overextend this line
$this->width = 0;
$this->height = 0;
} elseif (is_a($parent->last_in_line(), "WhitespaceBox")) {
// Duplicate whitespace boxes should not offset further content and affect the line box length
$this->width = 0;
$this->height = 0;
}
GenericFormattedBox::reflow($parent, $context);
// Apply 'line-height'
$this->_apply_line_height();
// default baseline
$this->baseline = $this->default_baseline;
// append to parent line box
$parent->append_line($this);
// Move box to the parent current point
$this->guess_corner($parent);
// Offset parent's current point
$parent->_current_x += $this->width;
// Extend parent height
$parent->extend_height($this->get_bottom_margin());
// Update the value of current collapsed margin; pure text (non-span)
// boxes always have zero margin
$context->pop_collapsed_margin();
$context->push_collapsed_margin(0);
}
示例2: reflow_static
function reflow_static(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
// Determine the box width
$this->_calc_percentage_width($parent, $context);
$this->put_full_width($this->get_min_width($context, $parent->get_width()));
$this->setCSSProperty(CSS_WIDTH, new WCNone());
// Check if we need a line break here
$this->maybe_line_break($parent, $context);
// append to parent line box
$parent->append_line($this);
// Determine coordinates of upper-left _margin_ corner
$this->guess_corner($parent);
$this->reflow_content($context);
/**
* After text content have been reflown, we may determine the baseline of the control item itself;
*
* As there will be some extra whitespace on the top of the control box, we must add this whitespace
* to the calculated baseline value, so text before and after control item will be aligned
* with the text inside the box.
*/
$this->default_baseline = $this->content[0]->baseline + $this->get_extra_top();
$this->baseline = $this->content[0]->baseline + $this->get_extra_top();
// center the button text vertically inside the button
$text =& $this->content[0];
$delta = $text->get_top() - $text->get_height() / 2 - ($this->get_top() - $this->get_height() / 2);
$text->offset(0, -$delta);
// Offset parent current X coordinate
$parent->_current_x += $this->get_full_width();
// Extends parents height
$parent->extend_height($this->get_bottom_margin());
}
示例3: reflow_absolute
/**
* Reflow absolutely positioned block box. Note that according to CSS 2.1
* the only types of boxes which could be absolutely positioned are
* 'block' and 'table'
*
* @param FlowContext $context A flow context object containing the additional layout data.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo CSS 2.1: Relationships between 'display', 'position', and 'float'
*/
function reflow_absolute(&$context)
{
GenericFormattedBox::reflow($this->parent, $context);
$position_strategy =& new StrategyPositionAbsolute();
$position_strategy->apply($this);
/**
* As sometimes left/right values may not be set, we need to use the "fit" width here.
* If box have a width constraint, 'get_max_width' will return constrained value;
* othersise, an intrictic width will be returned.
*
* Note that get_max_width returns width _including_ external space line margins, borders and padding;
* as we're setting the "internal" - content width, we must subtract "extra" space width from the
* value received
*
* @see GenericContainerBox::get_max_width()
*/
$this->put_width($this->get_max_width($context) - $this->_get_hor_extra());
/**
* Update the width, as it should be calculated based upon containing block width, not real parent.
* After this we should remove width constraints or we may encounter problem
* in future when we'll try to call get_..._width functions for this box
*
* @todo Update the family of get_..._width function so that they would apply constraint
* using the containing block width, not "real" parent width
*/
$wc = $this->getCSSProperty(CSS_WIDTH);
$containing_block =& $this->_get_containing_block();
$this->put_width($wc->apply($this->get_width(), $containing_block['right'] - $containing_block['left']));
$this->setCSSProperty(CSS_WIDTH, new WCNone());
/**
* Layout element's children
*/
$this->reflow_content($context);
/**
* As absolute-positioned box generated new flow contexy, extend the height to fit all floats
*/
$this->fitFloats($context);
/**
* If element have been positioned using 'right' or 'bottom' property,
* we need to offset it, as we assumed it had zero width and height at
* the moment we placed it
*/
$right = $this->getCSSProperty(CSS_RIGHT);
$left = $this->getCSSProperty(CSS_LEFT);
if ($left->isAuto() && !$right->isAuto()) {
$this->offset(-$this->get_width(), 0);
}
$bottom = $this->getCSSProperty(CSS_BOTTOM);
$top = $this->getCSSProperty(CSS_TOP);
if ($top->isAuto() && !$bottom->isAuto()) {
$this->offset(0, $this->get_height());
}
}
示例4: reflow
function reflow(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
// set default baseline
$this->baseline = $this->default_baseline;
// append to parent line box
$parent->append_line($this);
// Determine coordinates of upper-left _margin_ corner
$this->guess_corner($parent);
// Offset parent current X coordinate
$parent->_current_x += $this->get_full_width();
// Extends parents height
$parent->extend_height($this->get_bottom_margin());
}
示例5: reflow_static
function reflow_static(&$parent, &$context)
{
$this->pre_reflow_images();
GenericFormattedBox::reflow($parent, $context);
// Check if we need a line break here
$this->maybe_line_break($parent, $context);
// set default baseline
$this->baseline = $this->default_baseline;
// append to parent line box
$parent->append_line($this);
// Move box to the parent current point
$this->guess_corner($parent);
// Move parent's X coordinate
$parent->_current_x += $this->get_full_width();
// Extend parent height
$parent->extend_height($this->get_bottom_margin());
}
示例6: reflow
function reflow(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
// Determine upper-left _content_ corner position of current box
$this->put_left($parent->get_left_padding());
$this->put_top($parent->get_top_padding());
// Legends will not wrap
$this->put_full_width($this->get_max_width($context));
// Reflow contents
$this->reflow_content($context);
// Adjust legend position
$height = $this->get_full_height();
$this->offset(units2pt(LEGEND_HORIZONTAL_OFFSET) + $this->get_extra_left(), $height / 2);
// Adjust parent position
$parent->offset(0, -$height / 2);
// Adjust parent content position
for ($i = 0; $i < count($parent->content); $i++) {
if ($parent->content[$i]->uid != $this->uid) {
$parent->content[$i]->offset(0, -$height / 2);
}
}
$parent->_current_y -= $height / 2;
$parent->extend_height($this->get_bottom_margin());
}
示例7: reflow_static_normal
/**
* Layout normal (non-floating) static-positioned block box.
*
* @param GenericContainerBox $parent The document element which should be treated as the parent of current element
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
*/
function reflow_static_normal(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
if ($parent) {
/**
* Child block will fill the whole content width of the parent block.
*
* 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' +
* 'border-right-width' + 'margin-right' = width of containing block
*
* See CSS 2.1 for more detailed explanation
*
* @link http://www.w3.org/TR/CSS21/visudet.html#blockwidth CSS 2.1. 10.3.3 Block-level, non-replaced elements in normal flow
*/
/**
* Calculate margin values if they have been set as a percentage; replace percentage-based values
* with fixed lengths.
*/
$this->_calc_percentage_margins($parent);
$this->_calc_percentage_padding($parent);
/**
* Calculate width value if it had been set as a percentage; replace percentage-based value
* with fixed value
*/
$this->put_full_width($parent->get_width());
$this->_calc_percentage_width($parent, $context);
/**
* Calculate 'auto' values of width and margins. Unlike tables, DIV width is either constrained
* by some CSS rules or expanded to the parent width; thus, we can calculate 'auto' margin
* values immediately.
*
* @link http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins CSS 2.1 Calculating widths and margins
*/
$this->_calc_auto_width_margins($parent);
/**
* Collapse top margin
*
* @see GenericFormattedBox::collapse_margin()
*
* @link http://www.w3.org/TR/CSS21/box.html#collapsing-margins CSS 2.1 Collapsing margins
*/
$y = $this->collapse_margin($parent, $context);
/**
* At this moment we have top parent/child collapsed margin at the top of context object
* margin stack
*/
/**
* Apply 'clear' property; the current Y coordinate can be modified as a result of 'clear'.
*/
$y = $this->apply_clear($y, $context);
/**
* Store calculated Y coordinate as current Y coordinate in the parent box
* No more content will be drawn abowe this mark; current box padding area will
* start below.
*/
$parent->_current_y = $y;
/**
* Terminate current parent line-box (as current box is not inline)
*/
$parent->close_line($context);
/**
* Add current box to the parent's line-box; we will close the line box below
* after content will be reflown, so the line box will contain only current box.
*/
$parent->append_line($this);
/**
* Now, place the current box upper left content corner. Note that we should not
* use get_extra_top here, as _current_y value already culculated using the top margin value
* of the current box! The top content edge should be offset from that level only of padding and
* border width.
*/
$border = $this->get_css_property(CSS_BORDER);
$padding = $this->get_css_property(CSS_PADDING);
$this->moveto($parent->get_left() + $this->get_extra_left(), $parent->_current_y - $border->top->get_width() - $padding->top->value);
}
/**
* Reflow element's children
*/
$this->reflow_content($context);
if ($this->get_css_property(CSS_OVERFLOW) != OVERFLOW_VISIBLE) {
$this->fitFloats($context);
}
/**
* After child elements have been reflown, we should the top collapsed margin stack value
* replaced by the value of last child bottom collapsed margin;
* if no children contained, then this value should be reset to 0.
*
* Note that invisible and
* whitespaces boxes would not affect the collapsed margin value, so we need to
* use 'get_first' function instead of just accessing the $content array.
*
//.........这里部分代码省略.........
示例8: reflow_static
/**
* Layout current 'inline-block' element assument it has 'position: static'
*
* @param GenericContainerBox $parent The document element which should
* be treated as the parent of current element
*
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
*
* @todo re-check this layout routine; it seems that 'inline-block' boxes have
* their width calculated incorrectly
*/
function reflow_static(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
/**
* Calculate margin values if they have been set as a percentage
*/
$this->_calc_percentage_margins($parent);
/**
* Calculate width value if it had been set as a percentage
*/
$this->_calc_percentage_width($parent, $context);
/**
* Calculate 'auto' values of width and margins
*/
$this->_calc_auto_width_margins($parent);
/**
* add current box to the parent's line-box (alone)
*/
$parent->append_line($this);
/**
* Calculate position of the upper-left corner of the current box
*/
$this->guess_corner($parent);
/**
* By default, child block box will fill all available parent width;
* note that actual content width will be smaller because of non-zero padding, border and margins
*/
$this->put_full_width($parent->get_width());
/**
* Layout element's children
*/
$this->reflow_content($context);
/**
* Calculate element's baseline, as it should be aligned inside the
* parent's line box vertically
*/
$this->default_baseline = $this->get_height() + $this->font_size;
/**
* Extend parent's height to fit current box
*/
$parent->extend_height($this->get_bottom_margin());
/**
* Offset current x coordinate of parent box
*/
$parent->_current_x = $this->get_right_margin();
}
示例9: reflow_static_normal
/**
* Layout normal (non-floating) static-positioned block box.
*
* @param GenericContainerBox $parent The document element which should be treated as the parent of current element
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
*/
function reflow_static_normal(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
if ($parent) {
/**
* Child block will fill the whole content width of the parent block.
*
* 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' +
* 'border-right-width' + 'margin-right' = width of containing block
*
* See CSS 2.1 for more detailed explanation
*
* @link http://www.w3.org/TR/CSS21/visudet.html#blockwidth CSS 2.1. 10.3.3 Block-level, non-replaced elements in normal flow
*/
$this->put_full_width($parent->get_width());
/**
* Calculate margin values if they have been set as a percentage; replace percentage-based values
* with fixed lengths.
*/
$this->_calc_percentage_margins($parent);
/**
* Calculate width value if it had been set as a percentage; replace percentage-based value
* with fixed value
*/
$this->_calc_percentage_width($parent, $context);
/**
* Calculate 'auto' values of width and margins. Unlike tables, DIV width is either constrained
* by some CSS rules or expanded to the parent width; thus, we can calculate 'auto' margin
* values immediately.
*
* @link http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins CSS 2.1 Calculating widths and margins
*/
$this->_calc_auto_width_margins($parent);
/**
* Collapse top margin
*
* @see GenericFormattedBox::collapse_margin()
*
* @link http://www.w3.org/TR/CSS21/box.html#collapsing-margins CSS 2.1 Collapsing margins
*/
$y = $this->collapse_margin($parent, $context);
/**
* At this moment we have top parent/child collapsed margin at the top of context object
* margin stack
*/
/**
* Apply 'clear' property; the current Y coordinate can be modified as a result of 'clear'.
*/
$y = $this->apply_clear($y, $context);
/**
* Store calculated Y coordinate as current Y coordinate in the parent box
* No more content will be drawn abowe this mark; current box padding area will
* start below.
*/
$parent->_current_y = $y;
/**
* Terminate current parent line-box (as current box is not inline)
*/
$parent->close_line($context);
/**
* Add current box to the parent's line-box; we will close the line box below
* after content will be reflown, so the line box will contain only current box.
*/
$parent->append_line($this);
/**
* Now, place the current box upper left content corner. Note that we should not
* use get_extra_top here, as _current_y value already culculated using the top margin value
* of the current box! The top content edge should be offset from that level only of padding and
* border width.
*/
$this->moveto($parent->get_left() + $this->get_extra_left(), $parent->_current_y - $this->border->top->get_width() - $this->padding->top->value);
}
/**
* Reflow element's children
*/
$this->reflow_content($context);
/**
* After child elements have been reflown, we should the top collapsed margin stack value
* replaced by the value of last child bottom collapsed margin;
* if no children contained, then this value should be reset to 0.
*
* Note that invisible and
* whitespaces boxes would not affect the collapsed margin value, so we need to
* use 'get_first' function instead of just accessing the $content array.
*
* @see GenericContainerBox::get_first
*/
if (!is_null($this->get_first())) {
$cm = 0;
} else {
$cm = $context->get_collapsed_margin();
//.........这里部分代码省略.........
示例10: reflow
/**
* Layout current checkbox element. Note that most CSS properties do not apply to the
* checkboxes; i.e. margin/padding values are ignored, checkboxes always aligned to
* to bottom of current line, etc.
*
* @param GenericContainerBox $parent
* @param FlowContext $context Context object describing current flow parameters
*
* @return Boolean flag indicating the error/success state; 'null' value in case of critical error
*/
function reflow(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
// set default baseline
$this->baseline = $this->default_baseline;
// // Vertical-align
// $this->_apply_vertical_align($parent);
/**
* append to parent line box
*/
$parent->append_line($this);
/**
* Determine coordinates of upper-left margin corner
*/
$this->guess_corner($parent);
/**
* Offset parent current X coordinate
*/
$parent->_current_x += $this->get_full_width();
/**
* Extend parents height to fit the checkbox
*/
$parent->extend_height($this->get_bottom_margin());
}
示例11: reflow
function reflow(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
global $g_config;
$size = count($this->content);
if ($g_config['mode'] == "quirks" && $size > 0) {
// QUIRKS MODE:
// H1-H6 and P elements should have their top/bottom margin suppressed if they occur as the first/last table cell child
// correspondingly; note that we cannot do it usung CSS rules, as there's no selectors for the last child.
//
$first =& $this->get_first();
if (!is_null($first) && $this->_suppress_first && $first->isBlockLevel()) {
$first->margin->top->value = 0;
$first->margin->top->percentage = null;
}
$last =& $this->get_last();
if (!is_null($last) && $this->_suppress_last && $last->isBlockLevel()) {
$last->margin->bottom->value = 0;
$last->margin->bottom->percentage = null;
}
}
// Determine upper-left _content_ corner position of current box
$this->put_left($parent->_current_x + $this->get_extra_left());
// NOTE: Table cell margin is used as a cell-spacing value
$border = $this->getCSSProperty(CSS_BORDER);
$padding = $this->getCSSProperty(CSS_PADDING);
$this->put_top($parent->_current_y - $border->top->get_width() - $padding->top->value);
// CSS 2.1:
// Floats, absolutely positioned elements, inline-blocks, table-cells, and elements with 'overflow' other than
// 'visible' establish new block formatting contexts.
$context->push();
$context->push_container_uid($this->uid);
// Reflow cell content
$this->reflow_content($context);
// Extend the table cell height to fit all contained floats
//
// Determine the bottom edge corrdinate of the bottommost float
//
$float_bottom = $context->float_bottom();
if (!is_null($float_bottom)) {
$this->extend_height($float_bottom);
}
// Restore old context
$context->pop_container_uid();
$context->pop();
}
示例12: reflow_static
function reflow_static(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
// Note that inline boxes (actually SPANS)
// are never added to the parent's line boxes
// Move current box to the parent's current coordinates
// Note that span box will start at the far left of the parent, NOT on its current X!
// Also, note that inline box can have margins, padding and borders!
$this->put_left($parent->get_left());
$this->put_top($parent->get_top() - $this->get_extra_top());
// first line of the SPAN will be offset to its parent current-x
// PLUS the left padding of current span!
$parent->_current_x += $this->get_extra_left();
$this->_current_x = $parent->_current_x;
// Note that the same operation IS NOT applied to parent current-y!
// The padding space is just extended to the top possibly OVERLAPPING the above boxes.
$this->width = 0;
// Reflow contents
$size = count($this->content);
for ($i = 0; $i < $size; $i++) {
$child =& $this->content[$i];
// Add current element into _parent_ line box and reflow it
$child->reflow($parent, $context);
// In general, if inline box centained whitespace box only,
// it could be removed during reflow function call;
// let's check it and skip to next child
//
// if no children left AT ALL (so this box is empty), just exit
// Track the real height of the inline box; it will be used by other functions
// (say, functions calculating content height)
$this->extend_height($child->get_bottom_margin());
}
// Apply right extra space value (padding + border + margin)
$parent->_current_x += $this->get_extra_right();
// Margins of inline boxes are not collapsed
if ($this->get_first_data()) {
$context->pop_collapsed_margin();
$context->push_collapsed_margin(0);
}
}
示例13: reflow
/**
* Layout current checkbox element. Note that most CSS properties do not apply to the
* checkboxes; i.e. margin/padding values are ignored, checkboxes always aligned to
* to bottom of current line, etc.
*
* @param GenericContainerBox $parent
* @param FlowContext $context Context object describing current flow parameters
*
* @return Boolean flag indicating the error/success state; 'null' value in case of critical error
*/
function reflow(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
/**
* Check box size is constant (defined in config.inc.php) and is never affected
* neither by CSS nor HTML. Call setup_dimensions once more to restore possible
* changes size
*
* @see CHECKBOX_SIZE
*/
$this->setup_dimensions();
// set default baseline
$this->baseline = $this->default_baseline;
// // Vertical-align
// $this->_apply_vertical_align($parent);
/**
* append to parent line box
*/
$parent->append_line($this);
/**
* Determine coordinates of upper-left margin corner
*/
$this->guess_corner($parent);
/**
* Offset parent current X coordinate
*/
$parent->_current_x += $this->get_full_width();
/**
* Extend parents height to fit the checkbox
*/
$parent->extend_height($this->get_bottom_margin());
}
示例14: reflow_static_normal
/**
* TODO: unlike block elements, table unconstrained width is determined
* with its content, so it may be smaller than parent available width!
*/
function reflow_static_normal(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
// Calculate margin values if they have been set as a percentage
$this->_calc_percentage_margins($parent);
// Calculate width value if it had been set as a percentage
$this->_calc_percentage_width($parent, $context);
$wc = $this->getCSSProperty(CSS_WIDTH);
if ($wc && !$wc->isNull()) {
$col_width = $this->get_table_columns_min_widths($context);
$maxw = $this->get_table_columns_max_widths($context);
$col_width = $this->_table_apply_colspans($col_width, $context, 'get_min_width', $col_width, $maxw);
if (array_sum($col_width) > $this->get_width()) {
$wc = new WCConstant(array_sum($col_width));
}
}
// As table width can be deterimined by its contents, we may calculate auto values
// only AFTER the contents have been reflown; thus, we'll offset the table
// as a whole by a value of left margin AFTER the content reflow
// Do margin collapsing
$y = $this->collapse_margin($parent, $context);
// At this moment we have top parent/child collapsed margin at the top of context object
// margin stack
$y = $this->apply_clear($y, $context);
// Store calculated Y coordinate as current Y in the parent box
$parent->_current_y = $y;
// Terminate current parent line-box
$parent->close_line($context);
// And add current box to the parent's line-box (alone)
$parent->append_line($this);
// Determine upper-left _content_ corner position of current box
// Also see note above regarding margins
$border = $this->getCSSProperty(CSS_BORDER);
$padding = $this->getCSSProperty(CSS_PADDING);
$plus = $parent->_current_x;
if ($border->left) {
$plus += $border->left->get_width();
}
if ($padding->left) {
$plus += $padding->left->value;
}
$this->put_left($plus);
// Note that top margin already used above during maring collapsing
$mins = $parent->_current_y;
if ($border->top) {
$mins -= $border->top->get_width();
}
if ($padding->top) {
$mins -= $padding->top->value;
}
$this->put_top($mins);
/**
* By default, child block box will fill all available parent width;
* note that actual width will be smaller because of non-zero padding, border and margins
*/
$this->put_full_width($parent->get_available_width($context));
// Reflow contents
$this->reflow_content($context);
// Update the collapsed margin value with current box bottom margin
$margin = $this->getCSSProperty(CSS_MARGIN);
$context->pop_collapsed_margin();
$context->pop_collapsed_margin();
$context->push_collapsed_margin($margin->bottom->value);
// Calculate margins and/or width is 'auto' values have been specified
$this->_calc_auto_width_margins($parent);
$this->offset($margin->left->value, 0);
// Extend parent's height to fit current box
$parent->extend_height($this->get_bottom_margin());
// Terminate parent's line box
$parent->close_line($context);
}
示例15: reflow_static_normal
function reflow_static_normal(&$parent, &$context)
{
GenericFormattedBox::reflow($parent, $context);
// if ($parent) {
// Calculate margin values if they have been set as a percentage
$this->_calc_percentage_margins($parent);
// Calculate width value if it had been set as a percentage
$this->_calc_percentage_width($parent, $context);
if (!is_a($this->_width_constraint, "WCNone")) {
$col_width = $this->get_table_columns_min_widths($context);
if (array_sum($col_width) > $this->get_width()) {
$this->_width_constraint = new WCNone();
}
}
// As table width can be deterimined by its contents, we may calculate auto values
// only AFTER the contents have been reflown; thus, we'll offset the table
// as a whole by a value of left margin AFTER the content reflow
// Do margin collapsing
$y = $this->collapse_margin($parent, $context);
// At this moment we have top parent/child collapsed margin at the top of context object
// margin stack
$y = $this->apply_clear($y, $context);
// Store calculated Y coordinate as current Y in the parent box
$parent->_current_y = $y;
// Terminate current parent line-box
$parent->close_line($context);
// And add current box to the parent's line-box (alone)
$parent->append_line($this);
// Determine upper-left _content_ corner position of current box
// Also see note above regarding margins
$this->put_left($parent->_current_x + $this->border->left->get_width() + $this->padding->left->value);
// Note that top margin already used above during maring collapsing
$this->put_top($parent->_current_y - $this->border->top->get_width() - $this->padding->top->value);
// By default, child block box will fill all available parent width;
// note that actual width will be smaller because of non-zero padding, border and margins
$this->put_full_width($parent->get_available_width($context));
// }
// Reflow contents
$this->reflow_content($context);
// Update the collapsed margin value with current box bottom margin
$context->pop_collapsed_margin();
$context->pop_collapsed_margin();
$context->push_collapsed_margin($this->margin->bottom->value);
// if ($parent) {
// Calculate margins and/or width is 'auto' values have been specified
$this->_calc_auto_width_margins($parent);
$this->offset($this->margin->left->value, 0);
// Extend parent's height to fit current box
$parent->extend_height($this->get_bottom_margin());
// Terminate parent's line box
$parent->close_line($context);
// };
}