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

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

Issue 68563003: Create DOM exceptions in the correct context. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased onto df9a982fbe97 Created 7 years, 1 month 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8: :Value>& info) 74 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8: :Value>& info)
75 { 75 {
76 if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType( info.GetIsolate()))) { 76 if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType( info.GetIsolate()))) {
77 setDOMException(TypeMismatchError, info.GetIsolate()); 77 setDOMException(TypeMismatchError, info.GetIsolate());
78 return; 78 return;
79 } 79 }
80 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder() ); 80 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder() );
81 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj ect>(v8::Handle<v8::Object>::Cast(info[0]))); 81 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj ect>(v8::Handle<v8::Object>::Cast(info[0])));
82 82
83 ExceptionState exceptionState(info.GetIsolate()); 83 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
84 if (info.Length() < 2) 84 if (info.Length() < 2)
85 imp->add(option, exceptionState); 85 imp->add(option, exceptionState);
86 else { 86 else {
87 bool ok; 87 bool ok;
88 V8TRYCATCH_VOID(int, index, toInt32(info[1], ok)); 88 V8TRYCATCH_VOID(int, index, toInt32(info[1], ok));
89 if (!ok) 89 if (!ok)
90 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessage s::failedToExecute("add", "HTMLOptionsCollection", "The index provided could not be interpreted as an integer.")); 90 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessage s::failedToExecute("add", "HTMLOptionsCollection", "The index provided could not be interpreted as an integer."));
91 else 91 else
92 imp->add(option, index, exceptionState); 92 imp->add(option, index, exceptionState);
93 } 93 }
94 94
95 exceptionState.throwIfNeeded(); 95 exceptionState.throwIfNeeded();
96 } 96 }
97 97
98 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v alue, const v8::PropertyCallbackInfo<void>& info) 98 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v alue, const v8::PropertyCallbackInfo<void>& info)
99 { 99 {
100 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder() ); 100 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder() );
101 double v = value->NumberValue(); 101 double v = value->NumberValue();
102 unsigned newLength = 0; 102 unsigned newLength = 0;
103 ExceptionState exceptionState(info.GetIsolate()); 103 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
104 if (!std::isnan(v) && !std::isinf(v)) { 104 if (!std::isnan(v) && !std::isinf(v)) {
105 if (v < 0.0) 105 if (v < 0.0)
106 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages:: failedToSet("length", "HTMLOptionsCollection", "The value provided (" + String:: number(v) + ") is negative. Lengths must be greater than or equal to 0.")); 106 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages:: failedToSet("length", "HTMLOptionsCollection", "The value provided (" + String:: number(v) + ") is negative. Lengths must be greater than or equal to 0."));
107 else if (v > static_cast<double>(UINT_MAX)) 107 else if (v > static_cast<double>(UINT_MAX))
108 newLength = UINT_MAX; 108 newLength = UINT_MAX;
109 else 109 else
110 newLength = static_cast<unsigned>(v); 110 newLength = static_cast<unsigned>(v);
111 } 111 }
112 112
113 if (exceptionState.throwIfNeeded()) 113 if (exceptionState.throwIfNeeded())
114 return; 114 return;
115 115
116 imp->setLength(newLength, exceptionState); 116 imp->setLength(newLength, exceptionState);
117 } 117 }
118 118
119 } // namespace WebCore 119 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8HTMLFrameElementCustom.cpp ('k') | Source/bindings/v8/custom/V8HistoryCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698