Merge from Chromium at DEPS revision 222756

This commit was generated by merge_to_master.py.

Change-Id: I085d892f6f1583a45f10eb394f195bbea5a334ef
diff --git a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
index ede0046..206ce6b 100644
--- a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
+++ b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
@@ -45,11 +45,11 @@
 
 #define CALLBACK_LIST(V)                  \
     V(created, Created)                   \
-    V(enteredDocument, EnteredDocument)   \
-    V(leftDocument, LeftDocument)         \
+    V(enteredView, EnteredView)           \
+    V(leftView, LeftView)                 \
     V(attributeChanged, AttributeChanged)
 
-PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks::create(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredDocument, v8::Handle<v8::Function> leftDocument, v8::Handle<v8::Function> attributeChanged)
+PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks::create(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
 {
     // A given object can only be used as a Custom Element prototype
     // once; see customElementIsInterfacePrototypeObject
@@ -61,19 +61,19 @@
     CALLBACK_LIST(SET_HIDDEN_PROPERTY)
 #undef SET_HIDDEN_PROPERTY
 
-    return adoptRef(new V8CustomElementLifecycleCallbacks(scriptExecutionContext, prototype, created, enteredDocument, leftDocument, attributeChanged));
+    return adoptRef(new V8CustomElementLifecycleCallbacks(scriptExecutionContext, prototype, created, enteredView, leftView, attributeChanged));
 }
 
-static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Function> enteredDocument, v8::Handle<v8::Function> leftDocument, v8::Handle<v8::Function> attributeChanged)
+static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
 {
     // V8 Custom Elements always run created to swizzle prototypes.
     int flags = CustomElementLifecycleCallbacks::Created;
 
-    if (!enteredDocument.IsEmpty())
-        flags |= CustomElementLifecycleCallbacks::EnteredDocument;
+    if (!enteredView.IsEmpty())
+        flags |= CustomElementLifecycleCallbacks::EnteredView;
 
-    if (!leftDocument.IsEmpty())
-        flags |= CustomElementLifecycleCallbacks::LeftDocument;
+    if (!leftView.IsEmpty())
+        flags |= CustomElementLifecycleCallbacks::LeftView;
 
     if (!attributeChanged.IsEmpty())
         flags |= CustomElementLifecycleCallbacks::AttributeChanged;
@@ -87,14 +87,14 @@
     handle->clear();
 }
 
-V8CustomElementLifecycleCallbacks::V8CustomElementLifecycleCallbacks(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredDocument, v8::Handle<v8::Function> leftDocument, v8::Handle<v8::Function> attributeChanged)
-    : CustomElementLifecycleCallbacks(flagSet(enteredDocument, leftDocument, attributeChanged))
+V8CustomElementLifecycleCallbacks::V8CustomElementLifecycleCallbacks(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
+    : CustomElementLifecycleCallbacks(flagSet(enteredView, leftView, attributeChanged))
     , ActiveDOMCallback(scriptExecutionContext)
     , m_world(DOMWrapperWorld::current())
     , m_prototype(prototype)
     , m_created(created)
-    , m_enteredDocument(enteredDocument)
-    , m_leftDocument(leftDocument)
+    , m_enteredView(enteredView)
+    , m_leftView(leftView)
     , m_attributeChanged(attributeChanged)
     , m_owner(0)
 {
@@ -125,7 +125,7 @@
     if (!m_owner)
         return;
 
-    v8::HandleScope handleScope;
+    v8::HandleScope handleScope(getIsolateFromScriptExecutionContext(scriptExecutionContext()));
     if (V8PerContextData* perContextData = creationContextData())
         perContextData->clearCustomElementBinding(m_owner);
 }
@@ -153,13 +153,13 @@
 
     element->setCustomElementState(Element::Upgraded);
 
-    v8::HandleScope handleScope;
+    v8::Isolate* isolate = getIsolateFromScriptExecutionContext(scriptExecutionContext());
+    v8::HandleScope handleScope(isolate);
     v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());
     if (context.IsEmpty())
         return;
 
     v8::Context::Scope scope(context);
-    v8::Isolate* isolate = context->GetIsolate();
 
     v8::Handle<v8::Object> receiver = DOMDataStore::current(isolate)->get<V8Element>(element, isolate);
     if (!receiver.IsEmpty()) {
@@ -183,17 +183,17 @@
 
     v8::TryCatch exceptionCatcher;
     exceptionCatcher.SetVerbose(true);
-    ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0);
+    ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0, isolate);
 }
 
-void V8CustomElementLifecycleCallbacks::enteredDocument(Element* element)
+void V8CustomElementLifecycleCallbacks::enteredView(Element* element)
 {
-    call(m_enteredDocument, element);
+    call(m_enteredView, element);
 }
 
-void V8CustomElementLifecycleCallbacks::leftDocument(Element* element)
+void V8CustomElementLifecycleCallbacks::leftView(Element* element)
 {
-    call(m_leftDocument, element);
+    call(m_leftView, element);
 }
 
 void V8CustomElementLifecycleCallbacks::attributeChanged(Element* element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
@@ -201,13 +201,13 @@
     if (!canInvokeCallback())
         return;
 
-    v8::HandleScope handleScope;
+    v8::Isolate* isolate = getIsolateFromScriptExecutionContext(scriptExecutionContext());
+    v8::HandleScope handleScope(isolate);
     v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());
     if (context.IsEmpty())
         return;
 
     v8::Context::Scope scope(context);
-    v8::Isolate* isolate = context->GetIsolate();
 
     v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).As<v8::Object>();
     ASSERT(!receiver.IsEmpty());
@@ -224,7 +224,7 @@
 
     v8::TryCatch exceptionCatcher;
     exceptionCatcher.SetVerbose(true);
-    ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, WTF_ARRAY_LENGTH(argv), argv);
+    ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, WTF_ARRAY_LENGTH(argv), argv, isolate);
 }
 
 void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function>& weakCallback, Element* element)
@@ -232,7 +232,7 @@
     if (!canInvokeCallback())
         return;
 
-    v8::HandleScope handleScope;
+    v8::HandleScope handleScope(getIsolateFromScriptExecutionContext(scriptExecutionContext()));
     v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());
     if (context.IsEmpty())
         return;
@@ -249,7 +249,7 @@
 
     v8::TryCatch exceptionCatcher;
     exceptionCatcher.SetVerbose(true);
-    ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0);
+    ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0, isolate);
 }
 
 } // namespace WebCore