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

Side by Side Diff: Source/bindings/dart/DartCustomElementWrapper.cpp

Issue 26789007: Add a native subtype of function that uses the native C++ class hierarchy to check if an element (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/dart/DartDOMData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 DartDOMWrapper::writeNativePointer(newInstance, element, DartHTMLElement::da rtClassId);
117 118
118 Dart_Handle result = Dart_SetNativeInstanceField(newInstance, 0, reinterpret _cast<intptr_t>(element)); 119 Dart_Handle result = Dart_InvokeConstructor(newInstance, Dart_NewStringFromC String("created"), 0, 0);
119 UNUSED_PARAM(result);
120 ASSERT(!Dart_IsError(result));
121
122 result = Dart_InvokeConstructor(newInstance, Dart_NewStringFromCString("crea ted"), 0, 0);
123 120
124 if (Dart_IsError(result)) { 121 if (Dart_IsError(result)) {
125 DartUtilities::reportProblem(domData->scriptExecutionContext(), result); 122 DartUtilities::reportProblem(domData->scriptExecutionContext(), result);
126 123
127 // Fall back to the old wrapper if possible. 124 // Fall back to the old wrapper if possible.
128 if (oldInstance) { 125 if (oldInstance) {
129 Dart_Handle oldWrapper = Dart_HandleFromWeakPersistent(oldInstance); 126 Dart_Handle oldWrapper = Dart_HandleFromWeakPersistent(oldInstance);
130 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, oldWrapper); 127 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, oldWrapper);
131 return oldWrapper; 128 return oldWrapper;
132 } 129 }
133 130
134 // When the upgrade fails the failed wrapper may have been associated, 131 // When the upgrade fails the failed wrapper may have been associated,
135 // 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.
136 Dart_Handle fallbackWrapper = createUpgradeCandidateWrapper(element, cre ateSpecificWrapper); 133 Dart_Handle fallbackWrapper = createUpgradeCandidateWrapper(element, cre ateSpecificWrapper);
137 134
138 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, fall backWrapper); 135 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, fall backWrapper);
139 Dart_Handle result = Dart_SetNativeInstanceField(fallbackWrapper, 0, rei nterpret_cast<intptr_t>(element)); 136 DartDOMWrapper::writeNativePointer(fallbackWrapper, element, DartHTMLEle ment::dartClassId);
140 UNUSED_PARAM(result);
141 ASSERT(!Dart_IsError(result));
142
143 return fallbackWrapper; 137 return fallbackWrapper;
144 } 138 }
145 return newInstance; 139 return newInstance;
146 } 140 }
147 141
148 template<> 142 template<>
149 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))
150 { 144 {
151 // TODO: support SVG elements. 145 // TODO: support SVG elements.
152 ASSERT(FALSE); 146 ASSERT(FALSE);
(...skipping 16 matching lines...) Expand all
169 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, wrapper) ; 163 DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, wrapper) ;
170 } 164 }
171 165
172 template 166 template
173 class DartCustomElementWrapper<HTMLElement>; 167 class DartCustomElementWrapper<HTMLElement>;
174 168
175 template 169 template
176 class DartCustomElementWrapper<SVGElement>; 170 class DartCustomElementWrapper<SVGElement>;
177 171
178 } // namespace WebCore 172 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/dart/DartDOMData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698