| OLD | NEW |
| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 Inline Styles | 255 Inline Styles |
| 256 ------------- | 256 ------------- |
| 257 | 257 |
| 258 ```javascript | 258 ```javascript |
| 259 partial class Element { | 259 partial class Element { |
| 260 readonly attribute StyleDeclarationList style; | 260 readonly attribute StyleDeclarationList style; |
| 261 } | 261 } |
| 262 | 262 |
| 263 class StyleDeclarationList { | 263 class StyleDeclarationList { |
| 264 constructor (); | 264 constructor (); |
| 265 void add(StyleDeclaration styles, String? pseudoElement = null); // O(1) // in
debug mode, throws if the dictionary has any properties that aren't registered | 265 |
| 266 void remove(StyleDeclaration styles, String? pseudoElement = null); // O(N) in
number of declarations | 266 // There are two batches of styles in a StyleDeclarationList. |
| 267 // TODO(ianh): Need to support inserting rules preserving order somehow | 267 |
| 268 // The first batch is the per-frame styles. These get cleared each |
| 269 // frame, after which all the matching rules in relevant <style> blocks |
| 270 // get added back in, followed by all the animation-derived rules. |
| 271 // Scripts can add styles themselves. |
| 272 void addFrameStyles(StyleDeclaration styles, String? pseudoElement = null); //
O(1) |
| 273 void clearFrameStyles(); |
| 274 |
| 275 // The second batch is the persistent styles. |
| 276 // Once added, they remain forever until removed. |
| 277 void addPersistentStyles(StyleDeclaration styles, String? pseudoElement = null
); // O(1) |
| 278 void removePersistentStyles(StyleDeclaration styles, String? pseudoElement = n
ull); // O(N) in number of declarations |
| 279 |
| 280 // This returns all the frame styles followed by all the persistent styles, in
insertion order. |
| 268 Array<StyleDeclaration> getDeclarations(String? pseudoElement = null); // O(N)
in number of declarations | 281 Array<StyleDeclaration> getDeclarations(String? pseudoElement = null); // O(N)
in number of declarations |
| 269 } | 282 } |
| 270 | 283 |
| 271 typedef StyleDeclaration Dictionary<ParsedValue>; | 284 typedef StyleDeclaration Dictionary<ParsedValue>; |
| 272 ``` | 285 ``` |
| 273 | 286 |
| 274 Rule Matching | 287 Rule Matching |
| 275 ------------- | 288 ------------- |
| 276 | 289 |
| 277 ```javascript | 290 ```javascript |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 be dropped from the render tree. | 330 be dropped from the render tree. |
| 318 | 331 |
| 319 If any node is removed in this pass relative to the previous pass, and | 332 If any node is removed in this pass relative to the previous pass, and |
| 320 it has an ownerLayoutManager, then call | 333 it has an ownerLayoutManager, then call |
| 321 | 334 |
| 322 ```javascript | 335 ```javascript |
| 323 node.ownerLayoutManager.release(node) | 336 node.ownerLayoutManager.release(node) |
| 324 ``` | 337 ``` |
| 325 | 338 |
| 326 ...to notify the layout manager that the node went away, then set the | 339 ...to notify the layout manager that the node went away, then set the |
| 327 node's layoutManager and ownerLayoutManager attributes to null. | 340 node's ownerLayoutManager attribute to null. |
| 328 | 341 |
| 329 ```javascript | 342 ```javascript |
| 343 partial class Element { |
| 344 readonly attribute StyleNode? layout; // TODO(ianh): come up with a better nam
e (sadly "style" is taken) |
| 345 // this will be null until the first time it is rendered |
| 346 } |
| 347 |
| 330 callback any ValueResolver (any value, String propertyName, StyleNode node, Floa
t containerWidth, Float containerHeight); | 348 callback any ValueResolver (any value, String propertyName, StyleNode node, Floa
t containerWidth, Float containerHeight); |
| 331 | 349 |
| 332 class StyleNode { | 350 class StyleNode { |
| 333 // this is generated before layout | 351 // this is generated before layout |
| 334 readonly attribute String text; | 352 readonly attribute String text; |
| 335 readonly attribute Node? parentNode; | 353 readonly attribute Node? parentNode; |
| 336 readonly attribute Node? firstChild; | 354 readonly attribute Node? firstChild; |
| 337 readonly attribute Node? nextSibling; | 355 readonly attribute Node? nextSibling; |
| 338 | 356 |
| 339 // access to the results of the cascade | 357 // access to the results of the cascade |
| 358 // only works during layout and painting |
| 340 any getProperty(String name, String? pseudoElement = null); | 359 any getProperty(String name, String? pseudoElement = null); |
| 360 // throw if this isn't during layout or painting |
| 361 // TODO(ianh): if the implementation of this does allow it to be queried
the rest of the time too, relax this constraint |
| 341 // looking at the declarations for the given pseudoElement: | 362 // looking at the declarations for the given pseudoElement: |
| 342 // if there's a cached value, return it | 363 // if there's a cached value, return it |
| 343 // otherwise, if there's an applicable ParsedValue, then | 364 // otherwise, if there's an applicable ParsedValue, then |
| 344 // if it has a resolver: | 365 // if it has a resolver: |
| 345 // call it | 366 // call it |
| 346 // cache the value | 367 // cache the value |
| 347 // if relativeDimension is true, then mark the value as provisional | 368 // if relativeDimension is true, then mark the value as provisional |
| 348 // return the value | 369 // return the value |
| 349 // otherwise use the ParsedValue's value; cache it; return it | 370 // otherwise use the ParsedValue's value; cache it; return it |
| 350 // otherwise, if a pseudo-element was specified, try again without one | 371 // otherwise, if a pseudo-element was specified, try again without one |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 ```javascript | 657 ```javascript |
| 637 { display: { value: sky.ErrorLayoutManager } } | 658 { display: { value: sky.ErrorLayoutManager } } |
| 638 ``` | 659 ``` |
| 639 | 660 |
| 640 The ``div`` element doesn't have any default styles. | 661 The ``div`` element doesn't have any default styles. |
| 641 | 662 |
| 642 These declarations are all shared between all the elements (so e.g. if | 663 These declarations are all shared between all the elements (so e.g. if |
| 643 you reach in and change the declaration that was added to a ``title`` | 664 you reach in and change the declaration that was added to a ``title`` |
| 644 element, you're going to change the styles of all the other | 665 element, you're going to change the styles of all the other |
| 645 default-hidden elements). | 666 default-hidden elements). |
| OLD | NEW |