Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: Source/bindings/v8/custom/V8HTMLPictureElementConstructor.cpp

Issue 14449003: Picture element initial implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@picture_after_rebase
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/v8/custom/V8HTMLPictureElementConstructor.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "V8HTMLImageElementConstructor.h" 32 #if ENABLE(PICTURE)
33 #include "V8HTMLPictureElementConstructor.h"
33 34
34 #include "BindingState.h" 35 #include "BindingState.h"
35 #include "Document.h" 36 #include "Document.h"
36 #include "Frame.h" 37 #include "Frame.h"
37 #include "HTMLImageElement.h"
38 #include "HTMLNames.h" 38 #include "HTMLNames.h"
39 #include "HTMLPictureElement.h"
39 #include "V8Binding.h" 40 #include "V8Binding.h"
40 #include "V8Document.h" 41 #include "V8Document.h"
41 #include "V8HTMLImageElement.h" 42 #include "V8HTMLPictureElement.h"
42 #include <wtf/RefPtr.h> 43 #include <wtf/RefPtr.h>
43 44
44 namespace WebCore { 45 namespace WebCore {
45 46
46 WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstr uctor::GetTemplate, V8HTMLImageElement::derefObject, 0, V8HTMLImageElement::toEv entTarget, 0, V8HTMLImageElement::installPerContextPrototypeProperties, 0, Wrapp erTypeObjectPrototype }; 47 WrapperTypeInfo V8HTMLPictureElementConstructor::info = { V8HTMLPictureElementCo nstructor::GetTemplate, V8HTMLPictureElement::derefObject, 0, V8HTMLPictureEleme nt::toEventTarget, 0, V8HTMLPictureElement::installPerContextPrototypeProperties , 0, WrapperTypeObjectPrototype };
47 48
48 static v8::Handle<v8::Value> v8HTMLImageElementConstructorMethodCustom(const v8: :Arguments& args) 49 static v8::Handle<v8::Value> v8HTMLPictureElementConstructorMethodCustom(const v 8::Arguments& args)
49 { 50 {
50 if (!args.IsConstructCall()) 51 if (!args.IsConstructCall())
51 return throwTypeError("DOM object constructor cannot be called as a func tion.", args.GetIsolate()); 52 return throwTypeError("DOM object constructor cannot be called as a func tion.", args.GetIsolate());
52 53
53 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) 54 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
54 return args.Holder(); 55 return args.Holder();
55 56
56 Document* document = currentDocument(BindingState::instance()); 57 Document* document = currentDocument(BindingState::instance());
57 58
58 // Make sure the document is added to the DOM Node map. Otherwise, the HTMLI mageElement instance 59 // Make sure the document is added to the DOM Node map. Otherwise, the HTMLP ictureElement instance
59 // may end up being the only node in the map and get garbage-collected prema turely. 60 // may end up being the only node in the map and get garbage-collected prema turely.
60 // FIXME: The correct way to do this would be to make HTMLImageElement deriv e from 61 // FIXME: The correct way to do this would be to make HTMLPictureElement der ive from
61 // ActiveDOMObject and use its interface to keep its wrapper alive. Then we would 62 // ActiveDOMObject and use its interface to keep its wrapper alive. Then we would
62 // remove this code and the special case in isObservableThroughDOM. 63 // remove this code and the special case in isObservableThroughDOM.
63 toV8(document, args.Holder(), args.GetIsolate()); 64 toV8(document, args.Holder(), args.GetIsolate());
64 65
65 int width; 66 int width;
66 int height; 67 int height;
67 int* optionalWidth = 0; 68 int* optionalWidth = 0;
68 int* optionalHeight = 0; 69 int* optionalHeight = 0;
69 if (args.Length() > 0) { 70 if (args.Length() > 0) {
70 width = toInt32(args[0]); 71 width = toInt32(args[0]);
71 optionalWidth = &width; 72 optionalWidth = &width;
72 } 73 }
73 if (args.Length() > 1) { 74 if (args.Length() > 1) {
74 height = toInt32(args[1]); 75 height = toInt32(args[1]);
75 optionalHeight = &height; 76 optionalHeight = &height;
76 } 77 }
77 78
78 RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(do cument, optionalWidth, optionalHeight); 79 RefPtr<HTMLPictureElement> image = HTMLPictureElement::createForJSConstructo r(document, optionalWidth, optionalHeight);
79 v8::Handle<v8::Object> wrapper = args.Holder(); 80 v8::Handle<v8::Object> wrapper = args.Holder();
80 V8DOMWrapper::associateObjectWithWrapper(image.release(), &V8HTMLImageElemen tConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent) ; 81 V8DOMWrapper::associateObjectWithWrapper(image.release(), &V8HTMLPictureElem entConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependen t);
81 return wrapper; 82 return wrapper;
82 } 83 }
83 84
84 v8::Persistent<v8::FunctionTemplate> V8HTMLImageElementConstructor::GetTemplate( v8::Isolate* isolate, WrapperWorldType worldType) 85 v8::Persistent<v8::FunctionTemplate> V8HTMLPictureElementConstructor::GetTemplat e(v8::Isolate* isolate, WrapperWorldType worldType)
85 { 86 {
86 static v8::Persistent<v8::FunctionTemplate> cachedTemplate; 87 static v8::Persistent<v8::FunctionTemplate> cachedTemplate;
87 if (!cachedTemplate.IsEmpty()) 88 if (!cachedTemplate.IsEmpty())
88 return cachedTemplate; 89 return cachedTemplate;
89 90
90 v8::HandleScope scope; 91 v8::HandleScope scope;
91 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(v8HTMLIma geElementConstructorMethodCustom); 92 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(v8HTMLPic tureElementConstructorMethodCustom);
92 93
93 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); 94 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate();
94 instance->SetInternalFieldCount(V8HTMLImageElement::internalFieldCount); 95 instance->SetInternalFieldCount(V8HTMLPictureElement::internalFieldCount);
95 result->SetClassName(v8::String::NewSymbol("HTMLImageElement")); 96 result->SetClassName(v8::String::New("HTMLPictureElement"));
96 result->Inherit(V8HTMLImageElement::GetTemplate(isolate, worldType)); 97 result->Inherit(V8HTMLPictureElement::GetTemplate(isolate, worldType));
97 98
98 cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result); 99 cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result);
99 return cachedTemplate; 100 return cachedTemplate;
100 } 101 }
101 102
102 } // namespace WebCore 103 } // namespace WebCore
104 #endif
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8HTMLPictureElementConstructor.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698