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

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

Issue 957563002: Specs: turns out my Expando-based WeakMap thing won't work :-( (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « 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 Note: This is a work in progress that will eventually replace 4 Note: This is a work in progress that will eventually replace
5 (style.md)[style.md]. 5 (style.md)[style.md].
6 6
7 The Sky style API looks like the following: 7 The Sky style API looks like the following:
8 8
9 ```dart 9 ```dart
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 var style2 = new StyleDeclaration.clone(style); 51 var style2 = new StyleDeclaration.clone(style);
52 ``` 52 ```
53 53
54 The dart:sky library contains the following to define this API: 54 The dart:sky library contains the following to define this API:
55 55
56 ```dart 56 ```dart
57 import 'dart:mirrors'; 57 import 'dart:mirrors';
58 import 'dart:math'; 58 import 'dart:math';
59 59
60 class WeakMap<Key, Value> { 60 class WeakMap<Key, Value> {
61 Expando<Value> _map = new Expando<Value>(); 61 // This is not actually a weak map right now, because Dart doesn't let us have weak references.
62 // We should fix that, or else we're going to keep alive every object you ever tear off through
63 // the StyleDeclaration API, even if you never use it again, until the StyleDe claration object
64 // itself is GC'ed, which is likely when the element is GC'ed, which is likely never.
65 Map<Key, Value> _map = new Map<Key, Value>();
62 operator[](Key key) => _map[key]; 66 operator[](Key key) => _map[key];
63 operator[]=(Key key, Value value) => _map[key] = value; 67 operator[]=(Key key, Value value) => _map[key] = value;
64 bool containsKey(Key key) => _map[key] != null; 68 bool containsKey(Key key) => _map.containsKey(key);
65 } 69 }
66 70
67 typedef void StringSetter(Symbol propertySymbol, StyleDeclaration declaration, S tring value); 71 typedef void StringSetter(Symbol propertySymbol, StyleDeclaration declaration, S tring value);
68 typedef String StringGetter(Symbol propertySymbol, StyleDeclaration declaration) ; 72 typedef String StringGetter(Symbol propertySymbol, StyleDeclaration declaration) ;
69 typedef Property ObjectConstructor(Symbol propertySymbol, StyleDeclaration decla ration); 73 typedef Property ObjectConstructor(Symbol propertySymbol, StyleDeclaration decla ration);
70 74
71 class PropertyTable { 75 class PropertyTable {
72 const PropertyTable({this.symbol, this.inherited, this.stringGetter, this.stri ngSetter, this.objectConstructor}); 76 const PropertyTable({this.symbol, this.inherited, this.stringGetter, this.stri ngSetter, this.objectConstructor});
73 final Symbol symbol; 77 final Symbol symbol;
74 final bool inherited; 78 final bool inherited;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 registerProperty(new PropertyTable( 346 registerProperty(new PropertyTable(
343 symbol: #transform, 347 symbol: #transform,
344 inherited: false, 348 inherited: false,
345 stringSetter: transformPropertyStringSetter, 349 stringSetter: transformPropertyStringSetter,
346 stringGetter: transformPropertyStringGetter, 350 stringGetter: transformPropertyStringGetter,
347 objectConstructor: (Symbol propertySymbol, StyleDeclaration declaration) => 351 objectConstructor: (Symbol propertySymbol, StyleDeclaration declaration) =>
348 new TransformProperty(propertySymbol, declaration))); 352 new TransformProperty(propertySymbol, declaration)));
349 } 353 }
350 ``` 354 ```
351 355
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