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

Side by Side Diff: sky/specs/style.md

Issue 836193002: Specs: Move default layout manager stuff from default styles to getLayoutManager() (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/specs/modules.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Sky Style Language 1 Sky Style Language
2 ================== 2 ==================
3 3
4 Planed changes 4 Planed changes
5 -------------- 5 --------------
6 6
7 Add //-to-end-of-line comments to be consistent with the script 7 Add //-to-end-of-line comments to be consistent with the script
8 language. 8 language.
9 9
10 10
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 +-- AbstractStyleValue 226 +-- AbstractStyleValue
227 | 227 |
228 +-- NumericStyleValue 228 +-- NumericStyleValue
229 | | 229 | |
230 | +-- AnimatableNumericStyleValue* 230 | +-- AnimatableNumericStyleValue*
231 | 231 |
232 +-- LengthStyleValue 232 +-- LengthStyleValue
233 | | 233 | |
234 | +-- AnimatableLengthStyleValue* 234 | +-- AnimatableLengthStyleValue*
235 | | 235 | |
236 | +-- TransitionLengthStyleValue*
237 | |
236 | +-- PixelLengthStyleValue 238 | +-- PixelLengthStyleValue
237 | | 239 | |
238 | +-- EmLengthStyleValue* 240 | +-- EmLengthStyleValue*
239 | | 241 | |
240 | +-- VHLengthStyleValue* 242 | +-- VHLengthStyleValue*
241 | | 243 | |
242 | +-- CalcLengthStyleValue* 244 | +-- CalcLengthStyleValue*
243 | 245 |
244 +-- ColorStyleValue 246 +-- ColorStyleValue
245 | | 247 | |
(...skipping 14 matching lines...) Expand all
260 | +-- StringStyleValue* 262 | +-- StringStyleValue*
261 | | | 263 | | |
262 | | +-- AnimatableStringStyleValue* 264 | | +-- AnimatableStringStyleValue*
263 | | 265 | |
264 | +-- ObjectStyleValue 266 | +-- ObjectStyleValue
265 | 267 |
266 +-- PrimitiveValuesListStyleValue* 268 +-- PrimitiveValuesListStyleValue*
267 */ 269 */
268 ``` 270 ```
269 271
270 The types marked with * in the list above are not part of sky:core. 272 The types marked with * in the list above are not part of sky:core,
273 and are only shown here to illustrate what kinds of extensions are
274 possible and where they would fit.
271 275
272 TODO(ianh): consider removing 'StyleValue' from these class names 276 TODO(ianh): consider removing 'StyleValue' from these class names
273 277
274 ```javascript 278 ```javascript
275 abstract class StyleNode { 279 abstract class StyleNode {
276 abstract void markDirty(); 280 abstract void markDirty();
277 } 281 }
278 282
279 dictionary StyleValueResolverSettingsSettings { 283 dictionary StyleValueResolverSettingsSettings {
280 Boolean firstTime = false; 284 Boolean firstTime = false;
281 any state = null; 285 any state = null;
282 } 286 }
283 287
284 class StyleValueResolverSettings { 288 class StyleValueResolverSettings {
285 // this is used as an "out" parameter for 'resolve()' below 289 // this is used as an "out" parameter for 'resolve()' below
286 constructor(StyleValueResolverSettingsSettings initial); 290 constructor(StyleValueResolverSettingsSettings initial);
287 void reset(StyleValueResolverSettingsSettings initial); 291 void reset(StyleValueResolverSettingsSettings initial);
288 // sets firstTime and state to given values 292 // sets firstTime and state to given values
289 // sets layoutDependent to false 293 // sets layoutDependent to false
290 // sets dependencies to empty set 294 // sets dependencies to empty set
291 295
292 readonly attribute Boolean firstTime; 296 readonly attribute Boolean firstTime;
293 // true if this is the first time this property is being resolved for this e lement, 297 // true if this is the first time this property is being resolved for this e lement,
294 // or if the last time it was resolved, the value was a different object 298 // or if the last time it was resolved, the value was a different object
295 299
296 attribute Boolean layoutDependent; // default to false 300 // attribute Boolean layoutDependent
297 // set this if the value should be recomputed each time the ownerLayoutManag er's dimensions change, rather than being cached 301 void setLayoutDependent();
302 // call this if the value should be recomputed each time the ownerLayoutMana ger's dimensions change, rather than being cached
303 Boolean getLayoutDependent();
304 // returns true if setLayoutDependent has been called since the last reset()
298 305
299 // attribute "BitField" dependencies; // defaults to no bits set 306 // attribute "BitField" dependencies; // defaults to no bits set
300 void dependsOn(PropertyHandle property); 307 void dependsOn(PropertyHandle property);
301 // if the given property doesn't have a dependency bit assigned: 308 // if the given property doesn't have a dependency bit assigned:
302 // - assign the next bit to the property 309 // - assign the next bit to the property
303 // - if there's no bits left, throw 310 // - if there's no bits left, throw
304 // set the bit on this StyleValueResolverSettings's dependencies bitfield 311 // set the bit on this StyleValueResolverSettings's dependencies bitfield
305 Array<PropertyHandle> getDependencies(); 312 Array<PropertyHandle> getDependencies();
306 // returns an array of the PropertyHandle values for the bits that are set i n dependencies 313 // returns an array of the PropertyHandle values for the bits that are set i n dependencies
307 314
308 attribute any state; // initially null, can be set to store value for this Ren derNode/property pair 315 attribute any state; // initially null, can be set to store value for this Ren derNode/property pair
309 // for example, TransitioningColorStyleValue would store 316 // for example, TransitioningColorStyleValue would store
310 // { 317 // {
311 // initial: /* color at time of transition */, 318 // initial: /* color at time of transition */,
312 // target: /* color at end of transition */, 319 // target: /* color at end of transition */,
313 // start: /* time at start of transition */, 320 // start: /* time at start of transition */,
314 // } 321 // }
315 // ...which would enable it to update appropriately, and would also 322 // ...which would enable it to update appropriately, and would also
316 // let other transitions that come later know that you were half-way 323 // let other transitions that come later know that you were half-way
317 // through a transition so they can shorten their time accordingly 324 // through a transition so they can shorten their time accordingly
325 //
326 // best practices: if you're a style value that contains multiple
327 // style values, then before you call their resolve you should
328 // replace the state with a state that is specific to them, and
329 // when you get it back you should insert that value into your
330 // state somehow. For example, in a resolve()r with two child
331 // style values a and b:
332 // let ourState;
333 // if (settings.firstTime)
334 // ourState = { a: null, b: null };
335 // else
336 // ourState = settings.state;
337 // settings.state = ourState.a;
338 // let aResult = a.resolve(node, settings);
339 // ourState.a = settings.state;
340 // settings.state = ourState.b;
341 // let aResult = b.resolve(node, settings);
342 // ourState.b = settings.state;
343 // settings.state = ourState;
344 // return a + b; // or whatever
318 } 345 }
319 346
320 class Property : StyleNode { 347 class Property : StyleNode {
321 constructor (AbstractStyleDeclaration parentNode, PropertyHandle property, Abs tractStyleValue? initialValue = null); 348 constructor (AbstractStyleDeclaration parentNode, PropertyHandle property, Abs tractStyleValue? initialValue = null);
322 readonly attribute AbstractStyleDeclaration parentNode; 349 readonly attribute AbstractStyleDeclaration parentNode;
323 readonly attribute PropertyHandle property; 350 readonly attribute PropertyHandle property;
324 readonly attribute AbstractStyleValue value; 351 readonly attribute AbstractStyleValue value;
325 352
326 void setValue(AbstractStyleValue? newValue); 353 void setValue(AbstractStyleValue? newValue);
327 // updates value and calls markDirty() 354 // updates value and calls markDirty()
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 can call them from their paint() functions. 965 can call them from their paint() functions.
939 966
940 967
941 968
942 Default Styles 969 Default Styles
943 -------------- 970 --------------
944 971
945 In the constructors for the default elements, they add to themselves 972 In the constructors for the default elements, they add to themselves
946 StyleDeclaration objects as follows: 973 StyleDeclaration objects as follows:
947 974
948 * ``import``
949 * ``template``
950 * ``style``
951 * ``script``
952 * ``content``
953 * ``title``
954 These all add to themselves the same declaration as follows:
955 ```javascript
956 let d = new StyleDeclaration();
957 d[pDisplay] = new ObjectStyleValue(null);
958 this.style.addStyles(d);
959 ```
960
961 * ``img``
962 This adds to itself the declaration as follows:
963 ```javascript
964 let d = new StyleDeclaration();
965 d[pDisplay] = new ObjectStyleValue(ImageElementLayoutManager);
966 this.style.addStyles(d);
967 ```
968
969 * ``span`` 975 * ``span``
970 * ``a`` 976 * ``a``
971 These all add to themselves the same declaration as follows: 977 These all add to themselves the same declaration as follows:
972 ```javascript 978 ```javascript
973 let d = new StyleDeclaration(); 979 let d = new StyleDeclaration();
974 d[pDisplay] = new ObjectStyleValue(InlineLayoutManager); 980 d[pDisplay] = new ObjectStyleValue(InlineLayoutManager);
975 this.style.addStyles(d); 981 this.style.addStyles(d);
976 ``` 982 ```
977 983
978 * ``iframe``
979 This adds to itself the declaration as follows:
980 ```javascript
981 let d = new StyleDeclaration();
982 d[pDisplay] = new ObjectStyleValue(IFrameElementLayoutManager);
983 this.style.addStyles(d);
984 ```
985
986 * ``t`` 984 * ``t``
987 This adds to itself the declaration as follows: 985 This adds to itself the declaration as follows:
988 ```javascript 986 ```javascript
989 let d = new StyleDeclaration(); 987 let d = new StyleDeclaration();
990 d[pDisplay] = new ObjectStyleValue(ParagraphLayoutManager); 988 d[pDisplay] = new ObjectStyleValue(ParagraphLayoutManager);
991 this.style.addStyles(d); 989 this.style.addStyles(d);
992 ``` 990 ```
993 991
994 * ``error`` 992 The other elements doe't have any default styles.
995 This adds to itself the declaration as follows:
996 ```javascript
997 let d = new StyleDeclaration();
998 d[pDisplay] = new ObjectStyleValue(ErrorLayoutManager);
999 this.style.addStyles(d);
1000 ```
1001
1002 The ``div`` element doesn't have any default styles.
1003 993
1004 These declarations are all shared between all the elements (so e.g. if 994 These declarations are all shared between all the elements (so e.g. if
1005 you reach in and change the declaration that was added to a ``title`` 995 you reach in and change the declaration that was added to a ``span``
1006 element, you're going to change the styles of all the other 996 element, you're going to change the styles of all the other
1007 default-hidden elements). (In other words, in the code snippets above, 997 default-hidden elements). (In other words, in the code snippets above,
1008 the ``d`` variable is initialised in shared code, and only the 998 the ``d`` variable is initialised in shared code, and only the
1009 addStyles() call is per-element.) 999 addStyles() call is per-element.)
OLDNEW
« no previous file with comments | « sky/specs/modules.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698