Changeset 128102 in webkit
- Timestamp:
- Sep 10, 2012 1:54:43 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128098 r128102 1 2012-09-10 Adam Barth <abarth@webkit.org> 2 3 [V8] setNamedHiddenWindowReference doesn't need to be a special case 4 https://bugs.webkit.org/show_bug.cgi?id=96198 5 6 Reviewed by Nate Chapin. 7 8 Prior to this patch, the DOMWindow cached its properties on the outter 9 global object rather than on the Holder of the properties. (We cache 10 properties to prevent their DOM wrappers from being garbage collected 11 too early.) There doesn't seem to be any reason why DOMWindow need to 12 be special-cased in this regard. We can just cache the properities on 13 their Holders, as usual. 14 15 * bindings/scripts/CodeGeneratorV8.pm: 16 (GenerateNormalAttrGetter): 17 * bindings/v8/V8DOMWrapper.cpp: 18 * bindings/v8/V8DOMWrapper.h: 19 (V8DOMWrapper): 20 * bindings/v8/custom/V8LocationCustom.cpp: 21 * page/Location.idl: 22 - Previously, Location had a custom toV8 function so that 23 document.location would cache its wrapper in the same place as 24 window.location. However, that's no longer necessary as the 25 DOMWindow now holds its Document in a hidden property, which 26 means the DOMWindow keeps the cached location property on 27 Document alive anyway. 28 1 29 2012-09-10 Anders Carlsson <andersca@apple.com> 2 30 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r128094 r128102 985 985 # garbage-collected prematurely when their lifetime is strongly tied to their owner. We accomplish this by inserting a reference to 986 986 # the newly created wrapper into an internal field of the holder object. 987 if (!IsNodeSubType($dataNode) && $attrName ne "self" && (IsWrapperType($returnType) && ($attribute->type =~ /^readonly/ || $attribute->signature->extendedAttributes->{"Replaceable"} )987 if (!IsNodeSubType($dataNode) && $attrName ne "self" && (IsWrapperType($returnType) && ($attribute->type =~ /^readonly/ || $attribute->signature->extendedAttributes->{"Replaceable"} || $attrName eq "location") 988 988 && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow" 989 989 && $returnType ne "MessagePortArray" … … 1010 1010 push(@implContentDecls, " wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());\n"); 1011 1011 push(@implContentDecls, " if (!wrapper.IsEmpty())\n"); 1012 if ($dataNode->name eq "DOMWindow") { 1013 AddToImplIncludes("Frame.h"); 1014 push(@implContentDecls, " V8DOMWrapper::setNamedHiddenWindowReference(imp->frame(), \"${attrName}\", wrapper);\n"); 1015 } else { 1016 push(@implContentDecls, " V8DOMWrapper::setNamedHiddenReference(info.Holder(), \"${attrName}\", wrapper);\n"); 1017 } 1012 push(@implContentDecls, " V8DOMWrapper::setNamedHiddenReference(info.Holder(), \"${attrName}\", wrapper);\n"); 1018 1013 push(@implContentDecls, " }\n"); 1019 1014 push(@implContentDecls, " return wrapper;\n"); -
trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp
r127972 r128102 122 122 } 123 123 124 void V8DOMWrapper::setNamedHiddenWindowReference(Frame* frame, const char* name, v8::Handle<v8::Value> jsObject)125 {126 // Get DOMWindow127 if (!frame)128 return; // Object might be detached from window129 v8::Handle<v8::Context> context = frame->script()->currentWorldContext();130 if (context.IsEmpty())131 return;132 133 v8::Handle<v8::Object> global = context->Global();134 // Look for real DOM wrapper.135 global = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), global);136 ASSERT(!global.IsEmpty());137 138 setNamedHiddenReference(global, name, jsObject);139 }140 141 124 WrapperTypeInfo* V8DOMWrapper::domWrapperType(v8::Handle<v8::Object> object) 142 125 { -
trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h
r127997 r128102 111 111 static bool isWrapperOfType(v8::Handle<v8::Value>, WrapperTypeInfo*); 112 112 113 // Proper object lifetime support.114 //115 // Helper functions to make sure the child object stays alive116 // while the parent is alive. Using the name more than once117 // overwrites previous references making it possible to free118 // old children.119 113 static void setNamedHiddenReference(v8::Handle<v8::Object> parent, const char* name, v8::Handle<v8::Value> child); 120 static void setNamedHiddenWindowReference(Frame*, const char*, v8::Handle<v8::Value>);121 114 122 115 static v8::Local<v8::Object> instantiateV8Object(WrapperTypeInfo*, void*); -
trunk/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp
r127946 r128102 271 271 } 272 272 273 v8::Handle<v8::Value> toV8(Location* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)274 {275 if (!impl)276 return v8NullWithCheck(isolate);277 v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl);278 if (wrapper.IsEmpty()) {279 wrapper = V8Location::wrap(impl, creationContext, isolate);280 if (!wrapper.IsEmpty())281 V8DOMWrapper::setNamedHiddenWindowReference(impl->frame(), "location", wrapper);282 }283 return wrapper;284 }285 286 273 } // namespace WebCore -
trunk/Source/WebCore/page/Location.idl
r113945 r128102 41 41 JSCustomNamedGetterOnPrototype, 42 42 JSCustomDefineOwnPropertyOnPrototype, 43 OmitConstructor, 44 V8CustomToJSObject 43 OmitConstructor 45 44 ] Location { 46 45 #if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
Note: See TracChangeset
for help on using the changeset viewer.