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

Unified Diff: Source/bindings/dart/DartCustomElementWrapper.cpp

Issue 27183006: Setting native pointer of custom elements before running constructor. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/dart/DartDOMData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartCustomElementWrapper.cpp
diff --git a/Source/bindings/dart/DartCustomElementWrapper.cpp b/Source/bindings/dart/DartCustomElementWrapper.cpp
index 28da221dbc7f52d01a85639e59651d52715fde25..8217d88111844c21cf733fc6552cba41b3e9db4a 100644
--- a/Source/bindings/dart/DartCustomElementWrapper.cpp
+++ b/Source/bindings/dart/DartCustomElementWrapper.cpp
@@ -112,13 +112,17 @@ Dart_Handle DartCustomElementWrapper<HTMLElement>::upgradeDartWrapper(HTMLElemen
Dart_HandleFromWeakPersistent(oldInstance));
}
- domData->pushUpgradingCustomElement(element);
+ Dart_Handle newInstance = Dart_Allocate(customType);
+ ASSERT(!Dart_IsError(newInstance));
- Dart_Handle newInstance = Dart_New(customType, Dart_NewStringFromCString("created"), 0, 0);
- if (Dart_IsError(newInstance)) {
- domData->popUpgradingCustomElement();
+ Dart_Handle result = Dart_SetNativeInstanceField(newInstance, 0, reinterpret_cast<intptr_t>(element));
+ UNUSED_PARAM(result);
+ ASSERT(!Dart_IsError(result));
- DartUtilities::reportProblem(DartDOMData::current()->scriptExecutionContext(), newInstance);
+ result = Dart_InvokeConstructor(newInstance, Dart_NewStringFromCString("created"), 0, 0);
+
+ if (Dart_IsError(result)) {
+ DartUtilities::reportProblem(domData->scriptExecutionContext(), newInstance);
// Fall back to the old wrapper if possible.
if (oldInstance) {
@@ -138,8 +142,6 @@ Dart_Handle DartCustomElementWrapper<HTMLElement>::upgradeDartWrapper(HTMLElemen
return fallbackWrapper;
}
- // Should have come through initializeCustomElement.
- ASSERT(!domData->isUpgradingCustomElement(element));
return newInstance;
}
@@ -155,17 +157,16 @@ template<>
void DartCustomElementWrapper<HTMLElement>::initializeCustomElement(Dart_Handle wrapper, Dart_Handle& exception)
{
DartDOMData* domData = DartDOMData::current();
- HTMLElement* element = reinterpret_cast<HTMLElement*>(domData->popUpgradingCustomElement());
+ HTMLElement* element = DartDOMWrapper::unwrapDartWrapper<DartHTMLElement>(domData, wrapper, exception);
+ if (exception) {
+ return;
+ }
if (!element) {
exception = Dart_NewStringFromCString("created called outside of custom element creation.");
return;
}
DartDOMWrapper::associateWrapper<DartHTMLElement>(domData, element, wrapper);
-
- Dart_Handle result = Dart_SetNativeInstanceField(wrapper, 0, reinterpret_cast<intptr_t>(element));
- UNUSED_PARAM(result);
- ASSERT(!Dart_IsError(result));
}
template
« 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