Changeset 51407 in webkit


Ignore:
Timestamp:
Nov 26, 2009 12:43:41 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-26 Søren Gjesse <sgjesse@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):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51402 r51407  
     12009-11-26  Søren Gjesse  <sgjesse@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        [V8] Avoid using JavaScript objects as context data
     6        https://bugs.webkit.org/show_bug.cgi?id=31873
     7
     8        Change the context "data" from a JavaScript object holding the two properties type and value to
     9        a string holding type and value separated by a comma.
     10
     11        * bindings/v8/V8Proxy.cpp:
     12        (WebCore::V8Proxy::setInjectedScriptContextDebugId):
     13        (WebCore::V8Proxy::setContextDebugId):
     14        (WebCore::V8Proxy::contextDebugId):
     15
    1162009-11-25  Dimitri Glazkov  <dglazkov@chromium.org>
    217
  • trunk/WebCore/bindings/v8/V8Proxy.cpp

    r51312 r51407  
    5555
    5656#include <algorithm>
     57#include <stdio.h>
    5758#include <utility>
    5859#include <v8.h>
     
    6162#include <wtf/OwnArrayPtr.h>
    6263#include <wtf/StdLibExtras.h>
     64#include <wtf/StringExtras.h>
    6365#include <wtf/UnusedParam.h>
    6466
     
    6971// Static list of registered extensions
    7072V8Extensions V8Proxy::m_extensions;
    71 
    72 const char* V8Proxy::kContextDebugDataType = "type";
    73 const char* V8Proxy::kContextDebugDataValue = "value";
    7473
    7574void batchConfigureAttributes(v8::Handle<v8::ObjectTemplate> instance,
     
    388387    // Setup context id for JS debugger.
    389388    v8::Context::Scope contextScope(targetContext);
    390     v8::Handle<v8::Object> contextData = v8::Object::New();
    391     if (contextData.IsEmpty())
    392         return false;
    393 
    394389    if (m_context.IsEmpty())
    395390        return false;
    396     v8::Handle<v8::Value> windowContextData = m_context->GetData();
    397     if (windowContextData->IsObject()) {
    398         v8::Handle<v8::String> propertyName = v8::String::New(kContextDebugDataValue);
    399         if (propertyName.IsEmpty())
    400             return false;
    401         contextData->Set(propertyName, v8::Object::Cast(*windowContextData)->Get(propertyName));
    402     }
    403     v8::Handle<v8::String> propertyName = v8::String::New(kContextDebugDataType);
    404     if (propertyName.IsEmpty())
    405         return false;
    406     contextData->Set(propertyName, v8::String::New("injected"));
    407     targetContext->SetData(contextData);
     391    int debugId = contextDebugId(m_context);
     392    if (debugId == -1)
     393        return false;
     394
     395    char buffer[32];
     396    snprintf(buffer, sizeof(buffer), "injected,%d", debugId);
     397    targetContext->SetData(v8::String::New(buffer));
     398
    408399    return true;
    409400}
     
    13671358
    13681359    v8::Context::Scope contextScope(m_context);
    1369     v8::Handle<v8::Object> contextData = v8::Object::New();
    1370     contextData->Set(v8::String::New(kContextDebugDataType), v8::String::New("page"));
    1371     contextData->Set(v8::String::New(kContextDebugDataValue), v8::Integer::New(debugId));
    1372     m_context->SetData(contextData);
     1360
     1361    char buffer[32];
     1362    snprintf(buffer, sizeof(buffer), "page,%d", debugId);
     1363    m_context->SetData(v8::String::New(buffer));
     1364
    13731365    return true;
    13741366}
     
    13771369{
    13781370    v8::HandleScope scope;
    1379     if (!context->GetData()->IsObject())
     1371    if (!context->GetData()->IsString())
    13801372        return -1;
    1381     v8::Handle<v8::Value> data = context->GetData()->ToObject()->Get( v8::String::New(kContextDebugDataValue));
    1382     return data->IsInt32() ? data->Int32Value() : -1;
     1373    v8::String::AsciiValue ascii(context->GetData());
     1374    char* comma = strnstr(*ascii, ",", ascii.length());
     1375    return atoi(comma + 1);
    13831376}
    13841377
  • trunk/WebCore/bindings/v8/V8Proxy.h

    r51312 r51407  
    366366
    367367    private:
    368         static const char* kContextDebugDataType;
    369         static const char* kContextDebugDataValue;
    370 
    371368        void setSecurityToken();
    372369        void clearDocumentWrapper();
Note: See TracChangeset for help on using the changeset viewer.