| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 if (CustomElementRegistry::isCustomTagName(element->localName())) | 78 if (CustomElementRegistry::isCustomTagName(element->localName())) |
| 79 return createDirectWrapper(element, creationContext, isolate); | 79 return createDirectWrapper(element, creationContext, isolate); |
| 80 if (createSpecificWrapper) | 80 if (createSpecificWrapper) |
| 81 return createSpecificWrapper(element, creationContext, isolate); | 81 return createSpecificWrapper(element, creationContext, isolate); |
| 82 return createFallbackWrapper(element, creationContext, isolate); | 82 return createFallbackWrapper(element, creationContext, isolate); |
| 83 } | 83 } |
| 84 | 84 |
| 85 template<typename ElementType> | 85 template<typename ElementType> |
| 86 v8::Handle<v8::Object> CustomElementWrapper<ElementType>::wrap(PassRefPtr<Elemen
tType> element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, v8
::Handle<v8::Object> (*createSpecificWrapper)(ElementType* element, v8::Handle<v
8::Object> creationContext, v8::Isolate*)) | 86 v8::Handle<v8::Object> CustomElementWrapper<ElementType>::wrap(PassRefPtr<Elemen
tType> element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, v8
::Handle<v8::Object> (*createSpecificWrapper)(ElementType* element, v8::Handle<v
8::Object> creationContext, v8::Isolate*)) |
| 87 { | 87 { |
| 88 ASSERT(DOMDataStore::getWrapper(element.get(), isolate).IsEmpty()); | 88 ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty()
); |
| 89 | 89 |
| 90 // FIXME: creationContext.IsEmpty() should never happen. Remove | 90 // FIXME: creationContext.IsEmpty() should never happen. Remove |
| 91 // this when callers (like InspectorController::inspect) are fixed | 91 // this when callers (like InspectorController::inspect) are fixed |
| 92 // to never pass an empty creation context. | 92 // to never pass an empty creation context. |
| 93 v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCu
rrentContext() : creationContext->CreationContext(); | 93 v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCu
rrentContext() : creationContext->CreationContext(); |
| 94 | 94 |
| 95 CustomElementRegistry* registry = element->document()->registry(); | 95 CustomElementRegistry* registry = element->document()->registry(); |
| 96 RefPtr<CustomElementDefinition> definition = registry->findFor(element.get()
); | 96 RefPtr<CustomElementDefinition> definition = registry->findFor(element.get()
); |
| 97 if (!element->isUpgradedCustomElement() || !definition) | 97 if (!element->isUpgradedCustomElement() || !definition) |
| 98 return createUpgradeCandidateWrapper(element.get(), creationContext, iso
late, createSpecificWrapper); | 98 return createUpgradeCandidateWrapper(element.get(), creationContext, iso
late, createSpecificWrapper); |
| 99 | 99 |
| 100 V8PerContextData* perContextData = V8PerContextData::from(context); | 100 V8PerContextData* perContextData = V8PerContextData::from(context); |
| 101 if (!perContextData) | 101 if (!perContextData) |
| 102 return v8::Handle<v8::Object>(); | 102 return v8::Handle<v8::Object>(); |
| 103 | 103 |
| 104 CustomElementBinding* customElementBinding = perContextData->customElementBi
nding(definition->type()); | 104 CustomElementBinding* customElementBinding = perContextData->customElementBi
nding(definition->type()); |
| 105 | 105 |
| 106 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, customElementBinding->wrapperType(), element.get(), isolate); | 106 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, customElementBinding->wrapperType(), element.get(), isolate); |
| 107 if (wrapper.IsEmpty()) | 107 if (wrapper.IsEmpty()) |
| 108 return v8::Handle<v8::Object>(); | 108 return v8::Handle<v8::Object>(); |
| 109 | 109 |
| 110 wrapper->SetPrototype(customElementBinding->prototype()); | 110 wrapper->SetPrototype(customElementBinding->prototype()); |
| 111 | 111 |
| 112 V8DOMWrapper::associateObjectWithWrapper(element, customElementBinding->wrap
perType(), wrapper, isolate, WrapperConfiguration::Dependent); | 112 V8DOMWrapper::associateObjectWithWrapper<V8Element>(element, customElementBi
nding->wrapperType(), wrapper, isolate, WrapperConfiguration::Dependent); |
| 113 return wrapper; | 113 return wrapper; |
| 114 } | 114 } |
| 115 | 115 |
| 116 template | 116 template |
| 117 class CustomElementWrapper<HTMLElement>; | 117 class CustomElementWrapper<HTMLElement>; |
| 118 | 118 |
| 119 template | 119 template |
| 120 class CustomElementWrapper<SVGElement>; | 120 class CustomElementWrapper<SVGElement>; |
| 121 | 121 |
| 122 } // namespace WebCore | 122 } // namespace WebCore |
| OLD | NEW |