[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Wed Apr 7 23:57:42 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit b5721653e503d217023c1b7d834f7f8dd191c1fa
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 26 08:43:41 2009 +0000

    2009-11-26  Søren Gjesse  <sgjesse at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            [V8] Avoid using JavaScript objects as context data
            https://bugs.webkit.org/show_bug.cgi?id=31873
    
            Change the context "data" from a JavaScript object holding the two properties type and value to
            a string holding type and value separated by a comma.
    
            * bindings/v8/V8Proxy.cpp:
            (WebCore::V8Proxy::setInjectedScriptContextDebugId):
            (WebCore::V8Proxy::setContextDebugId):
            (WebCore::V8Proxy::contextDebugId):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51407 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7d79ea6..e314ac1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-26  Søren Gjesse  <sgjesse at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        [V8] Avoid using JavaScript objects as context data
+        https://bugs.webkit.org/show_bug.cgi?id=31873
+
+        Change the context "data" from a JavaScript object holding the two properties type and value to
+        a string holding type and value separated by a comma.
+
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::setInjectedScriptContextDebugId):
+        (WebCore::V8Proxy::setContextDebugId):
+        (WebCore::V8Proxy::contextDebugId):
+
 2009-11-25  Dimitri Glazkov  <dglazkov at chromium.org>
 
         Reviewed by David Levin.
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index 89a8b57..6764d0d 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -54,12 +54,14 @@
 #include "WorkerContextExecutionProxy.h"
 
 #include <algorithm>
+#include <stdio.h>
 #include <utility>
 #include <v8.h>
 #include <v8-debug.h>
 #include <wtf/Assertions.h>
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/StdLibExtras.h>
+#include <wtf/StringExtras.h>
 #include <wtf/UnusedParam.h>
 
 namespace WebCore {
@@ -69,9 +71,6 @@ v8::Persistent<v8::Context> V8Proxy::m_utilityContext;
 // Static list of registered extensions
 V8Extensions V8Proxy::m_extensions;
 
-const char* V8Proxy::kContextDebugDataType = "type";
-const char* V8Proxy::kContextDebugDataValue = "value";
-
 void batchConfigureAttributes(v8::Handle<v8::ObjectTemplate> instance, 
                               v8::Handle<v8::ObjectTemplate> proto, 
                               const BatchedAttribute* attributes, 
@@ -387,24 +386,16 @@ bool V8Proxy::setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetCont
 {
     // Setup context id for JS debugger.
     v8::Context::Scope contextScope(targetContext);
-    v8::Handle<v8::Object> contextData = v8::Object::New();
-    if (contextData.IsEmpty())
-        return false;
-
     if (m_context.IsEmpty())
         return false;
-    v8::Handle<v8::Value> windowContextData = m_context->GetData();
-    if (windowContextData->IsObject()) {
-        v8::Handle<v8::String> propertyName = v8::String::New(kContextDebugDataValue);
-        if (propertyName.IsEmpty())
-            return false;
-        contextData->Set(propertyName, v8::Object::Cast(*windowContextData)->Get(propertyName));
-    }
-    v8::Handle<v8::String> propertyName = v8::String::New(kContextDebugDataType);
-    if (propertyName.IsEmpty())
+    int debugId = contextDebugId(m_context);
+    if (debugId == -1)
         return false;
-    contextData->Set(propertyName, v8::String::New("injected"));
-    targetContext->SetData(contextData);
+
+    char buffer[32];
+    snprintf(buffer, sizeof(buffer), "injected,%d", debugId);
+    targetContext->SetData(v8::String::New(buffer));
+
     return true;
 }
 
@@ -1366,20 +1357,22 @@ bool V8Proxy::setContextDebugId(int debugId)
         return false;
 
     v8::Context::Scope contextScope(m_context);
-    v8::Handle<v8::Object> contextData = v8::Object::New();
-    contextData->Set(v8::String::New(kContextDebugDataType), v8::String::New("page"));
-    contextData->Set(v8::String::New(kContextDebugDataValue), v8::Integer::New(debugId));
-    m_context->SetData(contextData);
+
+    char buffer[32];
+    snprintf(buffer, sizeof(buffer), "page,%d", debugId);
+    m_context->SetData(v8::String::New(buffer));
+
     return true;
 }
 
 int V8Proxy::contextDebugId(v8::Handle<v8::Context> context)
 {
     v8::HandleScope scope;
-    if (!context->GetData()->IsObject())
+    if (!context->GetData()->IsString())
         return -1;
-    v8::Handle<v8::Value> data = context->GetData()->ToObject()->Get( v8::String::New(kContextDebugDataValue));
-    return data->IsInt32() ? data->Int32Value() : -1;
+    v8::String::AsciiValue ascii(context->GetData());
+    char* comma = strnstr(*ascii, ",", ascii.length());
+    return atoi(comma + 1);
 }
 
 v8::Handle<v8::Value> V8Proxy::getHiddenObjectPrototype(v8::Handle<v8::Context> context)
diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h
index c8628d1..ab351af 100644
--- a/WebCore/bindings/v8/V8Proxy.h
+++ b/WebCore/bindings/v8/V8Proxy.h
@@ -365,9 +365,6 @@ namespace WebCore {
         void updateDocumentWrapper(v8::Handle<v8::Value> wrapper);
 
     private:
-        static const char* kContextDebugDataType;
-        static const char* kContextDebugDataValue;
-
         void setSecurityToken();
         void clearDocumentWrapper();
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list