• R/O
  • SSH
  • HTTPS

copper: Commit


Commit MetaInfo

Revision1568 (tree)
Time2018-07-05 11:41:02
Authormiyabe

Log Message

(empty log message)

Change Summary

Incremental Difference

--- copper/trunk/homare/src/main/java/jp/cssj/homare/css/property/ElementPropertySet.java (revision 1567)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/css/property/ElementPropertySet.java (revision 1568)
@@ -114,6 +114,7 @@
114114 import jp.cssj.homare.impl.css.property.css3.TextStrokeWidth;
115115 import jp.cssj.homare.impl.css.property.css3.Transform;
116116 import jp.cssj.homare.impl.css.property.css3.TransformOrigin;
117+import jp.cssj.homare.impl.css.property.css3.WordBreak;
117118 import jp.cssj.homare.impl.css.property.css3.WordWrap;
118119 import jp.cssj.homare.impl.css.property.css3.WritingModeShorthand;
119120 import jp.cssj.homare.impl.css.property.ext.CSSJBreakCharacters;
@@ -288,6 +289,7 @@
288289 this.put(TextAlignLast.INFO);
289290 this.putShorthand(WritingModeShorthand.INFO);
290291 this.put(WordWrap.INFO);
292+ this.put(WordBreak.INFO);
291293 this.put(ColumnCount.INFO);
292294 this.put(ColumnWidth.INFO);
293295 this.put(ColumnGap.INFO);
--- copper/trunk/homare/src/main/java/jp/cssj/homare/css/style/StyleBuilder.java (revision 1567)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/css/style/StyleBuilder.java (revision 1568)
@@ -151,6 +151,7 @@
151151 import jp.cssj.homare.impl.css.property.css3.TextStrokeWidth;
152152 import jp.cssj.homare.impl.css.property.css3.Transform;
153153 import jp.cssj.homare.impl.css.property.css3.TransformOrigin;
154+import jp.cssj.homare.impl.css.property.css3.WordBreak;
154155 import jp.cssj.homare.impl.css.property.css3.WordWrap;
155156 import jp.cssj.homare.impl.css.property.ext.CSSJBreakCharacters;
156157 import jp.cssj.homare.impl.css.property.ext.CSSJDirectionMode;
@@ -568,7 +569,10 @@
568569 private void setupTextParams(AbstractTextParams params, CSSStyle style) {
569570 this.setupParams(params, style);
570571 params.whiteSpace = WhiteSpace.get(style);
571- params.wordWrap = WordWrap.get(style);
572+ params.wordWrap = WordBreak.get(style);
573+ if (params.wordWrap == AbstractTextParams.WORD_WRAP_NORMAL) {
574+ params.wordWrap = WordWrap.get(style);
575+ }
572576 params.color = TextFillColor.get(style);
573577 params.decoration = TextDecoration.get(style);
574578 params.decorationThickness = 1.0 / style.getUserAgent().getFontSize(UserAgent.FONT_SIZE_MEDIUM) / 2.0;
--- copper/trunk/homare/src/main/java/jp/cssj/homare/css/value/css3/CSS3Value.java (revision 1567)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/css/value/css3/CSS3Value.java (revision 1568)
@@ -22,4 +22,6 @@
2222 public static final short TYPE_CH_LENGTH = 3009;
2323
2424 public static final short TYPE_BOX_SIZING = 3010;
25+
26+ public static final short TYPE_WORD_BREAK = 3011;
2527 }
\ No newline at end of file
--- copper/trunk/homare/src/main/java/jp/cssj/homare/css/value/css3/WordBreakValue.java (nonexistent)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/css/value/css3/WordBreakValue.java (revision 1568)
@@ -0,0 +1,40 @@
1+package jp.cssj.homare.css.value.css3;
2+
3+import jp.cssj.homare.style.box.params.AbstractTextParams;
4+
5+/**
6+ * @author MIYABE Tatsuhiko
7+ * @version $Id: WordWrapValue.java 1552 2018-04-26 01:43:24Z miyabe $
8+ */
9+public class WordBreakValue implements CSS3Value {
10+ public static final WordBreakValue NORMAL_VALUE = new WordBreakValue(AbstractTextParams.WORD_WRAP_NORMAL);
11+
12+ public static final WordBreakValue BREAK_ALL_VALUE = new WordBreakValue(AbstractTextParams.WORD_WRAP_BREAK_ALL);
13+
14+ private final byte wordBreak;
15+
16+ private WordBreakValue(byte wordBreak) {
17+ this.wordBreak = wordBreak;
18+ }
19+
20+ public short getValueType() {
21+ return TYPE_WORD_BREAK;
22+ }
23+
24+ public byte getWordBreak() {
25+ return this.wordBreak;
26+ }
27+
28+ public String toString() {
29+ switch (this.wordBreak) {
30+ case AbstractTextParams.WORD_WRAP_NORMAL:
31+ return "normal";
32+
33+ case AbstractTextParams.WORD_WRAP_BREAK_ALL:
34+ return "break-all";
35+
36+ default:
37+ throw new IllegalStateException();
38+ }
39+ }
40+}
\ No newline at end of file
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/homare/src/main/java/jp/cssj/homare/impl/css/property/css3/WordBreak.java (nonexistent)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/impl/css/property/css3/WordBreak.java (revision 1568)
@@ -0,0 +1,56 @@
1+package jp.cssj.homare.impl.css.property.css3;
2+
3+import java.net.URI;
4+
5+import jp.cssj.homare.css.CSSStyle;
6+import jp.cssj.homare.css.property.AbstractPrimitivePropertyInfo;
7+import jp.cssj.homare.css.property.PrimitivePropertyInfo;
8+import jp.cssj.homare.css.property.PropertyException;
9+import jp.cssj.homare.css.value.Value;
10+import jp.cssj.homare.css.value.css3.WordBreakValue;
11+import jp.cssj.homare.ua.UserAgent;
12+import jp.cssj.sakae.sac.css.LexicalUnit;
13+
14+/**
15+ * @author MIYABE Tatsuhiko
16+ * @version $Id: WordWrap.java 1552 2018-04-26 01:43:24Z miyabe $
17+ */
18+public class WordBreak extends AbstractPrimitivePropertyInfo {
19+ public static final PrimitivePropertyInfo INFO = new WordBreak();
20+
21+ public static byte get(CSSStyle style) {
22+ return ((WordBreakValue) style.get(INFO)).getWordBreak();
23+ }
24+
25+ protected WordBreak() {
26+ super("word-break");
27+ }
28+
29+ public Value getDefault(CSSStyle style) {
30+ return WordBreakValue.NORMAL_VALUE;
31+ }
32+
33+ public boolean isInherited() {
34+ return true;
35+ }
36+
37+ public Value getComputedValue(Value value, CSSStyle style) {
38+ return value;
39+ }
40+
41+ public Value parseProperty(LexicalUnit lu, UserAgent ua, URI uri) throws PropertyException {
42+ switch (lu.getLexicalUnitType()) {
43+ case LexicalUnit.SAC_IDENT:
44+ String ident = lu.getStringValue().toLowerCase();
45+ if (ident.equals("normal") || ident.equals("keep-all")) {
46+ return WordBreakValue.NORMAL_VALUE;
47+ } else if (ident.equals("break-all")) {
48+ return WordBreakValue.BREAK_ALL_VALUE;
49+ }
50+
51+ default:
52+ throw new PropertyException();
53+ }
54+ }
55+
56+}
\ No newline at end of file
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/homare/src/main/java/jp/cssj/homare/style/box/params/AbstractTextParams.java (revision 1567)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/style/box/params/AbstractTextParams.java (revision 1568)
@@ -38,6 +38,8 @@
3838 public static final byte WORD_WRAP_NORMAL = 1;
3939
4040 public static final byte WORD_WRAP_BREAK_WORD = 2;
41+
42+ public static final byte WORD_WRAP_BREAK_ALL = 3;
4143
4244 public static final byte DECORATION_UNDERLINE = 0x01;
4345
--- copper/trunk/homare/src/main/java/jp/cssj/homare/style/builder/impl/TextBuilder.java (revision 1567)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/style/builder/impl/TextBuilder.java (revision 1568)
@@ -94,10 +94,15 @@
9494 private boolean toLineFeed = false;
9595
9696 /**
97- * スペースのつぶし、折り返し、単語の分割。
97+ * スペースのつぶし、折り返し。
9898 */
99- private boolean collapseSpaces, wrap, breakWord;
99+ private boolean collapseSpaces, wrap;
100100
101+ /**
102+ * 単語の分割
103+ */
104+ private byte breakWord;
105+
101106 private double textIndent, letterSpacing, minLineAxis, maxLineSize, maxPageSize, lastSpaceAdvance;
102107
103108 private double pageAxis = 0;
@@ -175,7 +180,11 @@
175180 default:
176181 throw new IllegalStateException();
177182 }
178- this.breakWord = this.wrap && params.wordWrap == AbstractTextParams.WORD_WRAP_BREAK_WORD;
183+ if (this.wrap) {
184+ this.breakWord = params.wordWrap;
185+ } else {
186+ this.breakWord = AbstractTextParams.WORD_WRAP_NORMAL;
187+ }
179188 this.letterSpacing = StyleUtils.computeLength(params.letterSpacing, this.builder.getFlowBox().getLineSize());
180189 // System.err.println("CHANGE_TEXT: " + this.wrap);
181190 }
@@ -720,9 +729,10 @@
720729 } else {
721730 // 分割可能な箇所で分割
722731 e = text.split(this.textUnitGlyphCount);
723- TextImpl prevText = (TextImpl)e;
732+ TextImpl prevText = (TextImpl) e;
724733 // 分割部分のカーニングを取り消して位置を計算する
725- this.lineAxis += this.fontMetrics.getKerning(prevText.gids[prevText.glen - 1], text.gids[0]);
734+ this.lineAxis += this.fontMetrics.getKerning(prevText.gids[prevText.glen - 1],
735+ text.gids[0]);
726736 this.textBuffer.add(i, e);
727737 }
728738 }
@@ -836,28 +846,32 @@
836846 }
837847
838848 public void glyph(int charOffset, char[] ch, int coff, byte clen, int gid) {
839-// if (this.breakWord && this.unitAdvance > 0) {
840-// if (this.firstUnit) {
841-// this.locateLine();
842-// this.firstUnit = false;
843-// }
844-// this.flush();
845-// }
846- if (this.breakWord && this.unitAdvance > 0) {
849+ // if (this.breakWord && this.unitAdvance > 0) {
850+ // if (this.firstUnit) {
851+ // this.locateLine();
852+ // this.firstUnit = false;
853+ // }
854+ // this.flush();
855+ // }
856+ if (this.breakWord != AbstractTextParams.WORD_WRAP_NORMAL && this.unitAdvance > 0) {
847857 if (this.firstUnit) {
848858 this.locateLine();
849859 this.firstUnit = false;
850860 }
851- double lineAxis = this.unitAdvance + this.letterSpacing;
852- if (this.text == null) {
853- lineAxis += this.fontMetrics.getAdvance(gid);
861+ if (this.breakWord == AbstractTextParams.WORD_WRAP_BREAK_ALL) {
862+ this.flush();
854863 } else {
855- lineAxis += this.text.glyphAdvance(gid);
864+ double lineAxis = this.unitAdvance + this.letterSpacing;
865+ if (this.text == null) {
866+ lineAxis += this.fontMetrics.getAdvance(gid);
867+ } else {
868+ lineAxis += this.text.glyphAdvance(gid);
869+ }
870+ final double maxLineAxis = this.maxLineSize - this.textIndent;
871+ if (StyleUtils.compare(lineAxis, maxLineAxis) > 0) {
872+ this.flush();
873+ }
856874 }
857- final double maxLineAxis = this.maxLineSize - this.textIndent;
858- if (StyleUtils.compare(lineAxis, maxLineAxis) > 0) {
859- this.flush();
860- }
861875 }
862876
863877 if (this.text == null) {
Show on old repository browser