diff options
author | Roman Kennke <roman@kennke.org> | 2006-11-16 16:07:13 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-11-16 16:07:13 +0000 |
commit | 4974bf3cd2889569efbcfc422afa78171f75e78d (patch) | |
tree | 0af50bbc981e43c2107ba13e2787db54c5144396 /javax | |
parent | 63cd013ae30b6b4db963ae282e484b7edaa97f63 (diff) | |
download | classpath-4974bf3cd2889569efbcfc422afa78171f75e78d.tar.gz |
2006-11-16 Roman Kennke <kennke@aicas.com>
* gnu/javax/swing/text/html/css/CSSParser.java
(parseRuleset): Support 'combined' selectors.
(main): Adapt callback for combined selectors support.
* gnu/javax/swing/text/html/css/CSSParserCallback.java
(startStatement): Take selector array as argument, to
support combined selectors.
* javax/swing/text/html/BlockView.java
(calculateMinorAxisRequirements): Fetch and apply alignment.
* javax/swing/text/html/StyleSheet.java
(CSSStyle): Inverted the constants for correct precedence.
(CSSStyleSheetParserCallback.styles): New field. Stores the current
styles.
(CSSStyleSheetParserCallback.style): Removed.
(CSSStyleSheetParserCallback.declaration): Update multiple styles.
(CSSStyleSheetParserCallback.end): Push multiple styles.
(CSSStyleSheetParserCallback.start): Initialize multiple styles.
Diffstat (limited to 'javax')
-rw-r--r-- | javax/swing/text/html/BlockView.java | 16 | ||||
-rw-r--r-- | javax/swing/text/html/StyleSheet.java | 33 |
2 files changed, 36 insertions, 13 deletions
diff --git a/javax/swing/text/html/BlockView.java b/javax/swing/text/html/BlockView.java index d7519ef9a..2e781412c 100644 --- a/javax/swing/text/html/BlockView.java +++ b/javax/swing/text/html/BlockView.java @@ -171,6 +171,22 @@ public class BlockView extends BoxView } else r = super.calculateMinorAxisRequirements(axis, r); + + // Apply text alignment if appropriate. + if (axis == X_AXIS) + { + Object o = getAttributes().getAttribute(CSS.Attribute.TEXT_ALIGN); + if (o != null) + { + String al = o.toString().trim(); + if (al.equals("center")) + r.alignment = 0.5f; + else if (al.equals("right")) + r.alignment = 1.0f; + else + r.alignment = 0.0f; + } + } return r; } diff --git a/javax/swing/text/html/StyleSheet.java b/javax/swing/text/html/StyleSheet.java index 72cf7044f..150b27426 100644 --- a/javax/swing/text/html/StyleSheet.java +++ b/javax/swing/text/html/StyleSheet.java @@ -107,9 +107,9 @@ public class StyleSheet extends StyleContext implements CSSParserCallback { /** - * The current style. + * The current styles. */ - private CSSStyle style; + private CSSStyle[] styles; /** * The precedence of the stylesheet to be parsed. @@ -133,9 +133,11 @@ public class StyleSheet extends StyleContext * * @param sel the selector */ - public void startStatement(Selector sel) + public void startStatement(Selector[] sel) { - style = new CSSStyle(precedence, sel); + styles = new CSSStyle[sel.length]; + for (int i = 0; i < sel.length; i++) + styles[i] = new CSSStyle(precedence, sel[i]); } /** @@ -143,8 +145,9 @@ public class StyleSheet extends StyleContext */ public void endStatement() { - css.add(style); - style = null; + for (int i = 0; i < styles.length; i++) + css.add(styles[i]); + styles = null; } /** @@ -157,9 +160,13 @@ public class StyleSheet extends StyleContext { CSS.Attribute cssAtt = CSS.getAttribute(property); Object val = CSS.getValue(cssAtt, value); - CSS.addInternal(style, cssAtt, value); - if (cssAtt != null) - style.addAttribute(cssAtt, val); + for (int i = 0; i < styles.length; i++) + { + CSSStyle style = styles[i]; + CSS.addInternal(style, cssAtt, value); + if (cssAtt != null) + style.addAttribute(cssAtt, val); + } } } @@ -172,11 +179,11 @@ public class StyleSheet extends StyleContext implements Style, Comparable { - static final int PREC_UA = 400000; - static final int PREC_NORM = 300000; + static final int PREC_UA = 0; + static final int PREC_NORM = 100000; static final int PREC_AUTHOR_NORMAL = 200000; - static final int PREC_AUTHOR_IMPORTANT = 100000; - static final int PREC_USER_IMPORTANT = 0; + static final int PREC_AUTHOR_IMPORTANT = 300000; + static final int PREC_USER_IMPORTANT = 400000; /** * The priority of this style when matching CSS selectors. |