[eluser]bhakti.thakkar[/eluser]
[code]
<?php
class Frame {
/**
* The DOMNode object this frame represents
*
* @var DOMNode
*/
protected $_node;
/**
* Unique identifier for this frame. Used to reference this frame
* via the node.
*
* @var string
*/
protected $_id;
/**
* This frame's calculated style
*
* @var Style
*/
protected $_style;
/**
* This frame's original style. Needed for cases where frames are
* split across pages.
*
* @var Style
*/
protected $_original_style;
/**
* This frame's parent in the document tree.
*
* @var Frame
*/
protected $_parent;
/**
* This frame's first child. All children are handled as a
* doubly-linked list.
*
* @var Frame
*/
protected $_first_child;
/**
* This frame's last child.
*
* @var Frame
*/
protected $_last_child;
/**
* This frame's previous sibling in the document tree.
*
* @var Frame
*/
protected $_prev_sibling;
/**
* This frame's next sibling in the document tree.
*
* @var Frame
*/
protected $_next_sibling;
/**
* This frame's containing block (used in layout): array(x, y, w, h)
*
* @var array
*/
protected $_containing_block;
/**
* Position on the page of the top-left corner of the margin box of
* this frame: array(x,y)
*
* @var array
*/
protected $_position;
/**
* This frame's decorator
*
* @var Frame_Decorator
*/
protected $_decorator;
/**
* Class constructor
*
* @param DOMNode $node the DOMNode this frame represents
*/
function __construct(DomNode $node) {
$this->_node = $node;
$this->_parent = null;
$this->_first_child = null;
$this->_last_child = null;
$this->_prev_sibling = $this->_next_sibling = null;
$this->_style = null;
$this->_original_style = null;
$this->_containing_block = array("x" => null,
"y" => null,
"w" => null,
"h" => null);
$this->_position = array("x" => null,
"y" => null);
$this->_decorator = null;
//$this->set_id( uniqid(rand(),true) );
/*
if (!isset($GLOBALS['dompdfuniqueid']))
{
$GLOBALS['dompdfuniqueid'] = 1;
} else {
$this->set_id($GLOBALS['dompdfuniqueid']++);
}
*/
/*
global $dompdf_unique_id;
if (isset($dompdf_unique_id)) { $dompdf_unique_id++; } else { $dompdf_unique_id = 1; }
$this->set_id( $dompdf_unique_id );
*/
$this->set_id($GLOBALS['dompdfuniqueid']++);
}
/**
* "Destructor": forcibly free all references held by this frame
*
* @param bool $recursive if true, call dispose on all children
*/
function dispose($recursive = false) {
if ( $recursive ) {
while ( $child = $this->_first_child )
$child->dispose(true);
}
// Remove this frame from the tree
if ( $this->_prev_sibling ) {
$this->_prev_sibling->_next_sibling = $this->_next_sibling;
}
if ( $this->_next_sibling ) {
$this->_next_sibling->_prev_sibling = $this->_prev_sibling;
}
if ( $this->_parent && $this->_parent->_first_child === $this ) {
$this->_parent->_first_child = $this->_next_sibling;
}
if ( $this->_parent && $this->_parent->_last_child === $this ) {
$this->_parent->_last_child = $this->_prev_sibling;
}
if ( $this->_parent ) {
$this->_parent->get_node()->removeChild($this->_node);
}
$this->_style->dispose();
unset($this->_style);
$this->_original_style->dispose();
unset($this->_original_style);
}
// Re-initialize the frame
function reset() {
$this->_position = array("x" => null,
"y" => null);
$this->_containing_block = array("x" => null,
"y" => null,
"w" => null,
"h" => null);
unset(