| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "bindings/v8/CustomElementHelpers.h" | 33 #include "bindings/v8/CustomElementHelpers.h" |
| 34 | 34 |
| 35 #include "HTMLNames.h" | 35 #include "HTMLNames.h" |
| 36 #include "V8CustomElementConstructor.h" | 36 #include "V8CustomElementConstructor.h" |
| 37 #include "V8HTMLElementWrapperFactory.h" | 37 #include "V8HTMLElementWrapperFactory.h" |
| 38 #include "bindings/v8/DOMDataStore.h" |
| 38 #include "bindings/v8/DOMWrapperWorld.h" | 39 #include "bindings/v8/DOMWrapperWorld.h" |
| 39 #include "bindings/v8/ScriptController.h" | 40 #include "bindings/v8/ScriptController.h" |
| 40 #include "core/dom/CustomElementRegistry.h" | 41 #include "core/dom/CustomElementRegistry.h" |
| 41 #include "core/dom/Node.h" | 42 #include "core/dom/Node.h" |
| 42 #include "core/html/HTMLElement.h" | 43 #include "core/html/HTMLElement.h" |
| 43 #include "core/html/HTMLUnknownElement.h" | 44 #include "core/html/HTMLUnknownElement.h" |
| 44 | 45 |
| 45 #if ENABLE(SVG) | 46 #if ENABLE(SVG) |
| 46 #include "V8SVGElementWrapperFactory.h" | 47 #include "V8SVGElementWrapperFactory.h" |
| 47 #include "SVGNames.h" | 48 #include "SVGNames.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 return 0; | 240 return 0; |
| 240 if (const QualifiedName* htmlName = findHTMLTagNameOfV8Type(type)) | 241 if (const QualifiedName* htmlName = findHTMLTagNameOfV8Type(type)) |
| 241 return htmlName; | 242 return htmlName; |
| 242 #if ENABLE(SVG) | 243 #if ENABLE(SVG) |
| 243 if (const QualifiedName* svgName = findSVGTagNameOfV8Type(type)) | 244 if (const QualifiedName* svgName = findSVGTagNameOfV8Type(type)) |
| 244 return svgName; | 245 return svgName; |
| 245 #endif | 246 #endif |
| 246 return 0; | 247 return 0; |
| 247 } | 248 } |
| 248 | 249 |
| 250 void CustomElementHelpers::upgradeWrappers(ScriptExecutionContext* executionCont
ext, const HashSet<Element*>& elements, const ScriptValue& prototype) |
| 251 { |
| 252 if (elements.isEmpty()) |
| 253 return; |
| 254 |
| 255 v8::HandleScope handleScope; |
| 256 v8::Handle<v8::Context> context = toV8Context(executionContext, mainThreadNo
rmalWorld()); |
| 257 v8::Context::Scope scope(context); |
| 258 |
| 259 v8::Handle<v8::Value> v8Prototype = prototype.v8Value(); |
| 260 |
| 261 for (HashSet<Element*>::const_iterator it = elements.begin(); it != elements
.end(); ++it) { |
| 262 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld(*i
t); |
| 263 if (wrapper.IsEmpty()) { |
| 264 // The wrapper will be created with the right prototype when |
| 265 // retrieved; we don't need to eagerly create the wrapper. |
| 266 continue; |
| 267 } |
| 268 wrapper->SetPrototype(v8Prototype); |
| 269 } |
| 270 } |
| 271 |
| 249 void CustomElementHelpers::invokeReadyCallbackIfNeeded(Element* element, v8::Han
dle<v8::Context> context) | 272 void CustomElementHelpers::invokeReadyCallbackIfNeeded(Element* element, v8::Han
dle<v8::Context> context) |
| 250 { | 273 { |
| 251 v8::Handle<v8::Value> wrapperValue = toV8(element, context->Global(), contex
t->GetIsolate()); | 274 v8::Handle<v8::Value> wrapperValue = toV8(element, context->Global(), contex
t->GetIsolate()); |
| 252 if (wrapperValue.IsEmpty() || !wrapperValue->IsObject()) | 275 if (wrapperValue.IsEmpty() || !wrapperValue->IsObject()) |
| 253 return; | 276 return; |
| 254 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(wrapperValue); | 277 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(wrapperValue); |
| 255 v8::Handle<v8::Value> prototypeValue = wrapper->GetPrototype(); | 278 v8::Handle<v8::Value> prototypeValue = wrapper->GetPrototype(); |
| 256 if (prototypeValue.IsEmpty() || !prototypeValue->IsObject()) | 279 if (prototypeValue.IsEmpty() || !prototypeValue->IsObject()) |
| 257 return; | 280 return; |
| 258 v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(prototypeVal
ue); | 281 v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(prototypeVal
ue); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 278 return; | 301 return; |
| 279 v8::Context::Scope scope(context); | 302 v8::Context::Scope scope(context); |
| 280 | 303 |
| 281 for (size_t i = 0; i < invocations.size(); ++i) { | 304 for (size_t i = 0; i < invocations.size(); ++i) { |
| 282 ASSERT(executionContext == invocations[i].element()->document()); | 305 ASSERT(executionContext == invocations[i].element()->document()); |
| 283 invokeReadyCallbackIfNeeded(invocations[i].element(), context); | 306 invokeReadyCallbackIfNeeded(invocations[i].element(), context); |
| 284 } | 307 } |
| 285 } | 308 } |
| 286 | 309 |
| 287 } // namespace WebCore | 310 } // namespace WebCore |
| OLD | NEW |