Skip to content

Commit

Permalink
Always return a list for the transform property
Browse files Browse the repository at this point in the history
  • Loading branch information
Mellthas committed Jun 13, 2022
1 parent d88d496 commit c080f17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Css/Style.php
Expand Up @@ -153,7 +153,7 @@
* @property float|string $text_indent Length in pt or a percentage value
* @property string $text_transform
* @property float|string $top Length in pt, a percentage value, or `auto`
* @property array $transform
* @property array $transform List of transforms
* @property array $transform_origin
* @property string $unicode_bidi
* @property string $unicode_range
Expand Down Expand Up @@ -3440,7 +3440,7 @@ protected function _compute_size(string $val)

/**
* @param string $computed
* @return array|null
* @return array
*
* @link https://www.w3.org/TR/css-transforms-1/#transform-property
*/
Expand All @@ -3453,7 +3453,7 @@ protected function _get_transform($computed)
$angle = "\s*([^,\s]+(?:deg|rad)?)\s*";

if (!preg_match_all("/[a-z]+\([^\)]+\)/i", $computed, $parts, PREG_SET_ORDER)) {
return null;
return [];
}

$functions = [
Expand Down
10 changes: 6 additions & 4 deletions src/Renderer.php
Expand Up @@ -65,19 +65,21 @@ public function render(Frame $frame)

$style = $frame->get_style();

if (in_array($style->visibility, ["hidden", "collapse"])) {
if (in_array($style->visibility, ["hidden", "collapse"], true)) {
return;
}

$display = $style->display;
$transformList = $style->transform;
$hasTransform = $transformList !== [];

// Starts the CSS transformation
if ($style->transform && is_array($style->transform)) {
if ($hasTransform) {
$this->_canvas->save();
list($x, $y) = $frame->get_padding_box();
$origin = $style->transform_origin;

foreach ($style->transform as $transform) {
foreach ($transformList as $transform) {
list($function, $values) = $transform;
if ($function === "matrix") {
$function = "transform";
Expand Down Expand Up @@ -200,7 +202,7 @@ public function render(Frame $frame)
$this->_canvas->clipping_end();
}

if ($style->transform && is_array($style->transform)) {
if ($hasTransform) {
$this->_canvas->restore();
}

Expand Down

0 comments on commit c080f17

Please sign in to comment.