Unreviewed, rolling out r143441.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 21:56:27 +0000 (21:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 21:56:27 +0000 (21:56 +0000)
http://trac.webkit.org/changeset/143441
https://bugs.webkit.org/show_bug.cgi?id=110376

May be causing chromium content_browsertests failures.
(Requested by vollick on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2013-02-20

* bindings/v8/ScriptValue.cpp:
(WebCore::ScriptValue::serialize):
(WebCore::ScriptValue::getString):
(WebCore::ScriptValue::toString):
(WebCore::ScriptValue::toInspectorValue):
* bindings/v8/ScriptValue.h:
(WebCore::ScriptValue::ScriptValue):
(WebCore::ScriptValue::operator=):
(WebCore::ScriptValue::operator==):
(WebCore::ScriptValue::isEqual):
(WebCore::ScriptValue::isFunction):
(WebCore::ScriptValue::isNull):
(WebCore::ScriptValue::isUndefined):
(WebCore::ScriptValue::isObject):
(WebCore::ScriptValue::hasNoValue):
(WebCore::ScriptValue::clear):
(WebCore::ScriptValue::v8Value):
(ScriptValue):
* bindings/v8/SharedPersistent.h:
(WebCore):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::InjectedScriptHost::scriptValueAsNode):
* bindings/v8/custom/V8MessageEventCustom.cpp:
(WebCore::V8MessageEvent::dataAttrGetterCustom):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143503 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/ScriptValue.cpp
Source/WebCore/bindings/v8/ScriptValue.h
Source/WebCore/bindings/v8/SharedPersistent.h
Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp

index c3d0bcf46cf8385c1015a0fe19efa92facb9601d..500ba584c9390fd6aa29e58084c4dbe9d13d534f 100644 (file)
@@ -1,3 +1,37 @@
+2013-02-20  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r143441.
+        http://trac.webkit.org/changeset/143441
+        https://bugs.webkit.org/show_bug.cgi?id=110376
+
+        May be causing chromium content_browsertests failures.
+        (Requested by vollick on #webkit).
+
+        * bindings/v8/ScriptValue.cpp:
+        (WebCore::ScriptValue::serialize):
+        (WebCore::ScriptValue::getString):
+        (WebCore::ScriptValue::toString):
+        (WebCore::ScriptValue::toInspectorValue):
+        * bindings/v8/ScriptValue.h:
+        (WebCore::ScriptValue::ScriptValue):
+        (WebCore::ScriptValue::operator=):
+        (WebCore::ScriptValue::operator==):
+        (WebCore::ScriptValue::isEqual):
+        (WebCore::ScriptValue::isFunction):
+        (WebCore::ScriptValue::isNull):
+        (WebCore::ScriptValue::isUndefined):
+        (WebCore::ScriptValue::isObject):
+        (WebCore::ScriptValue::hasNoValue):
+        (WebCore::ScriptValue::clear):
+        (WebCore::ScriptValue::v8Value):
+        (ScriptValue):
+        * bindings/v8/SharedPersistent.h:
+        (WebCore):
+        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+        (WebCore::InjectedScriptHost::scriptValueAsNode):
+        * bindings/v8/custom/V8MessageEventCustom.cpp:
+        (WebCore::V8MessageEvent::dataAttrGetterCustom):
+
 2013-02-15  Dirk Schulze  <krit@webkit.org>
 
         [Chromium] Add runtime flag for CanvasPath
index bd0515739d18e0f672384baa9694ecb71a853fad..0799948533cab354a9f1eb25c9602d95bb7db94e 100644 (file)
@@ -47,13 +47,13 @@ ScriptValue::~ScriptValue()
 PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState)
 {
     ScriptScope scope(scriptState);
-    return SerializedScriptValue::create(v8ValueRaw());
+    return SerializedScriptValue::create(v8Value());
 }
 
 PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, bool& didThrow)
 {
     ScriptScope scope(scriptState);
-    return SerializedScriptValue::create(v8ValueRaw(), messagePorts, arrayBuffers, didThrow);
+    return SerializedScriptValue::create(v8Value(), messagePorts, arrayBuffers, didThrow);
 }
 
 ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value)
@@ -64,20 +64,20 @@ ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptV
 
 bool ScriptValue::getString(String& result) const
 {
-    if (hasNoValue())
+    if (m_value.isEmpty())
         return false;
 
-    if (!v8ValueRaw()->IsString())
+    if (!m_value->IsString())
         return false;
 
-    result = toWebCoreString(v8ValueRaw());
+    result = toWebCoreString(m_value.get());
     return true;
 }
 
 String ScriptValue::toString(ScriptState*) const
 {
     v8::TryCatch block;
-    v8::Handle<v8::String> string = v8ValueRaw()->ToString();
+    v8::Handle<v8::String> string = m_value->ToString();
     if (block.HasCaught())
         return String();
     return v8StringToWebCoreString<String>(string, DoNotExternalize);
@@ -142,7 +142,7 @@ PassRefPtr<InspectorValue> ScriptValue::toInspectorValue(ScriptState* scriptStat
     v8::HandleScope handleScope;
     // v8::Object::GetPropertyNames() expects current context to be not null.
     v8::Context::Scope contextScope(scriptState->context());
-    return v8ToInspectorValue(v8ValueRaw(), InspectorValue::maxDepth);
+    return v8ToInspectorValue(m_value.get(), InspectorValue::maxDepth);
 }
 #endif
 
index 2ba9d3177d501b7cccdfd6bb9f8726bea9c0855e..aa8c9983464c60823ab471d1734b6a8792811982 100644 (file)
@@ -31,8 +31,8 @@
 #ifndef ScriptValue_h
 #define ScriptValue_h
 
+#include "ScopedPersistent.h"
 #include "ScriptState.h"
-#include "SharedPersistent.h"
 #include <v8.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
@@ -60,37 +60,47 @@ public:
     ScriptValue() { }
     virtual ~ScriptValue();
 
-    ScriptValue(v8::Handle<v8::Value> value)
-        : m_value(value.IsEmpty() ? 0 : SharedPersistent<v8::Value>::create(value))
+    ScriptValue(v8::Handle<v8::Value> value) 
     {
+        if (value.IsEmpty())
+            return;
+        m_value.set(value);
     }
 
-    ScriptValue(const ScriptValue& value)
-        : m_value(value.m_value)
+    ScriptValue(const ScriptValue& value) 
     {
+        if (value.hasNoValue())
+            return;
+        m_value.set(value.m_value.get());
     }
 
     ScriptValue& operator=(const ScriptValue& value) 
     {
-        if (this != &value)
-            m_value = value.m_value;
+        if (this == &value) 
+            return *this;
+
+        m_value.clear();
+
+        if (value.hasNoValue())
+            return *this;
+
+        m_value.set(value.m_value.get());
         return *this;
     }
 
     bool operator==(const ScriptValue& value) const
     {
-        return v8ValueRaw() == value.v8ValueRaw();
+        return m_value.get() == value.m_value.get();
     }
 
     bool isEqual(ScriptState*, const ScriptValue& value) const
     {
-        return operator==(value);
+        return m_value.get() == value.m_value.get();
     }
 
     bool isFunction() const
     {
-        ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsFunction();
+        return m_value->IsFunction();
     }
 
     bool operator!=(const ScriptValue& value) const
@@ -100,25 +110,22 @@ public:
 
     bool isNull() const
     {
-        ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsNull();
+        return m_value->IsNull();
     }
 
     bool isUndefined() const
     {
-        ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsUndefined();
+        return m_value->IsUndefined();
     }
 
     bool isObject() const
     {
-        ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsObject();
+        return m_value->IsObject();
     }
 
     bool hasNoValue() const
     {
-        return !m_value.get() || m_value->get().IsEmpty();
+        return m_value.isEmpty();
     }
 
     PassRefPtr<SerializedScriptValue> serialize(ScriptState*);
@@ -127,19 +134,10 @@ public:
 
     void clear()
     {
-        m_value = 0;
-    }
-
-    v8::Handle<v8::Value> v8Value() const
-    {
-        return v8::Local<v8::Value>::New(v8ValueRaw());
+        m_value.clear();
     }
 
-    // FIXME: This function should be private. 
-    v8::Handle<v8::Value> v8ValueRaw() const
-    {
-        return m_value.get() ? m_value->get() : v8::Handle<v8::Value>();
-    }
+    v8::Handle<v8::Value> v8Value() const { return m_value.get(); }
 
     bool getString(ScriptState*, String& result) const { return getString(result); }
     bool getString(String& result) const;
@@ -148,7 +146,7 @@ public:
     PassRefPtr<InspectorValue> toInspectorValue(ScriptState*) const;
 
 private:
-    RefPtr<SharedPersistent<v8::Value> > m_value;
+    ScopedPersistent<v8::Value> m_value;
 };
 
 } // namespace WebCore
index 52106c29cfdf4404efd6b70de071e69deb6d6469..2e39a06305c03967af428625560e69368296507d 100644 (file)
@@ -38,6 +38,7 @@
 
 namespace WebCore {
 
+    // FIXME: Remove this class.
     template <typename T>
     class SharedPersistent : public RefCounted<SharedPersistent<T> > {
     public:
index 8126954bc7e5e269332734b1fa9b0b9ca678f2d6..b26164162bed1e508c9de98a6f1056eae33a7057 100644 (file)
@@ -65,7 +65,7 @@ Node* InjectedScriptHost::scriptValueAsNode(ScriptValue value)
 {
     if (!value.isObject() || value.isNull())
         return 0;
-    return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8ValueRaw()));
+    return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8Value()));
 }
 
 ScriptValue InjectedScriptHost::nodeAsScriptValue(ScriptState* state, Node* node)
index 516629c5ea446f417903fa8db3675832681c4cd6..24b063b19fa44e4e09d6a26fa8f2a211894daaa3 100644 (file)
@@ -53,7 +53,7 @@ v8::Handle<v8::Value> V8MessageEvent::dataAttrGetterCustom(v8::Local<v8::String>
         if (scriptValue.hasNoValue())
             result = v8Null(info.GetIsolate());
         else
-            result = scriptValue.v8Value();
+            result = v8::Local<v8::Value>::New(scriptValue.v8Value());
         break;
     }