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: third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp

Issue 2834463002: Move CreateDOMException out of V8ThrowException (Closed)
Patch Set: Add comments Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ScriptCustomElementDefinition.h" 5 #include "bindings/core/v8/ScriptCustomElementDefinition.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8BindingMacros.h" 9 #include "bindings/core/v8/V8BindingMacros.h"
10 #include "bindings/core/v8/V8CustomElementRegistry.h" 10 #include "bindings/core/v8/V8CustomElementRegistry.h"
11 #include "bindings/core/v8/V8Element.h" 11 #include "bindings/core/v8/V8Element.h"
12 #include "bindings/core/v8/V8ErrorHandler.h" 12 #include "bindings/core/v8/V8ErrorHandler.h"
13 #include "bindings/core/v8/V8PrivateProperty.h" 13 #include "bindings/core/v8/V8PrivateProperty.h"
14 #include "bindings/core/v8/V8ScriptRunner.h" 14 #include "bindings/core/v8/V8ScriptRunner.h"
15 #include "bindings/core/v8/V8ThrowException.h" 15 #include "bindings/core/v8/V8ThrowDOMException.h"
16 #include "core/dom/ExceptionCode.h" 16 #include "core/dom/ExceptionCode.h"
17 #include "core/dom/ExecutionContext.h" 17 #include "core/dom/ExecutionContext.h"
18 #include "core/dom/custom/CustomElement.h" 18 #include "core/dom/custom/CustomElement.h"
19 #include "core/events/ErrorEvent.h" 19 #include "core/events/ErrorEvent.h"
20 #include "core/html/HTMLElement.h" 20 #include "core/html/HTMLElement.h"
21 #include "core/html/imports/HTMLImportsController.h" 21 #include "core/html/imports/HTMLImportsController.h"
22 #include "platform/wtf/Allocator.h" 22 #include "platform/wtf/Allocator.h"
23 #include "v8.h" 23 #include "v8.h"
24 24
25 namespace blink { 25 namespace blink {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // To report exception thrown from callConstructor() 252 // To report exception thrown from callConstructor()
253 if (try_catch.HasCaught()) 253 if (try_catch.HasCaught())
254 return false; 254 return false;
255 255
256 // To report InvalidStateError Exception, when the constructor returns some 256 // To report InvalidStateError Exception, when the constructor returns some
257 // different object 257 // different object
258 if (result != element) { 258 if (result != element) {
259 const String& message = 259 const String& message =
260 "custom element constructors must call super() first and must " 260 "custom element constructors must call super() first and must "
261 "not return a different object"; 261 "not return a different object";
262 v8::Local<v8::Value> exception = V8ThrowException::CreateDOMException( 262 v8::Local<v8::Value> exception = V8ThrowDOMException::CreateDOMException(
263 script_state_->GetIsolate(), kInvalidStateError, message); 263 script_state_->GetIsolate(), kInvalidStateError, message);
264 DispatchErrorEvent(isolate, exception, Constructor()); 264 DispatchErrorEvent(isolate, exception, Constructor());
265 return false; 265 return false;
266 } 266 }
267 267
268 return true; 268 return true;
269 } 269 }
270 270
271 Element* ScriptCustomElementDefinition::CallConstructor() { 271 Element* ScriptCustomElementDefinition::CallConstructor() {
272 v8::Isolate* isolate = script_state_->GetIsolate(); 272 v8::Isolate* isolate = script_state_->GetIsolate();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 v8::Local<v8::Value> argv[] = { 368 v8::Local<v8::Value> argv[] = {
369 V8String(isolate, name.LocalName()), V8StringOrNull(isolate, old_value), 369 V8String(isolate, name.LocalName()), V8StringOrNull(isolate, old_value),
370 V8StringOrNull(isolate, new_value), 370 V8StringOrNull(isolate, new_value),
371 V8StringOrNull(isolate, name.NamespaceURI()), 371 V8StringOrNull(isolate, name.NamespaceURI()),
372 }; 372 };
373 RunCallback(attribute_changed_callback_.NewLocal(isolate), element, 373 RunCallback(attribute_changed_callback_.NewLocal(isolate), element,
374 WTF_ARRAY_LENGTH(argv), argv); 374 WTF_ARRAY_LENGTH(argv), argv);
375 } 375 }
376 376
377 } // namespace blink 377 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698