@@ -288,7 +288,7 @@ private function parseColorValue() {
288
288
if (mb_strlen ($ sValue , $ this ->sCharset ) === 3 ) {
289
289
$ sValue = $ sValue [0 ].$ sValue [0 ].$ sValue [1 ].$ sValue [1 ].$ sValue [2 ].$ sValue [2 ];
290
290
}
291
- $ aColor = array ('r ' => intval ($ sValue [0 ].$ sValue [1 ], 16 ), 'g ' => intval ($ sValue [2 ].$ sValue [3 ], 16 ), 'b ' => intval ($ sValue [4 ].$ sValue [5 ], 16 ));
291
+ $ aColor = array ('r ' => new CSSSize ( intval ($ sValue [0 ].$ sValue [1 ], 16 )) , 'g ' => new CSSSize ( intval ($ sValue [2 ].$ sValue [3 ], 16 )) , 'b ' => new CSSSize ( intval ($ sValue [4 ].$ sValue [5 ], 16 ) ));
292
292
} else {
293
293
$ sColorMode = $ this ->parseIdentifier ();
294
294
$ this ->consumeWhiteSpace ();
@@ -448,14 +448,14 @@ protected function allRuleSets(&$aResult) {
448
448
}
449
449
}
450
450
451
- protected function allValues ($ oElement , &$ aResult ) {
451
+ protected function allValues ($ oElement , &$ aResult, $ sSearchString = null ) {
452
452
if ($ oElement instanceof CSSList) {
453
453
foreach ($ oElement ->getContents () as $ oContent ) {
454
- $ this ->allValues ($ oContent , $ aResult );
454
+ $ this ->allValues ($ oContent , $ aResult, $ sSearchString );
455
455
}
456
456
} else if ($ oElement instanceof CSSRuleSet) {
457
- foreach ($ oElement ->getRules () as $ oRule ) {
458
- $ this ->allValues ($ oRule , $ aResult );
457
+ foreach ($ oElement ->getRules ($ sSearchString ) as $ oRule ) {
458
+ $ this ->allValues ($ oRule , $ aResult, $ sSearchString );
459
459
}
460
460
} else if ($ oElement instanceof CSSRule) {
461
461
foreach ($ oElement ->getValues () as $ aValues ) {
@@ -480,12 +480,16 @@ public function getAllRuleSets() {
480
480
return $ aResult ;
481
481
}
482
482
483
- public function getAllValues ($ oElement = null ) {
484
- if ($ oElement === null ) {
485
- $ oElement = $ this ;
483
+ public function getAllValues ($ mElement = null ) {
484
+ $ sSearchString = null ;
485
+ if ($ mElement === null ) {
486
+ $ mElement = $ this ;
487
+ } else if (is_string ($ mElement )) {
488
+ $ sSearchString = $ mElement ;
489
+ $ mElement = $ this ;
486
490
}
487
491
$ aResult = array ();
488
- $ this ->allValues ($ oElement , $ aResult );
492
+ $ this ->allValues ($ mElement , $ aResult, $ sSearchString );
489
493
return $ aResult ;
490
494
}
491
495
}
@@ -567,8 +571,25 @@ public function addRule(CSSRule $oRule) {
567
571
$ this ->aRules [$ oRule ->getRule ()] = $ oRule ;
568
572
}
569
573
570
- public function getRules () {
571
- return $ this ->aRules ;
574
+ public function getRules ($ mRule = null ) {
575
+ if ($ mRule === null ) {
576
+ return $ this ->aRules ;
577
+ }
578
+ $ aResult = array ();
579
+ if ($ mRule instanceof CSSRule) {
580
+ $ mRule = $ mRule ->getRule ();
581
+ }
582
+ if (strrpos ($ mRule , '- ' )===strlen ($ mRule )-strlen ('- ' )) {
583
+ $ sStart = substr ($ mRule , 0 , -1 );
584
+ foreach ($ this ->aRules as $ oRule ) {
585
+ if ($ oRule ->getRule () === $ sStart || strpos ($ oRule ->getRule (), $ mRule ) === 0 ) {
586
+ $ aResult [$ oRule ->getRule ()] = $ this ->aRules [$ oRule ->getRule ()];
587
+ }
588
+ }
589
+ } else if (isset ($ this ->aRules [$ mRule ])) {
590
+ $ aResult [$ mRule ] = $ this ->aRules [$ mRule ];
591
+ }
592
+ return $ aResult ;
572
593
}
573
594
574
595
public function removeRule ($ mRule ) {
@@ -600,6 +621,7 @@ class CSSAtRule extends CSSRuleSet {
600
621
private $ sType ;
601
622
602
623
public function __construct ($ sType ) {
624
+ parent ::__construct ();
603
625
$ this ->sType = $ sType ;
604
626
}
605
627
@@ -702,8 +724,8 @@ class CSSSize extends CSSValue {
702
724
private $ fSize ;
703
725
private $ sUnit ;
704
726
705
- public function __construct ($ fSize , $ sUnit ) {
706
- $ this ->fSize = $ fSize ;
727
+ public function __construct ($ fSize , $ sUnit = null ) {
728
+ $ this ->fSize = floatval ( $ fSize) ;
707
729
$ this ->sUnit = $ sUnit ;
708
730
}
709
731
@@ -753,8 +775,12 @@ public function getColor() {
753
775
return $ this ->aColor ;
754
776
}
755
777
778
+ public function getColorDescription () {
779
+ return implode ('' , array_keys ($ this ->aColor ));
780
+ }
781
+
756
782
public function __toString () {
757
- return implode ( '' , array_keys ( $ this ->aColor ) ).'( ' .implode (', ' , $ this ->aColor ).') ' ;
783
+ return $ this ->getColorDescription ( ).'( ' .implode (', ' , $ this ->aColor ).') ' ;
758
784
}
759
785
}
760
786
0 commit comments