The main purpose of this class is to provide a single location for methods that hide some nastinesses of the existing style implementation.
Every piece of code that gets a StyleValue from a StyleProperties that has been created as part of the CSS emulation has to check for null before it can do anything with it. If it is null then the code has to hard code the initial value. The proper way to solve this is to build the initial values for every property into the StyleProperties created by the CSS emulation. This means that it will never return null and the code that is calling it does not need to know the initial value.
Unfortunately a simplistic approach to this will lead to the following problems:
This is because many pieces of code assume that a null value indicates that it is the device default and as such does not need to set the attribute. By always providing an initial value this code will always write out an attribute hence increasing the page weight.
The assumption on which this code is based is wrong because many devices use default attribute values that do not match the protocol specification. Therefore, the correct approach is to store what the device defaults are and compare the resulting value against that. If they are the same then no attribute is written. If done properly this could reduce the page weight in the case that the author has specified an explicit value that matches the device default.
The majority of stylistic properties only have a single value type, e.g. keyword, or integer, apart from inherit. If inheritance was supported by the CSS emulator properly then the inherit value would be replaced with the value of the property from the enclosing element and so would never appear in code that deals with StyleProperties created by CSS emulation.
A simplistic approach to this would have similar problems to those above and would be addressed by the same solutions.
This class provides methods that serve two functions, the first is to hide the above issues from the code using it and the second is to provide a convenient way of identifying those areas that will need fixing in future once the above issues have been resolved.
|
|
|
|
|
|
|
|
|
|
|
|
|
|