OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 width = toInt32(args[0]); | 75 width = toInt32(args[0]); |
76 optionalWidth = &width; | 76 optionalWidth = &width; |
77 } | 77 } |
78 if (args.Length() > 1) { | 78 if (args.Length() > 1) { |
79 height = toInt32(args[1]); | 79 height = toInt32(args[1]); |
80 optionalHeight = &height; | 80 optionalHeight = &height; |
81 } | 81 } |
82 | 82 |
83 RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(do
cument, optionalWidth, optionalHeight); | 83 RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(do
cument, optionalWidth, optionalHeight); |
84 v8::Handle<v8::Object> wrapper = args.Holder(); | 84 v8::Handle<v8::Object> wrapper = args.Holder(); |
85 V8DOMWrapper::associateObjectWithWrapper(image.release(), &V8HTMLImageElemen
tConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent)
; | 85 V8DOMWrapper::associateObjectWithWrapper<V8HTMLImageElement>(image.release()
, &V8HTMLImageElementConstructor::info, wrapper, args.GetIsolate(), WrapperConfi
guration::Dependent); |
86 v8SetReturnValue(args, wrapper); | 86 v8SetReturnValue(args, wrapper); |
87 } | 87 } |
88 | 88 |
89 v8::Handle<v8::FunctionTemplate> V8HTMLImageElementConstructor::GetTemplate(v8::
Isolate* isolate, WrapperWorldType worldType) | 89 v8::Handle<v8::FunctionTemplate> V8HTMLImageElementConstructor::GetTemplate(v8::
Isolate* isolate, WrapperWorldType worldType) |
90 { | 90 { |
91 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; | 91 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; |
92 if (!cachedTemplate.IsEmpty()) | 92 if (!cachedTemplate.IsEmpty()) |
93 return v8::Local<v8::FunctionTemplate>::New(isolate, cachedTemplate); | 93 return v8::Local<v8::FunctionTemplate>::New(isolate, cachedTemplate); |
94 | 94 |
95 v8::HandleScope scope(isolate); | 95 v8::HandleScope scope(isolate); |
96 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(v8HTMLIma
geElementConstructorMethodCustom); | 96 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(v8HTMLIma
geElementConstructorMethodCustom); |
97 | 97 |
98 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); | 98 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); |
99 instance->SetInternalFieldCount(V8HTMLImageElement::internalFieldCount); | 99 instance->SetInternalFieldCount(V8HTMLImageElement::internalFieldCount); |
100 result->SetClassName(v8::String::NewSymbol("HTMLImageElement")); | 100 result->SetClassName(v8::String::NewSymbol("HTMLImageElement")); |
101 result->Inherit(V8HTMLImageElement::GetTemplate(isolate, worldType)); | 101 result->Inherit(V8HTMLImageElement::GetTemplate(isolate, worldType)); |
102 | 102 |
103 cachedTemplate.Reset(isolate, result); | 103 cachedTemplate.Reset(isolate, result); |
104 return scope.Close(v8::Local<v8::FunctionTemplate>::New(isolate, cachedTempl
ate)); | 104 return scope.Close(v8::Local<v8::FunctionTemplate>::New(isolate, cachedTempl
ate)); |
105 } | 105 } |
106 | 106 |
107 } // namespace WebCore | 107 } // namespace WebCore |
OLD | NEW |