/** * Set inherited properties in this style using values in $parent * * @param Style $parent * * @return Style */ function inherit(Style $parent) { // Set parent font size $this->_parent_font_size = $parent->get_font_size(); foreach (self::$_inherited as $prop) { //inherit the !important property also. //if local property is also !important, don't inherit. if (isset($parent->_props[$prop]) && (!isset($this->_props[$prop]) || isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]))) { if (isset($parent->_important_props[$prop])) { $this->_important_props[$prop] = true; } //see __set and __get, on all assignments clear cache! $this->_prop_cache[$prop] = null; $this->_props[$prop] = $parent->_props[$prop]; } } foreach ($this->_props as $prop => $value) { if ($value === "inherit") { if (isset($parent->_important_props[$prop])) { $this->_important_props[$prop] = true; } //do not assign direct, but //implicite assignment through __set, redirect to specialized, get value with __get //This is for computing defaults if the parent setting is also missing. //Therefore do not directly assign the value without __set //set _important_props before that to be able to propagate. //see __set and __get, on all assignments clear cache! //$this->_prop_cache[$prop] = null; //$this->_props[$prop] = $parent->_props[$prop]; //props_set for more obvious explicite assignment not implemented, because //too many implicite uses. // $this->props_set($prop, $parent->$prop); $this->__set($prop, $parent->__get($prop)); } } return $this; }