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

Side by Side Diff: Source/bindings/dart/DartDOMWrapper.h

Issue 54833003: Fixing another case of multiple upgrades of a custom element (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« 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 // Copyright 2011, Google Inc. 1 // Copyright 2011, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // FIXME: the fact that we return 0 on error rather than asserting is 265 // FIXME: the fact that we return 0 on error rather than asserting is
266 // somewhat of a hack. We currently make this method return 0 because 266 // somewhat of a hack. We currently make this method return 0 because
267 // we reuse this method to verify that objects are actually native 267 // we reuse this method to verify that objects are actually native
268 // Node objects rather than objects that implement the Node interface. 268 // Node objects rather than objects that implement the Node interface.
269 if (Dart_IsError(result)) 269 if (Dart_IsError(result))
270 return 0; 270 return 0;
271 return reinterpret_cast<void*>(value); 271 return reinterpret_cast<void*>(value);
272 } 272 }
273 273
274 template <class BindingsClass> 274 template <class BindingsClass>
275 static void wrapperWeakCallback(Dart_WeakPersistentHandle, void* peer) 275 static void wrapperWeakCallback(Dart_WeakPersistentHandle wrapper, void* pee r)
276 { 276 {
277 typedef DartDOMWrapperTraits<BindingsClass> Traits; 277 typedef DartDOMWrapperTraits<BindingsClass> Traits;
278 DartDOMData* domData = DartDOMData::current(); 278 DartDOMData* domData = DartDOMData::current();
279 typename BindingsClass::NativeType* domObject = static_cast<typename Bin dingsClass::NativeType*>(peer); 279 typename BindingsClass::NativeType* domObject = static_cast<typename Bin dingsClass::NativeType*>(peer);
280 Dart_WeakPersistentHandle currentWrapper = Traits::MapTraits::domMap(dom Data)->get(domObject);
281 // This could be an old wrapper which has been replaced with a custom el ement.
282 if (!Dart_IdentityEquals(Dart_HandleFromWeakPersistent(currentWrapper), Dart_HandleFromWeakPersistent(wrapper))) {
blois 2013/10/31 18:43:07 Changing the check to: if (currentWrapper != wrapp
siva 2013/10/31 19:42:40 if (currentWrapper != wrapper) {} is preferable fo
blois 2013/10/31 20:24:18 Done.
283 return;
284 }
285
280 if (DartDOMWrapperTraits<BindingsClass>::MapTraits::domMap(domData)->con tains(domObject)) { 286 if (DartDOMWrapperTraits<BindingsClass>::MapTraits::domMap(domData)->con tains(domObject)) {
281 Traits::MapTraits::domMap(domData)->remove(domObject); 287 Traits::MapTraits::domMap(domData)->remove(domObject);
282 Traits::ActiveTraits::removeWrapper(domData, domObject); 288 Traits::ActiveTraits::removeWrapper(domData, domObject);
283 Traits::EventTargetTraits::removeWrapper(domData, domObject); 289 Traits::EventTargetTraits::removeWrapper(domData, domObject);
284 } 290 }
285 domObject->deref(); 291 domObject->deref();
286 } 292 }
287 293
288 template <class BindingsClass> 294 template <class BindingsClass>
289 static void associateWrapper( 295 static void associateWrapper(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 static DartMessagePortMap* domMap(DartDOMData* domData) { return domData ->messagePortMap(); } 397 static DartMessagePortMap* domMap(DartDOMData* domData) { return domData ->messagePortMap(); }
392 }; 398 };
393 typedef MessagePortMapTraits MapTraits; 399 typedef MessagePortMapTraits MapTraits;
394 typedef DartDOMWrapperActiveTraits<DartMessagePort, false> ActiveTraits; 400 typedef DartDOMWrapperActiveTraits<DartMessagePort, false> ActiveTraits;
395 typedef DartDOMWrapperEventTargetTraits<DartMessagePort, true> EventTargetTr aits; 401 typedef DartDOMWrapperEventTargetTraits<DartMessagePort, true> EventTargetTr aits;
396 }; 402 };
397 403
398 } 404 }
399 405
400 #endif // DartDOMWrapper_h 406 #endif // DartDOMWrapper_h
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