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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 489 |
490 | 490 |
491 Cascade | 491 Cascade |
492 ------- | 492 ------- |
493 | 493 |
494 Simultaneously walk the tree rooted at the application Document, | 494 Simultaneously walk the tree rooted at the application Document, |
495 taking into account shadow trees and child distribution, and the tree | 495 taking into account shadow trees and child distribution, and the tree |
496 rooted at the document's RenderNode. | 496 rooted at the document's RenderNode. |
497 | 497 |
498 If you come across a node that doesn't have an assigned RenderNode, | 498 If you come across a node that doesn't have an assigned RenderNode, |
499 then create one and mark it "isNew", and place it in the appropriate | 499 then create one, placing it in the appropriate place in the RenderTree |
500 place in the RenderTree tree, after any nodes marked isGhost. | 500 tree, after any nodes marked isGhost=true, with ownerLayoutManager |
| 501 pointing to the parent RenderNode's layoutManager, and then, if |
| 502 autoreap is false on the ownerLayoutManager, mark it "isNew". |
501 | 503 |
502 For each element, if the node's needsManager is true, call | 504 For each element, if the node's needsManager is true, call |
503 getLayoutManager() on the element, and if that's not null, and if the | 505 getLayoutManager() on the element, and if that's not null, and if the |
504 returned class isn't the same class as the current layoutManager, if | 506 returned class isn't the same class as the current layoutManager, if |
505 any, construct the given class and assign it to the RenderNode's | 507 any, construct the given class and assign it to the RenderNode's |
506 layoutManager, then set all the child RenderNodes' ownerLayoutManager | 508 layoutManager, then set all the child RenderNodes' ownerLayoutManager |
507 to that object; if it returns null, and that node already has a | 509 to that object; if it returns null, and that node already has a |
508 layoutManager, then set isGhost=true for that node and all its | 510 layoutManager, then set isGhost=true for that node and all its |
509 children (without changing the layoutManager). Otherwise, if it | 511 children (without changing the layoutManager). Otherwise, if it |
510 returned null and there's already no layoutManager, remove the node | 512 returned null and there's already no layoutManager, remove the node |
511 from the tree. Then, in any case, clear the needsManager bit. | 513 from the tree. Then, in any case, clear the needsManager bit. |
512 | 514 |
513 When an Element or Text node is to be removed from its parent, and it | 515 When an Element or Text node is to be removed from its parent, and it |
514 has a renderNode, and that renderNode has an ownerLayoutManager with | 516 has a renderNode, and that renderNode has an ownerLayoutManager with |
515 autoreap=false, then before actually removing the node, the node's | 517 autoreap=false, then before actually removing the node, the node's |
516 renderNode should be marked isGhost=true, and the relevant | 518 renderNode should be marked isGhost=true, and the relevant |
517 ElementStyleDeclarationList should be flattened and the values stored on | 519 ElementStyleDeclarationList should be flattened and the values stored on |
518 the RenderNode's overrideStyles for use later. (Or we can just clone the | 520 the RenderNode's overrideStyles for use later. (Or we can just clone the |
519 StyleDeclarations directly without flattening. That would probably | 521 StyleDeclarations directly without flattening. That would probably |
520 be faster.) | 522 be faster.) |
521 | 523 |
522 When an Element is to be removed from its parent, regardless of the | 524 When an Element is to be removed from its parent, regardless of the |
523 above, the node's renderNode attribute should be nulled out. | 525 above, the node's renderNode attribute should be nulled out. |
524 | 526 |
| 527 When a RenderNode is added with isNew=true, call its parent |
| 528 RenderNode's LayoutManager's childAdded() callback. When a a |
| 529 RenderNode has its isGhost property set to true, then call it's parent |
| 530 RenderNode's LayoutManager's childRemoved() callback. |
| 531 |
525 | 532 |
526 ```javascript | 533 ```javascript |
527 callback any ValueResolver (any value, String propertyName, RenderNode node, Flo
at containerWidth, Float containerHeight); | 534 callback any ValueResolver (any value, String propertyName, RenderNode node, Flo
at containerWidth, Float containerHeight); |
528 | 535 |
529 class RenderNode { // implemented in C++ with no virtual tables | 536 class RenderNode { // implemented in C++ with no virtual tables |
530 // this is generated before layout | 537 // this is generated before layout |
531 readonly attribute String text; | 538 readonly attribute String text; |
532 readonly attribute Node? parentNode; | 539 readonly attribute Node? parentNode; |
533 readonly attribute Node? firstChild; | 540 readonly attribute Node? firstChild; |
534 readonly attribute Node? nextSibling; | 541 readonly attribute Node? nextSibling; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 // replaces the value that getProperty() would return on that node with /val
ue/ | 668 // replaces the value that getProperty() would return on that node with /val
ue/ |
662 | 669 |
663 void take(RenderNode victim); // sets victim.ownerLayoutManager = this; | 670 void take(RenderNode victim); // sets victim.ownerLayoutManager = this; |
664 // assert: victim hasn't been take()n yet during this layout | 671 // assert: victim hasn't been take()n yet during this layout |
665 // assert: victim.needsLayout == true | 672 // assert: victim.needsLayout == true |
666 // assert: an ancestor of victim has node.layoutManager == this (aka, victim
is a descendant of this.node) | 673 // assert: an ancestor of victim has node.layoutManager == this (aka, victim
is a descendant of this.node) |
667 | 674 |
668 virtual void release(RenderNode victim); | 675 virtual void release(RenderNode victim); |
669 // called when the RenderNode was removed from the tree | 676 // called when the RenderNode was removed from the tree |
670 | 677 |
| 678 virtual void childAdded(RenderNode child); |
| 679 virtual void childRemoved(RenderNode child); |
| 680 // called when a child has its isNew or isGhost attributes set respectively |
| 681 |
671 void setChildPosition(child, x, y); // sets child.x, child.y | 682 void setChildPosition(child, x, y); // sets child.x, child.y |
672 void setChildX(child, y); // sets child.x | 683 void setChildX(child, y); // sets child.x |
673 void setChildY(child, y); // sets child.y | 684 void setChildY(child, y); // sets child.y |
674 void setChildSize(child, width, height); // sets child.width, child.height | 685 void setChildSize(child, width, height); // sets child.width, child.height |
675 void setChildWidth(child, width); // sets child.width | 686 void setChildWidth(child, width); // sets child.width |
676 void setChildHeight(child, height); // sets child.height | 687 void setChildHeight(child, height); // sets child.height |
677 // for setChildSize/Width/Height: if the new dimension is different than the
last assumed dimensions, and | 688 // for setChildSize/Width/Height: if the new dimension is different than the
last assumed dimensions, and |
678 // any RenderNodes with an ownerLayoutManager==this have cached values for g
etProperty() that are marked | 689 // any RenderNodes with an ownerLayoutManager==this have cached values for g
etProperty() that are marked |
679 // as layout-dependent, clear them | 690 // as layout-dependent, clear them |
680 void welcomeChild(child); // resets child.isNew | 691 void welcomeChild(child); // resets child.isNew |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 ``` | 922 ``` |
912 | 923 |
913 The ``div`` element doesn't have any default styles. | 924 The ``div`` element doesn't have any default styles. |
914 | 925 |
915 These declarations are all shared between all the elements (so e.g. if | 926 These declarations are all shared between all the elements (so e.g. if |
916 you reach in and change the declaration that was added to a ``title`` | 927 you reach in and change the declaration that was added to a ``title`` |
917 element, you're going to change the styles of all the other | 928 element, you're going to change the styles of all the other |
918 default-hidden elements). (In other words, in the code snippets above, | 929 default-hidden elements). (In other words, in the code snippets above, |
919 the ``d`` variable is initialised in shared code, and only the | 930 the ``d`` variable is initialised in shared code, and only the |
920 addStyles() call is per-element.) | 931 addStyles() call is per-element.) |
OLD | NEW |