| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 ------------- | 249 ------------- |
| 250 | 250 |
| 251 partial class Element { | 251 partial class Element { |
| 252 readonly attribute StyleDeclarationList style; | 252 readonly attribute StyleDeclarationList style; |
| 253 } | 253 } |
| 254 | 254 |
| 255 class StyleDeclarationList { | 255 class StyleDeclarationList { |
| 256 constructor (); | 256 constructor (); |
| 257 void add(StyleDeclaration styles, String? pseudoElement = null); // O(1) // in
debug mode, throws if the dictionary has any properties that aren't registered | 257 void add(StyleDeclaration styles, String? pseudoElement = null); // O(1) // in
debug mode, throws if the dictionary has any properties that aren't registered |
| 258 void remove(StyleDeclaration styles, String? pseudoElement = null); // O(N) in
number of declarations | 258 void remove(StyleDeclaration styles, String? pseudoElement = null); // O(N) in
number of declarations |
| 259 // TODO(ianh): Need to support inserting rules preserving order somehow |
| 259 Array<StyleDeclaration> getDeclarations(String? pseudoElement = null); // O(N)
in number of declarations | 260 Array<StyleDeclaration> getDeclarations(String? pseudoElement = null); // O(N)
in number of declarations |
| 260 } | 261 } |
| 261 | 262 |
| 262 typedef StyleDeclaration Dictionary<ParsedValue>; | 263 typedef StyleDeclaration Dictionary<ParsedValue>; |
| 263 | 264 |
| 264 | 265 |
| 265 Rule Matching | 266 Rule Matching |
| 266 ------------- | 267 ------------- |
| 267 | 268 |
| 268 partial class StyleElement { | 269 partial class StyleElement { |
| 269 Array<Rule> getRules(); // O(N) in rules | 270 Array<Rule> getRules(); // O(N) in rules |
| 270 } | 271 } |
| 271 | 272 |
| 272 class Rule { | 273 class Rule { |
| 273 constructor (); | 274 constructor (); |
| 274 attribute SelectorQuery selector; // O(1) | 275 attribute SelectorQuery selector; // O(1) |
| 275 attribute String? pseudoElement; // O(1) | 276 attribute String? pseudoElement; // O(1) |
| 276 attribute StyleDeclaration styles; // O(1) | 277 attribute StyleDeclaration styles; // O(1) |
| 277 } | 278 } |
| 278 | 279 |
| 279 Each frame, at some defined point relative to requestAnimationFrame(): | 280 Each frame, at some defined point relative to requestAnimationFrame(): |
| 280 - If a rule starts applying to an element, sky:core calls thatElement.style.add
(rule.styles, rule.pseudoElement); | 281 - If a rule starts applying to an element, sky:core calls thatElement.style.add
(rule.styles, rule.pseudoElement); |
| 281 - If a rule stops applying to an element, sky:core calls thatElement.style.remo
ve(rule.styles, rule.pseudoElement); | 282 - If a rule stops applying to an element, sky:core calls thatElement.style.remo
ve(rule.styles, rule.pseudoElement); |
| 282 | 283 |
| 284 TODO(ianh): fix the above so that rule order is maintained |
| 285 |
| 283 | 286 |
| 284 Cascade | 287 Cascade |
| 285 ------- | 288 ------- |
| 286 | 289 |
| 287 For each Element, the StyleDeclarationList is conceptually flattened | 290 For each Element, the StyleDeclarationList is conceptually flattened |
| 288 so that only the last declaration mentioning a property is left. | 291 so that only the last declaration mentioning a property is left. |
| 289 | 292 |
| 290 Create the flattened render tree as a tree of StyleNode objects | 293 Create the flattened render tree as a tree of StyleNode objects |
| 291 (described below). For each one, run the equivalent of the following | 294 (described below). For each one, run the equivalent of the following |
| 292 code: | 295 code: |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 * ``error`` | 509 * ``error`` |
| 507 This adds to itself the declaration with value: | 510 This adds to itself the declaration with value: |
| 508 ``{ display: { value: sky.ErrorLayoutManager } }`` | 511 ``{ display: { value: sky.ErrorLayoutManager } }`` |
| 509 | 512 |
| 510 The ``div`` element doesn't have any default styles. | 513 The ``div`` element doesn't have any default styles. |
| 511 | 514 |
| 512 These declarations are all shared between all the elements (so e.g. if | 515 These declarations are all shared between all the elements (so e.g. if |
| 513 you reach in and change the declaration that was added to a ``title`` | 516 you reach in and change the declaration that was added to a ``title`` |
| 514 element, you're going to change the styles of all the other | 517 element, you're going to change the styles of all the other |
| 515 default-hidden elements). | 518 default-hidden elements). |
| OLD | NEW |