Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
class CSSPropertyHandler {
4
  var $_inheritable;
5
  var $_inheritable_text;
6
 
7
  function css($value, &$pipeline) {
8
    $css_state =& $pipeline->get_current_css_state();
9
 
10
    if ($this->applicable($css_state)) {
11
      $this->replace($this->parse($value, $pipeline), $css_state);
12
    };
13
  }
14
 
15
  function applicable($css_state) {
16
    return true;
17
  }
18
 
19
  function clearDefaultFlags(&$state) {
20
    $state->set_propertyDefaultFlag($this->get_property_code(), false);
21
  }
22
 
23
  function CSSPropertyHandler($inheritable, $inheritable_text) {
24
    $this->_inheritable = $inheritable;
25
    $this->_inheritable_text = $inheritable_text;
26
  }
27
 
28
  /**
29
   * Optimization: this function is called very often, so
30
   * we minimize the overhead by calling $this->get_property_code()
31
   * once per property handler object instead of calling in every
32
   * CSSPropertyHandler::get() call.
33
   */
34
  function &get(&$state) {
35
    static $property_code = null;
36
    if (is_null($property_code)) {
37
      $property_code = $this->get_property_code();
38
    };
39
 
40
    if (!isset($state[$property_code])) {
41
      $null = null;
42
      return $null;
43
    };
44
 
45
    return $state[$property_code];
46
  }
47
 
48
  function inherit($old_state, &$new_state) {
49
    $code = $this->get_property_code();
50
    $new_state[$code] = ($this->_inheritable ?
51
                         $old_state[$code] :
52
                         $this->default_value());
53
  }
54
 
55
  function isInheritableText() {
56
    return $this->_inheritable_text;
57
  }
58
 
59
  function isInheritable() {
60
    return $this->_inheritable;
61
  }
62
 
63
  function inherit_text($old_state, &$new_state) {
64
    $code = $this->get_property_code();
65
 
66
    if ($this->_inheritable_text) {
67
      $new_state[$code] = $old_state[$code];
68
    } else {
69
      $new_state[$code] = $this->default_value();
70
    };
71
  }
72
 
73
  function is_default($value) {
74
    if (is_object($value)) {
75
      return $value->is_default();
76
    } else {
77
      return $this->default_value() === $value;
78
    };
79
  }
80
 
81
  function is_subproperty() { return false; }
82
 
83
  function replace($value, &$state) {
84
    $state->set_property($this->get_property_code(), $value);
85
  }
86
 
87
  function replaceDefault($value, &$state) {
88
    $state->set_propertyDefault($this->get_property_code(), $value);
89
  }
90
 
91
  function replace_array($value, &$state) {
92
    static $property_code = null;
93
    if (is_null($property_code)) {
94
      $property_code = $this->get_property_code();
95
    };
96
 
97
    $state[$property_code] = $value;
98
  }
99
}
100
 
101
?>