本文整理汇总了PHP中Frame::get_prev_sibling方法的典型用法代码示例。如果您正苦于以下问题:PHP Frame::get_prev_sibling方法的具体用法?PHP Frame::get_prev_sibling怎么用?PHP Frame::get_prev_sibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame::get_prev_sibling方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: while
/**
* @return Frame_Decorator
*/
function get_prev_sibling()
{
$s = $this->_frame->get_prev_sibling();
if ($s && $deco = $s->get_decorator()) {
while ($tmp = $deco->get_decorator())
$deco = $tmp;
return $deco;
} else if ($s)
return $s;
else
return null;
}
示例2: while
/**
* @return Frame_Decorator
*/
function get_prev_sibling()
{
$s = $this->_frame->get_prev_sibling();
if ($s && ($deco = $s->get_decorator())) {
while ($tmp = $deco->get_decorator()) {
$deco = $tmp;
}
return $deco;
} else {
if ($s) {
return $s;
}
}
return null;
}
示例3: while
/**
* Check if $frame will fit on the page. If the frame does not fit,
* the frame tree is modified so that a page break occurs in the
* correct location.
*
* @param Frame $frame the frame to check
* @return Frame the frame following the page break
*/
function check_page_break(Frame $frame)
{
// Do not split if we have already or if the frame was already
// pushed to the next page (prevents infinite loops)
if ($this->_page_full || $frame->_already_pushed) {
return false;
}
// If the frame is absolute of fixed it shouldn't break
$p = $frame;
do {
if ($p->is_absolute()) {
return false;
}
} while ($p = $p->get_parent());
$margin_height = $frame->get_margin_height();
// FIXME If the row is taller than the page and
// if it the first of the page, we don't break
if ($frame->get_style()->display === "table-row" && !$frame->get_prev_sibling() && $margin_height > $this->get_margin_height()) {
return false;
}
// Determine the frame's maximum y value
$max_y = $frame->get_position("y") + $margin_height;
// If a split is to occur here, then the bottom margins & paddings of all
// parents of $frame must fit on the page as well:
$p = $frame->get_parent();
while ($p) {
$style = $p->get_style();
$max_y += $style->length_in_pt(array($style->margin_bottom, $style->padding_bottom, $style->border_bottom_width));
$p = $p->get_parent();
}
// Check if $frame flows off the page
if ($max_y <= $this->_bottom_page_margin) {
// no: do nothing
return false;
}
dompdf_debug("page-break", "check_page_break");
dompdf_debug("page-break", "in_table: " . $this->_in_table);
// yes: determine page break location
$iter = $frame;
$flg = false;
$in_table = $this->_in_table;
dompdf_debug("page-break", "Starting search");
while ($iter) {
// echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). "";
if ($iter === $this) {
dompdf_debug("page-break", "reached root.");
// We've reached the root in our search. Just split at $frame.
break;
}
if ($this->_page_break_allowed($iter)) {
dompdf_debug("page-break", "break allowed, splitting.");
$iter->split(null, true);
$this->_page_full = true;
$this->_in_table = $in_table;
$frame->_already_pushed = true;
return true;
}
if (!$flg && ($next = $iter->get_last_child())) {
dompdf_debug("page-break", "following last child.");
if ($next->is_table()) {
$this->_in_table++;
}
$iter = $next;
continue;
}
if ($next = $iter->get_prev_sibling()) {
dompdf_debug("page-break", "following prev sibling.");
if ($next->is_table() && !$iter->is_table()) {
$this->_in_table++;
} else {
if (!$next->is_table() && $iter->is_table()) {
$this->_in_table--;
}
}
$iter = $next;
$flg = false;
continue;
}
if ($next = $iter->get_parent()) {
dompdf_debug("page-break", "following parent.");
if ($iter->is_table()) {
$this->_in_table--;
}
$iter = $next;
$flg = true;
continue;
}
break;
}
$this->_in_table = $in_table;
// No valid page break found. Just break at $frame.
dompdf_debug("page-break", "no valid break found, just splitting.");
//.........这里部分代码省略.........
示例4: _page_break_allowed
/**
* Determine if a page break is allowed before $frame
* http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks
*
* In the normal flow, page breaks can occur at the following places:
*
* 1. In the vertical margin between block boxes. When a page
* break occurs here, the used values of the relevant
* 'margin-top' and 'margin-bottom' properties are set to '0'.
* 2. Between line boxes inside a block box.
*
* These breaks are subject to the following rules:
*
* * Rule A: Breaking at (1) is allowed only if the
* 'page-break-after' and 'page-break-before' properties of
* all the elements generating boxes that meet at this margin
* allow it, which is when at least one of them has the value
* 'always', 'left', or 'right', or when all of them are
* 'auto'.
*
* * Rule B: However, if all of them are 'auto' and the
* nearest common ancestor of all the elements has a
* 'page-break-inside' value of 'avoid', then breaking here is
* not allowed.
*
* * Rule C: Breaking at (2) is allowed only if the number of
* line boxes between the break and the start of the enclosing
* block box is the value of 'orphans' or more, and the number
* of line boxes between the break and the end of the box is
* the value of 'widows' or more.
*
* * Rule D: In addition, breaking at (2) is allowed only if
* the 'page-break-inside' property is 'auto'.
*
* If the above doesn't provide enough break points to keep
* content from overflowing the page boxes, then rules B and D are
* dropped in order to find additional breakpoints.
*
* If that still does not lead to sufficient break points, rules A
* and C are dropped as well, to find still more break points.
*
* We will also allow breaks between table rows. However, when
* splitting a table, the table headers should carry over to the
* next page (but they don't yet).
*
* @param Frame $frame the frame to check
* @return bool true if a break is allowed, false otherwise
*/
protected function _page_break_allowed(Frame $frame)
{
$block_types = array("block", "list-item", "table", "-dompdf-image");
dompdf_debug("page-break", "_page_break_allowed(" . $frame->get_node()->nodeName . ")");
$display = $frame->get_style()->display;
// Block Frames (1):
if (in_array($display, $block_types)) {
// Avoid breaks within table-cells
if ($this->_in_table) {
dompdf_debug("page-break", "In table: " . $this->_in_table);
return false;
}
// Rules A & B
if ($frame->get_style()->page_break_before === "avoid") {
dompdf_debug("page-break", "before: avoid");
return false;
}
// Find the preceeding block-level sibling
$prev = $frame->get_prev_sibling();
while ($prev && !in_array($prev->get_style()->display, $block_types)) {
$prev = $prev->get_prev_sibling();
}
// Does the previous element allow a page break after?
if ($prev && $prev->get_style()->page_break_after === "avoid") {
dompdf_debug("page-break", "after: avoid");
return false;
}
// If both $prev & $frame have the same parent, check the parent's
// page_break_inside property.
$parent = $frame->get_parent();
if ($prev && $parent && $parent->get_style()->page_break_inside === "avoid") {
dompdf_debug("page-break", "parent inside: avoid");
return false;
}
// To prevent cascading page breaks when a top-level element has
// page-break-inside: avoid, ensure that at least one frame is
// on the page before splitting.
if ($parent->get_node()->nodeName === "body" && !$prev) {
// We are the body's first child
dompdf_debug("page-break", "Body's first child.");
return false;
}
// If the frame is the first block-level frame, use the value from
// $frame's parent instead.
if (!$prev && $parent) {
return $this->_page_break_allowed($parent);
}
dompdf_debug("page-break", "block: break allowed");
return true;
} else {
if (in_array($display, Style::$INLINE_TYPES)) {
// Avoid breaks within table-cells
//.........这里部分代码省略.........
示例5: _page_break_allowed
/**
* Determine if a page break is allowed before $frame
*
* @param Frame $frame the frame to check
* @return bool true if a break is allowed, false otherwise
*/
protected function _page_break_allowed(Frame $frame)
{
/**
*
* http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks
* /*
* In the normal flow, page breaks can occur at the following places:
*
* 1. In the vertical margin between block boxes. When a page
* break occurs here, the used values of the relevant
* 'margin-top' and 'margin-bottom' properties are set to '0'.
* 2. Between line boxes inside a block box.
*
* These breaks are subject to the following rules:
*
* * Rule A: Breaking at (1) is allowed only if the
* 'page-break-after' and 'page-break-before' properties of
* all the elements generating boxes that meet at this margin
* allow it, which is when at least one of them has the value
* 'always', 'left', or 'right', or when all of them are
* 'auto'.
*
* * Rule B: However, if all of them are 'auto' and the
* nearest common ancestor of all the elements has a
* 'page-break-inside' value of 'avoid', then breaking here is
* not allowed.
*
* * Rule C: Breaking at (2) is allowed only if the number of
* line boxes between the break and the start of the enclosing
* block box is the value of 'orphans' or more, and the number
* of line boxes between the break and the end of the box is
* the value of 'widows' or more.
*
* * Rule D: In addition, breaking at (2) is allowed only if
* the 'page-break-inside' property is 'auto'.
*
* If the above doesn't provide enough break points to keep
* content from overflowing the page boxes, then rules B and D are
* dropped in order to find additional breakpoints.
*
* If that still does not lead to sufficient break points, rules A
* and C are dropped as well, to find still more break points.
*
* [endquote]
*
* We will also allow breaks between table rows. However, when
* splitting a table, the table headers should carry over to the
* next page (but they don't yet).
*/
$block_types = array("block", "list-item", "table");
// echo "\nbreak_allowed: " . $frame->get_node()->nodeName ."\n";
$display = $frame->get_style()->display;
// Block Frames (1):
if (in_array($display, $block_types)) {
// Avoid breaks within table-cells
if ($this->_in_table) {
// echo "In table: " . $this->_in_table ."\n";
return false;
}
// Rules A & B
if ($frame->get_style()->page_break_before == "avoid") {
// echo "before: avoid\n";
return false;
}
// Find the preceeding block-level sibling
$prev = $frame->get_prev_sibling();
while ($prev && !in_array($prev->get_style()->display, $block_types)) {
$prev = $prev->get_prev_sibling();
}
// Does the previous element allow a page break after?
if ($prev && $prev->get_style()->page_break_after == "avoid") {
// echo "after: avoid\n";
return false;
}
// If both $prev & $frame have the same parent, check the parent's
// page_break_inside property.
$parent = $frame->get_parent();
if ($prev && $parent && $parent->get_style()->page_break_inside == "avoid") {
// echo "parent inside: avoid\n";
return false;
}
// To prevent cascading page breaks when a top-level element has
// page-break-inside: avoid, ensure that at least one frame is
// on the page before splitting.
if ($parent->get_node()->nodeName == "body" && !$prev) {
// We are the body's first child
// echo "Body's first child.\n";
return false;
}
// If the frame is the first block-level frame, use the value from
// $frame's parent instead.
if (!$prev && $parent) {
return $this->_page_break_allowed($parent);
}
//.........这里部分代码省略.........
示例6: while
function check_page_break(Frame $frame)
{
if ($this->_page_full || $frame->_already_pushed) {
return false;
}
$p = $frame;
do {
if ($p->is_absolute()) {
return false;
}
} while ($p = $p->get_parent());
$margin_height = $frame->get_margin_height();
if ($frame->get_style()->display === "table-row" && !$frame->get_prev_sibling() && $margin_height > $this->get_margin_height()) {
return false;
}
$max_y = $frame->get_position("y") + $margin_height;
$p = $frame->get_parent();
while ($p) {
$style = $p->get_style();
$max_y += $style->length_in_pt(array($style->margin_bottom, $style->padding_bottom, $style->border_bottom_width));
$p = $p->get_parent();
}
if ($max_y <= $this->_bottom_page_margin) {
return false;
}
dompdf_debug("page-break", "check_page_break");
dompdf_debug("page-break", "in_table: " . $this->_in_table);
$iter = $frame;
$flg = false;
$in_table = $this->_in_table;
dompdf_debug("page-break", "Starting search");
while ($iter) {
if ($iter === $this) {
dompdf_debug("page-break", "reached root.");
break;
}
if ($this->_page_break_allowed($iter)) {
dompdf_debug("page-break", "break allowed, splitting.");
$iter->split(null, true);
$this->_page_full = true;
$this->_in_table = $in_table;
$frame->_already_pushed = true;
return true;
}
if (!$flg && ($next = $iter->get_last_child())) {
dompdf_debug("page-break", "following last child.");
if ($next->is_table()) {
$this->_in_table++;
}
$iter = $next;
continue;
}
if ($next = $iter->get_prev_sibling()) {
dompdf_debug("page-break", "following prev sibling.");
if ($next->is_table() && !$iter->is_table()) {
$this->_in_table++;
} else {
if (!$next->is_table() && $iter->is_table()) {
$this->_in_table--;
}
}
$iter = $next;
$flg = false;
continue;
}
if ($next = $iter->get_parent()) {
dompdf_debug("page-break", "following parent.");
if ($iter->is_table()) {
$this->_in_table--;
}
$iter = $next;
$flg = true;
continue;
}
break;
}
$this->_in_table = $in_table;
dompdf_debug("page-break", "no valid break found, just splitting.");
if ($this->_in_table) {
$num_tables = $this->_in_table - 1;
$iter = $frame;
while ($iter && $num_tables && $iter->get_style()->display !== "table") {
$iter = $iter->get_parent();
$num_tables--;
}
$iter = $frame;
while ($iter && $iter->get_style()->display !== "table-row") {
$iter = $iter->get_parent();
}
}
$frame->split(null, true);
$this->_page_full = true;
$frame->_already_pushed = true;
return true;
}
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:95,代码来源:page_frame_decorator.cls.php