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

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

Issue 23549004: Fix the HTMLSelectElement.prototype.remove() method (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "V8HTMLOptionsCollection.h" 32 #include "V8HTMLOptionsCollection.h"
33 33
34 #include "V8HTMLOptionElement.h" 34 #include "V8HTMLOptionElement.h"
35 #include "V8Node.h" 35 #include "V8Node.h"
36 #include "V8NodeList.h" 36 #include "V8NodeList.h"
37 #include "bindings/v8/ExceptionState.h" 37 #include "bindings/v8/ExceptionState.h"
38 #include "bindings/v8/V8Binding.h" 38 #include "bindings/v8/V8Binding.h"
39 #include "bindings/v8/custom/V8HTMLSelectElementCustom.h"
40 #include "core/dom/ExceptionCode.h" 39 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/NamedNodesCollection.h" 40 #include "core/dom/NamedNodesCollection.h"
42 #include "core/html/HTMLOptionElement.h" 41 #include "core/html/HTMLOptionElement.h"
43 #include "core/html/HTMLOptionsCollection.h" 42 #include "core/html/HTMLOptionsCollection.h"
44 #include "core/html/HTMLSelectElement.h" 43 #include "core/html/HTMLSelectElement.h"
45 44
46 namespace WebCore { 45 namespace WebCore {
47 46
48 template<typename CallbackInfo> 47 template<typename CallbackInfo>
49 static void getNamedItems(HTMLOptionsCollection* collection, const AtomicString& name, const CallbackInfo& callbackInfo) 48 static void getNamedItems(HTMLOptionsCollection* collection, const AtomicString& name, const CallbackInfo& callbackInfo)
(...skipping 13 matching lines...) Expand all
63 62
64 v8SetReturnValueFast(callbackInfo, NamedNodesCollection::create(namedItems), collection); 63 v8SetReturnValueFast(callbackInfo, NamedNodesCollection::create(namedItems), collection);
65 } 64 }
66 65
67 void V8HTMLOptionsCollection::namedItemMethodCustom(const v8::FunctionCallbackIn fo<v8::Value>& args) 66 void V8HTMLOptionsCollection::namedItemMethodCustom(const v8::FunctionCallbackIn fo<v8::Value>& args)
68 { 67 {
69 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder() ); 68 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder() );
70 getNamedItems(imp, toWebCoreString(args[0]), args); 69 getNamedItems(imp, toWebCoreString(args[0]), args);
71 } 70 }
72 71
73 void V8HTMLOptionsCollection::removeMethodCustom(const v8::FunctionCallbackInfo< v8::Value>& args)
74 {
75 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder() );
76 HTMLSelectElement* base = toHTMLSelectElement(imp->ownerNode());
77 removeElement(base, args);
78 }
79
80 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8: :Value>& args) 72 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8: :Value>& args)
81 { 73 {
82 if (!V8HTMLOptionElement::HasInstance(args[0], args.GetIsolate(), worldType( args.GetIsolate()))) { 74 if (!V8HTMLOptionElement::HasInstance(args[0], args.GetIsolate(), worldType( args.GetIsolate()))) {
83 setDOMException(TypeMismatchError, args.GetIsolate()); 75 setDOMException(TypeMismatchError, args.GetIsolate());
84 return; 76 return;
85 } 77 }
86 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder() ); 78 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder() );
87 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj ect>(v8::Handle<v8::Object>::Cast(args[0]))); 79 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj ect>(v8::Handle<v8::Object>::Cast(args[0])));
88 80
89 ExceptionState es(args.GetIsolate()); 81 ExceptionState es(args.GetIsolate());
(...skipping 26 matching lines...) Expand all
116 newLength = static_cast<unsigned>(v); 108 newLength = static_cast<unsigned>(v);
117 } 109 }
118 110
119 if (es.throwIfNeeded()) 111 if (es.throwIfNeeded())
120 return; 112 return;
121 113
122 imp->setLength(newLength, es); 114 imp->setLength(newLength, es);
123 } 115 }
124 116
125 } // namespace WebCore 117 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698