Changeset 65803 in webkit
- Timestamp:
- Aug 23, 2010 5:14:15 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r65802 r65803 1 2010-08-23 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 WebInspector: inspector protocol should be switched from array based 6 message format to object based message format. 7 Almost all the protocol related things is generated by CodeGeneratorInspector.pm 8 It was changed a bit. As result InspectorBackendStub.js wraps the 9 calls into Request objects. InspectorBackendDispatcher.cpp unwraps 10 these objects and calls corresponding agents. These two files and 11 RemoteInspectorFrontend are generated by CodeGeneratorInspector.pm 12 Dispatching part of WebInspector also was adjusted for handling Event 13 objects produced by RemoteInspectorFrontend.cpp and Response objects 14 produced by InspectorBackendDispatcher.cpp 15 https://bugs.webkit.org/show_bug.cgi?id=44338 16 17 * inspector/CodeGeneratorInspector.pm: 18 * inspector/Inspector.idl: 19 * inspector/InspectorController.cpp: 20 (WebCore::InspectorController::setAttachedWindow): 21 * inspector/InspectorController.h: 22 * inspector/InspectorFrontendClientLocal.cpp: 23 (WebCore::InspectorFrontendClientLocal::setAttachedWindow): 24 * inspector/InspectorValues.h: 25 (WebCore::InspectorObject::find): 26 * inspector/front-end/Callback.js: 27 (WebInspector.Callback.prototype.processResponse): 28 * inspector/front-end/inspector.js: 29 (WebInspector.dispatch): 30 (WebInspector_syncDispatch): 31 (WebInspector.dispatchMessageFromBackend): 32 (WebInspector.reportProtocolError): 33 1 34 2010-08-23 Alejandro G. Castro <alex@igalia.com> 2 35 -
trunk/WebCore/inspector/CodeGeneratorInspector.pm
r65797 r65803 18 18 "forward" => "InspectorBackend", 19 19 "header" => "InspectorBackend.h", 20 " handlerAccessor" => "m_inspectorController->inspectorBackend()",20 "domainAccessor" => "m_inspectorController->inspectorBackend()", 21 21 }; 22 22 $typeTransform{"Controller"} = { 23 23 "forwardHeader" => "InspectorController.h", 24 " handlerAccessor" => "m_inspectorController",24 "domainAccessor" => "m_inspectorController", 25 25 }; 26 26 $typeTransform{"Debug"} = { 27 27 "forward" => "InspectorDebuggerAgent", 28 28 "header" => "InspectorDebuggerAgent.h", 29 " handlerAccessor" => "m_inspectorController->debuggerAgent()",29 "domainAccessor" => "m_inspectorController->debuggerAgent()", 30 30 }; 31 31 $typeTransform{"DOM"} = { 32 32 "forward" => "InspectorDOMAgent", 33 33 "header" => "InspectorDOMAgent.h", 34 " handlerAccessor" => "m_inspectorController->domAgent()",34 "domainAccessor" => "m_inspectorController->domAgent()", 35 35 }; 36 36 $typeTransform{"ApplicationCache"} = { 37 37 "forward" => "InspectorApplicationCacheAgent", 38 38 "header" => "InspectorApplicationCacheAgent.h", 39 " handlerAccessor" => "m_inspectorController->applicationCacheAgent()",39 "domainAccessor" => "m_inspectorController->applicationCacheAgent()", 40 40 }; 41 41 $typeTransform{"Profiler"} = { 42 42 "forward" => "InspectorProfilerAgent", 43 43 "header" => "InspectorProfilerAgent.h", 44 " handlerAccessor" => "m_inspectorController->profilerAgent()",44 "domainAccessor" => "m_inspectorController->profilerAgent()", 45 45 }; 46 46 $typeTransform{"Frontend"} = { … … 57 57 "forward" => "InspectorObject", 58 58 "header" => "InspectorValues.h", 59 " accessorSuffix" => "Object"59 "JSONType" => "Object" 60 60 }; 61 61 $typeTransform{"Array"} = { … … 65 65 "forward" => "InspectorArray", 66 66 "header" => "InspectorValues.h", 67 " accessorSuffix" => "Array"67 "JSONType" => "Array" 68 68 }; 69 69 $typeTransform{"Value"} = { … … 73 73 "forward" => "InspectorValue", 74 74 "header" => "InspectorValues.h", 75 " accessorSuffix" => "Value"75 "JSONType" => "Value" 76 76 }; 77 77 $typeTransform{"String"} = { … … 80 80 "forwardHeader" => "wtf/Forward.h", 81 81 "header" => "PlatformString.h", 82 " accessorSuffix" => "String"82 "JSONType" => "String" 83 83 }; 84 84 $typeTransform{"long"} = { … … 88 88 "forward" => "", 89 89 "header" => "", 90 " accessorSuffix" => "Number"90 "JSONType" => "Number" 91 91 }; 92 92 $typeTransform{"int"} = { … … 96 96 "forward" => "", 97 97 "header" => "", 98 " accessorSuffix" => "Number",98 "JSONType" => "Number", 99 99 }; 100 100 $typeTransform{"unsigned long"} = { … … 104 104 "forward" => "", 105 105 "header" => "", 106 " accessorSuffix" => "Number"106 "JSONType" => "Number" 107 107 }; 108 108 $typeTransform{"unsigned int"} = { … … 112 112 "forward" => "", 113 113 "header" => "", 114 " accessorSuffix" => "Number"114 "JSONType" => "Number" 115 115 }; 116 116 $typeTransform{"boolean"} = { … … 120 120 "forward" => "", 121 121 "header" => "", 122 " accessorSuffix" => "Bool"122 "JSONType" => "Bool" 123 123 }; 124 124 $typeTransform{"void"} = { … … 162 162 my @frontendConstantDefinitions; 163 163 my $frontendFooter; 164 165 my $callId = new domSignature(); # it is just structure for describing parameters from IDLStructure.pm.166 $callId->type("long");167 $callId->name("callId");168 164 169 165 # Default constructor … … 223 219 $backendTypes{"InspectorClient"} = 1; 224 220 $backendTypes{"PassRefPtr"} = 1; 225 $backendTypes{"Array"} = 1; 226 227 push(@backendMethodsImpl, generateBackendPrivateFunctions()); 221 $backendTypes{"Object"} = 1; 222 228 223 push(@backendMethodsImpl, generateBackendMessageParser()); 229 224 generateFunctions($interface); … … 260 255 map($frontendTypes{$_->type} = 1, @argsFiltered); # register required types. 261 256 my $arguments = join(", ", map($typeTransform{$_->type}->{"param"} . " " . $_->name, @argsFiltered)); # prepare arguments for function signature. 262 my @pushArguments = map(" arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @argsFiltered);263 257 264 258 my $signature = " void ${functionName}(${arguments});"; … … 269 263 push(@function, "void ${frontendClassName}::${functionName}(${arguments})"); 270 264 push(@function, "{"); 271 push(@function, " RefPtr<InspectorArray> arguments = InspectorArray::create();"); 272 push(@function, " arguments->pushString(\"$functionName\");"); 265 push(@function, " RefPtr<InspectorObject> ${functionName}Message = InspectorObject::create();"); 266 push(@function, " ${functionName}Message->setString(\"type\", \"event\");"); 267 push(@function, " ${functionName}Message->setString(\"event\", \"$functionName\");"); 268 push(@function, " RefPtr<InspectorObject> payloadDataObject = InspectorObject::create();"); 269 my @pushArguments = map(" payloadDataObject->set" . $typeTransform{$_->type}->{"JSONType"} . "(\"" . $_->name . "\", " . $_->name . ");", @argsFiltered); 273 270 push(@function, @pushArguments); 274 push(@function, " m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());"); 271 push(@function, " ${functionName}Message->setObject(\"data\", payloadDataObject);"); 272 push(@function, " m_inspectorClient->sendMessageToFrontend(${functionName}Message->toJSONString());"); 275 273 276 274 push(@function, "}"); … … 280 278 } 281 279 282 sub generateBackendPrivateFunctions283 {284 my $privateFunctions = << "EOF";285 static String formatWrongArgumentsCountMessage(unsigned expected, unsigned actual)286 {287 return String::format("Wrong number of parameters: %d (expected: %d)", actual, expected);288 }289 290 static String formatWrongArgumentTypeMessage(unsigned position, const char* name, const char* expectedType)291 {292 return String::format("Failed to convert parameter %d (%s) to %s", position, name, expectedType);293 }294 EOF295 return split("\n", $privateFunctions);296 }297 298 280 sub generateBackendFunction 299 281 { … … 306 288 307 289 map($backendTypes{$_->type} = 1, @{$function->parameters}); # register required types 308 my @inArgs = grep($_->direction eq "in" , @{$function->parameters});290 my @inArgs = grep($_->direction eq "in" && !($_->name eq "callId") , @{$function->parameters}); 309 291 my @outArgs = grep($_->direction eq "out", @{$function->parameters}); 310 292 311 my $signature = " void ${functionName}( PassRefPtr<InspectorArray> args);";293 my $signature = " void ${functionName}(long callId, InspectorObject* requestMessageObject);"; 312 294 !$backendMethods{${signature}} || die "Duplicate function was detected for signature '$signature'."; 313 295 $backendMethods{${signature}} = $functionName; 314 296 315 297 my @function; 316 push(@function, "void ${backendClassName}::${functionName}(PassRefPtr<InspectorArray> args)"); 298 my $requestMessageObject = scalar(@inArgs) ? " requestMessageObject" : ""; 299 push(@function, "void ${backendClassName}::${functionName}(long callId, InspectorObject*$requestMessageObject)"); 317 300 push(@function, "{"); 318 push(@function, " long callId = 0;");301 push(@function, " RefPtr<InspectorArray> protocolErrors = InspectorArray::create();"); 319 302 push(@function, ""); 320 303 321 my $expectedParametersCount = scalar(@inArgs); 322 my $expectedParametersCountWithMethodName = scalar(@inArgs) + 1; 323 push(@function, " if (args->length() != $expectedParametersCountWithMethodName) {"); 324 push(@function, " ASSERT_NOT_REACHED();"); 325 push(@function, " reportProtocolError(callId, ${functionName}Cmd, formatWrongArgumentsCountMessage(args->length() - 1, $expectedParametersCount));"); 326 push(@function, " return;"); 327 push(@function, " }"); 304 my $domain = $function->signature->extendedAttributes->{"handler"} || "Controller"; 305 my $domainAccessor = $typeTransform{$domain}->{"domainAccessor"}; 306 $backendTypes{$domain} = 1; 307 push(@function, " if (!$domainAccessor)"); 308 push(@function, " protocolErrors->pushString(String::format(\"Error: %s handler is not available.\", \"$domain\"));"); 328 309 push(@function, ""); 329 310 330 my $i = 1; # zero element is the method name. 331 foreach my $parameter (@inArgs) { 332 my $type = $parameter->type; 333 my $argumentType = $typeTransform{$type}->{"variable"}; 334 push(@function, " $argumentType " . $parameter->name . ";") if !($parameter->name eq "callId"); 335 push(@function, " if (!args->get($i)->as" . $typeTransform{$type}->{"accessorSuffix"} . "(&" . $parameter->name . ")) {"); 311 if (scalar(@inArgs)) { 312 # declare variables for all 'in' args; 313 push(@function, map(" " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . ";", @inArgs)); 314 315 push(@function, ""); 316 push(@function, " RefPtr<InspectorObject> argumentsContainer;"); 317 push(@function, " if (!(argumentsContainer = requestMessageObject->getObject(\"arguments\"))) {"); 336 318 push(@function, " ASSERT_NOT_REACHED();"); 337 push(@function, " reportProtocolError(callId, ${functionName}Cmd, formatWrongArgumentTypeMessage($i, \"" . $parameter->name . "\", \"$type\"));"); 338 push(@function, " return;"); 319 push(@function, " protocolErrors->pushString(String::format(\"Error: arguments object was not found.\"));"); 320 push(@function, " } else {"); 321 push(@function, " InspectorObject::const_iterator argumentsEndIterator = argumentsContainer->end();"); 322 323 foreach my $parameter (@inArgs) { 324 my $name = $parameter->name; 325 my $type = $parameter->type; 326 my $variableType = $typeTransform{$type}->{"variable"}; 327 my $JSONType = $typeTransform{$type}->{"JSONType"}; 328 329 push(@function, ""); 330 push(@function, " InspectorObject::const_iterator ${name}ValueIterator = argumentsContainer->find(\"$name\");"); 331 push(@function, " if (${name}ValueIterator == argumentsEndIterator) {"); 332 push(@function, " ASSERT_NOT_REACHED();"); 333 push(@function, " protocolErrors->pushString(String::format(\"Error: Argument '%s' with type '%s' was not found.\", \"$name\", \"$JSONType\"));"); 334 push(@function, " } else {"); 335 push(@function, " if (!${name}ValueIterator->second->as$JSONType(&$name)) {"); 336 push(@function, " ASSERT_NOT_REACHED();"); 337 push(@function, " protocolErrors->pushString(String::format(\"Error: Argument '%s' has wrong type. It should be '%s'.\", \"$name\", \"$JSONType\"));"); 338 push(@function, " }"); 339 push(@function, " }"); 340 } 339 341 push(@function, " }"); 340 push(@function, ""); 341 ++$i; 342 } 343 344 my $handler = $function->signature->extendedAttributes->{"handler"} || "Controller"; 345 my $handlerAccessor = $typeTransform{$handler}->{"handlerAccessor"}; 346 $backendTypes{$handler} = 1; 347 push(@function, " if (!$handlerAccessor) {"); 348 push(@function, " reportProtocolError(callId, ${functionName}Cmd, \"Error: $handler handler is not available.\");"); 349 push(@function, " return;"); 350 push(@function, " }"); 351 push(@function, ""); 352 342 } 353 343 354 344 foreach (@outArgs) { # declare local variables for out arguments. 355 345 my $initializer = $typeTransform{$_->type}->{"defaultValue"} ? " = " . $typeTransform{$_->type}->{"defaultValue"} : ""; 356 push(@function, " " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . "$initializer;"); 357 } 358 359 my $args = join(", ", (grep(!($_ eq "callId"), map($_->name, @inArgs)), map("&" . $_->name, @outArgs))); 360 push(@function, " $handlerAccessor->$functionName($args);"); 361 362 # The results of function call should be transfered back to frontend. 363 if (scalar(grep($_->name eq "callId", @inArgs))) { 364 my @pushArguments = map(" arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @outArgs); 365 366 push(@function, ""); 367 push(@function, " // use InspectorFrontend as a marker of WebInspector availability"); 368 push(@function, " if (m_inspectorController->hasFrontend()) {"); 369 push(@function, " RefPtr<InspectorArray> arguments = InspectorArray::create();"); 370 push(@function, " arguments->pushString(\"processResponse\");"); 371 push(@function, " arguments->pushNumber(callId);"); 372 push(@function, @pushArguments); 373 push(@function, " m_inspectorController->inspectorClient()->sendMessageToFrontend(arguments->toJSONString());"); 374 push(@function, " }"); 375 } 346 push(@function, " " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . "$initializer;"); 347 } 348 349 my $args = join(", ", (map($_->name, @inArgs), map("&" . $_->name, @outArgs))); 350 push(@function, " if (!protocolErrors->length())"); 351 push(@function, " $domainAccessor->$functionName($args);"); 352 push(@function, ""); 353 354 push(@function, " // use InspectorFrontend as a marker of WebInspector availability"); 355 push(@function, " if (callId && m_inspectorController->hasFrontend()) {"); 356 push(@function, " RefPtr<InspectorObject> responseMessage = InspectorObject::create();"); 357 push(@function, " responseMessage->setNumber(\"seq\", callId);"); 358 push(@function, " responseMessage->setString(\"type\", \"response\");"); 359 push(@function, " responseMessage->setString(\"domain\", \"$domain\");"); 360 push(@function, " responseMessage->setString(\"command\", \"$functionName\");"); 361 push(@function, " responseMessage->setBool(\"success\", !protocolErrors->length());"); 362 push(@function, ""); 363 push(@function, " if (protocolErrors->length())"); 364 push(@function, " responseMessage->setArray(\"errors\", protocolErrors);"); 365 if (scalar(@outArgs)) { 366 push(@function, " else {"); 367 push(@function, " RefPtr<InspectorObject> responseData = InspectorObject::create();"); 368 push(@function, map(" responseData->set" . $typeTransform{$_->type}->{"JSONType"} . "(\"" . $_->name . "\", " . $_->name . ");", @outArgs)); 369 push(@function, " responseMessage->setObject(\"data\", responseData);"); 370 push(@function, " }"); 371 } 372 push(@function, " m_inspectorController->inspectorClient()->sendMessageToFrontend(responseMessage->toJSONString());"); 373 push(@function, " }"); 374 375 376 376 push(@function, "}"); 377 377 push(@function, ""); … … 385 385 void ${backendClassName}::reportProtocolError(const long callId, const String& method, const String& errorText) const 386 386 { 387 RefPtr<InspectorArray> arguments = InspectorArray::create(); 388 arguments->pushString("reportProtocolError"); 389 arguments->pushNumber(callId); 390 arguments->pushString(method); 391 arguments->pushString(errorText); 392 m_inspectorController->inspectorClient()->sendMessageToFrontend(arguments->toJSONString()); 387 RefPtr<InspectorObject> message = InspectorObject::create(); 388 message->setNumber("seq", callId); 389 message->setString("type", "error"); 390 message->setString("domain", "inspectorProtocol"); 391 message->setString("command", method); 392 message->setBool("success", false); 393 RefPtr<InspectorArray> errors = InspectorArray::create(); 394 errors->pushString(errorText); 395 message->setArray("errors", errors); 396 m_inspectorController->inspectorClient()->sendMessageToFrontend(message->toJSONString()); 393 397 } 394 398 EOF 395 399 return split("\n", $reportProtocolError); 396 400 } 401 397 402 398 403 sub generateBackendDispatcher … … 406 411 void ${backendClassName}::dispatch(const String& message) 407 412 { 408 typedef void (${backendClassName}::*CallHandler)( PassRefPtr<InspectorArray> args);413 typedef void (${backendClassName}::*CallHandler)(long callId, InspectorObject* messageObject); 409 414 typedef HashMap<String, CallHandler> DispatchMap; 410 415 DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, ); 416 long callId = 0; 417 411 418 if (dispatchMap.isEmpty()) { 412 419 $mapEntries … … 416 423 if (!parsedMessage) { 417 424 ASSERT_NOT_REACHED(); 418 reportProtocolError( 0, "dispatch", "Error: Invalid message format. Message should be in JSON format.");425 reportProtocolError(callId, "dispatch", "Error: Invalid message format. Message should be in JSON format."); 419 426 return; 420 427 } 421 428 422 RefPtr<Inspector Array> messageArray = parsedMessage->asArray();423 if (!message Array) {429 RefPtr<InspectorObject> messageObject = parsedMessage->asObject(); 430 if (!messageObject) { 424 431 ASSERT_NOT_REACHED(); 425 reportProtocolError( 0, "dispatch", "Error: Invalid message format. The message should be a JSONified array of arguments.");432 reportProtocolError(callId, "dispatch", "Error: Invalid message format. The message should be a JSONified object."); 426 433 return; 427 434 } 428 435 429 if (!messageArray->length()) { 436 RefPtr<InspectorValue> callIdValue = messageObject->get("seq"); 437 if (!callIdValue) { 430 438 ASSERT_NOT_REACHED(); 431 reportProtocolError( 0, "dispatch", "Error: Invalid message format. Empty message was received.");439 reportProtocolError(callId, "dispatch", "Error: Invalid message format. 'seq' property was not found in the request."); 432 440 return; 433 441 } 434 442 435 String methodName; 436 if (!messageArray->get(0)->asString(&methodName)) { 443 if (!callIdValue->asNumber(&callId)) { 437 444 ASSERT_NOT_REACHED(); 438 reportProtocolError( 0, "dispatch", "Error: Invalid message format. The first element of the message should be method name.");445 reportProtocolError(callId, "dispatch", "Error: Invalid message format. the type of 'seq' property should be number."); 439 446 return; 440 447 } 441 448 442 HashMap<String, CallHandler>::iterator it = dispatchMap.find(methodName); 449 RefPtr<InspectorValue> commandValue = messageObject->get("command"); 450 if (!commandValue) { 451 ASSERT_NOT_REACHED(); 452 reportProtocolError(callId, "dispatch", "Error: Invalid message format. 'command' property wasn't found."); 453 return; 454 } 455 456 String command; 457 if (!commandValue->asString(&command)) { 458 ASSERT_NOT_REACHED(); 459 reportProtocolError(callId, "dispatch", "Error: Invalid message format. The type of 'command' property should be string."); 460 return; 461 } 462 463 HashMap<String, CallHandler>::iterator it = dispatchMap.find(command); 443 464 if (it == dispatchMap.end()) { 444 465 ASSERT_NOT_REACHED(); 445 reportProtocolError( 0, "dispatch", String::format("Error: Invalid method name. '%s' wasn't found.", methodName.utf8().data()));466 reportProtocolError(callId, "dispatch", String::format("Error: Invalid command was received. '%s' wasn't found.", command.utf8().data())); 446 467 return; 447 468 } 448 469 449 ((*this).*it->second)( messageArray);470 ((*this).*it->second)(callId, messageObject.get()); 450 471 } 451 472 EOF … … 461 482 if (!value) 462 483 return false; 463 RefPtr<InspectorArray> array = value->asArray(); 464 if (!array) 484 485 RefPtr<InspectorObject> object = value->asObject(); 486 if (!object) 465 487 return false; 466 488 467 if (!array->length()) 489 RefPtr<InspectorValue> commandValue = object->get("command"); 490 if (!commandValue) 468 491 return false; 469 return array->get(0)->asString(result); 470 } 492 493 return commandValue->asString(result); 494 } 495 471 496 EOF 472 497 return split("\n", $messageParserBody); … … 477 502 my $interface = shift; 478 503 my @backendFunctions = grep(!$_->signature->extendedAttributes->{"notify"}, @{$interface->functions}); 479 my @JSStubs = map(" this._registerDelegate(\"" . $_->signature->name . "\");", @backendFunctions); 504 my @JSStubs; 505 506 foreach my $function (@backendFunctions) { 507 my $name = $function->signature->name; 508 my $domain = $function->signature->extendedAttributes->{"handler"}; 509 my $argumentNames = join(",", map("\"" . $_->name . "\": null", grep($_->direction eq "in", @{$function->parameters}))); 510 push(@JSStubs, " this._registerDelegate('{" . 511 "\"seq\": 0, " . 512 "\"type\": \"request\", " . 513 "\"domain\": \"$domain\", " . 514 "\"command\": \"$name\", " . 515 "\"arguments\": {$argumentNames}" . 516 "}');"); 517 } 480 518 481 519 my $JSStubs = join("\n", @JSStubs); … … 489 527 490 528 WebInspector.InspectorBackendStub.prototype = { 491 _registerDelegate: function( methodName)529 _registerDelegate: function(commandInfo) 492 530 { 493 this[methodName] = this.sendMessageToBackend.bind(this, methodName); 531 var commandObject = JSON.parse(commandInfo); 532 this[commandObject.command] = this.sendMessageToBackend.bind(this, commandInfo); 494 533 }, 495 534 496 535 sendMessageToBackend: function() 497 536 { 498 var message = JSON.stringify(Array.prototype.slice.call(arguments)); 537 var args = Array.prototype.slice.call(arguments); 538 var request = JSON.parse(args.shift()); 539 for (var key in request.arguments) { 540 if (key === "callId") 541 request.seq = args.shift(); 542 else 543 request.arguments[key] = args.shift(); 544 } 545 if (args.length === 1 && typeof args[0] === "function") 546 request.seq = WebInspector.Callback.wrap(args[0]); 547 548 var message = JSON.stringify(request); 499 549 InspectorFrontendHost.sendMessageToBackend(message); 500 550 } -
trunk/WebCore/inspector/Inspector.idl
r65797 r65803 58 58 [notify] void searchingForNodeWasEnabled(); 59 59 [notify] void searchingForNodeWasDisabled(); 60 [notify] void setAttachedWindow(out boolean attached); 60 61 [notify] void setChildNodes(out long parentId, out Array nodes); 61 62 [notify] void setDetachedRoot(out Object root); -
trunk/WebCore/inspector/InspectorController.cpp
r65797 r65803 421 421 } 422 422 423 void InspectorController::setAttachedWindow(bool attached) 424 { 425 if (!m_remoteFrontend) { 426 ASSERT_NOT_REACHED(); 427 return; 428 } 429 m_remoteFrontend->setAttachedWindow(attached); 430 } 431 423 432 void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) 424 433 { -
trunk/WebCore/inspector/InspectorController.h
r65797 r65803 148 148 void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient> client); 149 149 bool hasInspectorFrontendClient() const { return m_inspectorFrontendClient; } 150 void setAttachedWindow(bool attached); 150 151 151 152 void inspectedWindowScriptObjectCleared(Frame*); -
trunk/WebCore/inspector/InspectorFrontendClientLocal.cpp
r65053 r65803 122 122 void InspectorFrontendClientLocal::setAttachedWindow(bool attached) 123 123 { 124 ScriptObject webInspectorObj; 125 if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) { 126 ASSERT_NOT_REACHED(); 127 return; 128 } 129 ScriptFunctionCall function(webInspectorObj, "dispatch"); 130 function.appendArgument("setAttachedWindow"); 131 function.appendArgument(attached); 132 function.call(); 124 m_inspectorController->setAttachedWindow(attached); 133 125 } 134 126 -
trunk/WebCore/inspector/InspectorValues.h
r65320 r65803 177 177 void setArray(const String& name, PassRefPtr<InspectorArray>); 178 178 179 const_iterator find(const String& name) const; 179 180 bool getBool(const String& name, bool* output) const; 180 181 bool getNumber(const String& name, double* output) const; … … 225 226 }; 226 227 228 inline InspectorObject::const_iterator InspectorObject::find(const String& name) const 229 { 230 return m_data.find(name); 231 } 232 227 233 inline void InspectorObject::setBool(const String& name, bool value) 228 234 { -
trunk/WebCore/inspector/front-end/Callback.js
r65052 r65803 43 43 }, 44 44 45 processResponse: function(callbackId, opt_vararg)45 processResponse: function(callbackId, args) 46 46 { 47 var args = Array.prototype.slice.call(arguments, 1);48 47 var callback = this._callbacks[callbackId]; 49 48 callback.apply(null, args); -
trunk/WebCore/inspector/front-end/inspector.js
r65677 r65803 590 590 window.addEventListener("load", windowLoaded, false); 591 591 592 WebInspector.dispatch = function() { 593 var methodName = arguments[0]; 594 var parameters = Array.prototype.slice.call(arguments, 1); 595 592 WebInspector.dispatch = function(message) { 596 593 // We'd like to enforce asynchronous interaction between the inspector controller and the frontend. 597 594 // This is important to LayoutTests. 598 595 function delayDispatch() 599 596 { 600 if (!(methodName in WebInspector)) { 601 console.error("Attempted to dispatch unimplemented WebInspector method: %s", methodName); 602 return; 603 } 604 605 WebInspector[methodName].apply(WebInspector, parameters); 597 WebInspector_syncDispatch(message); 606 598 WebInspector.pendingDispatches--; 607 599 } … … 613 605 WebInspector_syncDispatch = function(message) 614 606 { 615 var args = JSON.parse(message); 616 var methodName = args[0]; 617 var parameters = args.slice(1); 618 WebInspector[methodName].apply(WebInspector, parameters); 619 } 620 621 WebInspector.dispatchMessageFromBackend = function(arguments) 622 { 623 WebInspector.dispatch.apply(this, arguments); 624 } 625 626 WebInspector.reportProtocolError = function(callId, methodName, errorText) 627 { 628 console.error("InspectorBackend." + methodName + " failed with error text: '" + errorText + "'"); 629 WebInspector.removeResponseCallbackEntry(callId); 607 var messageObject = (typeof message === "string") ? JSON.parse(message) : message; 608 if (messageObject.type === "response" && !messageObject.success) { 609 WebInspector.removeResponseCallbackEntry(messageObject.seq) 610 WebInspector.reportProtocolError(messageObject); 611 return; 612 } 613 614 var arguments = []; 615 if (messageObject.data) 616 for (var key in messageObject.data) 617 arguments.push(messageObject.data[key]); 618 619 if (messageObject.type === "event") { 620 if (!messageObject.event in WebInspector) { 621 console.error("Attempted to dispatch unimplemented WebInspector method: %s", messageObject.event); 622 return; 623 } 624 WebInspector[messageObject.event].apply(WebInspector, arguments); 625 } 626 627 if (messageObject.type === "response") 628 WebInspector.processResponse(messageObject.seq, arguments); 629 } 630 631 WebInspector.dispatchMessageFromBackend = function(messageObject) 632 { 633 WebInspector.dispatch(messageObject); 634 } 635 636 WebInspector.reportProtocolError = function(messageObject) 637 { 638 console.error("Error: InspectorBackend." + messageObject.command + " failed."); 639 for (var error in messageObject.errors) 640 console.error(" " + error); 641 WebInspector.removeResponseCallbackEntry(messageObject.seq); 630 642 } 631 643
Note: See TracChangeset
for help on using the changeset viewer.