Title: [132845] trunk/Source
Revision
132845
Author
[email protected]
Date
2012-10-29 14:05:32 -0700 (Mon, 29 Oct 2012)

Log Message

Remove ensureAuxiliaryContext
https://bugs.webkit.org/show_bug.cgi?id=99975

Patch by Dan Carney <[email protected]> on 2012-10-29
Reviewed by Adam Barth.

Source/WebCore:

Removed auxilliaryContext as use if it is problematic in IDB.

No new tests. No change in functionality.

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::setValueReady):
* Modules/indexeddb/IDBCursor.h:
(IDBCursor):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::generateIndexKeysForValue):
(WebCore::IDBObjectStore::put):
(WebCore):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::onSuccess):
(WebCore::IDBRequest::dispatchEvent):
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromScriptValueAndKeyPath):
(WebCore::deserializeIDBValue):
(WebCore::injectIDBKeyIntoScriptValue):
* bindings/v8/IDBBindingUtilities.h:
(WebCore):
* bindings/v8/V8Binding.cpp:
(WebCore::toV8Context):
(WebCore):
* bindings/v8/V8Binding.h:
(WebCore):
* bindings/v8/V8PerIsolateData.cpp:
(WebCore):
* bindings/v8/V8PerIsolateData.h:

Source/WebKit/chromium:

Updated tests to use correct v8 context.

* tests/IDBBindingUtilitiesTest.cpp:
(WebKit::checkKeyFromValueAndKeyPathInternal):
(WebKit::checkKeyPathNullValue):
(WebKit::injectKey):
(WebKit::checkInjection):
(WebKit::checkInjectionFails):
(WebKit::checkKeyPathStringValue):
(WebKit::checkKeyPathNumberValue):
(WebKit::scriptExecutionContext):
(WebKit):
(WebKit::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132844 => 132845)


--- trunk/Source/WebCore/ChangeLog	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebCore/ChangeLog	2012-10-29 21:05:32 UTC (rev 132845)
@@ -1,3 +1,41 @@
+2012-10-29  Dan Carney  <[email protected]>
+
+        Remove ensureAuxiliaryContext
+        https://bugs.webkit.org/show_bug.cgi?id=99975
+
+        Reviewed by Adam Barth.
+
+        Removed auxilliaryContext as use if it is problematic in IDB.
+
+        No new tests. No change in functionality.
+
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::update):
+        (WebCore::IDBCursor::setValueReady):
+        * Modules/indexeddb/IDBCursor.h:
+        (IDBCursor):
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::generateIndexKeysForValue):
+        (WebCore::IDBObjectStore::put):
+        (WebCore):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::onSuccess):
+        (WebCore::IDBRequest::dispatchEvent):
+        * bindings/v8/IDBBindingUtilities.cpp:
+        (WebCore::createIDBKeyFromScriptValueAndKeyPath):
+        (WebCore::deserializeIDBValue):
+        (WebCore::injectIDBKeyIntoScriptValue):
+        * bindings/v8/IDBBindingUtilities.h:
+        (WebCore):
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::toV8Context):
+        (WebCore):
+        * bindings/v8/V8Binding.h:
+        (WebCore):
+        * bindings/v8/V8PerIsolateData.cpp:
+        (WebCore):
+        * bindings/v8/V8PerIsolateData.h:
+
 2012-10-29  Alpha Lam  <[email protected]>
 
         [skia] Handle mask box image.

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (132844 => 132845)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2012-10-29 21:05:32 UTC (rev 132845)
@@ -42,6 +42,9 @@
 #include "IDBTracing.h"
 #include "IDBTransaction.h"
 #include "ScriptExecutionContext.h"
+#if USE(V8)
+#include "V8Binding.h"
+#endif
 
 namespace WebCore {
 
@@ -76,6 +79,9 @@
     , m_pendingCursor(0)
     , m_didFireUpgradeNeededEvent(false)
     , m_preventPropagation(false)
+#if USE(V8)
+    , m_worldContextHandle(UseCurrentWorld)
+#endif
 {
     if (m_transaction) {
         m_transaction->registerRequest(this);
@@ -284,6 +290,14 @@
     if (!shouldEnqueueEvent())
         return;
 
+#if USE(V8)
+    v8::HandleScope handleScope;
+    v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
+    if (context.IsEmpty())
+        CRASH();
+    v8::Context::Scope contextScope(context);
+#endif
+
     ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serializedValue);
     ASSERT(m_cursorType != IDBCursorBackendInterface::InvalidCursorType);
     RefPtr<IDBCursor> cursor;
@@ -340,6 +354,14 @@
     if (!shouldEnqueueEvent())
         return;
 
+#if USE(V8)
+    v8::HandleScope handleScope;
+    v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
+    if (context.IsEmpty())
+        CRASH();
+    v8::Context::Scope contextScope(context);
+#endif
+
     ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serializedScriptValue);
     onSuccessInternal(value);
 }
@@ -363,6 +385,14 @@
     if (!shouldEnqueueEvent())
         return;
 
+#if USE(V8)
+    v8::HandleScope handleScope;
+    v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
+    if (context.IsEmpty())
+        CRASH();
+    v8::Context::Scope contextScope(context);
+#endif
+
 #ifndef NDEBUG
     ASSERT(keyPath == effectiveObjectStore(m_source)->keyPath());
 #endif
@@ -404,6 +434,14 @@
     if (!shouldEnqueueEvent())
         return;
 
+#if USE(V8)
+    v8::HandleScope handleScope;
+    v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
+    if (context.IsEmpty())
+        CRASH();
+    v8::Context::Scope contextScope(context);
+#endif
+
     ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serializedValue);
     ASSERT(m_pendingCursor);
     setResultCursor(m_pendingCursor.release(), key, primaryKey, value);
@@ -449,6 +487,15 @@
     ASSERT(scriptExecutionContext());
     ASSERT(event->target() == this);
     ASSERT_WITH_MESSAGE(m_readyState < DONE, "When dispatching event %s, m_readyState < DONE(%d), was %d", event->type().string().utf8().data(), DONE, m_readyState);
+
+#if USE(V8)
+    v8::HandleScope handleScope;
+    v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
+    if (context.IsEmpty())
+        CRASH();
+    v8::Context::Scope contextScope(context);
+#endif
+
     if (event->type() != eventNames().blockedEvent)
         m_readyState = DONE;
 

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h (132844 => 132845)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2012-10-29 21:05:32 UTC (rev 132845)
@@ -42,6 +42,9 @@
 #include "IDBCallbacks.h"
 #include "IDBCursor.h"
 #include "IDBCursorBackendInterface.h"
+#if USE(V8)
+#include "WorldContextHandle.h"
+#endif
 
 namespace WebCore {
 
@@ -155,6 +158,9 @@
     bool m_preventPropagation;
 
     EventTargetData m_eventTargetData;
+#if USE(V8)
+    WorldContextHandle m_worldContextHandle;
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp (132844 => 132845)


--- trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp	2012-10-29 21:05:32 UTC (rev 132845)
@@ -179,10 +179,9 @@
     IDBKeyPathParseError error;
     IDBParseKeyPath(keyPath, keyPathElements, error);
     ASSERT(error == IDBKeyPathParseErrorNone);
+    ASSERT(v8::Context::InContext());
 
     v8::HandleScope handleScope;
-    v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
-
     v8::Handle<v8::Value> v8Value(value.v8Value());
     v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size()));
     if (v8Key.IsEmpty())
@@ -194,8 +193,10 @@
 {
     IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
     ASSERT(!keyPath.isNull());
+    ASSERT(v8::Context::InContext());
 
-    v8::HandleScope scope;
+
+    v8::HandleScope handleScope;
     if (keyPath.type() == IDBKeyPath::ArrayType) {
         IDBKey::KeyArray result;
         const Vector<String>& array = keyPath.array();
@@ -212,11 +213,10 @@
     return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string());
 }
 
-// FIXME: The only reason this exists is because we need a v8::Context and scope inside a timer. Is there a better / more general way to do this?
 ScriptValue deserializeIDBValue(ScriptExecutionContext* scriptContext, PassRefPtr<SerializedScriptValue> prpValue)
 {
+    ASSERT(v8::Context::InContext());
     v8::HandleScope handleScope;
-    v8::Context::Scope contextScope(toV8Context(scriptContext, UseCurrentWorld));
     RefPtr<SerializedScriptValue> serializedValue = prpValue;
     if (serializedValue)
         return ScriptValue(serializedValue->deserialize());
@@ -226,6 +226,7 @@
 bool injectIDBKeyIntoScriptValue(PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
 {
     IDB_TRACE("injectIDBKeyIntoScriptValue");
+    ASSERT(v8::Context::InContext());
 
     ASSERT(keyPath.type() == IDBKeyPath::StringType);
     Vector<String> keyPathElements;
@@ -237,8 +238,6 @@
         return 0;
 
     v8::HandleScope handleScope;
-    v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
-
     v8::Handle<v8::Value> v8Value(value.v8Value());
     v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1));
     if (parent.IsEmpty())
@@ -268,9 +267,8 @@
 
 ScriptValue idbKeyToScriptValue(ScriptExecutionContext* scriptContext, PassRefPtr<IDBKey> key)
 {
+    ASSERT(v8::Context::InContext());
     v8::HandleScope handleScope;
-    v8::Context::Scope contextScope(toV8Context(scriptContext, UseCurrentWorld));
-
     v8::Handle<v8::Value> v8Value(toV8(key.get()));
     return ScriptValue(v8Value);
 }

Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp (132844 => 132845)


--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp	2012-10-29 21:05:32 UTC (rev 132845)
@@ -132,13 +132,6 @@
 }
 #endif
 
-v8::Handle<v8::Context> V8PerIsolateData::ensureAuxiliaryContext()
-{
-    if (m_auxiliaryContext.isEmpty())
-        m_auxiliaryContext.adopt(v8::Context::New());
-    return m_auxiliaryContext.get();
-}
-
 v8::Handle<v8::Value> V8PerIsolateData::constructorOfToString(const v8::Arguments& args)
 {
     // The DOM constructors' toString functions grab the current toString

Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h (132844 => 132845)


--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h	2012-10-29 21:05:32 UTC (rev 132845)
@@ -86,7 +86,6 @@
     DOMDataList& allStores() { return m_domDataList; }
 
     V8HiddenPropertyName* hiddenPropertyName() { return m_hiddenPropertyName.get(); }
-    v8::Handle<v8::Context> ensureAuxiliaryContext();
 
     void registerDOMDataStore(DOMDataStore* domDataStore) 
     {

Modified: trunk/Source/WebKit/chromium/ChangeLog (132844 => 132845)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-10-29 21:05:32 UTC (rev 132845)
@@ -1,3 +1,24 @@
+2012-10-29  Dan Carney  <[email protected]>
+
+        Remove ensureAuxiliaryContext
+        https://bugs.webkit.org/show_bug.cgi?id=99975
+
+        Reviewed by Adam Barth.
+
+        Updated tests to use correct v8 context.
+
+        * tests/IDBBindingUtilitiesTest.cpp:
+        (WebKit::checkKeyFromValueAndKeyPathInternal):
+        (WebKit::checkKeyPathNullValue):
+        (WebKit::injectKey):
+        (WebKit::checkInjection):
+        (WebKit::checkInjectionFails):
+        (WebKit::checkKeyPathStringValue):
+        (WebKit::checkKeyPathNumberValue):
+        (WebKit::scriptExecutionContext):
+        (WebKit):
+        (WebKit::TEST):
+
 2012-10-29  Patrick Dubroy  <[email protected]>
 
         Web Inspector: Style toolbar to match Chromium toolbar on Chromium/Mac.

Modified: trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp (132844 => 132845)


--- trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp	2012-10-29 20:57:13 UTC (rev 132844)
+++ trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp	2012-10-29 21:05:32 UTC (rev 132845)
@@ -24,11 +24,19 @@
  */
 
 #include "config.h"
+#include "Document.h"
+#include "Frame.h"
+#include "FrameTestHelpers.h"
 #include "IDBBindingUtilities.h"
 #include "IDBKey.h"
 #include "IDBKeyPath.h"
+#include "V8Binding.h"
 #include "V8PerIsolateData.h"
 #include "V8Utilities.h"
+#include "WebFrame.h"
+#include "WebFrameImpl.h"
+#include "WebView.h"
+#include "WorldContextHandle.h"
 
 #include <gtest/gtest.h>
 #include <wtf/Vector.h>
@@ -36,6 +44,7 @@
 #if ENABLE(INDEXED_DATABASE)
 
 using namespace WebCore;
+using namespace WebKit;
 
 namespace {
 
@@ -90,10 +99,21 @@
     ASSERT_TRUE(expected == idbKey->number());
 }
 
+static v8::Handle<v8::Context> context()
+{
+    static WebView* webView;
+    if (!webView) {
+        webView = FrameTestHelpers::createWebViewAndLoad("about:blank");
+        webView->setFocus(true);
+    }
+    ScriptExecutionContext* context = static_cast<WebFrameImpl*>(webView->mainFrame())->frame()->document();
+    return toV8Context(context, WorldContextHandle(UseCurrentWorld));
+}
+
 TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue)
 {
     v8::HandleScope handleScope;
-    v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
+    v8::Context::Scope scope(context());
 
     v8::Local<v8::Object> object = v8::Object::New();
     object->Set(v8::String::New("foo"), v8::String::New("zoo"));
@@ -107,7 +127,7 @@
 TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue)
 {
     v8::HandleScope handleScope;
-    v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
+    v8::Context::Scope scope(context());
 
     v8::Local<v8::Object> object = v8::Object::New();
     object->Set(v8::String::New("foo"), v8::Number::New(456));
@@ -121,7 +141,7 @@
 TEST(IDBKeyFromValueAndKeyPathTest, SubProperty)
 {
     v8::HandleScope handleScope;
-    v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
+    v8::Context::Scope scope(context());
 
     v8::Local<v8::Object> object = v8::Object::New();
     v8::Local<v8::Object> subProperty = v8::Object::New();
@@ -137,7 +157,7 @@
 TEST(InjectIDBKeyTest, TopLevelPropertyStringValue)
 {
     v8::HandleScope handleScope;
-    v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
+    v8::Context::Scope scope(context());
 
     v8::Local<v8::Object> object = v8::Object::New();
     object->Set(v8::String::New("foo"), v8::String::New("zoo"));
@@ -152,7 +172,7 @@
 TEST(InjectIDBKeyTest, SubProperty)
 {
     v8::HandleScope handleScope;
-    v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
+    v8::Context::Scope scope(context());
 
     v8::Local<v8::Object> object = v8::Object::New();
     v8::Local<v8::Object> subProperty = v8::Object::New();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to