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

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

Issue 792993002: Specs: Tentative approach for enabling removing/adding/moving children (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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 | « no previous file | 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 constructor (Array<StyleToken> tokens); 189 constructor (Array<StyleToken> tokens);
190 IteratorResult next(); 190 IteratorResult next();
191 TokenSourceBookmark getBookmark(); 191 TokenSourceBookmark getBookmark();
192 void rewind(TokenSourceBookmark bookmark); 192 void rewind(TokenSourceBookmark bookmark);
193 } 193 }
194 class TokenSourceBookmark { 194 class TokenSourceBookmark {
195 constructor (); 195 constructor ();
196 // TokenSource stores unforgeable state on this object using symbols or a weak map or some such 196 // TokenSource stores unforgeable state on this object using symbols or a weak map or some such
197 } 197 }
198 198
199 // TODO(ianh): this is a non-starter, we need something better to handle units a nd custom painting
199 dictionary ParsedValue { 200 dictionary ParsedValue {
200 any value = null; 201 any value = null;
201 ValueResolver? resolver = null; 202 ValueResolver? resolver = null;
202 Boolean relativeDimension = false; // if true, e.g. for % lengths, the callbac k will be called again if an ancestor's dimensions change 203 Boolean relativeDimension = false; // if true, e.g. for % lengths, the callbac k will be called again if an ancestor's dimensions change
203 Painter? painter = null; 204 Painter? painter = null;
204 } 205 }
205 206
206 // best practice convention: if you're creating a property with needsPaint, you should 207 // best practice convention: if you're creating a property with needsPaint, you should
207 // create a new style value type for it so that it can set the paint callback ri ght; 208 // create a new style value type for it so that it can set the paint callback ri ght;
208 // you should never use such a style type when parsing another property 209 // you should never use such a style type when parsing another property
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 readonly attribute LayoutManager layoutManager; 387 readonly attribute LayoutManager layoutManager;
387 readonly attribute LayoutManager ownerLayoutManager; // defaults to the parent Node.layoutManager 388 readonly attribute LayoutManager ownerLayoutManager; // defaults to the parent Node.layoutManager
388 // if you are not the ownerLayoutManager, then ignore this StyleNode in layo ut() and paintChildren() 389 // if you are not the ownerLayoutManager, then ignore this StyleNode in layo ut() and paintChildren()
389 // using walkChildren() does this for you 390 // using walkChildren() does this for you
390 391
391 // only the ownerLayoutManager can change these 392 // only the ownerLayoutManager can change these
392 readonly attribute Float x; // relative to left edge of ownerLayoutManager 393 readonly attribute Float x; // relative to left edge of ownerLayoutManager
393 readonly attribute Float y; // relative to top edge of ownerLayoutManager 394 readonly attribute Float y; // relative to top edge of ownerLayoutManager
394 readonly attribute Float width; 395 readonly attribute Float width;
395 readonly attribute Float height; 396 readonly attribute Float height;
397 readonly attribute Boolean isNew; // node has just been added (and maybe you w ant to animate it in)
398 readonly attribute Boolean isGhost; // node has just been removed (and maybe y ou want to animate it away)
396 } 399 }
397 ``` 400 ```
398 401
399 The flattened tree is represented as a hierarchy of Node objects. For 402 The flattened tree is represented as a hierarchy of Node objects. For
400 any element that only contains text node children, the "text" property 403 any element that only contains text node children, the "text" property
401 is set accordingly. For elements with mixed text node and non-text 404 is set accordingly. For elements with mixed text node and non-text
402 node children, each run of text nodes is represented as a separate 405 node children, each run of text nodes is represented as a separate
403 Node with the "text" property set accordingly and the styles set as if 406 Node with the "text" property set accordingly and the styles set as if
404 the Node inherited everything inheritable from its parent. 407 the Node inherited everything inheritable from its parent.
405 408
(...skipping 27 matching lines...) Expand all
433 - 'none': null 436 - 'none': null
434 437
435 438
436 Layout managers inherit from the following API: 439 Layout managers inherit from the following API:
437 440
438 ```javascript 441 ```javascript
439 class LayoutManager : EventTarget { 442 class LayoutManager : EventTarget {
440 readonly attribute StyleNode node; 443 readonly attribute StyleNode node;
441 constructor LayoutManager(StyleNode node); 444 constructor LayoutManager(StyleNode node);
442 445
446 readonly attribute Boolean autoreap;
447 // defaults to true
448 // when true, any children that are isNew or isGhost are welcomed/reaped imp licitly by default layout()
449
443 virtual Array<EventTarget> getEventDispatchChain(); // O(N) in number of this. node's ancestors // implements EventTarget.getEventDispatchChain() 450 virtual Array<EventTarget> getEventDispatchChain(); // O(N) in number of this. node's ancestors // implements EventTarget.getEventDispatchChain()
444 // let result = []; 451 // let result = [];
445 // let node = this.node; 452 // let node = this.node;
446 // while (node && node.layoutManager) { 453 // while (node && node.layoutManager) {
447 // result.push(node.layoutManager); 454 // result.push(node.layoutManager);
448 // node = node.parentNode; 455 // node = node.parentNode;
449 // } 456 // }
450 // return result; 457 // return result;
451 458
452 void take(StyleNode victim); // sets victim.ownerLayoutManager = this; 459 void take(StyleNode victim); // sets victim.ownerLayoutManager = this;
453 // assert: victim hasn't been take()n yet during this layout 460 // assert: victim hasn't been take()n yet during this layout
454 // assert: victim.needsLayout == true 461 // assert: victim.needsLayout == true
455 // assert: an ancestor of victim has node.layoutManager == this (aka, victim is a descendant of this.node) 462 // assert: an ancestor of victim has node.layoutManager == this (aka, victim is a descendant of this.node)
456 463
457 virtual void release(StyleNode victim); 464 virtual void release(StyleNode victim);
458 // called when the StyleNode was removed from the tree 465 // called when the StyleNode was removed from the tree
459 466
460 void setChildPosition(child, x, y); // sets child.x, child.y 467 void setChildPosition(child, x, y); // sets child.x, child.y
461 void setChildX(child, y); // sets child.x 468 void setChildX(child, y); // sets child.x
462 void setChildY(child, y); // sets child.y 469 void setChildY(child, y); // sets child.y
463 void setChildSize(child, width, height); // sets child.width, child.height 470 void setChildSize(child, width, height); // sets child.width, child.height
464 void setChildWidth(child, width); // sets child.width 471 void setChildWidth(child, width); // sets child.width
465 void setChildHeight(child, height); // sets child.height 472 void setChildHeight(child, height); // sets child.height
466 // for setChildSize/Width/Height: if the new dimension is different than the last assumed dimensions, and 473 // for setChildSize/Width/Height: if the new dimension is different than the last assumed dimensions, and
467 // any StyleNodes with an ownerLayoutManager==this have cached values for ge tProperty() that are marked 474 // any StyleNodes with an ownerLayoutManager==this have cached values for ge tProperty() that are marked
468 // as provisional, clear them 475 // as provisional, clear them
476 void welcomeChild(child); // resets child.isNew
477 void reapChild(child); // resets child.isGhost
469 478
470 Generator<StyleNode> walkChildren(); 479 Generator<StyleNode> walkChildren();
471 // returns a generator that iterates over the children, skipping any whose o wnerLayoutManager is not |this| 480 // returns a generator that iterates over the children, skipping any whose o wnerLayoutManager is not |this|
472 481
473 Generator<StyleNode> walkChildrenBackwards(); 482 Generator<StyleNode> walkChildrenBackwards();
474 // returns a generator that iterates over the children backwards, skipping a ny whose ownerLayoutManager is not |this| 483 // returns a generator that iterates over the children backwards, skipping a ny whose ownerLayoutManager is not |this|
475 484
476 void assumeDimensions(Float width, Float height); 485 void assumeDimensions(Float width, Float height);
477 // sets the assumed dimensions for calls to getProperty() on StyleNodes that have this as an ownerLayoutManager 486 // sets the assumed dimensions for calls to getProperty() on StyleNodes that have this as an ownerLayoutManager
478 // if the new dimension is different than the last assumed dimensions, and a ny StyleNodes with an 487 // if the new dimension is different than the last assumed dimensions, and a ny StyleNodes with an
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 minimum: minHeight, 541 minimum: minHeight,
533 value: defaultHeight, 542 value: defaultHeight,
534 maximum: maxHeight, 543 maximum: maxHeight,
535 }; 544 };
536 } 545 }
537 */ 546 */
538 547
539 void markAsLaidOut(); // sets this.node.needsLayout and this.node.descendantNe edsLayout to false 548 void markAsLaidOut(); // sets this.node.needsLayout and this.node.descendantNe edsLayout to false
540 virtual Dimensions layout(Number? width, Number? height); 549 virtual Dimensions layout(Number? width, Number? height);
541 // call markAsLaidOut(); 550 // call markAsLaidOut();
551 // if autoreap is true: use walkChildren() to call welcomeChild() and reapCh ild() on each child
542 // if width is null, set width to getIntrinsicWidth().value 552 // if width is null, set width to getIntrinsicWidth().value
543 // if height is null, set width height getIntrinsicHeight().value 553 // if height is null, set width height getIntrinsicHeight().value
544 // call this.assumeDimensions(width, height); 554 // call this.assumeDimensions(width, height);
545 // call this.layoutChildren(width, height); 555 // call this.layoutChildren(width, height);
546 // return { width: width, height: height } 556 // return { width: width, height: height }
547 // - this should always call this.markAsLaidOut() to reset needsLayout 557 // - this should always call this.markAsLaidOut() to reset needsLayout
548 // - the return value should include the final value for whichever of the wi dth and height arguments 558 // - the return value should include the final value for whichever of the wi dth and height arguments
549 // that is null 559 // that is null
550 // - subclasses that want to make 'auto' values dependent on the children sh ould override this 560 // - subclasses that want to make 'auto' values dependent on the children sh ould override this
551 // entirely, rather than overriding layoutChildren 561 // entirely, rather than overriding layoutChildren
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 ```javascript 678 ```javascript
669 { display: { value: sky.ErrorLayoutManager } } 679 { display: { value: sky.ErrorLayoutManager } }
670 ``` 680 ```
671 681
672 The ``div`` element doesn't have any default styles. 682 The ``div`` element doesn't have any default styles.
673 683
674 These declarations are all shared between all the elements (so e.g. if 684 These declarations are all shared between all the elements (so e.g. if
675 you reach in and change the declaration that was added to a ``title`` 685 you reach in and change the declaration that was added to a ``title``
676 element, you're going to change the styles of all the other 686 element, you're going to change the styles of all the other
677 default-hidden elements). 687 default-hidden elements).
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698