Changeset 51407 in webkit
- Timestamp:
- Nov 26, 2009 12:43:41 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r51402 r51407 1 2009-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 1 16 2009-11-25 Dimitri Glazkov <dglazkov@chromium.org> 2 17 -
trunk/WebCore/bindings/v8/V8Proxy.cpp
r51312 r51407 55 55 56 56 #include <algorithm> 57 #include <stdio.h> 57 58 #include <utility> 58 59 #include <v8.h> … … 61 62 #include <wtf/OwnArrayPtr.h> 62 63 #include <wtf/StdLibExtras.h> 64 #include <wtf/StringExtras.h> 63 65 #include <wtf/UnusedParam.h> 64 66 … … 69 71 // Static list of registered extensions 70 72 V8Extensions V8Proxy::m_extensions; 71 72 const char* V8Proxy::kContextDebugDataType = "type";73 const char* V8Proxy::kContextDebugDataValue = "value";74 73 75 74 void batchConfigureAttributes(v8::Handle<v8::ObjectTemplate> instance, … … 388 387 // Setup context id for JS debugger. 389 388 v8::Context::Scope contextScope(targetContext); 390 v8::Handle<v8::Object> contextData = v8::Object::New();391 if (contextData.IsEmpty())392 return false;393 394 389 if (m_context.IsEmpty()) 395 390 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 408 399 return true; 409 400 } … … 1367 1358 1368 1359 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 1373 1365 return true; 1374 1366 } … … 1377 1369 { 1378 1370 v8::HandleScope scope; 1379 if (!context->GetData()->Is Object())1371 if (!context->GetData()->IsString()) 1380 1372 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); 1383 1376 } 1384 1377 -
trunk/WebCore/bindings/v8/V8Proxy.h
r51312 r51407 366 366 367 367 private: 368 static const char* kContextDebugDataType;369 static const char* kContextDebugDataValue;370 371 368 void setSecurityToken(); 372 369 void clearDocumentWrapper();
Note: See TracChangeset
for help on using the changeset viewer.