radkovo / jStyleParser

jStyleParser is a CSS parser written in Java. It has its own application interface that is designed to allow an efficient CSS processing in Java and mapping the values to the Java data types. It parses CSS 2.1 style sheets into structures that can be efficiently assigned to DOM elements. It is intended be the primary CSS parser for the CSSBox library. While handling errors, it is user agent conforming according to the CSS specification.
http://cssbox.sourceforge.net/jstyleparser/
GNU Lesser General Public License v3.0
92 stars 49 forks source link

Fix/line height #4

Closed chetankothari closed 10 years ago

chetankothari commented 10 years ago

NodeData's push() method when called from DirectAnalyzer's getElementStyle() method was mutating the original Term values from the StyleSheet which was passed to the DirectAnalyzer while constructing it. To avoid this, Term now implements Cloneable interface, so wherever we want to mutate the term, we can get a clone of it and then mutate it. This will keep the original values intact.

This problem was being initially encountered for the following test case :-

<p style="font: 400 italic 40px/2 serif;">test</p>

where the operator of the line-height was being set to null, the second time when we were calling the getElementStyle() the operator SLASH(/) was missing, which was required for it to match a variant in processFont() method in DeclarationTransformer's. processFont() was called from parseDeclaration() method in the same class. Since the operator was missing, the font property would have been invalid.

radkovo commented 10 years ago

Well done. Thanks!