Changeset 56877 in webkit
- Timestamp:
- Mar 31, 2010 5:09:55 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56875 r56877 1 2010-03-31 Vitaly Repeshko <vitalyr@chromium.org> 2 3 Reviewed by David Levin. 4 5 [V8] SerializedScriptValue must be deserialized only once and in the right context 6 https://bugs.webkit.org/show_bug.cgi?id=36892 7 8 See also https://bugs.webkit.org/show_bug.cgi?id=34227 for the 9 corresponding JSC change. 10 11 General idea: SerializedScriptValue must be deserialized only once 12 and in the context of the intended MessageEvent recepient. The 13 approach we take for now is to eagerly deserialize when a 14 JavaScript wrapper for MessageEvent is created. 15 16 A better fix would be to keep a reference to the context in 17 MessageEvent and use it when lazily deserializing. It's harder to 18 do since the API doesn't have a clean method to have such a reference. 19 20 Tested by fast/dom/Window/window-postmessage-clone-frames.html. This 21 test still fails but only for the types which we can't serialize yet. 22 23 * bindings/scripts/CodeGeneratorV8.pm: 24 * bindings/v8/SerializedScriptValue.h: 25 (WebCore::SerializedScriptValue::deserializeAndSetProperty): 26 * bindings/v8/custom/V8MessageEventCustom.cpp: 27 (WebCore::V8MessageEvent::initMessageEventCallback): 28 1 29 2010-03-31 Adam Barth <abarth@webkit.org> 2 30 -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r56849 r56877 1142 1142 my $attrExt = $attribute->signature->extendedAttributes; 1143 1143 1144 # Attributes of type SerializedScriptValue are set in the 1145 # constructor and don't require callbacks. 1146 return if ($attribute->signature->type eq "SerializedScriptValue"); 1147 1144 1148 my $accessControl = "v8::DEFAULT"; 1145 1149 if ($attrExt->{"DoNotCheckDomainSecurityOnGet"}) { … … 1468 1472 1469 1473 my $hasConstructors = 0; 1474 my $serializedAttribute; 1470 1475 # Generate property accessors for attributes. 1471 1476 for ($index = 0; $index < @{$dataNode->attributes}; $index++) { … … 1485 1490 if ($attrType eq "EventListener" && $interfaceName eq "DOMWindow") { 1486 1491 $attribute->signature->extendedAttributes->{"v8OnProto"} = 1; 1492 } 1493 1494 # Attributes of type SerializedScriptValue are set in the 1495 # constructor and don't require callbacks. 1496 if ($attrType eq "SerializedScriptValue") { 1497 die "Only one attribute of type SerializedScriptValue supported" if $serializedAttribute; 1498 $implIncludes{"SerializedScriptValue.h"} = 1; 1499 $serializedAttribute = $attribute; 1500 next; 1487 1501 } 1488 1502 … … 1912 1926 } 1913 1927 1914 GenerateToV8Converters($dataNode, $interfaceName, $className, $nativeType );1928 GenerateToV8Converters($dataNode, $interfaceName, $className, $nativeType, $serializedAttribute); 1915 1929 1916 1930 push(@implContent, <<END); … … 1941 1955 my $className = shift; 1942 1956 my $nativeType = shift; 1957 my $serializedAttribute = shift; 1943 1958 1944 1959 my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName); … … 1994 2009 wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); 1995 2010 END 1996 1997 2011 if (IsNodeSubType($dataNode)) { 1998 2012 push(@implContent, <<END); … … 2008 2022 END 2009 2023 push(@implContent, "\n impl->ref();\n") if IsRefPtrType($interfaceName); 2024 2025 # Eagerly deserialize attributes of type SerializedScriptValue 2026 # while we're in the right context. 2027 if ($serializedAttribute) { 2028 die "Attribute of type SerializedScriptValue expected" if $serializedAttribute->signature->type ne "SerializedScriptValue"; 2029 my $attrName = $serializedAttribute->signature->name; 2030 my $attrAttr = "v8::DontDelete"; 2031 if ($serializedAttribute->type =~ /^readonly/) { 2032 $attrAttr .= " | v8::ReadOnly"; 2033 } 2034 $attrAttr = "static_cast<v8::PropertyAttribute>($attrAttr)"; 2035 my $getterFunc = $codeGenerator->WK_lcfirst($attrName); 2036 push(@implContent, <<END); 2037 SerializedScriptValue::deserializeAndSetProperty(wrapper, "${attrName}", ${attrAttr}, impl->${getterFunc}()); 2038 END 2039 } 2010 2040 2011 2041 if ($domMapFunction) { -
trunk/WebCore/bindings/v8/SerializedScriptValue.h
r56070 r56877 41 41 class SerializedScriptValue : public RefCounted<SerializedScriptValue> { 42 42 public: 43 // Deserializes the given value and sets it as a property on the 44 // object. 45 static void deserializeAndSetProperty(v8::Handle<v8::Object> object, 46 const char* propertyName, 47 v8::PropertyAttribute attribute, 48 SerializedScriptValue* value) 49 { 50 ASSERT(value); 51 v8::Handle<v8::Value> deserialized = value->deserialize(); 52 object->ForceSet(v8::String::NewSymbol(propertyName), deserialized, attribute); 53 } 54 43 55 // Creates a serialized representation of the given V8 value. 44 56 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value> value) -
trunk/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
r54629 r56877 85 85 } 86 86 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg.release(), originArg, lastEventIdArg, sourceArg, portArray.release()); 87 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly); 88 SerializedScriptValue::deserializeAndSetProperty(args.Holder(), "data", dataAttr, event->data()); 87 89 return v8::Undefined(); 88 90 }
Note: See TracChangeset
for help on using the changeset viewer.