| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return 0; | 236 return 0; |
| 236 if (const QualifiedName* htmlName = findHTMLTagNameOfV8Type(type)) | 237 if (const QualifiedName* htmlName = findHTMLTagNameOfV8Type(type)) |
| 237 return htmlName; | 238 return htmlName; |
| 238 #if ENABLE(SVG) | 239 #if ENABLE(SVG) |
| 239 if (const QualifiedName* svgName = findSVGTagNameOfV8Type(type)) | 240 if (const QualifiedName* svgName = findSVGTagNameOfV8Type(type)) |
| 240 return svgName; | 241 return svgName; |
| 241 #endif | 242 #endif |
| 242 return 0; | 243 return 0; |
| 243 } | 244 } |
| 244 | 245 |
| 246 void CustomElementHelpers::upgradeWrappers(ScriptExecutionContext* executionCont
ext, const HashSet<Element*>& elements, const ScriptValue& prototype) |
| 247 { |
| 248 if (elements.isEmpty()) |
| 249 return; |
| 250 |
| 251 v8::HandleScope handleScope; |
| 252 v8::Handle<v8::Context> context = toV8Context(executionContext, mainThreadNo
rmalWorld()); |
| 253 v8::Context::Scope scope(context); |
| 254 |
| 255 v8::Handle<v8::Value> v8Prototype = prototype.v8Value(); |
| 256 |
| 257 for (HashSet<Element*>::const_iterator it = elements.begin(); it != elements
.end(); ++it) { |
| 258 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld(*i
t); |
| 259 if (wrapper.IsEmpty()) { |
| 260 // The wrapper will be created with the right prototype when |
| 261 // retrieved; we don't need to eagerly create the wrapper. |
| 262 continue; |
| 263 } |
| 264 wrapper->SetPrototype(v8Prototype); |
| 265 } |
| 266 } |
| 267 |
| 245 void CustomElementHelpers::invokeReadyCallbackIfNeeded(Element* element, v8::Han
dle<v8::Context> context) | 268 void CustomElementHelpers::invokeReadyCallbackIfNeeded(Element* element, v8::Han
dle<v8::Context> context) |
| 246 { | 269 { |
| 247 v8::Handle<v8::Value> wrapperValue = toV8(element, context->Global(), contex
t->GetIsolate()); | 270 v8::Handle<v8::Value> wrapperValue = toV8(element, context->Global(), contex
t->GetIsolate()); |
| 248 if (wrapperValue.IsEmpty() || !wrapperValue->IsObject()) | 271 if (wrapperValue.IsEmpty() || !wrapperValue->IsObject()) |
| 249 return; | 272 return; |
| 250 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(wrapperValue); | 273 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(wrapperValue); |
| 251 v8::Handle<v8::Value> prototypeValue = wrapper->GetPrototype(); | 274 v8::Handle<v8::Value> prototypeValue = wrapper->GetPrototype(); |
| 252 if (prototypeValue.IsEmpty() || !prototypeValue->IsObject()) | 275 if (prototypeValue.IsEmpty() || !prototypeValue->IsObject()) |
| 253 return; | 276 return; |
| 254 v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(prototypeVal
ue); | 277 v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(prototypeVal
ue); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 274 return; | 297 return; |
| 275 v8::Context::Scope scope(context); | 298 v8::Context::Scope scope(context); |
| 276 | 299 |
| 277 for (size_t i = 0; i < invocations.size(); ++i) { | 300 for (size_t i = 0; i < invocations.size(); ++i) { |
| 278 ASSERT(executionContext == invocations[i].element()->document()); | 301 ASSERT(executionContext == invocations[i].element()->document()); |
| 279 invokeReadyCallbackIfNeeded(invocations[i].element(), context); | 302 invokeReadyCallbackIfNeeded(invocations[i].element(), context); |
| 280 } | 303 } |
| 281 } | 304 } |
| 282 | 305 |
| 283 } // namespace WebCore | 306 } // namespace WebCore |
| OLD | NEW |