OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 for (var type in typeMap1) { | 122 for (var type in typeMap1) { |
123 if (TypeMapHasType(typeMap1, type) && TypeMapHasType(typeMap2, type)) | 123 if (TypeMapHasType(typeMap1, type) && TypeMapHasType(typeMap2, type)) |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 var defaultAcceptTypes = TypeMapCreateFromList([ | 130 var defaultAcceptTypes = TypeMapCreateFromList([ |
131 'new', | 131 'add', |
132 'updated', | 132 'update', |
133 'deleted', | 133 'delete', |
134 'prototype', | 134 'setPrototype', |
135 'reconfigured', | 135 'reconfigure', |
136 'preventExtensions' | 136 'preventExtensions' |
137 ]); | 137 ]); |
138 | 138 |
139 // An Observer is a registration to observe an object by a callback with | 139 // An Observer is a registration to observe an object by a callback with |
140 // a given set of accept types. If the set of accept types is the default | 140 // a given set of accept types. If the set of accept types is the default |
141 // set for Object.observe, the observer is represented as a direct reference | 141 // set for Object.observe, the observer is represented as a direct reference |
142 // to the callback. An observer never changes its accept types and thus never | 142 // to the callback. An observer never changes its accept types and thus never |
143 // needs to "normalize". | 143 // needs to "normalize". |
144 function ObserverCreate(callback, acceptList) { | 144 function ObserverCreate(callback, acceptList) { |
145 return IS_UNDEFINED(acceptList) ? callback : { | 145 return IS_UNDEFINED(acceptList) ? callback : { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 346 |
347 var objectInfo = objectInfoMap.get(object); | 347 var objectInfo = objectInfoMap.get(object); |
348 if (IS_UNDEFINED(objectInfo)) | 348 if (IS_UNDEFINED(objectInfo)) |
349 return object; | 349 return object; |
350 | 350 |
351 ObjectInfoRemoveObserver(objectInfo, callback); | 351 ObjectInfoRemoveObserver(objectInfo, callback); |
352 return object; | 352 return object; |
353 } | 353 } |
354 | 354 |
355 function ArrayObserve(object, callback) { | 355 function ArrayObserve(object, callback) { |
356 return ObjectObserve(object, callback, ['new', | 356 return ObjectObserve(object, callback, ['add', |
357 'updated', | 357 'update', |
358 'deleted', | 358 'delete', |
359 'splice']); | 359 'splice']); |
360 } | 360 } |
361 | 361 |
362 function ArrayUnobserve(object, callback) { | 362 function ArrayUnobserve(object, callback) { |
363 return ObjectUnobserve(object, callback); | 363 return ObjectUnobserve(object, callback); |
364 } | 364 } |
365 | 365 |
366 function ObserverEnqueueIfActive(observer, objectInfo, changeRecord, | 366 function ObserverEnqueueIfActive(observer, objectInfo, changeRecord, |
367 needsAccessCheck) { | 367 needsAccessCheck) { |
368 if (!ObserverIsActive(observer, objectInfo) || | 368 if (!ObserverIsActive(observer, objectInfo) || |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 "observe", ArrayObserve, | 584 "observe", ArrayObserve, |
585 "unobserve", ArrayUnobserve | 585 "unobserve", ArrayUnobserve |
586 )); | 586 )); |
587 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( | 587 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( |
588 "notify", ObjectNotifierNotify, | 588 "notify", ObjectNotifierNotify, |
589 "performChange", ObjectNotifierPerformChange | 589 "performChange", ObjectNotifierPerformChange |
590 )); | 590 )); |
591 } | 591 } |
592 | 592 |
593 SetupObjectObserve(); | 593 SetupObjectObserve(); |
OLD | NEW |