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

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

Issue 805083008: Specs: More cleanup around the proposed style model to make things more consistent. (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 | « sky/specs/apis.md ('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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 /* 221 /*
222 StyleNode 222 StyleNode
223 | 223 |
224 +-- Property 224 +-- Property
225 | 225 |
226 +-- AbstractStyleValue 226 +-- AbstractStyleValue
227 | 227 |
228 +-- NumericStyleValue 228 +-- NumericStyleValue
229 | | 229 | |
230 | +-- AnimatableNumericStyleValue 230 | +-- AnimatableNumericStyleValue*
231 | 231 |
232 +-- LengthStyleValue 232 +-- LengthStyleValue
233 | | 233 | |
234 | +-- AnimatableLengthStyleValue 234 | +-- AnimatableLengthStyleValue*
235 | | 235 | |
236 | +-- PixelLengthStyleValue 236 | +-- PixelLengthStyleValue
237 | | 237 | |
238 | +-- EmLengthStyleValue 238 | +-- EmLengthStyleValue*
239 | | 239 | |
240 | +-- VHLengthStyleValue 240 | +-- VHLengthStyleValue*
241 | | 241 | |
242 | +-- CalcLengthStyleValue 242 | +-- CalcLengthStyleValue*
243 | 243 |
244 +-- ColorStyleValue 244 +-- ColorStyleValue
245 | | 245 | |
246 | +-- RGBColorStyleValue 246 | +-- RGBColorStyleValue
247 | | 247 | |
248 | +-- AnimatableColorStyleValue 248 | +-- AnimatableColorStyleValue*
249 | 249 |
250 +-- AbstractStringStyleValue 250 +-- AbstractOpaqueStyleValue
251 | | 251 | |
252 | +-- IdentifierStyleValue 252 | +-- IdentifierStyleValue
253 | | | 253 | | |
254 | | +-- AnimatableIdentifierStyleValue 254 | | +-- AnimatableIdentifierStyleValue*
255 | | 255 | |
256 | +-- URLStyleValue 256 | +-- URLStyleValue*
257 | | | 257 | | |
258 | | +-- AnimatableURLStyleValue 258 | | +-- AnimatableURLStyleValue*
259 | | 259 | |
260 | +-- StringStyleValue 260 | +-- StringStyleValue*
261 | | 261 | | |
262 | +-- AnimatableStringStyleValue 262 | | +-- AnimatableStringStyleValue*
263 | |
264 | +-- ObjectStyleValue
263 | 265 |
264 +-- PrimitiveValuesListStyleValue 266 +-- PrimitiveValuesListStyleValue*
265 */ 267 */
268 ```
266 269
270 The types marked with * in the list above are not part of sky:core.
271
272 ```javascript
267 abstract class StyleNode { 273 abstract class StyleNode {
268 abstract void markDirty(); 274 abstract void markDirty();
269 } 275 }
270 276
271 class StyleValueResolverSettings { 277 class StyleValueResolverSettings {
272 // this is used as an "out" parameter for 'resolve()' below 278 // this is used as an "out" parameter for 'resolve()' below
273 constructor(); 279 constructor();
274 void reset(); // resets values to defaults so that object can be reused 280 void reset(); // resets values to defaults so that object can be reused
275 attribute Boolean layoutDependent; // default to false 281 attribute Boolean layoutDependent; // default to false
276 // set this if the value should be recomputed each time the ownerLayoutManag er's dimensions change, rather than being precomputed 282 // set this if the value should be recomputed each time the ownerLayoutManag er's dimensions change, rather than being precomputed
277 283
278 // attribute "BitField" dependencies; // defaults to no bits set 284 // attribute "BitField" dependencies; // defaults to no bits set
279 void dependsOn(PropertyHandle property); 285 void dependsOn(PropertyHandle property);
280 // if the given property doesn't have a dependency bit assigned: 286 // if the given property doesn't have a dependency bit assigned:
281 // - assign the next bit to the property 287 // - assign the next bit to the property
282 // - if there's no bits left, throw 288 // - if there's no bits left, throw
283 // set the bit on this StyleValueResolverSettings's dependencies bitfield 289 // set the bit on this StyleValueResolverSettings's dependencies bitfield
284 } 290 }
285 291
286 class Property : StyleNode { 292 class Property : StyleNode {
287 constructor (StyleDeclaration parentNode, PropertyHandle property, AbstractSty leValue? initialValue = null); 293 constructor (AbstractStyleDeclaration parentNode, PropertyHandle property, Abs tractStyleValue? initialValue = null);
288 readonly attribute StyleDeclaration parentNode; 294 readonly attribute AbstractStyleDeclaration parentNode;
289 readonly attribute PropertyHandle property; 295 readonly attribute PropertyHandle property;
290 readonly attribute AbstractStyleValue value; 296 readonly attribute AbstractStyleValue value;
291 297
292 void setValue(AbstractStyleValue? newValue); 298 void setValue(AbstractStyleValue? newValue);
293 // updates value and calls markDirty() 299 // updates value and calls markDirty()
294 300
295 void markDirty(); 301 void markDirty();
296 // call parentNode.markDirty(property); 302 // call parentNode.markDirty(property);
297 303
298 abstract any resolve(RenderNode node, StyleValueResolverSettings? settings = n ull); 304 abstract any resolve(RenderNode node, StyleValueResolverSettings? settings = n ull);
299 // if value is null, returns null 305 // if value is null, returns null
300 // otherwise, returns value.resolve(property, node, settings) 306 // otherwise, returns value.resolve(property, node, settings)
301 } 307 }
302 308
303 abstract class AbstractStyleValue : StyleNode { 309 abstract class AbstractStyleValue : StyleNode {
304 abstract constructor(StyleNode parentNode); 310 abstract constructor(StyleNode parentNode);
305 readonly attribute StyleNode parentNode; 311 readonly attribute StyleNode parentNode;
306 312
307 void markDirty(); 313 void markDirty();
308 // call this.parentNode.markDirty() 314 // call this.parentNode.markDirty()
309 315
310 abstract any resolve(PropertyHandle property, RenderNode node, StyleValueResol verSettings? settings = null); 316 abstract any resolve(PropertyHandle property, RenderNode node, StyleValueResol verSettings? settings = null);
311 } 317 }
312 318
313 abstract class LengthStyleValue : AbstractStyleValue { 319 abstract class LengthStyleValue : AbstractStyleValue {
314 abstract Float resolve(PropertyHandle property, RenderNode node, StyleValueRes olverSettings? settings = null); 320 abstract Float resolve(PropertyHandle property, RenderNode node, StyleValueRes olverSettings? settings = null);
315 } 321 }
316 322
317 class PixelLengthStyleValue : LengthStyleValue { 323 class PixelLengthStyleValue : LengthStyleValue {
324 constructor(StyleNode parentNode, Float number);
325 readonly attribute Float value;
318 Float resolve(PropertyHandle property, RenderNode node, StyleValueResolverSett ings? settings = null); 326 Float resolve(PropertyHandle property, RenderNode node, StyleValueResolverSett ings? settings = null);
319 } 327 }
320 328
321 // ... 329 typedef Color Float; // TODO(ianh): figure out what Color should be
330 class ColorStyleValue : LengthStyleValue {
331 constructor(StyleNode parentNode, Float red, Float green, Float blue, Float al pha);
332 // ... color API ...
333 Color resolve(PropertyHandle property, RenderNode node, StyleValueResolverSett ings? settings = null);
334 }
335
336 class AbstractOpaqueStyleValue : AbstractStyleValue {
337 abstract constructor(StyleNode parentNode, any value);
338 readonly attribute any value;
339 any resolve(PropertyHandle property, RenderNode node, StyleValueResolverSettin gs? settings = null);
340 // returns value
341 }
342
343 class IdentifierStyleValue : AbstractOpaqueStyleValue {
344 constructor(StyleNode parentNode, String value);
345 // calls superclass constructor
346 }
347
348 /*
349 class AnimatableIdentifierStyleValue : AbstractOpaqueStyleValue {
350 constructor(StyleNode parentNode, String value, String newValue, AnimationFunc tion player);
351 readonly attribute String newValue;
352 readonly attribute AnimationFunction player;
353 any resolve(PropertyHandle property, RenderNode node, StyleValueResolverSettin gs? settings = null);
354 }
355 */
356
357 class ObjectStyleValue : AbstractOpaqueStyleValue {
358 constructor(StyleNode parentNode, any value);
359 // calls superclass constructor
360 }
322 361
323 dictionary PropertySettings { 362 dictionary PropertySettings {
324 String name; 363 String name;
325 StyleGrammar grammar; 364 StyleGrammar grammar;
326 Boolean inherited = false; 365 Boolean inherited = false;
327 any initialValue = null; 366 any initialValue = null;
328 Boolean needsManager = false; 367 Boolean needsManager = false;
329 Boolean needsLayout = false; 368 Boolean needsLayout = false;
330 Boolean needsPaint = false; 369 Boolean needsPaint = false;
331 // PropertyHandle propertyHandle; // assigned by registerProperty 370 // PropertyHandle propertyHandle; // assigned by registerProperty
332 // Integer dependencyBit; // assigned by StyleValueResolverSettings.dependsOn( ) 371 // Integer dependencyBit; // assigned by StyleValueResolverSettings.dependsOn( )
333 } 372 }
334 typedef PropertyHandle Integer; 373 typedef PropertyHandle Integer;
335 PropertyHandle registerProperty(PropertySettings propertySettings); 374 PropertyHandle registerProperty(PropertySettings propertySettings);
336 375
337 // sky:core exports a bunch of style grammars so that people can extend them 376 // sky:core exports a bunch of style grammars so that people can extend them
338 attribute StyleGrammar PositiveLengthOrInfinityStyleGrammar; // resolves to Floa t 377 attribute StyleGrammar PositiveLengthOrInfinityStyleGrammar; // resolves to Leng thStyleValue
339 attribute StyleGrammar PositiveLengthOrAutoStyleGrammar; // resolves to Float or null 378 attribute StyleGrammar PositiveLengthOrAutoStyleGrammar; // resolves to LengthSt yleValue or IdentifierStyleValue (with value 'auto')
340 attribute StyleGrammar PositiveLengthStyleGrammar; // resolves to Float 379 attribute StyleGrammar PositiveLengthStyleGrammar; // resolves to LengthStyleVal ue
341 attribute StyleGrammar NumberGrammar; // resolves to Float 380 attribute StyleGrammar NumberGrammar; // resolves to NumericStyleValue
342 attribute StyleGrammar ColorGrammar; // resolves to object with 'red', 'green', 'blue', and 'alpha' properties each of which is a Float 0..1 381 attribute StyleGrammar ColorGrammar; // resolves to ColorStyleValue
343 attribute StyleGrammar DisplayStyleGrammar; // resolves to null or LayoutManager constructor 382 attribute StyleGrammar DisplayStyleGrammar; // resolves to ObjectStyleValue
344 ``` 383 ```
345 384
346 Inline Styles 385 Inline Styles
347 ------------- 386 -------------
348 387
349 ```javascript 388 ```javascript
350 class StyleDeclarationList { 389 abstract class AbstractStyleDeclarationList {
390 void addStyles(StyleDeclaration styles, String? pseudoElement = null); // O(1)
391 void removeStyles(StyleDeclaration styles, String? pseudoElement = null); // O (N) in number of declarations
392 Array<StyleDeclaration> getDeclarations(String? pseudoElement = null); // O(N) in number of declarations
393 }
394
395 class ElementStyleDeclarationList : AbstractStyleDeclarationList {
351 constructor (Element? element); 396 constructor (Element? element);
352 397
353 // There are two batches of styles in a StyleDeclarationList. 398 // there are two batches of styles in an ElementStyleDeclarationList.
354 399
355 // The first batch is the per-frame styles. These get cleared each 400 // the first batch is the per-frame styles; these get (conceptually)
356 // frame, after which all the matching rules in relevant <style> blocks 401 // cleared each frame, after which all the matching rules in relevant
357 // get added back in, followed by all the animation-derived rules. 402 // <style> blocks get added back in, followed by all the animation-
358 // Scripts can add styles themselves. 403 // derived rules; scripts can also add styles themselves, but they are
404 // dropped after the next frame
359 void addFrameStyles(StyleDeclaration styles, String? pseudoElement = null); // O(1) 405 void addFrameStyles(StyleDeclaration styles, String? pseudoElement = null); // O(1)
360 void clearFrameStyles(); 406 void clearFrameStyles();
361 407
362 // The second batch is the persistent styles. 408 // the second batch is the persistent styles, which remain until removed;
363 // Once added, they remain forever until removed. 409 // they are accessed via the AbstractStyleDeclarationList accessors
364 void addPersistentStyles(StyleDeclaration styles, String? pseudoElement = null ); // O(1)
365 void removePersistentStyles(StyleDeclaration styles, String? pseudoElement = n ull); // O(N) in number of declarations
366 410
367 // as StyleDeclaration are added and removed here, the StyleDeclarationList ca lls register(element) and 411 // as StyleDeclarations are added and removed, the ElementStyleDeclarationList
368 // unregister(element) respectively on those StyleDeclaration objects, where e lement is the element that 412 // calls register(element) and unregister(element) respectively on those
369 // was passed to the constructor, if not null 413 // StyleDeclaration objects, where element is the element that was passed
370 // then, it calls element.renderNode.cascadedValueAdded/cascadedValueRemoved f or each property on the object 414 // to the constructor, if not null
415 // then, it calls element.renderNode.cascadedValueAdded/cascadedValueRemoved
416 // for each property on the object
371 417
372 // This returns all the frame styles followed by all the persistent styles, in insertion order. 418 // the inherited getDeclarations() method returns all the frame
373 Array<StyleDeclaration> getDeclarations(String? pseudoElement = null); // O(N) in number of declarations 419 // styles followed by all the persistent styles, in insertion order
420 }
421
422 class RenderNodeStyleDeclarationList : AbstractStyleDeclarationList {
423 constructor (RenderNode? renderNode);
424
425 // as StyleDeclarations are added and removed, the RenderNodeStyleDeclarationL ist
426 // calls register(renderNode) and unregister(renderNode) respectively on those
427 // StyleDeclaration objects, where renderNode is the RenderNode that was passe d
428 // to the constructor, if not null
429 // then, it calls renderNode.cascadedValueAdded/cascadedValueRemoved
430 // for each property on the object
374 } 431 }
375 432
376 class StyleDeclaration { 433 class StyleDeclaration {
434 constructor ();
435
377 void markDirty(PropertyHandle property); 436 void markDirty(PropertyHandle property);
378 // this indicates that the cascaded value of the property thinks 437 // this indicates that the cascaded value of the property thinks
379 // it will now have a different result (as opposed to the cascaded 438 // it will now have a different result (as opposed to the cascaded
380 // value itself having changed) 439 // value itself having changed)
381 // invoke element.renderNode.cascadedValueDirty(property, pseudoElement); fo r each 440 // invoke element.renderNode.cascadedValueDirty(property, pseudoElement); fo r each
382 // currently registered consumer element/pseudoElement pair 441 // currently registered consumer element/pseudoElement pair
383 442
384 void register(Element element, String? pseudoElement = null); // O(1) 443 void register((Element or RenderNode) consumer, String? pseudoElement = null); // O(1)
385 void unregister(Element element, String? pseudoElement = null); // O(N) 444 void unregister((Element or RenderNode) consumer, String? pseudoElement = null ); // O(N)
386 // registers an element/pseudoElement pair with this StyleDeclaration so tha t when 445 // registers an element/pseudoElement or renderNode/pseudoElement pair with
387 // a property/value on the style declaration is marked dirty, the element 446 // this StyleDeclaration so that a property/value on the style declaration
388 // is informed and can then clear its property cache 447 // is marked dirty, the relevant render node is informed and can then update
448 // its property cache accordingly
389 449
390 getter AbstractStyleValue? (PropertyHandle property); 450 getter AbstractStyleValue? (PropertyHandle property);
391 // looks up the Property object for /property/, and returns its value 451 // looks up the Property object for /property/, and returns its value
392 // null if property is missing 452 // null if property is missing
393 453
394 setter void (PropertyHandle property, AbstractStyleValue value); 454 setter void (PropertyHandle property, AbstractStyleValue value);
395 // if there is no Property object for /property/, creates one 455 // if there is no Property object for /property/, creates one
396 // else calls its update() method to change the value 456 // else calls its update() method to change the value
397 // if the value changed: 457 // if the value changed:
398 // invoke consumer.renderNode.cascadedValueChanged(property); for each 458 // invoke consumer.renderNode.cascadedValueChanged(property); for each
(...skipping 14 matching lines...) Expand all
413 473
414 ```javascript 474 ```javascript
415 class Rule { 475 class Rule {
416 constructor (); 476 constructor ();
417 attribute SelectorQuery selector; // O(1) 477 attribute SelectorQuery selector; // O(1)
418 attribute String? pseudoElement; // O(1) 478 attribute String? pseudoElement; // O(1)
419 attribute StyleDeclaration styles; // O(1) 479 attribute StyleDeclaration styles; // O(1)
420 } 480 }
421 ``` 481 ```
422 482
423 Each frame, at some defined point relative to requestAnimationFrame(): 483 Each frame, at some defined point relative to requestAnimationFrame(),
424 - If a rule starts applying to an element, sky:core calls thatElement.style.add (rule.styles, rule.pseudoElement); 484 if a Rule has started applying, or a Rule stopped applying, to an
425 - If a rule stops applying to an element, sky:core calls thatElement.style.remo ve(rule.styles, rule.pseudoElement); 485 element, sky:core calls thatElement.style.clearFrameStyles() and then,
426 486 for each Rule that now applies, calls
427 TODO(ianh): fix the above so that rule order is maintained 487 thatElement.style.addFrameStyles() with the relevant StyleDeclaration
488 and pseudoElement from each such Rule.
428 489
429 490
430 Cascade 491 Cascade
431 ------- 492 -------
432 493
433 Simultaneously walk the tree rooted at the application Document, 494 Simultaneously walk the tree rooted at the application Document,
434 taking into account shadow trees and child distribution, and the tree 495 taking into account shadow trees and child distribution, and the tree
435 rooted at the document's RenderNode. 496 rooted at the document's RenderNode.
436 497
437 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,
438 then create one and mark it "isNew", and place it in the appropriate 499 then create one and mark it "isNew", and place it in the appropriate
439 place in the RenderTree tree, after any nodes marked isGhost. 500 place in the RenderTree tree, after any nodes marked isGhost.
440 501
441 For each element, if the node's needsManager is true, call 502 For each element, if the node's needsManager is true, call
442 getLayoutManager() on the element, and if that's not null, and if the 503 getLayoutManager() on the element, and if that's not null, and if the
443 returned class isn't the same class as the current layoutManager, if 504 returned class isn't the same class as the current layoutManager, if
444 any, construct the given class and assign it to the RenderNode's 505 any, construct the given class and assign it to the RenderNode's
445 layoutManager, then set all the child RenderNodes' ownerLayoutManager 506 layoutManager, then set all the child RenderNodes' ownerLayoutManager
446 to that object; if it returns null, and that node already has a 507 to that object; if it returns null, and that node already has a
447 layoutManager, then set isGhost=true for that node and all its 508 layoutManager, then set isGhost=true for that node and all its
448 children (without changing the layoutManager). Otherwise, if it 509 children (without changing the layoutManager). Otherwise, if it
449 returned null and there's already no layoutManager, remove the node 510 returned null and there's already no layoutManager, remove the node
450 from the tree. Then, in any case, clear the needsManager bit. 511 from the tree. Then, in any case, clear the needsManager bit.
451 512
452 When an Element or Text node is to be removed from its parent, and it 513 When an Element or Text node is to be removed from its parent, and it
453 has a renderNode, and that renderNode has an ownerLayoutManager with 514 has a renderNode, and that renderNode has an ownerLayoutManager with
454 autoreap=false, then before actually removing the node, the node's 515 autoreap=false, then before actually removing the node, the node's
455 renderNode should be marked isGhost=true, and the relevant 516 renderNode should be marked isGhost=true, and the relevant
456 StyleDeclarationList should be flattened and the values stored on the 517 ElementStyleDeclarationList should be flattened and the values stored on
457 RenderNode for use later. 518 the RenderNode's overrideStyles for use later. (Or we can just clone the
519 StyleDeclarations directly without flattening. That would probably
520 be faster.)
458 521
459 When an Element is to be removed from its parent, regardless of the 522 When an Element is to be removed from its parent, regardless of the
460 above, the node's renderNode attribute should be nulled out. 523 above, the node's renderNode attribute should be nulled out.
461 524
462 525
463 ```javascript 526 ```javascript
464 callback any ValueResolver (any value, String propertyName, RenderNode node, Flo at containerWidth, Float containerHeight); 527 callback any ValueResolver (any value, String propertyName, RenderNode node, Flo at containerWidth, Float containerHeight);
465 528
466 class RenderNode { // implemented in C++ with no virtual tables 529 class RenderNode { // implemented in C++ with no virtual tables
467 // this is generated before layout 530 // this is generated before layout
468 readonly attribute String text; 531 readonly attribute String text;
469 readonly attribute Node? parentNode; 532 readonly attribute Node? parentNode;
470 readonly attribute Node? firstChild; 533 readonly attribute Node? firstChild;
471 readonly attribute Node? nextSibling; 534 readonly attribute Node? nextSibling;
472 535
473 any getProperty(PropertyHandle property, String? pseudoElement = null); 536 any getProperty(PropertyHandle property, String? pseudoElement = null);
474 // looking at the cached data for the given pseudoElement: 537 // looking at the cached data for the given pseudoElement:
475 // if there's a cached value, return it 538 // if there's a cached value, return it
476 // otherwise, figure out which StyleValue we're going to be using, in this order: 539 // otherwise, figure out which StyleValue we're going to be using, in this order:
477 // - if we're isGhost, look out our cached declarations 540 // - look out our override declarations (first with the pseudo, if any, t hen without)
478 // - look at this element's StyleDeclarations for the given pseudo-elemen t (if any) 541 // - if there's an element:
479 // - look at this element's StyleDeclarations with no pseudo-element 542 // - look at this element's StyleDeclarations (first with the pseudo, i f any, then without)
480 // - if it's an inherited property and there's a parent 543 // - if it's an inherited property and there's a parent:
481 // - call getProperty() on the parent 544 // - call getProperty() on the parent (without the pseudo)
482 // otherwise use the default value 545 // - use the default value
483 // resolve the StyleValue giving it the property and node in question 546 // resolve the StyleValue giving it the property and node in question
484 // cache the value, along with the StyleValueResolverSettings 547 // cache the value, along with the StyleValueResolverSettings
485 548
549 readonly attribute RenderNodeStyleDeclarationList overrideStyles;
550 // mutable; initially empty
551 // this is used when isGhost is true, and can also be used more generally t o
552 // override styles from the layout manager (e.g. to animate a new node into view)
553
486 private void cascadedValueAdded(PropertyHandle property, String? pseudoElement = null); 554 private void cascadedValueAdded(PropertyHandle property, String? pseudoElement = null);
487 private void cascadedValueRemoved(PropertyHandle property, String? pseudoEleme nt = null); 555 private void cascadedValueRemoved(PropertyHandle property, String? pseudoEleme nt = null);
488 private void cascadedValueChanged(PropertyHandle property, String? pseudoEleme nt = null); 556 private void cascadedValueChanged(PropertyHandle property, String? pseudoEleme nt = null);
489 private void cascadedValueDirty(PropertyHandle property, String? pseudoElement = null); 557 private void cascadedValueDirty(PropertyHandle property, String? pseudoElement = null);
490 // - clear the cached data for this property/pseudoElement pair 558 // - clear the cached data for this property/pseudoElement pair
491 // - if the property is needsManager, set needsManager to true 559 // - if the property is needsManager, set needsManager to true
492 // - if the property is needsLayout, set needsLayout to true and walk 560 // - if the property is needsLayout, set needsLayout to true and walk
493 // up the tree setting descendantNeedsLayout 561 // up the tree setting descendantNeedsLayout
494 // - if the property is needsPaint, add the node to the list of nodes that n eed painting 562 // - if the property is needsPaint, add the node to the list of nodes that n eed painting
495 // - if the property has a dependencyBit defined, then check the cache of al l the 563 // - if the property has a dependencyBit defined, then check the cache of al l the
496 // properties on this RenderNode, and the cache for the property in all th e child 564 // properties on this RenderNode, and the cache for the property in all th e child
497 // nodes and (if pseudoElement is null) or the pseudoElements 565 // nodes and (if pseudoElement is null) or the pseudoElements
498 // and if any of them have the relevant dependency bit set then call 566 // and if any of them have the relevant dependency bit set then call
499 // thatRenderNode.cascadedValueDirty(thatProperty, thatPseudoElement) 567 // thatRenderNode.cascadedValueDirty(thatProperty, thatPseudoElement)
500 // - if the property is inherited: 568 // - if the property is inherited:
501 // - call this.cascadedValueDirty(property, eachPseudoElement) 569 // - call this.cascadedValueDirty(property, eachPseudoElement)
502 // - call eachChildRenderNode.cascadedValueDirty(property, null) 570 // - call eachChildRenderNode.cascadedValueDirty(property, null)
571 // (these four methods all do the same thing; they might get merged into one . For now
572 // they're separate in case we want to make them cleverer later.)
503 573
504 readonly attribute Boolean needsManager; 574 readonly attribute Boolean needsManager;
505 // means that a property with needsManager:true has changed on this node 575 // means that a property with needsManager:true has changed on this node
506 576
507 readonly attribute Boolean needsLayout; 577 readonly attribute Boolean needsLayout;
508 // means that either needsManager is true or a property with needsLayout:tru e has changed on this node 578 // means that either needsManager is true or a property with needsLayout:tru e has changed on this node
509 // needsLayout is set to false by the ownerLayoutManager's default layout() method 579 // needsLayout is set to false by the ownerLayoutManager's default layout() method
510 580
511 readonly attribute Boolean descendantNeedsLayout; 581 readonly attribute Boolean descendantNeedsLayout;
512 // means that some child of this node has needsLayout set to true 582 // means that some child of this node has needsLayout set to true
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 // while (node && node.layoutManager) { 653 // while (node && node.layoutManager) {
584 // result.push(node.layoutManager); 654 // result.push(node.layoutManager);
585 // node = node.parentNode; 655 // node = node.parentNode;
586 // } 656 // }
587 // return result; 657 // return result;
588 658
589 void setProperty(RenderNode node, PropertyHandle property, any value, String? pseudoElement = null); // O(1) 659 void setProperty(RenderNode node, PropertyHandle property, any value, String? pseudoElement = null); // O(1)
590 // if called from an adjustProperties() method during the property adjustmen t phase, 660 // if called from an adjustProperties() method during the property adjustmen t phase,
591 // replaces the value that getProperty() would return on that node with /val ue/ 661 // replaces the value that getProperty() would return on that node with /val ue/
592 662
593 virtual void adjustProperties();
594 // called before layout; can call setProperty to set new values
595 // note that this happens after the cascade so inheritance isn't applied to this new value
596 // also note that the value you set is a post-computation value, not an Abst ractStyleValue descendant
597 // so e.g. you can have an AnimatableColorStyleValue, get its value, and pus h it into setProperty()
598 // but you can't push the AnimatableColorStyleValue directly in, it won't do what you expect
599
600 void take(RenderNode victim); // sets victim.ownerLayoutManager = this; 663 void take(RenderNode victim); // sets victim.ownerLayoutManager = this;
601 // assert: victim hasn't been take()n yet during this layout 664 // assert: victim hasn't been take()n yet during this layout
602 // assert: victim.needsLayout == true 665 // assert: victim.needsLayout == true
603 // assert: an ancestor of victim has node.layoutManager == this (aka, victim is a descendant of this.node) 666 // assert: an ancestor of victim has node.layoutManager == this (aka, victim is a descendant of this.node)
604 667
605 virtual void release(RenderNode victim); 668 virtual void release(RenderNode victim);
606 // called when the RenderNode was removed from the tree 669 // called when the RenderNode was removed from the tree
607 670
608 void setChildPosition(child, x, y); // sets child.x, child.y 671 void setChildPosition(child, x, y); // sets child.x, child.y
609 void setChildX(child, y); // sets child.x 672 void setChildX(child, y); // sets child.x
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 dictionary Dimensions { 813 dictionary Dimensions {
751 Float width = 0; 814 Float width = 0;
752 Float height = 0; 815 Float height = 0;
753 } 816 }
754 ``` 817 ```
755 818
756 819
757 Paint 820 Paint
758 ----- 821 -----
759 822
760 Sky has a list of RenderNodes that need painting. 823 Sky has a list of RenderNodes that need painting. When a RenderNode is
761 When a RenderNode is created, it's added to this list. 824 created, it's added to this list. (See also needsPaint for another
825 time it is added to the list.)
762 826
763 ```javascript 827 ```javascript
764 callback void Painter (RenderNode node, RenderingSurface canvas); 828 callback void Painter (RenderNode node, RenderingSurface canvas);
765 829
766 class RenderingSurface { 830 class RenderingSurface {
767 831
768 // ... (API similar to <canvas>'s 2D API) 832 // ... (API similar to <canvas>'s 2D API)
769 833
770 void paintChild(RenderNode node); 834 void paintChild(RenderNode node);
771 // inserts a "paint this child" instruction in this canvas's display list. 835 // inserts a "paint this child" instruction in this canvas's display list.
(...skipping 19 matching lines...) Expand all
791 855
792 In the constructors for the default elements, they add to themselves 856 In the constructors for the default elements, they add to themselves
793 StyleDeclaration objects as follows: 857 StyleDeclaration objects as follows:
794 858
795 * ``import`` 859 * ``import``
796 * ``template`` 860 * ``template``
797 * ``style`` 861 * ``style``
798 * ``script`` 862 * ``script``
799 * ``content`` 863 * ``content``
800 * ``title`` 864 * ``title``
801 These all add to themselves the same declaration with value: 865 These all add to themselves the same declaration as follows:
802 ```javascript 866 ```javascript
803 { display: { value: null } } 867 let d = new StyleDeclaration();
868 d[pDisplay] = new ObjectStyleValue(null);
869 this.style.addStyles(d);
804 ``` 870 ```
805 871
806 * ``img`` 872 * ``img``
807 This adds to itself the declaration with value: 873 This adds to itself the declaration as follows:
808 ```javascript 874 ```javascript
809 { display: { value: sky.ImageElementLayoutManager } } 875 let d = new StyleDeclaration();
876 d[pDisplay] = new ObjectStyleValue(ImageElementLayoutManager);
877 this.style.addStyles(d);
810 ``` 878 ```
811 879
812 * ``span`` 880 * ``span``
813 * ``a`` 881 * ``a``
814 These all add to themselves the same declaration with value: 882 These all add to themselves the same declaration as follows:
815 ```javascript 883 ```javascript
816 { display: { value: sky.InlineLayoutManager } } 884 let d = new StyleDeclaration();
885 d[pDisplay] = new ObjectStyleValue(InlineLayoutManager);
886 this.style.addStyles(d);
817 ``` 887 ```
818 888
819 * ``iframe`` 889 * ``iframe``
820 This adds to itself the declaration with value: 890 This adds to itself the declaration as follows:
821 ```javascript 891 ```javascript
822 { display: { value: sky.IFrameElementLayoutManager } } 892 let d = new StyleDeclaration();
893 d[pDisplay] = new ObjectStyleValue(IFrameElementLayoutManager);
894 this.style.addStyles(d);
823 ``` 895 ```
824 896
825 * ``t`` 897 * ``t``
826 This adds to itself the declaration with value: 898 This adds to itself the declaration as follows:
827 ```javascript 899 ```javascript
828 { display: { value: sky.ParagraphLayoutManager } } 900 let d = new StyleDeclaration();
901 d[pDisplay] = new ObjectStyleValue(ParagraphLayoutManager);
902 this.style.addStyles(d);
829 ``` 903 ```
830 904
831 * ``error`` 905 * ``error``
832 This adds to itself the declaration with value: 906 This adds to itself the declaration as follows:
833 ```javascript 907 ```javascript
834 { display: { value: sky.ErrorLayoutManager } } 908 let d = new StyleDeclaration();
909 d[pDisplay] = new ObjectStyleValue(ErrorLayoutManager);
910 this.style.addStyles(d);
835 ``` 911 ```
836 912
837 The ``div`` element doesn't have any default styles. 913 The ``div`` element doesn't have any default styles.
838 914
839 These declarations are all shared between all the elements (so e.g. if 915 These declarations are all shared between all the elements (so e.g. if
840 you reach in and change the declaration that was added to a ``title`` 916 you reach in and change the declaration that was added to a ``title``
841 element, you're going to change the styles of all the other 917 element, you're going to change the styles of all the other
842 default-hidden elements). 918 default-hidden elements). (In other words, in the code snippets above,
919 the ``d`` variable is initialised in shared code, and only the
920 addStyles() call is per-element.)
OLDNEW
« no previous file with comments | « sky/specs/apis.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698