Skip to content

Commit 6552fc1

Browse files
committed
Merge pull request #165 from ovanderzee/text-placement
Text placement, aligning and decoration
2 parents 6ea6269 + 1086fe5 commit 6552fc1

File tree

3 files changed

+107
-3
lines changed

3 files changed

+107
-3
lines changed

src/css/Properties.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var Properties = {
99
"-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
1010
"-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
1111
"alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
12-
"alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
12+
"alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical | inherit",
1313
"animation" : 1,
1414
"animation-delay" : { multi: "<time>", comma: true },
1515
"animation-direction" : { multi: "normal | alternate", comma: true },
@@ -272,7 +272,7 @@ var Properties = {
272272
//D
273273
"direction" : "ltr | rtl | inherit",
274274
"display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
275-
"dominant-baseline" : 1,
275+
"dominant-baseline" : "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge | inherit",
276276
"drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
277277
"drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
278278
"drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
@@ -325,6 +325,8 @@ var Properties = {
325325
"font-weight" : "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit",
326326

327327
//G
328+
"glyph-orientation-horizontal" : "<glyph-angle> | inherit",
329+
"glyph-orientation-vertical" : "auto | <glyph-angle> | inherit",
328330
"grid" : 1,
329331
"grid-area" : 1,
330332
"grid-auto-columns" : 1,
@@ -494,9 +496,10 @@ var Properties = {
494496
"target-name" : 1,
495497
"target-new" : 1,
496498
"target-position" : 1,
499+
"text-anchor" : "start | middle | end | inherit",
497500
"text-align" : "left | right | center | justify | match-parent | start | end | inherit" ,
498501
"text-align-last" : 1,
499-
"text-decoration" : 1,
502+
"text-decoration" : "none | <text-decoration> | inherit",
500503
"text-emphasis" : 1,
501504
"text-height" : 1,
502505
"text-indent" : "<length> | <percentage> | inherit",

src/css/ValidationTypes.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ var ValidationTypes = {
148148
return part.type === "angle";
149149
},
150150

151+
"<glyph-angle>": function(part){
152+
return part.type == "angle" && part.units == 'deg';
153+
},
154+
151155
"<uri>": function(part){
152156
return part.type === "uri";
153157
},
@@ -460,6 +464,33 @@ var ValidationTypes = {
460464
throw new ValidationError("Expected (none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]) but found '" + expression.value.text + "'.", part.line, part.col);
461465
}
462466

467+
return result;
468+
},
469+
470+
"<text-decoration>": function(expression) {
471+
// none | [ underline || overline || line-through || blink ] | inherit
472+
var part,
473+
result,
474+
someOf = "[ underline || overline || line-through || blink ]",
475+
identifiers = {},
476+
found;
477+
478+
do {
479+
part = expression.next();
480+
found = 0;
481+
if (someOf.indexOf(part) > -1) {
482+
if (!identifiers[part]) {
483+
identifiers[part] = 0;
484+
}
485+
identifiers[part]++;
486+
found = identifiers[part];
487+
}
488+
} while (found == 1 && expression.hasNext());
489+
490+
result = found == 1 && !expression.hasNext();
491+
if (found === 0 && JSON.stringify(identifiers) == '{}') {
492+
expression.previous();
493+
}
463494
return result;
464495
}
465496
}

tests/css/Validation.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,57 @@
863863
}));
864864
});
865865

866+
suite.add(new ValidationTestCase({
867+
property: "glyph-orientation-horizontal",
868+
869+
valid: [
870+
"-43deg",
871+
".7deg",
872+
"90deg",
873+
"521deg",
874+
"inherit"
875+
],
876+
877+
invalid: {
878+
"auto" : "Expected (<glyph-angle> | inherit) but found 'auto'.",
879+
"70rad" : "Expected (<glyph-angle> | inherit) but found '70rad'.",
880+
"4grad" : "Expected (<glyph-angle> | inherit) but found '4grad'."
881+
}
882+
}));
883+
884+
suite.add(new ValidationTestCase({
885+
property: "glyph-orientation-vertical",
886+
887+
valid: [
888+
"auto",
889+
"-43deg",
890+
".7deg",
891+
"90deg",
892+
"521deg",
893+
"inherit"
894+
],
895+
896+
invalid: {
897+
"70rad" : "Expected (auto | <glyph-angle> | inherit) but found '70rad'.",
898+
"4grad" : "Expected (auto | <glyph-angle> | inherit) but found '4grad'."
899+
}
900+
}));
901+
902+
suite.add(new ValidationTestCase({
903+
property: "text-anchor",
904+
905+
valid: [
906+
"start",
907+
"middle",
908+
"end",
909+
"inherit"
910+
],
911+
912+
invalid: {
913+
"foo" : "Expected (start | middle | end | inherit) but found 'foo'."
914+
}
915+
}));
916+
866917
suite.add(new ValidationTestCase({
867918
property: "text-align",
868919

@@ -882,6 +933,25 @@
882933
}
883934
}));
884935

936+
suite.add(new ValidationTestCase({
937+
property: "text-decoration",
938+
939+
valid: [
940+
"none",
941+
"underline",
942+
"underline overline line-through blink",
943+
"inherit"
944+
],
945+
946+
invalid: {
947+
"none underline" : "Expected end of value but found 'underline'.",
948+
"line-through none" : "Expected (none | <text-decoration> | inherit) but found 'line-through none'.",
949+
"inherit blink" : "Expected end of value but found 'blink'.",
950+
"overline inherit" : "Expected (none | <text-decoration> | inherit) but found 'overline inherit'.",
951+
"foo" : "Expected (none | <text-decoration> | inherit) but found 'foo'."
952+
}
953+
}));
954+
885955
suite.add(new ValidationTestCase({
886956
property: "text-rendering",
887957

0 commit comments

Comments
 (0)