Esempio n. 1
0
 function NullBox()
 {
     // No CSS rules should be applied to null box
     push_css_defaults();
     $this->GenericFormattedBox();
     pop_css_defaults();
 }
Esempio n. 2
0
 /**
  * Create new BR element
  */
 function BRBox()
 {
     /**
      * We're trying to avoid inheriting any of current CSS properties;
      * push_css_defaults will prevent any unneeded CSS properties like margins and padding to be inherited;
      * on the other size, it will keep the 'font-size' property we need to calculate the line height 
      */
     push_css_defaults();
     $this->GenericFormattedBox();
     pop_css_defaults();
     /**
      * We treat BR as a block box; as default value of 'display' property is not 'block', we should 
      * set it up manually.
      */
     $this->display = 'block';
     /**
      * In addition to 'display', we should inherit the 'clear' CSS property, as the 
      * <BR style="clear: both;"> construct is often used all over the Net.
      */
     $handler =& get_css_handler('clear');
     $this->clear = $handler->get();
 }
Esempio n. 3
0
function &create_pdf_pseudoelement($root, $pe_type, &$pipeline)
{
    // Store initial values to CSS stack
    //
    push_css_defaults();
    // Apply default stylesheet rules (using base element)
    global $g_css_defaults_obj;
    $g_css_defaults_obj->apply($root, $pipeline);
    // Initially generated boxes do not require block wrappers
    // Block wrappers are required in following cases:
    // - float property is specified for non-block box which cannot be directly converted to block box
    //   (a button, for example)
    // - display set to block for such box
    $need_block_wrapper = false;
    // Order is important. Items with most priority should be applied last
    // Tag attributes
    execute_attrs_before($root, $pipeline);
    // CSS stylesheet
    global $g_css_obj;
    $g_css_obj->apply($root, $pipeline);
    // values from 'style' attribute
    if ($root->has_attribute("style")) {
        parse_style_attr(null, $root, $pipeline);
    }
    // Pseudoelement-specific rules; be default, it should flow inline
    //
    $handler =& get_css_handler('display');
    $handler->css('inline', $pipeline);
    $handler =& get_css_handler('content');
    $handler->css("", $pipeline);
    $handler =& get_css_handler('float');
    $handler->css("none", $pipeline);
    $handler =& get_css_handler('position');
    $handler->css("static", $pipeline);
    $handler =& get_css_handler('margin');
    $handler->css("0", $pipeline);
    $handler =& get_css_handler('width');
    $handler->css("auto", $pipeline);
    $handler =& get_css_handler('height');
    $handler->css("auto", $pipeline);
    $g_css_obj->apply_pseudoelement($pe_type, $root, $pipeline);
    // Now, if no content found, just return
    //
    $handler =& get_css_handler('content');
    $content = $handler->get();
    if ($content === "") {
        pop_css_defaults();
        $dummy = null;
        return $dummy;
    }
    // CSS 2.1:
    // 9.7 Relationships between 'display', 'position', and 'float'
    // The three properties that affect box generation and layout —
    // 'display', 'position', and 'float' — interact as follows:
    // 1. If 'display' has the value 'none', then 'position' and 'float' do not apply.
    //    In this case, the element generates no box.
    $position_handler =& get_css_handler('position');
    $float_handler =& get_css_handler('float');
    // 2. Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned,
    //    the computed value of 'float' is 'none', and display is set according to the table below.
    //    The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and
    //    the box's containing block.
    $position = $position_handler->get();
    if ($position === POSITION_ABSOLUTE || $position === POSITION_FIXED) {
        $float_handler->replace(FLOAT_NONE);
        $need_block_wrapper |= _fix_display_position_float();
    }
    // 3. Otherwise, if 'float' has a value other than 'none', the box is floated and 'display' is set
    //    according to the table below.
    $float = $float_handler->get();
    if ($float != FLOAT_NONE) {
        $need_block_wrapper |= _fix_display_position_float();
    }
    // 4. Otherwise, if the element is the root element, 'display' is set according to the table below.
    // 5. Otherwise, the remaining 'display' property values apply as specified. (see _fix_display_position_float)
    // Note that pseudoelements may get only standard display values
    $display_handler =& get_css_handler('display');
    switch (trim($display_handler->get())) {
        case "block":
            $box =& BlockBox::create_from_text($content);
            break;
        case "inline":
            $ws_handler =& get_css_handler('white-space');
            $box =& InlineBox::create_from_text($content, $ws_handler->get());
            break;
        default:
            die("Unsupported 'display' value: " . $display_handler->get());
    }
    // Check if this box needs a block wrapper (for example, floating button)
    // Note that to keep float/position information, we clear the CSS stack only
    // AFTER the wrapper box have been created; BUT we should clear the following CSS properties
    // to avoid the fake wrapper box actually affect the layout:
    // - margin
    // - border
    // - padding
    // - background
    //
    if ($need_block_wrapper) {
        $handler =& get_css_handler('margin');
        $handler->css("0", $pipeline);
        pop_border();
        push_border(default_border());
        pop_padding();
        push_padding(default_padding());
        $handler =& get_css_handler('background');
        $handler->css('transparent', $pipeline);
        // Create "clean" block box
        $wrapper =& new BlockBox();
        $wrapper->add_child($box);
        // Remove CSS propery values from stack
        execute_attrs_after($root, $pipeline);
        pop_css_defaults();
        return $wrapper;
    } else {
        // Remove CSS propery values from stack
        execute_attrs_after($root, $pipeline);
        pop_css_defaults();
        return $box;
    }
}
Esempio n. 4
0
 function &create_from_text($text, $white_space)
 {
     $box =& new InlineBox();
     // Apply/inherit text-related CSS properties
     push_css_text_defaults();
     if ($white_space == WHITESPACE_PRE) {
         $box->init_white_space_pre($text);
     } else {
         $box->init_white_space_normal($text);
     }
     // Clear the CSS stack
     pop_css_defaults();
     return $box;
 }
Esempio n. 5
0
 function TableBox(&$root, &$pipeline)
 {
     // Call parent constructor
     $this->GenericContainerBox();
     // Initialize line box
     //     $this->_current_x = 0;
     //     $this->_current_y = 0;
     // List of column width constraints
     $this->cwc = array();
     // Initialize content
     //     $this->content = array();
     // Automatically create at least one table row
     //     if (count($this->content) == 0) {
     // This row should not inherit any table specific properties!
     // 'overflow' for example
     //
     push_css_defaults();
     $this->content[] =& new TableRowBox($root);
     pop_css_defaults();
     //     }
     // Setup cellspacing / cellpadding values
     $handler =& get_css_handler('border-collapse');
     if ($handler->get() == BORDER_COLLAPSE) {
         $handler =& get_css_handler('padding');
         $handler->css("0", $pipeline);
     }
     // Set text-align to 'left'; all browsers I've ever seen prevent inheriting of
     // 'text-align' property by the tables.
     // Say, in the following example the text inside the table cell will be aligned left,
     // instead of inheriting 'center' value.
     //
     // <div style="text-align: center; background-color: green;">
     // <table width="100" bgcolor="red">
     // <tr><td>TEST
     // </table>
     // </div>
     $handler =& get_css_handler('text-align');
     $handler->css('left', $pipeline);
     // Parse table contents
     $child = $root->first_child();
     $col_index = 0;
     while ($child) {
         if ($child->node_type() === XML_ELEMENT_NODE) {
             if ($child->tagname() === 'colgroup') {
                 // COLGROUP tags do not generate boxes; they contain information on the columns
                 //
                 $col_index = $this->parse_colgroup_tag($child, $col_index);
             } else {
                 $child_box =& create_pdf_box($child, $pipeline);
                 $this->add_child($child_box);
             }
         }
         $child = $child->next_sibling();
     }
     $this->normalize();
     $this->normalize_cwc();
     $this->normalize_rhc();
     $this->normalize_parent();
 }
 function FakeTableCellBox()
 {
     // Required to reset any constraints initiated by CSS properties
     push_css_defaults();
     $this->colspan = 1;
     $this->rowspan = 1;
     $this->GenericContainerBox();
     $this->content[] = new NullBox();
     pop_css_defaults();
 }