Changeset 54047 in webkit


Ignore:
Timestamp:
Jan 28, 2010 11:16:56 PM (14 years ago)
Author:
oliver@apple.com
Message:

2010-01-28 Oliver Hunt <oliver@apple.com>

Reviewed by Gavin Barraclough.

MessageEvent.data should not be repeated deserialised
https://bugs.webkit.org/show_bug.cgi?id=34311

Add test to ensure we get the same value back when accessing event.data multiple times

  • fast/dom/Window/window-postmessage-clone.html:

2010-01-28 Oliver Hunt <oliver@apple.com>

Reviewed by Gavin Barraclough.

MessageEvent.data should not be repeated deserialised
https://bugs.webkit.org/show_bug.cgi?id=34311

Cache the result of deserialising the event data

  • bindings/scripts/CodeGeneratorJS.pm:
  • dom/MessageEvent.idl:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r54045 r54047  
     12010-01-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        MessageEvent.data should not be repeated deserialised
     6        https://bugs.webkit.org/show_bug.cgi?id=34311
     7
     8        Add test to ensure we get the same value back when accessing event.data multiple times
     9
     10        * fast/dom/Window/window-postmessage-clone.html:
     11
    1122010-01-28  Hayato Ito  <hayato@chromium.org>
    213
  • trunk/LayoutTests/fast/dom/Window/window-postmessage-clone.html

    r53774 r54047  
    7474
    7575function onmessage(evt) {
    76     eventData = evt.data
     76    eventData = evt.data;
     77    if (evt.data !== evt.data)
     78        console.innerHTML += "MessageEvent.data does not produce the same value on multiple queries.";
    7779    shouldBe("eventData", messages.shift());
    7880
  • trunk/WebCore/ChangeLog

    r54045 r54047  
     12010-01-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        MessageEvent.data should not be repeated deserialised
     6        https://bugs.webkit.org/show_bug.cgi?id=34311
     7
     8        Cache the result of deserialising the event data
     9
     10        * bindings/scripts/CodeGeneratorJS.pm:
     11        * dom/MessageEvent.idl:
     12
    1132010-01-28  Hayato Ito  <hayato@chromium.org>
    214
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r54042 r54047  
    3838my %implIncludes = ();
    3939my @depsContent = ();
     40my $numCachedAttributes = 0;
     41my $currentCachedAttribute = 0;
    4042
    4143# Default .h template
     
    669671            $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"};
    670672            $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"};
    671         }
    672     }
    673 
     673            if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
     674                push(@headerContent, "    static const unsigned " . $attribute->signature->name . "Slot = $numCachedAttributes + Base::AnonymousSlotCount;\n");
     675                $numCachedAttributes++;
     676            }
     677        }
     678    }
     679
     680    if ($numCachedAttributes > 0) {
     681        push(@headerContent, "    using $parentClassName" . "::putAnonymousValue;\n");
     682        push(@headerContent, "    using $parentClassName" . "::getAnonymousValue;\n");
     683    }
    674684    if ($numCustomAttributes > 0) {
    675685        push(@headerContent, "\n    // Custom attributes\n");
     
    718728    }
    719729   
     730    # anonymous slots
     731    if ($numCachedAttributes) {
     732        push(@headerContent, "public:\n");
     733        push(@headerContent, "    static const unsigned AnonymousSlotCount = $numCachedAttributes + Base::AnonymousSlotCount;\n");
     734    }
     735
    720736    # structure flags
    721737    push(@headerContent, "protected:\n");
     
    11701186    }
    11711187    push(@implContent, "{\n");
     1188    if ($numCachedAttributes > 0) {
     1189        push(@implContent, "    for (unsigned i = Base::AnonymousSlotCount; i < AnonymousSlotCount; i++)\n");
     1190        push(@implContent, "        putAnonymousValue(i, JSValue());\n");
     1191    }
    11721192    push(@implContent, "}\n\n");
    11731193
     
    13151335                } elsif (!@{$attribute->getterExceptions}) {
    13161336                    push(@implContent, "    UNUSED_PARAM(exec);\n");
     1337                    my $cacheIndex = 0;
     1338                    if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
     1339                        $cacheIndex = $currentCachedAttribute;
     1340                        $currentCachedAttribute++;
     1341                        push(@implContent, "    if (JSValue cachedValue = castedThis->getAnonymousValue(" . $className . "::" . $attribute->signature->name . "Slot))\n");
     1342                        push(@implContent, "        return cachedValue;\n");
     1343                    }
    13171344                    if ($podType) {
    13181345                        push(@implContent, "    $podType imp(*castedThis->impl());\n");
    13191346                        if ($podType eq "float") { # Special case for JSSVGNumber
    1320                             push(@implContent, "    return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "castedThis") . ";\n");
     1347                            push(@implContent, "    JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "castedThis") . ";\n");
    13211348                        } else {
    1322                             push(@implContent, "    return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "castedThis") . ";\n");
     1349                            push(@implContent, "    JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "castedThis") . ";\n");
    13231350                        }
    13241351                    } else {
     
    13391366                        if ($codeGenerator->IsSVGAnimatedType($type)) {
    13401367                            push(@implContent, "    RefPtr<$type> obj = $jsType;\n");
    1341                             push(@implContent, "    return toJS(exec, castedThis->globalObject(), obj.get(), imp);\n");
     1368                            push(@implContent, "    JSValue result = toJS(exec, castedThis->globalObject(), obj.get(), imp);\n");
    13421369                        } else {
    1343                             push(@implContent, "    return $jsType;\n");
     1370                            push(@implContent, "    JSValue result = $jsType;\n");
    13441371                        }
    13451372                    }
     1373                   
     1374                    push(@implContent, "    castedThis->putAnonymousValue(" . $className . "::" . $attribute->signature->name . "Slot, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"});
     1375                    push(@implContent, "    return result;\n");
     1376
    13461377                } else {
    13471378                    push(@implContent, "    ExceptionCode ec = 0;\n");                   
  • trunk/WebCore/dom/MessageEvent.idl

    r52537 r54047  
    3030        NoStaticTables
    3131    ] MessageEvent : Event {
    32         readonly attribute SerializedScriptValue data;
     32        readonly attribute [CachedAttribute] SerializedScriptValue data;
    3333
    3434        readonly attribute DOMString origin;
Note: See TracChangeset for help on using the changeset viewer.