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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (createSpecificWrapper) | 83 if (createSpecificWrapper) |
84 return createSpecificWrapper(element, creationContext, isolate); | 84 return createSpecificWrapper(element, creationContext, isolate); |
85 return createFallbackWrapper(element, creationContext, isolate); | 85 return createFallbackWrapper(element, creationContext, isolate); |
86 } | 86 } |
87 | 87 |
88 template<typename ElementType, typename WrapperType> | 88 template<typename ElementType, typename WrapperType> |
89 v8::Handle<v8::Object> CustomElementWrapper<ElementType, WrapperType>::wrap(Pass
RefPtrWillBeRawPtr<ElementType> element, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementTy
pe* element, v8::Handle<v8::Object> creationContext, v8::Isolate*)) | 89 v8::Handle<v8::Object> CustomElementWrapper<ElementType, WrapperType>::wrap(Pass
RefPtrWillBeRawPtr<ElementType> element, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementTy
pe* element, v8::Handle<v8::Object> creationContext, v8::Isolate*)) |
90 { | 90 { |
91 ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty()
); | 91 ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty()
); |
92 | 92 |
93 // FIXME: creationContext.IsEmpty() should never happen. Remove | 93 ASSERT(!creationContext.IsEmpty()); |
94 // this when callers (like InspectorController::inspect) are fixed | 94 v8::Handle<v8::Context> context = creationContext->CreationContext(); |
95 // to never pass an empty creation context. | |
96 v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCu
rrentContext() : creationContext->CreationContext(); | |
97 | 95 |
98 if (!element->isUpgradedCustomElement() || DOMWrapperWorld::world(context).i
sIsolatedWorld()) | 96 if (!element->isUpgradedCustomElement() || DOMWrapperWorld::world(context).i
sIsolatedWorld()) |
99 return createUpgradeCandidateWrapper(element.get(), creationContext, iso
late, createSpecificWrapper); | 97 return createUpgradeCandidateWrapper(element.get(), creationContext, iso
late, createSpecificWrapper); |
100 | 98 |
101 V8PerContextData* perContextData = V8PerContextData::from(context); | 99 V8PerContextData* perContextData = V8PerContextData::from(context); |
102 if (!perContextData) | 100 if (!perContextData) |
103 return v8::Handle<v8::Object>(); | 101 return v8::Handle<v8::Object>(); |
104 | 102 |
105 CustomElementBinding* binding = perContextData->customElementBinding(element
->customElementDefinition()); | 103 CustomElementBinding* binding = perContextData->customElementBinding(element
->customElementDefinition()); |
106 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, binding->wrapperType(), element.get(), isolate); | 104 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, binding->wrapperType(), element.get(), isolate); |
107 if (wrapper.IsEmpty()) | 105 if (wrapper.IsEmpty()) |
108 return v8::Handle<v8::Object>(); | 106 return v8::Handle<v8::Object>(); |
109 | 107 |
110 wrapper->SetPrototype(binding->prototype()); | 108 wrapper->SetPrototype(binding->prototype()); |
111 | 109 |
112 V8DOMWrapper::associateObjectWithWrapper<WrapperType>(element, binding->wrap
perType(), wrapper, isolate, WrapperConfiguration::Dependent); | 110 V8DOMWrapper::associateObjectWithWrapper<WrapperType>(element, binding->wrap
perType(), wrapper, isolate, WrapperConfiguration::Dependent); |
113 return wrapper; | 111 return wrapper; |
114 } | 112 } |
115 | 113 |
116 template | 114 template |
117 class CustomElementWrapper<HTMLElement, V8HTMLElement>; | 115 class CustomElementWrapper<HTMLElement, V8HTMLElement>; |
118 | 116 |
119 template | 117 template |
120 class CustomElementWrapper<SVGElement, V8SVGElement>; | 118 class CustomElementWrapper<SVGElement, V8SVGElement>; |
121 | 119 |
122 } // namespace WebCore | 120 } // namespace WebCore |
OLD | NEW |