Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Removed the need to define DEBUGCSS constant
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbull committed Mar 23, 2014
1 parent 1f62f9e commit ba752b6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/Dompdf/Css/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ function get_font_family()
return $this->_font_family;
}

$DEBUGCSS = DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug
$DEBUGCSS = defined('DEBUGCSS') ? DEBUGCSS : false; //=DEBUGCSS; Allow override of global setting for ad hoc debug

// Select the appropriate font. First determine the subtype, then check
// the specified font-families for a candidate.
Expand Down Expand Up @@ -1538,7 +1538,7 @@ protected function _set_style($style, $val, $important)

protected function _image($val)
{
$DEBUGCSS = DEBUGCSS;
$DEBUGCSS = defined('DEBUGCSS') ? DEBUGCSS : false;
$parsed_url = "none";

if (mb_strpos($val, "url") === false) {
Expand Down
34 changes: 17 additions & 17 deletions src/Dompdf/Css/Stylesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private function _specificity($selector, $origin = self::ORIG_AUTHOR)
$d++;
}

if (DEBUGCSS) {
if (defined('DEBUGCSS') && DEBUGCSS) {
/*DEBUGCSS*/
print "<pre>\n";
/*DEBUGCSS*/
Expand Down Expand Up @@ -951,7 +951,7 @@ function apply_styles(FrameTree $tree)
// Sort by specificity
ksort($applied_styles);

if (DEBUGCSS) {
if (defined('DEBUGCSS') && DEBUGCSS) {
$debug_nodename = $frame->get_node()->nodeName;
print "<pre>\n[$debug_nodename\n";
foreach ($applied_styles as $spec => $arr) {
Expand All @@ -975,7 +975,7 @@ function apply_styles(FrameTree $tree)
// Inherit parent's styles if required
if ($p) {

if (DEBUGCSS) {
if (defined('DEBUGCSS') && DEBUGCSS) {
print "inherit:\n";
print "[\n";
$p->get_style()->debug_print();
Expand All @@ -985,7 +985,7 @@ function apply_styles(FrameTree $tree)
$style->inherit($p->get_style());
}

if (DEBUGCSS) {
if (defined('DEBUGCSS') && DEBUGCSS) {
print "DomElementStyle:\n";
print "[\n";
$style->debug_print();
Expand Down Expand Up @@ -1156,7 +1156,7 @@ private function _parse_css($str)
/* See also style.cls Style::_image(), refactoring?, works also for imported css files */
protected function _image($val)
{
$DEBUGCSS = DEBUGCSS;
$DEBUGCSS = defined('DEBUGCSS') ? DEBUGCSS : false;
$parsed_url = "none";

if (mb_strpos($val, "url") === false) {
Expand Down Expand Up @@ -1308,7 +1308,7 @@ private function _parse_properties($str)
{
$properties = preg_split("/;(?=(?:[^\(]*\([^\)]*\))*(?![^\)]*\)))/", $str);

if (DEBUGCSS) print '[_parse_properties';
if (defined('DEBUGCSS') && DEBUGCSS) print '[_parse_properties';

// Create the style
$style = new Style($this);
Expand Down Expand Up @@ -1336,7 +1336,7 @@ private function _parse_properties($str)
}
$prop = trim($prop);
*/
if (DEBUGCSS) print '(';
if (defined('DEBUGCSS') && DEBUGCSS) print '(';

$important = false;
$prop = trim($prop);
Expand All @@ -1351,19 +1351,19 @@ private function _parse_properties($str)
}

if ($prop === "") {
if (DEBUGCSS) print 'empty)';
if (defined('DEBUGCSS') && DEBUGCSS) print 'empty)';
continue;
}

$i = mb_strpos($prop, ":");
if ($i === false) {
if (DEBUGCSS) print 'novalue' . $prop . ')';
if (defined('DEBUGCSS') && DEBUGCSS) print 'novalue' . $prop . ')';
continue;
}

$prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i)));
$value = ltrim(mb_substr($prop, $i + 1));
if (DEBUGCSS) print $prop_name . ':=' . $value . ($important ? '!IMPORTANT' : '') . ')';
if (defined('DEBUGCSS') && DEBUGCSS) print $prop_name . ':=' . $value . ($important ? '!IMPORTANT' : '') . ')';
//New style, anyway empty
//if ($important || !$style->important_get($prop_name) ) {
//$style->$prop_name = array($value,$important);
Expand All @@ -1377,7 +1377,7 @@ private function _parse_properties($str)
$style->$prop_name = $value;
//$style->props_set($prop_name, $value);
}
if (DEBUGCSS) print '_parse_properties]';
if (defined('DEBUGCSS') && DEBUGCSS) print '_parse_properties]';

return $style;
}
Expand All @@ -1397,32 +1397,32 @@ private function _parse_sections($str)
$str = preg_replace($patterns, $replacements, $str);

$sections = explode("}", $str);
if (DEBUGCSS) print '[_parse_sections';
if (defined('DEBUGCSS') && DEBUGCSS) print '[_parse_sections';
foreach ($sections as $sect) {
$i = mb_strpos($sect, "{");

$selectors = explode(",", mb_substr($sect, 0, $i));
if (DEBUGCSS) print '[section';
if (defined('DEBUGCSS') && DEBUGCSS) print '[section';
$style = $this->_parse_properties(trim(mb_substr($sect, $i + 1)));

// Assign it to the selected elements
foreach ($selectors as $selector) {
$selector = trim($selector);

if ($selector == "") {
if (DEBUGCSS) print '#empty#';
if (defined('DEBUGCSS') && DEBUGCSS) print '#empty#';
continue;
}
if (DEBUGCSS) print '#' . $selector . '#';
if (defined('DEBUGCSS') && DEBUGCSS) print '#' . $selector . '#';
//if (DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }

$this->add_style($selector, $style);
}

if (DEBUGCSS) print 'section]';
if (defined('DEBUGCSS') && DEBUGCSS) print 'section]';
}

if (DEBUGCSS) print '_parse_sections]';
if (defined('DEBUGCSS') && DEBUGCSS) print '_parse_sections]';
}

/**
Expand Down

0 comments on commit ba752b6

Please sign in to comment.