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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp

Issue 2595543003: Rename toV8(...) function in Blink to ToV8(...). (Closed)
Patch Set: Rebasing... Created 3 years, 11 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"
(...skipping 13 matching lines...) Expand all
24 namespace blink { 24 namespace blink {
25 25
26 // Retrieves the custom elements constructor -> name map, creating it 26 // Retrieves the custom elements constructor -> name map, creating it
27 // if necessary. 27 // if necessary.
28 static v8::Local<v8::Map> ensureCustomElementRegistryMap( 28 static v8::Local<v8::Map> ensureCustomElementRegistryMap(
29 ScriptState* scriptState, 29 ScriptState* scriptState,
30 CustomElementRegistry* registry) { 30 CustomElementRegistry* registry) {
31 CHECK(scriptState->world().isMainWorld()); 31 CHECK(scriptState->world().isMainWorld());
32 v8::Local<v8::String> name = 32 v8::Local<v8::String> name =
33 V8HiddenValue::customElementsRegistryMap(scriptState->isolate()); 33 V8HiddenValue::customElementsRegistryMap(scriptState->isolate());
34 v8::Local<v8::Object> wrapper = toV8(registry, scriptState).As<v8::Object>(); 34 v8::Local<v8::Object> wrapper = ToV8(registry, scriptState).As<v8::Object>();
35 v8::Local<v8::Value> map = 35 v8::Local<v8::Value> map =
36 V8HiddenValue::getHiddenValue(scriptState, wrapper, name); 36 V8HiddenValue::getHiddenValue(scriptState, wrapper, name);
37 if (map.IsEmpty()) { 37 if (map.IsEmpty()) {
38 map = v8::Map::New(scriptState->isolate()); 38 map = v8::Map::New(scriptState->isolate());
39 V8HiddenValue::setHiddenValue(scriptState, wrapper, name, map); 39 V8HiddenValue::setHiddenValue(scriptState, wrapper, name, map);
40 } 40 }
41 return map.As<v8::Map>(); 41 return map.As<v8::Map>();
42 } 42 }
43 43
44 ScriptCustomElementDefinition* ScriptCustomElementDefinition::forConstructor( 44 ScriptCustomElementDefinition* ScriptCustomElementDefinition::forConstructor(
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 v8::Isolate* isolate = m_scriptState->isolate(); 304 v8::Isolate* isolate = m_scriptState->isolate();
305 305
306 // Invoke custom element reactions 306 // Invoke custom element reactions
307 // https://html.spec.whatwg.org/multipage/scripting.html#invoke-custom-element -reactions 307 // https://html.spec.whatwg.org/multipage/scripting.html#invoke-custom-element -reactions
308 // If this throws any exception, then report the exception. 308 // If this throws any exception, then report the exception.
309 v8::TryCatch tryCatch(isolate); 309 v8::TryCatch tryCatch(isolate);
310 tryCatch.SetVerbose(true); 310 tryCatch.SetVerbose(true);
311 311
312 ExecutionContext* executionContext = m_scriptState->getExecutionContext(); 312 ExecutionContext* executionContext = m_scriptState->getExecutionContext();
313 v8::Local<v8::Value> elementHandle = 313 v8::Local<v8::Value> elementHandle =
314 toV8(element, m_scriptState->context()->Global(), isolate); 314 ToV8(element, m_scriptState->context()->Global(), isolate);
315 V8ScriptRunner::callFunction(callback, executionContext, elementHandle, argc, 315 V8ScriptRunner::callFunction(callback, executionContext, elementHandle, argc,
316 argv, isolate); 316 argv, isolate);
317 } 317 }
318 318
319 void ScriptCustomElementDefinition::runConnectedCallback(Element* element) { 319 void ScriptCustomElementDefinition::runConnectedCallback(Element* element) {
320 if (!m_scriptState->contextIsValid()) 320 if (!m_scriptState->contextIsValid())
321 return; 321 return;
322 ScriptState::Scope scope(m_scriptState.get()); 322 ScriptState::Scope scope(m_scriptState.get());
323 v8::Isolate* isolate = m_scriptState->isolate(); 323 v8::Isolate* isolate = m_scriptState->isolate();
324 runCallback(m_connectedCallback.newLocal(isolate), element); 324 runCallback(m_connectedCallback.newLocal(isolate), element);
325 } 325 }
326 326
327 void ScriptCustomElementDefinition::runDisconnectedCallback(Element* element) { 327 void ScriptCustomElementDefinition::runDisconnectedCallback(Element* element) {
328 if (!m_scriptState->contextIsValid()) 328 if (!m_scriptState->contextIsValid())
329 return; 329 return;
330 ScriptState::Scope scope(m_scriptState.get()); 330 ScriptState::Scope scope(m_scriptState.get());
331 v8::Isolate* isolate = m_scriptState->isolate(); 331 v8::Isolate* isolate = m_scriptState->isolate();
332 runCallback(m_disconnectedCallback.newLocal(isolate), element); 332 runCallback(m_disconnectedCallback.newLocal(isolate), element);
333 } 333 }
334 334
335 void ScriptCustomElementDefinition::runAdoptedCallback(Element* element, 335 void ScriptCustomElementDefinition::runAdoptedCallback(Element* element,
336 Document* oldOwner, 336 Document* oldOwner,
337 Document* newOwner) { 337 Document* newOwner) {
338 if (!m_scriptState->contextIsValid()) 338 if (!m_scriptState->contextIsValid())
339 return; 339 return;
340 ScriptState::Scope scope(m_scriptState.get()); 340 ScriptState::Scope scope(m_scriptState.get());
341 v8::Isolate* isolate = m_scriptState->isolate(); 341 v8::Isolate* isolate = m_scriptState->isolate();
342 v8::Local<v8::Value> argv[] = { 342 v8::Local<v8::Value> argv[] = {
343 toV8(oldOwner, m_scriptState->context()->Global(), isolate), 343 ToV8(oldOwner, m_scriptState->context()->Global(), isolate),
344 toV8(newOwner, m_scriptState->context()->Global(), isolate)}; 344 ToV8(newOwner, m_scriptState->context()->Global(), isolate)};
345 runCallback(m_adoptedCallback.newLocal(isolate), element, 345 runCallback(m_adoptedCallback.newLocal(isolate), element,
346 WTF_ARRAY_LENGTH(argv), argv); 346 WTF_ARRAY_LENGTH(argv), argv);
347 } 347 }
348 348
349 void ScriptCustomElementDefinition::runAttributeChangedCallback( 349 void ScriptCustomElementDefinition::runAttributeChangedCallback(
350 Element* element, 350 Element* element,
351 const QualifiedName& name, 351 const QualifiedName& name,
352 const AtomicString& oldValue, 352 const AtomicString& oldValue,
353 const AtomicString& newValue) { 353 const AtomicString& newValue) {
354 if (!m_scriptState->contextIsValid()) 354 if (!m_scriptState->contextIsValid())
355 return; 355 return;
356 ScriptState::Scope scope(m_scriptState.get()); 356 ScriptState::Scope scope(m_scriptState.get());
357 v8::Isolate* isolate = m_scriptState->isolate(); 357 v8::Isolate* isolate = m_scriptState->isolate();
358 v8::Local<v8::Value> argv[] = { 358 v8::Local<v8::Value> argv[] = {
359 v8String(isolate, name.localName()), v8StringOrNull(isolate, oldValue), 359 v8String(isolate, name.localName()), v8StringOrNull(isolate, oldValue),
360 v8StringOrNull(isolate, newValue), 360 v8StringOrNull(isolate, newValue),
361 v8StringOrNull(isolate, name.namespaceURI()), 361 v8StringOrNull(isolate, name.namespaceURI()),
362 }; 362 };
363 runCallback(m_attributeChangedCallback.newLocal(isolate), element, 363 runCallback(m_attributeChangedCallback.newLocal(isolate), element,
364 WTF_ARRAY_LENGTH(argv), argv); 364 WTF_ARRAY_LENGTH(argv), argv);
365 } 365 }
366 366
367 } // namespace blink 367 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/Maplike.h ('k') | third_party/WebKit/Source/bindings/core/v8/ScriptPromise.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698