| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 Sky Style uses whatever SelectorQuery. Maybe one day we'll make | 136 Sky Style uses whatever SelectorQuery. Maybe one day we'll make |
| 137 SelectorQuery support being extended to support arbitrary selectors, | 137 SelectorQuery support being extended to support arbitrary selectors, |
| 138 but for now, it supports: | 138 but for now, it supports: |
| 139 | 139 |
| 140 tagname | 140 tagname |
| 141 #id | 141 #id |
| 142 .class | 142 .class |
| 143 [attrname] | 143 [attrname] |
| 144 [attrname=value] | 144 [attrname=value] |
| 145 :host | 145 :host ("host" string is fixed) |
| 146 ::pseudo-element |
| 146 | 147 |
| 147 These can be combined (without whitespace), with at most one tagname, | 148 These can be combined (without whitespace), with at most one tagname |
| 148 as in: | 149 (must be first) and at most one pseudo-element (must be last) as in: |
| 149 | 150 |
| 150 tagname[attrname]#id:host.class.class[attrname=value] | 151 tagname[attrname]#id:host.class.class[attrname=value]::foo |
| 151 | 152 |
| 152 In debug mode, giving two IDs, or the same selector twice (e.g. the | 153 In debug mode, giving two IDs, or the same selector twice (e.g. the |
| 153 same classname), or specifying other redundant or conflicting | 154 same classname), or specifying other redundant or conflicting |
| 154 selectors (e.g. [foo][foo=bar], or [foo=bar][foo=baz]) will be | 155 selectors (e.g. [foo][foo=bar], or [foo=bar][foo=baz]) will be |
| 155 flagged. | 156 flagged. |
| 156 | 157 |
| 157 Alternatively, a selector can be the following special value: | 158 Alternatively, a selector can be the special value "@document", |
| 159 optionally followed by a pseudo-element, as in: |
| 158 | 160 |
| 159 @document | 161 @document::bar |
| 160 | 162 |
| 161 | 163 |
| 162 Value Parser | 164 Value Parser |
| 163 ------------ | 165 ------------ |
| 164 | 166 |
| 165 class StyleToken { | 167 class StyleToken { |
| 166 constructor (String king, String value); | 168 constructor (String king, String value); |
| 167 readonly attribute String kind; | 169 readonly attribute String kind; |
| 168 // string | 170 // string |
| 169 // identifier | 171 // identifier |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 247 |
| 246 Inline Styles | 248 Inline Styles |
| 247 ------------- | 249 ------------- |
| 248 | 250 |
| 249 partial class Element { | 251 partial class Element { |
| 250 readonly attribute StyleDeclarationList style; | 252 readonly attribute StyleDeclarationList style; |
| 251 } | 253 } |
| 252 | 254 |
| 253 class StyleDeclarationList { | 255 class StyleDeclarationList { |
| 254 constructor (); | 256 constructor (); |
| 255 void add(StyleDeclaration styles); // O(1) // in debug mode, throws if the dic
tionary 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 |
| 256 void remove(StyleDeclaration styles); // O(N) in number of declarations | 258 void remove(StyleDeclaration styles, String? pseudoElement = null); // O(N) in
number of declarations |
| 257 Array<StyleDeclaration> getDeclarations(); // O(N) in number of declarations | 259 Array<StyleDeclaration> getDeclarations(String? pseudoElement = null); // O(N)
in number of declarations |
| 258 } | 260 } |
| 259 | 261 |
| 260 typedef StyleDeclaration Dictionary<ParsedValue>; | 262 typedef StyleDeclaration Dictionary<ParsedValue>; |
| 261 | 263 |
| 262 | 264 |
| 263 Rule Matching | 265 Rule Matching |
| 264 ------------- | 266 ------------- |
| 265 | 267 |
| 266 partial class StyleElement { | 268 partial class StyleElement { |
| 267 Array<Rule> getRules(); // O(N) in rules | 269 Array<Rule> getRules(); // O(N) in rules |
| 268 } | 270 } |
| 269 | 271 |
| 270 class Rule { | 272 class Rule { |
| 271 constructor (); | 273 constructor (); |
| 272 attribute SelectorQuery selector; // O(1) | 274 attribute SelectorQuery selector; // O(1) |
| 275 attribute String? pseudoElement; // O(1) |
| 273 attribute StyleDeclaration styles; // O(1) | 276 attribute StyleDeclaration styles; // O(1) |
| 274 } | 277 } |
| 275 | 278 |
| 276 Each frame, at some defined point relative to requestAnimationFrame(): | 279 Each frame, at some defined point relative to requestAnimationFrame(): |
| 277 - If a rule starts applying to an element, sky:core calls thatElement.style.add
(rule.styles); | 280 - If a rule starts applying to an element, sky:core calls thatElement.style.add
(rule.styles, rule.pseudoElement); |
| 278 - If a rule stops applying to an element, sky:core calls thatElement.style.remo
ve(rule.styles); | 281 - If a rule stops applying to an element, sky:core calls thatElement.style.remo
ve(rule.styles, rule.pseudoElement); |
| 279 | 282 |
| 280 | 283 |
| 281 Cascade | 284 Cascade |
| 282 ------- | 285 ------- |
| 283 | 286 |
| 284 For each Element, the StyleDeclarationList is conceptually flattened | 287 For each Element, the StyleDeclarationList is conceptually flattened |
| 285 so that only the last declaration mentioning a property is left. | 288 so that only the last declaration mentioning a property is left. |
| 286 | 289 |
| 287 Create the flattened render tree as a tree of StyleNode objects | 290 Create the flattened render tree as a tree of StyleNode objects |
| 288 (described below). For each one, run the equivalent of the following | 291 (described below). For each one, run the equivalent of the following |
| (...skipping 18 matching lines...) Expand all Loading... |
| 307 callback any ValueResolver (any value, String propertyName, StyleNode node, Fl
oat containerWidth, Float containerHeight); | 310 callback any ValueResolver (any value, String propertyName, StyleNode node, Fl
oat containerWidth, Float containerHeight); |
| 308 | 311 |
| 309 class StyleNode { | 312 class StyleNode { |
| 310 // this is generated before layout | 313 // this is generated before layout |
| 311 readonly attribute String text; | 314 readonly attribute String text; |
| 312 readonly attribute Node? parentNode; | 315 readonly attribute Node? parentNode; |
| 313 readonly attribute Node? firstChild; | 316 readonly attribute Node? firstChild; |
| 314 readonly attribute Node? nextSibling; | 317 readonly attribute Node? nextSibling; |
| 315 | 318 |
| 316 // access to the results of the cascade | 319 // access to the results of the cascade |
| 317 any getProperty(String name); | 320 any getProperty(String name, String? pseudoElement = null); |
| 321 // looking at the declarations for the given pseudoElement: |
| 318 // if there's a cached value, return it | 322 // if there's a cached value, return it |
| 319 // otherwise, if there's an applicable ParsedValue, then | 323 // otherwise, if there's an applicable ParsedValue, then |
| 320 // if it has a resolver: | 324 // if it has a resolver: |
| 321 // call it | 325 // call it |
| 322 // cache the value | 326 // cache the value |
| 323 // if relativeDimension is true, then mark the value as provisional | 327 // if relativeDimension is true, then mark the value as provisional |
| 324 // return the value | 328 // return the value |
| 325 // otherwise use the ParsedValue's value; cache it; return it | 329 // otherwise use the ParsedValue's value; cache it; return it |
| 330 // otherwise, if a pseudo-element was specified, try again without one |
| 326 // otherwise, if the property is inherited and there's a parent: | 331 // otherwise, if the property is inherited and there's a parent: |
| 327 // get it from the parent; cache it; return it | 332 // get it from the parent (without pseudo); cache it; return it |
| 328 // otherwise, get the default value; cache it; return it | 333 // otherwise, get the default value; cache it; return it |
| 329 | 334 |
| 330 readonly attribute Boolean needsLayout; // means that a property with needsL
ayout:true has changed on this node or one of its descendants | 335 readonly attribute Boolean needsLayout; // means that a property with needsL
ayout:true has changed on this node or one of its descendants |
| 331 readonly attribute LayoutManager layoutManager; | 336 readonly attribute LayoutManager layoutManager; |
| 332 | 337 |
| 333 readonly attribute LayoutManager ownerLayoutManager; // defaults to the pare
ntNode.layoutManager | 338 readonly attribute LayoutManager ownerLayoutManager; // defaults to the pare
ntNode.layoutManager |
| 334 // if you are not the ownerLayoutManager, then ignore this StyleNode in la
yout() and paintChildren() | 339 // if you are not the ownerLayoutManager, then ignore this StyleNode in la
yout() and paintChildren() |
| 335 // using walkChildren() does this for you | 340 // using walkChildren() does this for you |
| 336 | 341 |
| 337 readonly attribute Boolean needsPaint; // means that either needsLayout is t
rue or a property with needsPaint:true has changed on this node or one of its de
scendants | 342 readonly attribute Boolean needsPaint; // means that either needsLayout is t
rue or a property with needsPaint:true has changed on this node or one of its de
scendants |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 * ``error`` | 506 * ``error`` |
| 502 This adds to itself the declaration with value: | 507 This adds to itself the declaration with value: |
| 503 ``{ display: { value: sky.ErrorLayoutManager } }`` | 508 ``{ display: { value: sky.ErrorLayoutManager } }`` |
| 504 | 509 |
| 505 The ``div`` element doesn't have any default styles. | 510 The ``div`` element doesn't have any default styles. |
| 506 | 511 |
| 507 These declarations are all shared between all the elements (so e.g. if | 512 These declarations are all shared between all the elements (so e.g. if |
| 508 you reach in and change the declaration that was added to a ``title`` | 513 you reach in and change the declaration that was added to a ``title`` |
| 509 element, you're going to change the styles of all the other | 514 element, you're going to change the styles of all the other |
| 510 default-hidden elements). | 515 default-hidden elements). |
| OLD | NEW |