| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 domData, DartHTMLElement::isNode, reinterpret_cast<HTMLElement*>(element
)); | 107 domData, DartHTMLElement::isNode, reinterpret_cast<HTMLElement*>(element
)); |
| 108 if (oldInstance) { | 108 if (oldInstance) { |
| 109 DartDOMWrapper::disassociateWrapper<DartHTMLElement>( | 109 DartDOMWrapper::disassociateWrapper<DartHTMLElement>( |
| 110 domData, | 110 domData, |
| 111 reinterpret_cast<HTMLElement*>(element), | 111 reinterpret_cast<HTMLElement*>(element), |
| 112 Dart_HandleFromWeakPersistent(oldInstance)); | 112 Dart_HandleFromWeakPersistent(oldInstance)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 Dart_Handle newInstance = Dart_Allocate(customType); | 115 Dart_Handle newInstance = Dart_Allocate(customType); |
| 116 ASSERT(!Dart_IsError(newInstance)); | 116 ASSERT(!Dart_IsError(newInstance)); |
| 117 // TODO(14190): Use a more specific type instead of DartHTMLElement here. | 117 DartDOMWrapper::writeNativePointer(newInstance, element, binding->nativeClas
sId()); |
| 118 DartDOMWrapper::writeNativePointer(newInstance, element, DartHTMLElement::da
rtClassId); | |
| 119 | 118 |
| 120 Dart_Handle result = Dart_InvokeConstructor(newInstance, Dart_NewStringFromC
String("created"), 0, 0); | 119 Dart_Handle result = Dart_InvokeConstructor(newInstance, Dart_NewStringFromC
String("created"), 0, 0); |
| 121 | 120 |
| 122 if (Dart_IsError(result)) { | 121 if (Dart_IsError(result)) { |
| 123 DartUtilities::reportProblem(domData->scriptExecutionContext(), result); | 122 DartUtilities::reportProblem(domData->scriptExecutionContext(), result); |
| 124 | 123 |
| 125 // Fall back to the old wrapper if possible. | 124 // Fall back to the old wrapper if possible. |
| 126 if (oldInstance) { | 125 if (oldInstance) { |
| 127 Dart_Handle oldWrapper = Dart_HandleFromWeakPersistent(oldInstance); | 126 Dart_Handle oldWrapper = Dart_HandleFromWeakPersistent(oldInstance); |
| 128 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element,
oldWrapper); | 127 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element,
oldWrapper); |
| 129 return oldWrapper; | 128 return oldWrapper; |
| 130 } | 129 } |
| 131 | 130 |
| 132 // When the upgrade fails the failed wrapper may have been associated, | 131 // When the upgrade fails the failed wrapper may have been associated, |
| 133 // so we need to create a new one and re-associate it. | 132 // so we need to create a new one and re-associate it. |
| 134 Dart_Handle fallbackWrapper = createUpgradeCandidateWrapper(element, cre
ateSpecificWrapper); | 133 Dart_Handle fallbackWrapper = createUpgradeCandidateWrapper(element, cre
ateSpecificWrapper); |
| 135 | 134 |
| 136 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, fall
backWrapper); | 135 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, fall
backWrapper); |
| 137 // TODO(14190): Use a more specific type instead of DartHTMLElement here
. | 136 DartDOMWrapper::writeNativePointer(fallbackWrapper, element, binding->na
tiveClassId()); |
| 138 DartDOMWrapper::writeNativePointer(fallbackWrapper, element, DartHTMLEle
ment::dartClassId); | |
| 139 return fallbackWrapper; | 137 return fallbackWrapper; |
| 140 } | 138 } |
| 141 return newInstance; | 139 return newInstance; |
| 142 } | 140 } |
| 143 | 141 |
| 144 template<> | 142 template<> |
| 145 Dart_Handle DartCustomElementWrapper<SVGElement>::upgradeDartWrapper(SVGElement*
element, Dart_Handle (*createSpecificWrapper)(SVGElement* element)) | 143 Dart_Handle DartCustomElementWrapper<SVGElement>::upgradeDartWrapper(SVGElement*
element, Dart_Handle (*createSpecificWrapper)(SVGElement* element)) |
| 146 { | 144 { |
| 147 // TODO: support SVG elements. | 145 // TODO: support SVG elements. |
| 148 ASSERT(FALSE); | 146 ASSERT(FALSE); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 165 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, wrapper)
; | 163 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, wrapper)
; |
| 166 } | 164 } |
| 167 | 165 |
| 168 template | 166 template |
| 169 class DartCustomElementWrapper<HTMLElement>; | 167 class DartCustomElementWrapper<HTMLElement>; |
| 170 | 168 |
| 171 template | 169 template |
| 172 class DartCustomElementWrapper<SVGElement>; | 170 class DartCustomElementWrapper<SVGElement>; |
| 173 | 171 |
| 174 } // namespace WebCore | 172 } // namespace WebCore |
| OLD | NEW |