Merge from Chromium at DEPS revision 262940

This commit was generated by merge_to_master.py.

Change-Id: I767658f35150c8e0099156a5a5daf4bdf7e8ae0f
diff --git a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
index f31a3bd..c74b075 100644
--- a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
+++ b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
@@ -158,14 +158,11 @@
 
     element->setCustomElementState(Element::Upgraded);
 
-    v8::Isolate* isolate = m_scriptState->isolate();
-    v8::HandleScope handleScope(isolate);
-    v8::Handle<v8::Context> context = m_scriptState->context();
-    if (context.IsEmpty())
+    if (m_scriptState->contextIsEmpty())
         return;
-
-    v8::Context::Scope scope(context);
-
+    NewScriptState::Scope scope(m_scriptState.get());
+    v8::Isolate* isolate = m_scriptState->isolate();
+    v8::Handle<v8::Context> context = m_scriptState->context();
     v8::Handle<v8::Object> receiver = DOMDataStore::current(isolate).get<V8Element>(element, isolate);
     if (!receiver.IsEmpty()) {
         // Swizzle the prototype of the existing wrapper. We don't need to
@@ -211,14 +208,11 @@
     if (!executionContext() || executionContext()->activeDOMObjectsAreStopped())
         return;
 
-    v8::Isolate* isolate = m_scriptState->isolate();
-    v8::HandleScope handleScope(isolate);
-    v8::Handle<v8::Context> context = m_scriptState->context();
-    if (context.IsEmpty())
+    if (m_scriptState->contextIsEmpty())
         return;
-
-    v8::Context::Scope scope(context);
-
+    NewScriptState::Scope scope(m_scriptState.get());
+    v8::Isolate* isolate = m_scriptState->isolate();
+    v8::Handle<v8::Context> context = m_scriptState->context();
     v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).As<v8::Object>();
     ASSERT(!receiver.IsEmpty());
 
@@ -247,14 +241,11 @@
     if (!executionContext() || executionContext()->activeDOMObjectsAreStopped())
         return;
 
-    v8::Isolate* isolate = m_scriptState->isolate();
-    v8::HandleScope handleScope(isolate);
-    v8::Handle<v8::Context> context = m_scriptState->context();
-    if (context.IsEmpty())
+    if (m_scriptState->contextIsEmpty())
         return;
-
-    v8::Context::Scope scope(context);
-
+    NewScriptState::Scope scope(m_scriptState.get());
+    v8::Isolate* isolate = m_scriptState->isolate();
+    v8::Handle<v8::Context> context = m_scriptState->context();
     v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate);
     if (callback.IsEmpty())
         return;