Changeset 83739 in webkit


Ignore:
Timestamp:
Apr 13, 2011 8:44:38 AM (13 years ago)
Author:
loislo@chromium.org
Message:

2011-04-13 Ilya Tikhonovsky <loislo@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: there is a problem if an optional param is not at the end of a params list.
https://bugs.webkit.org/show_bug.cgi?id=58440

In InspectorBackend.dispatch method we are converting the message's params object into array of arguments
for a callback. But in some cases the optional parameter is declared in the middle of the params list.
That gets us into a problem if this param has been skipped in the message. In that case the tail of the
event params will be shifted. We can slightly modify dispatcher and it will put the params in right places.

  • inspector/CodeGeneratorInspector.pm:
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83736 r83739  
     12011-04-13  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: there is a problem if an optional param is not at the end of a params list.
     6        https://bugs.webkit.org/show_bug.cgi?id=58440
     7
     8        In InspectorBackend.dispatch method we are converting the message's params object into array of arguments
     9        for a callback. But in some cases the optional parameter is declared in the middle of the params list.
     10        That gets us into a problem if this param has been skipped in the message. In that case the tail of the
     11        event params will be shifted. We can slightly modify dispatcher and it will put the params in right places.
     12
     13        * inspector/CodeGeneratorInspector.pm:
     14
    1152011-04-13  Ben Taylor  <bentaylor.solx86@gmail.com>
    216
  • trunk/Source/WebCore/inspector/CodeGeneratorInspector.pm

    r83580 r83739  
    224224my @backendFooter;
    225225my @backendJSStubs;
     226my @backendJSEvents;
    226227my %backendDomains;
    227228
     
    349350
    350351    collectBackendJSStubFunctions($interface);
     352    collectBackendJSStubEvents($interface);
    351353}
    352354
     
    682684}
    683685
     686sub collectBackendJSStubEvents
     687{
     688    my $interface = shift;
     689    my @functions = grep($_->signature->extendedAttributes->{"event"}, @{$interface->functions});
     690    my $domain = $interface->name;
     691
     692    foreach my $function (@functions) {
     693        my $name = $domain . "." . $function->signature->name;
     694        my @outArgs = grep($_->direction eq "out", @{$function->parameters});
     695        my $argumentNames = join(",", map("\"" . $_->name . "\"" , @outArgs));
     696        push(@backendJSEvents, "    this._eventArgs[\"" . $name . "\"] = [" . $argumentNames ."];");
     697    }
     698}
     699
    684700sub generateBackendStubJS
    685701{
    686702    my $JSStubs = join("\n", @backendJSStubs);
     703    my $JSEvents = join("\n", @backendJSEvents);
    687704    my $inspectorBackendStubJS = << "EOF";
    688705$licenseTemplate
     
    694711    this._callbacks = {};
    695712    this._domainDispatchers = {};
     713    this._eventArgs = {};
    696714$JSStubs
     715$JSEvents
    697716}
    698717
     
    812831            }
    813832
     833            if (!this._eventArgs[messageObject.method]) {
     834                console.error("Protocol Error: Attempted to dispatch an unspecified method '" + messageObject.method + "'");
     835                return;
     836            }
     837
    814838            var params = [];
    815839            if (messageObject.params) {
    816                 for (var key in messageObject.params)
    817                     params.push(messageObject.params[key]);
     840                var paramNames = this._eventArgs[messageObject.method];
     841                for (var i = 0; i < paramNames.length; ++i)
     842                    params.push(messageObject.params[paramNames[i]]);
    818843            }
    819844
Note: See TracChangeset for help on using the changeset viewer.