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

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

Issue 850593003: Examples: move markAsLaidOut() to just before the return, so the asserts work (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/examples/style/toolbar-layout.sky ('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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 any state = null; 285 any state = null;
286 } 286 }
287 287
288 class StyleValueResolverSettings { 288 class StyleValueResolverSettings {
289 // this is used as an "out" parameter for 'resolve()' below 289 // this is used as an "out" parameter for 'resolve()' below
290 constructor(StyleValueResolverSettingsSettings initial); 290 constructor(StyleValueResolverSettingsSettings initial);
291 void reset(StyleValueResolverSettingsSettings initial); 291 void reset(StyleValueResolverSettingsSettings initial);
292 // sets firstTime and state to given values 292 // sets firstTime and state to given values
293 // sets layoutDependent to false 293 // sets layoutDependent to false
294 // sets dependencies to empty set 294 // sets dependencies to empty set
295 // sets lifetime to Infinity
295 296
296 readonly attribute Boolean firstTime; 297 readonly attribute Boolean firstTime;
297 // true if this is the first time this property is being resolved for this e lement, 298 // true if this is the first time this property is being resolved for this e lement,
298 // or if the last time it was resolved, the value was a different object 299 // or if the last time it was resolved, the value was a different object
299 300
300 // attribute Boolean layoutDependent 301 // attribute Boolean layoutDependent
301 void setLayoutDependent(); 302 void setLayoutDependent();
302 // call this if the value should be recomputed each time the ownerLayoutMana ger's dimensions change, rather than being cached 303 // call this if the value should be recomputed each time the ownerLayoutMana ger's dimensions change, rather than being cached
303 Boolean getLayoutDependent(); 304 Boolean getLayoutDependent();
304 // returns true if setLayoutDependent has been called since the last reset() 305 // returns true if setLayoutDependent has been called since the last reset()
305 306
306 // attribute "BitField" dependencies; // defaults to no bits set 307 // attribute "BitField" dependencies; // defaults to no bits set
307 void dependsOn(PropertyHandle property); 308 void dependsOn(PropertyHandle property);
308 // if the given property doesn't have a dependency bit assigned: 309 // if the given property doesn't have a dependency bit assigned:
309 // - assign the next bit to the property 310 // - assign the next bit to the property
310 // - if there's no bits left, throw 311 // - if there's no bits left, throw
311 // set the bit on this StyleValueResolverSettings's dependencies bitfield 312 // set the bit on this StyleValueResolverSettings's dependencies bitfield
312 Array<PropertyHandle> getDependencies(); 313 Array<PropertyHandle> getDependencies();
313 // returns an array of the PropertyHandle values for the bits that are set i n dependencies 314 // returns an array of the PropertyHandle values for the bits that are set i n dependencies
314 315
316 // attribute (Float or Infinity) lifetime;
317 void setLifetime(Float age);
318 // if the new value is less than the current value of lifetime, update the c urrent value
319 (Float or Infinity) getLifetime();
320 // return current value of lfietime
321
315 attribute any state; // initially null, can be set to store value for this Ren derNode/property pair 322 attribute any state; // initially null, can be set to store value for this Ren derNode/property pair
316 // for example, TransitioningColorStyleValue would store 323 // for example, TransitioningColorStyleValue would store
317 // { 324 // {
318 // initial: /* color at time of transition */, 325 // initial: /* color at time of transition */,
319 // target: /* color at end of transition */, 326 // target: /* color at end of transition */,
320 // start: /* time at start of transition */, 327 // start: /* time at start of transition */,
321 // } 328 // }
322 // ...which would enable it to update appropriately, and would also 329 // ...which would enable it to update appropriately, and would also
323 // let other transitions that come later know that you were half-way 330 // let other transitions that come later know that you were half-way
324 // through a transition so they can shorten their time accordingly 331 // through a transition so they can shorten their time accordingly
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 468
462 ```javascript 469 ```javascript
463 abstract class AbstractStyleDeclarationList { 470 abstract class AbstractStyleDeclarationList {
464 void addStyles(StyleDeclaration styles, String pseudoElement = ''); // O(1) 471 void addStyles(StyleDeclaration styles, String pseudoElement = ''); // O(1)
465 void removeStyles(StyleDeclaration styles, String pseudoElement = ''); // O(N) in number of declarations 472 void removeStyles(StyleDeclaration styles, String pseudoElement = ''); // O(N) in number of declarations
466 Array<StyleDeclaration> getDeclarations(String pseudoElement = ''); // O(N) in number of declarations 473 Array<StyleDeclaration> getDeclarations(String pseudoElement = ''); // O(N) in number of declarations
467 } 474 }
468 475
469 class ElementStyleDeclarationList : AbstractStyleDeclarationList { 476 class ElementStyleDeclarationList : AbstractStyleDeclarationList {
470 constructor (Element? element); 477 constructor (Element? element);
478 readonly attribute Element? element;
471 479
472 // there are two batches of styles in an ElementStyleDeclarationList. 480 // there are two batches of styles in an ElementStyleDeclarationList.
473 481
474 // the first batch is the per-frame styles; these get (conceptually) 482 // the first batch is the per-frame styles; these get (conceptually)
475 // cleared each frame, after which all the matching rules in relevant 483 // cleared each frame, after which all the matching rules in relevant
476 // <style> blocks get added back in, followed by all the animation- 484 // <style> blocks get added back in, followed by all the animation-
477 // derived rules; scripts can also add styles themselves, but they are 485 // derived rules; scripts can also add styles themselves, but they are
478 // dropped after the next frame 486 // dropped after the next frame
479 void addFrameStyles(StyleDeclaration styles, String pseudoElement = ''); // O( 1) 487 void addFrameStyles(StyleDeclaration styles, String pseudoElement = ''); // O( 1)
480 void clearFrameStyles(); 488 void clearFrameStyles();
481 489
482 // the second batch is the persistent styles, which remain until removed; 490 // the second batch is the persistent styles, which remain until removed;
483 // they are accessed via the AbstractStyleDeclarationList accessors 491 // they are accessed via the AbstractStyleDeclarationList accessors
484 492
485 // as StyleDeclarations are added and removed, the ElementStyleDeclarationList 493 // as StyleDeclarations are added and removed, the ElementStyleDeclarationList
486 // calls register(element) and unregister(element) respectively on those 494 // calls register(element) and unregister(element) respectively on those
487 // StyleDeclaration objects, where element is the element that was passed 495 // StyleDeclaration objects, where element is the element that was passed
488 // to the constructor, if not null 496 // to the constructor, if not null
489 // then, it calls element.renderNode.cascadedValueChanged 497 // then, it calls element.renderNode.cascadedValueChanged
490 // for each property on the object 498 // for each property on the object
491 499
492 // the inherited getDeclarations() method returns all the frame 500 // the inherited getDeclarations() method returns all the frame
493 // styles followed by all the persistent styles, in insertion order 501 // styles followed by all the persistent styles, in insertion order
494 } 502 }
495 503
496 class RenderNodeStyleDeclarationList : AbstractStyleDeclarationList { 504 class RenderNodeStyleDeclarationList : AbstractStyleDeclarationList {
497 constructor (RenderNode? renderNode); 505 constructor (RenderNode? renderNode);
506 readonly attribute RenderNode? renderNode;
498 507
499 // as StyleDeclarations are added and removed, the RenderNodeStyleDeclarationL ist 508 // as StyleDeclarations are added and removed, the RenderNodeStyleDeclarationL ist
500 // calls register(renderNode) and unregister(renderNode) respectively on those 509 // calls register(renderNode) and unregister(renderNode) respectively on those
501 // StyleDeclaration objects, where renderNode is the RenderNode that was passe d 510 // StyleDeclaration objects, where renderNode is the RenderNode that was passe d
502 // to the constructor, if not null 511 // to the constructor, if not null
503 // then, it calls renderNode.cascadedValueChanged 512 // then, it calls renderNode.cascadedValueChanged
504 // for each property on the object 513 // for each property on the object
505 } 514 }
506 515
507 class StyleDeclaration { 516 class StyleDeclaration {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // - pseudoElement, property => StyleValue object, resolved value, StyleVal ueResolverSettings, cascade dirty bit, value dirty bit 647 // - pseudoElement, property => StyleValue object, resolved value, StyleVal ueResolverSettings, cascade dirty bit, value dirty bit
639 // - property state map (initially empty), as follows: 648 // - property state map (initially empty), as follows:
640 // - pseudoElement, property => object 649 // - pseudoElement, property => object
641 650
642 any getProperty(PropertyHandle property, GetPropertySettings? settings = null) ; 651 any getProperty(PropertyHandle property, GetPropertySettings? settings = null) ;
643 // looking at the cached data for the given pseudoElement: 652 // looking at the cached data for the given pseudoElement:
644 // if there's a cached value: 653 // if there's a cached value:
645 // if settings.forceCache is true, return the cached value 654 // if settings.forceCache is true, return the cached value
646 // if neither dirty bit is set, return the cached value 655 // if neither dirty bit is set, return the cached value
647 // if the cascade dirty bit is not set (value dirty is set) then 656 // if the cascade dirty bit is not set (value dirty is set) then
648 // resolve the value using the same StyleValue object 657 // - clear any pending lifetime-enforcing tasks for this
649 // - with firstTime=false on the resolver settings 658 // property/pseudoElement pair on this render node
650 // - with the cached state object if any 659 // - resolve the value using the same StyleValue object
651 // - jump to "cache" below 660 // - with firstTime=false on the resolver settings
661 // - with the cached state object if any
662 // - jump to "cache" below
652 // if settings.forceCache is true, return null 663 // if settings.forceCache is true, return null
664 // - clear any pending lifetime-enforcing tasks for this
665 // property/pseudoElement pair on this render node
653 // - if there's an override declaration with the property (with 666 // - if there's an override declaration with the property (with
654 // the pseudo or without), then get the value object from there and 667 // the pseudo or without), then get the value object from there
655 // jump to "resolve" below.
656 // - if there's an element and it has a style declaration with the property
657 // (with the pseudo or without), then get the value object from there
658 // and jump to "resolve" below. 668 // and jump to "resolve" below.
659 // - if it's not an inherited property, or if there's no parent, then get t he 669 // - if there's an element and it has a style declaration with
660 // default value and jump to "resolve" below. 670 // the property (with the pseudo or without), then get the
661 // - call the parent render node's getProperty() with the same property 671 // value object from there and jump to "resolve" below.
662 // but no settings, then cache that value as the value for this element 672 // - if it's not an inherited property, or if there's no parent,
663 // with the given pseudoElement, with no StyleValue object, no resolver 673 // then get the default value and jump to "resolve" below.
664 // settings, and set the state to null. 674 // - call the parent render node's getProperty() with the same
675 // property but no settings, then cache that value as the value
676 // for this element with the given pseudoElement, with no
677 // StyleValue object, no resolver settings, and set the state
678 // to null.
665 // resolve: 679 // resolve:
666 // - get a new resolver settings object 680 // - get a new resolver settings object (or reset an existing one)
667 // - if the obtained StyleValue object is different than the 681 // - if the obtained StyleValue object is different than the
668 // cached StyleValue object, or if there is no cached object, then set 682 // cached StyleValue object, or if there is no cached
669 // the resolver settings to firstTime=true, otherwise it's the same obj ect 683 // object, then set the resolver settings to
670 // and set firstTime=false. 684 // firstTime=true, otherwise it's the same object and set
671 // - set the resolver settings' state to the current state for this 685 // firstTime=false.
672 // pseudoElement/property combination 686 // - set the resolver settings' state to the current state
687 // for this pseudoElement/property combination
673 // - using the obtained StyleValue object, call resolve(), 688 // - using the obtained StyleValue object, call resolve(),
674 // passing it this node and the resolver settings object. 689 // passing it this node and the resolver settings object.
675 // - jump to "cache" below 690 // - jump to "cache" below
676 // cache: 691 // cache:
677 // - update the cache with the obtained value and resolver settings 692 // - update the cache with the obtained value and resolver
693 // settings
678 // - reset the dirty bits 694 // - reset the dirty bits
679 // - if the resolver settings' getShouldSaveState() method returns false, 695 // - if the resolver settings' getShouldSaveState() method
680 // then discard any cached state, otherwise, cache the new state 696 // returns false, then discard any cached state, otherwise,
697 // cache the new state
698 // - if the resolver settings' lifetime is not infinity, then
699 // queue a lifetime-enforcing task for the appropriate time
700 // in the future which calls cascadedValueDirty for this
701 // property/pseudoElement pair on this render node
681 702
682 readonly attribute RenderNodeStyleDeclarationList overrideStyles; 703 readonly attribute RenderNodeStyleDeclarationList overrideStyles;
683 // mutable; initially empty 704 // mutable; initially empty
684 // this is used when isGhost is true, and can also be used more generally t o 705 // this is used when isGhost is true, and can also be used more generally t o
685 // override styles from the layout manager (e.g. to animate a new node into view) 706 // override styles from the layout manager (e.g. to animate a new node into view)
686 707
687 private void cascadedValueChanged(PropertyHandle property, String pseudoElemen t = ''); 708 private void cascadedValueChanged(PropertyHandle property, String pseudoElemen t = '');
688 private void cascadedValueDirty(PropertyHandle property, String pseudoElement = ''); 709 private void cascadedValueDirty(PropertyHandle property, String pseudoElement = '');
689 // - set the appropriate dirty bit on the cached data for this property/pseu doElement pair 710 // - set the appropriate dirty bit on the cached data for this property/pseu doElement pair
690 // - cascade dirty for cascadedValueChanged 711 // - cascade dirty for cascadedValueChanged
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 ```javascript 791 ```javascript
771 callback LayoutManagerConstructor LayoutManager (RenderNode node); 792 callback LayoutManagerConstructor LayoutManager (RenderNode node);
772 793
773 class LayoutManager : EventTarget { 794 class LayoutManager : EventTarget {
774 readonly attribute RenderNode node; 795 readonly attribute RenderNode node;
775 constructor LayoutManager(RenderNode node); 796 constructor LayoutManager(RenderNode node);
776 // sets needsManager to false on the node 797 // sets needsManager to false on the node
777 798
778 readonly attribute Boolean autoreap; 799 readonly attribute Boolean autoreap;
779 // defaults to true 800 // defaults to true
780 // when true, any children that are isNew are automatically welcomed by the default layout() 801 // when true, children that are added don't get set to isNew=true
781 // when true, children that are removed don't get set to isGhost=true, they' re just removed 802 // when true, children that are removed don't get set to isGhost=true, they' re just removed
782 803
783 virtual Array<EventTarget> getEventDispatchChain(); // O(N) in number of this. node's ancestors // implements EventTarget.getEventDispatchChain() 804 virtual Array<EventTarget> getEventDispatchChain(); // O(N) in number of this. node's ancestors // implements EventTarget.getEventDispatchChain()
784 // let result = []; 805 // let result = [];
785 // let node = this.node; 806 // let node = this.node;
786 // while (node && node.layoutManager) { 807 // while (node && node.layoutManager) {
787 // result.push(node.layoutManager); 808 // result.push(node.layoutManager);
788 // node = node.parentNode; 809 // node = node.parentNode;
789 // } 810 // }
790 // return result; 811 // return result;
791 812
792 void setProperty(RenderNode node, PropertyHandle property, any value, String p seudoElement = ''); // O(1) 813 void setProperty(RenderNode node, PropertyHandle property, any value, String p seudoElement = ''); // O(1)
793 // if called from an adjustProperties() method during the property adjustmen t phase,
794 // replaces the value that getProperty() would return on that node with /val ue/ 814 // replaces the value that getProperty() would return on that node with /val ue/
795 // this also clears the dependency bits and sets the property state to null 815 // this also clears the dependency bits, dirty bits, and sets the property s tate to null
816 // this also clears any relevant lifetime-enforcing tasks
796 817
797 void take(RenderNode victim); // sets victim.ownerLayoutManager = this; 818 void take(RenderNode victim); // sets victim.ownerLayoutManager = this;
798 // assert: victim hasn't been take()n yet during this layout 819 // assert: victim hasn't been take()n yet during this layout
799 // assert: victim.needsLayout == true
800 // assert: an ancestor of victim has node.layoutManager == this (aka, victim is a descendant of this.node) 820 // assert: an ancestor of victim has node.layoutManager == this (aka, victim is a descendant of this.node)
801 821
802 virtual void release(RenderNode victim); 822 virtual void release(RenderNode victim);
803 // called when the RenderNode was removed from the tree 823 // called when the RenderNode was removed from the tree
804 824
805 virtual void childAdded(RenderNode child); 825 virtual void childAdded(RenderNode child);
806 virtual void childRemoved(RenderNode child); 826 virtual void childRemoved(RenderNode child);
807 // called when a child has its isNew or isGhost attributes set respectively 827 // called when a child has its isNew or isGhost attributes set respectively
808 828
809 void setChildPosition(child, x, y); // sets child.x, child.y 829 void setChildPosition(child, x, y); // sets child.x, child.y
810 void setChildX(child, y); // sets child.x 830 void setChildX(child, y); // sets child.x
811 void setChildY(child, y); // sets child.y 831 void setChildY(child, y); // sets child.y
812 void setChildSize(child, width, height); // sets child.width, child.height 832 void setChildSize(child, width, height); // sets child.width, child.height
813 void setChildWidth(child, width); // sets child.width 833 void setChildWidth(child, width); // sets child.width
814 void setChildHeight(child, height); // sets child.height 834 void setChildHeight(child, height); // sets child.height
835 // assert: child.ownerLayoutManager == this
815 // for setChildSize/Width/Height: if the new dimension is different than the last assumed dimensions, and 836 // for setChildSize/Width/Height: if the new dimension is different than the last assumed dimensions, and
816 // any RenderNodes with an ownerLayoutManager==this have cached values for g etProperty() that are marked 837 // any RenderNodes with an ownerLayoutManager==this have cached values for g etProperty() that are marked
817 // as layout-dependent, clear them 838 // as layout-dependent, mark them as dirty with cascadedValueDirty()
818 void welcomeChild(child); // resets child.isNew
819 void reapChild(child); // resets child.isGhost
820
821 Generator<RenderNode> walkChildren();
822 // returns a generator that iterates over the children, skipping any whose o wnerLayoutManager is not |this|
823
824 Generator<RenderNode> walkChildrenBackwards();
825 // returns a generator that iterates over the children backwards, skipping a ny whose ownerLayoutManager is not |this|
826 839
827 void assumeDimensions(Float width, Float height); 840 void assumeDimensions(Float width, Float height);
828 // sets the assumed dimensions for calls to getProperty() on RenderNodes tha t have this as an ownerLayoutManager 841 // sets the assumed dimensions for calls to getProperty() on RenderNodes tha t have this as an ownerLayoutManager,
842 // by updating renderNode width/height;
829 // if the new dimension is different than the last assumed dimensions, and a ny RenderNodes with an 843 // if the new dimension is different than the last assumed dimensions, and a ny RenderNodes with an
830 // ownerLayoutManager==this have cached values for getProperty() that are ma rked as layout-dependent, clear them 844 // ownerLayoutManager==this have cached values for getProperty() that are ma rked as layout-dependent, mark them
831 // TODO(ianh): should we force this to match the input to layout(), when cal led from inside layout() and when 845 // as dirty with cascadedValueDirty()
832 // layout() has a forced width and/or height?
833 846
834 virtual LayoutValueRange getIntrinsicWidth(Float? defaultWidth = null); 847 virtual LayoutValueRange getIntrinsicWidth(Float? defaultWidth = null);
835 /* 848 /*
836 function getIntrinsicWidth(defaultWidth) { 849 function getIntrinsicWidth(defaultWidth) {
837 if (defaultWidth == null) { 850 if (defaultWidth == null) {
838 defaultWidth = this.node.getProperty('width'); 851 defaultWidth = this.node.getProperty('width');
839 if (typeof defaultWidth != 'number') 852 if (typeof defaultWidth != 'number')
840 defaultWidth = 0; 853 defaultWidth = 0;
841 } 854 }
842 let minWidth = this.node.getProperty('min-width'); 855 let minWidth = this.node.getProperty('min-width');
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (defaultHeight < minHeight) 893 if (defaultHeight < minHeight)
881 defaultHeight = minHeight; 894 defaultHeight = minHeight;
882 return { 895 return {
883 minimum: minHeight, 896 minimum: minHeight,
884 value: defaultHeight, 897 value: defaultHeight,
885 maximum: maxHeight, 898 maximum: maxHeight,
886 }; 899 };
887 } 900 }
888 */ 901 */
889 902
903 void welcomeChild(child); // resets child.isNew
904 void reapChild(child); // resets child.isGhost
905
906 Generator<RenderNode> walkChildren();
907 // returns a generator that iterates over the children, skipping any whose o wnerLayoutManager is not |this|
908
909 Generator<RenderNode> walkChildrenBackwards();
910 // returns a generator that iterates over the children backwards, skipping a ny whose ownerLayoutManager is not |this|
911
890 void markAsLaidOut(); // sets this.node.needsLayout and this.node.descendantNe edsLayout to false 912 void markAsLaidOut(); // sets this.node.needsLayout and this.node.descendantNe edsLayout to false
891 virtual Dimensions layout(Float? width, Float? height); 913 virtual Dimensions layout(Float? width, Float? height);
892 // call markAsLaidOut();
893 // if autoreap is true: use walkChildren() to call welcomeChild() and reapCh ild() on each child
894 // if width is null, set width to getIntrinsicWidth().value 914 // if width is null, set width to getIntrinsicWidth().value
895 // if height is null, set width height getIntrinsicHeight().value 915 // if height is null, set height to getIntrinsicHeight().value
896 // call this.assumeDimensions(width, height); 916 // call this.assumeDimensions(width, height);
897 // call this.layoutChildren(width, height); 917 // call this.layoutChildren(width, height);
918 // call markAsLaidOut();
898 // return { width: width, height: height } 919 // return { width: width, height: height }
899 // - this should always call this.markAsLaidOut() to reset needsLayout 920 // - this should always call this.markAsLaidOut() to reset
900 // - the return value should include the final value for whichever of the wi dth and height arguments 921 // needsLayout and descendantNeedsLayout
901 // that is null 922 // - the return value should include the final value for whichever
902 // - subclasses that want to make 'auto' values dependent on the children sh ould override this 923 // of the width and height arguments that is null
903 // entirely, rather than overriding layoutChildren 924 // - subclasses that want to make 'auto' values dependent on the
925 // children should override this entirely, rather than
926 // overriding layoutChildren; but see layoutChildren()'s notes
927 // for how to do this
904 928
905 virtual void layoutChildren(Float width, Float height); 929 virtual void layoutChildren(Float width, Float height);
906 // default implementation does nothing 930 // default implementation does nothing
907 // - override this if you want to lay out children but not have the children affect your dimensions 931 // - override only this (and not layout()) if you want to lay out
932 // children but not have the children affect your dimensions
933 // - always call setChildSize() and setChildPosition() after
934 // calling a child's layout() method
935 // - if the child has needsLayout or if you need to have it
936 // autosize, call its ownerLayoutManager's layout() method
937 // - otherwise if the child has needs descendantNeedsLayout, call
938 // layoutDescendants()
939
940 virtual Dimensions layoutDescendants();
941 // assert: node.needsLayout is false, node.descendantNeedsLayout is true
942 // walk children:
943 // - if it has needsLayout, call its layout() method with its
944 // current width and height, then call setChildSize() with
945 // those same dimensions
946 // - else, if it has descendantNeedsLayout, call its
947 // layoutDescendants() method
948 // call markAsLaidOut();
949 // - override this if you use take() to control more children, in
950 // which case you should call their methods too
951 // - this should always call this.markAsLaidOut() to reset
952 // needsLayout and descendantNeedsLayout
908 953
909 virtual void paint(RenderingSurface canvas); 954 virtual void paint(RenderingSurface canvas);
910 // set a clip rect on the canvas for rect(0,0,this.width,this.height) 955 // set a clip rect on the canvas for rect(0,0,this.width,this.height)
911 // (? we don't really have to do this; consider shadows...) 956 // (? we don't really have to do this; consider shadows...)
912 // call the painter of each property, in order they were registered, which o n this element has a painter 957 // call the painter of each property, in order they were registered, which o n this element has a painter
913 // call this.paintChildren(canvas) 958 // call this.paintChildren(canvas)
914 // (the default implementation doesn't paint anything on top of the children ) 959 // (the default implementation doesn't paint anything on top of the children )
915 // unset the clip 960 // unset the clip
916 // - this gets called by the system if: 961 // - this gets called by the system if:
917 // - you are in your parent's current display list and it's in its parent 's and so on up to the top, and 962 // - you are in your parent's current display list and it's in its parent 's and so on up to the top, and
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 ``` 1057 ```
1013 1058
1014 The other elements don't have any default styles. 1059 The other elements don't have any default styles.
1015 1060
1016 These declarations are all shared between all the elements (so e.g. if 1061 These declarations are all shared between all the elements (so e.g. if
1017 you reach in and change the declaration that was added to a ``span`` 1062 you reach in and change the declaration that was added to a ``span``
1018 element, you're going to change the styles of all the other 1063 element, you're going to change the styles of all the other
1019 default-hidden elements). (In other words, in the code snippets above, 1064 default-hidden elements). (In other words, in the code snippets above,
1020 the ``d`` variable is initialised in shared code, and only the 1065 the ``d`` variable is initialised in shared code, and only the
1021 addStyles() call is per-element.) 1066 addStyles() call is per-element.)
OLDNEW
« no previous file with comments | « sky/examples/style/toolbar-layout.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698