Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: sky/examples/style/sky-core-styles.sky

Issue 845053002: Specs and Docs: minor updates to fix mistakes I found when proof-reading (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/examples/style/hex-layout.sky ('k') | sky/examples/style/toolbar-layout.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 SKY MODULE 1 SKY MODULE
2 <!-- this is part of sky:core --> 2 <!-- this is part of sky:core -->
3 <script> 3 <script>
4 // "internals" is an object only made visible to this module that exports stuff implemented in C++ 4 // "internals" is an object only made visible to this module that exports stuff implemented in C++
5 module.exports.registerProperty = internals.registerProperty; 5 module.exports.registerProperty = internals.registerProperty;
6 internals.registerLayoutManager('none', null); 6 internals.registerLayoutManager('none', null);
7 module.exports.LayoutManager = internals.LayoutManager; 7 module.exports.LayoutManager = internals.LayoutManager;
8 module.exports.InlineLayoutManager = internals.InlineLayoutManager; 8 module.exports.InlineLayoutManager = internals.InlineLayoutManager;
9 internals.registerLayoutManager('inline', internals.InlineLayoutManager); 9 internals.registerLayoutManager('inline', internals.InlineLayoutManager);
10 module.exports.ParagraphLayoutManager = internals.ParagraphLayoutManager; 10 module.exports.ParagraphLayoutManager = internals.ParagraphLayoutManager;
11 internals.registerLayoutManager('paragraph', internals.ParagraphLayoutManager); 11 internals.registerLayoutManager('paragraph', internals.ParagraphLayoutManager);
12 module.exports.BlockLayoutManager = internals.BlockLayoutManager; 12 module.exports.BlockLayoutManager = internals.BlockLayoutManager;
13 internals.registerLayoutManager('block', internals.BlockLayoutManager); 13 internals.registerLayoutManager('block', internals.BlockLayoutManager);
14 14
15 let displayTypes = new Map(); 15 let displayTypes = new Map();
16 module.exports.registerLayoutManager = function registerLayoutManager(displayVa lue, layoutManagerConstructor) { 16 module.exports.registerLayoutManager = function registerLayoutManager(displayVa lue, layoutManagerConstructor) {
17 // TODO(ianh): apply rules for type-checking displayValue is a String 17 // TODO(ianh): apply rules for type-checking displayValue is a String
18 // TODO(ianh): apply rules for type-checking layoutManagerConstructor impleme nts the LayoutManagerConstructor interface (or is null) 18 // TODO(ianh): apply rules for type-checking layoutManagerConstructor impleme nts the LayoutManagerConstructor interface (or is null)
19 if (displayTypes.has(displayValue)) 19 if (displayTypes.has(displayValue))
20 throw new Error(); 20 throw new Error();
21 displayTypes.set(displayValue, layoutManagerConstructor); 21 displayTypes.set(displayValue, layoutManagerConstructor);
22 }; 22 };
23 23
24 module.exports.DisplayStyleValueType = new StyleValueType(); // value is null o r a LayoutManagerConstructor 24 module.exports.DisplayStyleGrammar = new StyleGrammar(); // value is null or a LayoutManagerConstructor
25 module.exports.DisplayStyleValueType.addParser((tokens) => { 25 module.exports.DisplayStyleGrammar.addParser((tokens) => {
26 let token = tokens.next(); 26 let token = tokens.next();
27 if (token.done) 27 if (token.done)
28 throw new Error(); 28 throw new Error();
29 if (token.value.kind != 'identifier') 29 if (token.value.kind != 'identifier')
30 throw new Error(); 30 throw new Error();
31 if (!displayTypes.has(token.value.value)) 31 if (!displayTypes.has(token.value.value))
32 throw new Error(); 32 throw new Error();
33 return { 33 return {
34 value: displayTypes.get(token.value.value), 34 value: displayTypes.get(token.value.value),
35 } 35 }
36 }); 36 });
37 37
38 internals.registerProperty({ 38 internals.registerProperty({
39 name: 'display', 39 name: 'display',
40 type: module.exports.DisplayStyleValueType, 40 type: module.exports.DisplayStyleGrammar,
41 inherits: false, 41 inherits: false,
42 initialValue: internals.BlockLayoutManager, 42 initialValue: internals.BlockLayoutManager,
43 needsLayout: true, 43 needsLayout: true,
44 }); 44 });
45 45
46 module.exports.PositiveLengthStyleValueType = new StyleValueType(); // value is a ParsedValue whose value (once resolved) is a number in 96dpi pixels, >=0 46 module.exports.PositiveLengthStyleGrammar = new StyleGrammar(); // value is a P arsedValue whose value (once resolved) is a number in 96dpi pixels, >=0
47 module.exports.PositiveLengthStyleValueType.addParser((tokens) => { 47 module.exports.PositiveLengthStyleGrammar.addParser((tokens) => {
48 // just handle "<number>px" 48 // just handle "<number>px"
49 let token = tokens.next(); 49 let token = tokens.next();
50 if (token.done) 50 if (token.done)
51 throw new Error(); 51 throw new Error();
52 if (token.value.kind != 'dimension') 52 if (token.value.kind != 'dimension')
53 throw new Error(); 53 throw new Error();
54 if (token.value.unit != 'px') 54 if (token.value.unit != 'px')
55 throw new Error(); 55 throw new Error();
56 if (token.value.value < 0) 56 if (token.value.value < 0)
57 throw new Error(); 57 throw new Error();
58 return { 58 return {
59 value: token.value.value; 59 value: token.value.value;
60 }; 60 };
61 }); 61 });
62 62
63 internals.registerProperty({ 63 internals.registerProperty({
64 name: 'min-width', 64 name: 'min-width',
65 type: module.exports.PositiveLengthStyleValueType, 65 type: module.exports.PositiveLengthStyleGrammar,
66 inherits: false, 66 inherits: false,
67 initialValue: 0, 67 initialValue: 0,
68 needsLayout: true, 68 needsLayout: true,
69 }); 69 });
70 internals.registerProperty({ 70 internals.registerProperty({
71 name: 'min-height', 71 name: 'min-height',
72 type: module.exports.PositiveLengthStyleValueType, 72 type: module.exports.PositiveLengthStyleGrammar,
73 inherits: false, 73 inherits: false,
74 initialValue: 0, 74 initialValue: 0,
75 needsLayout: true, 75 needsLayout: true,
76 }); 76 });
77 77
78 module.exports.PositiveLengthOrAutoStyleValueType = new StyleValueType(); // va lue is a ParsedValue whose value (once resolved) is either a number in 96dpi pix els (>=0) or null (meaning 'auto') 78 module.exports.PositiveLengthOrAutoStyleGrammar = new StyleGrammar(); // value is a ParsedValue whose value (once resolved) is either a number in 96dpi pixels (>=0) or null (meaning 'auto')
79 module.exports.PositiveLengthOrAutoStyleValueType.addParser((tokens) => { 79 module.exports.PositiveLengthOrAutoStyleGrammar.addParser((tokens) => {
80 // handle 'auto' 80 // handle 'auto'
81 let token = tokens.next(); 81 let token = tokens.next();
82 if (token.done) 82 if (token.done)
83 throw new Error(); 83 throw new Error();
84 if (token.value.kind != 'identifier') 84 if (token.value.kind != 'identifier')
85 throw new Error(); 85 throw new Error();
86 if (token.value.value != 'auto') 86 if (token.value.value != 'auto')
87 throw new Error(); 87 throw new Error();
88 return { 88 return {
89 value: null, 89 value: null,
90 }; 90 };
91 }); 91 });
92 module.exports.PositiveLengthOrAutoStyleValueType.addParser((tokens) => { 92 module.exports.PositiveLengthOrAutoStyleGrammar.addParser((tokens) => {
93 return module.exports.PositiveLengthStyleValueType.parse(tokens); 93 return module.exports.PositiveLengthStyleGrammar.parse(tokens);
94 }); 94 });
95 95
96 internals.registerProperty({ 96 internals.registerProperty({
97 name: 'width', 97 name: 'width',
98 type: module.exports.PositiveLengthOrAutoStyleValueType, 98 type: module.exports.PositiveLengthOrAutoStyleGrammar,
99 inherits: false, 99 inherits: false,
100 initialValue: null, 100 initialValue: null,
101 needsLayout: true, 101 needsLayout: true,
102 }); 102 });
103 internals.registerProperty({ 103 internals.registerProperty({
104 name: 'height', 104 name: 'height',
105 type: module.exporets.PositiveLengthOrAutoStyleValueType, 105 type: module.exporets.PositiveLengthOrAutoStyleGrammar,
106 inherits: false, 106 inherits: false,
107 initialValue: null, 107 initialValue: null,
108 needsLayout: true, 108 needsLayout: true,
109 }); 109 });
110 110
111 module.exports.PositiveLengthOrInfinityStyleValueType = new StyleValueType(); / / value is a ParsedValue whose value (once resolved) is either a number in 96dpi pixels (>=0) or Infinity 111 module.exports.PositiveLengthOrInfinityStyleGrammar = new StyleGrammar(); // va lue is a ParsedValue whose value (once resolved) is either a number in 96dpi pix els (>=0) or Infinity
112 module.exports.PositiveLengthOrInfinityStyleValueType.addParser((tokens) => { 112 module.exports.PositiveLengthOrInfinityStyleGrammar.addParser((tokens) => {
113 // handle 'infinity' 113 // handle 'infinity'
114 let token = tokens.next(); 114 let token = tokens.next();
115 if (token.done) 115 if (token.done)
116 throw new Error(); 116 throw new Error();
117 if (token.value.kind != 'identifier') 117 if (token.value.kind != 'identifier')
118 throw new Error(); 118 throw new Error();
119 if (token.value.value != 'infinity') 119 if (token.value.value != 'infinity')
120 throw new Error(); 120 throw new Error();
121 return { 121 return {
122 value: Infinity, 122 value: Infinity,
123 }; 123 };
124 }); 124 });
125 module.exports.PositiveLengthOrInfinityStyleValueType.addParser((tokens) => { 125 module.exports.PositiveLengthOrInfinityStyleGrammar.addParser((tokens) => {
126 return module.exports.PositiveLengthStyleValueType.parse(tokens); 126 return module.exports.PositiveLengthStyleGrammar.parse(tokens);
127 }); 127 });
128 128
129 internals.registerProperty({ 129 internals.registerProperty({
130 name: 'width', 130 name: 'width',
131 type: module.exports.PositiveLengthOrInfinityStyleValueType, 131 type: module.exports.PositiveLengthOrInfinityStyleGrammar,
132 inherits: false, 132 inherits: false,
133 initialValue: Infinity, 133 initialValue: Infinity,
134 needsLayout: true, 134 needsLayout: true,
135 }); 135 });
136 internals.registerProperty({ 136 internals.registerProperty({
137 name: 'height', 137 name: 'height',
138 type: module.exporets.PositiveLengthOrInfinityStyleValueType, 138 type: module.exporets.PositiveLengthOrInfinityStyleGrammar,
139 inherits: false, 139 inherits: false,
140 initialValue: Infinity, 140 initialValue: Infinity,
141 needsLayout: true, 141 needsLayout: true,
142 }); 142 });
143 </script> 143 </script>
OLDNEW
« no previous file with comments | « sky/examples/style/hex-layout.sky ('k') | sky/examples/style/toolbar-layout.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698