| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #include "config.h" | |
| 32 #include "bindings/core/v8/V8Node.h" | |
| 33 | |
| 34 #include "bindings/core/v8/ExceptionState.h" | |
| 35 #include "bindings/core/v8/V8AbstractEventListener.h" | |
| 36 #include "bindings/core/v8/V8Attr.h" | |
| 37 #include "bindings/core/v8/V8Binding.h" | |
| 38 #include "bindings/core/v8/V8CDATASection.h" | |
| 39 #include "bindings/core/v8/V8Comment.h" | |
| 40 #include "bindings/core/v8/V8Document.h" | |
| 41 #include "bindings/core/v8/V8DocumentFragment.h" | |
| 42 #include "bindings/core/v8/V8DocumentType.h" | |
| 43 #include "bindings/core/v8/V8Element.h" | |
| 44 #include "bindings/core/v8/V8EventListener.h" | |
| 45 #include "bindings/core/v8/V8HTMLElement.h" | |
| 46 #include "bindings/core/v8/V8ProcessingInstruction.h" | |
| 47 #include "bindings/core/v8/V8SVGElement.h" | |
| 48 #include "bindings/core/v8/V8ShadowRoot.h" | |
| 49 #include "bindings/core/v8/V8Text.h" | |
| 50 #include "core/dom/Document.h" | |
| 51 #include "core/dom/custom/CustomElementCallbackDispatcher.h" | |
| 52 #include "core/dom/shadow/ShadowRoot.h" | |
| 53 #include "core/events/EventListener.h" | |
| 54 #include "wtf/RefPtr.h" | |
| 55 | |
| 56 namespace blink { | |
| 57 | |
| 58 // These functions are custom to prevent a wrapper lookup of the return value wh
ich is always | |
| 59 // part of the arguments. | |
| 60 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate) | |
| 61 { | |
| 62 ASSERT(impl); | |
| 63 switch (impl->nodeType()) { | |
| 64 case Node::ELEMENT_NODE: | |
| 65 // For performance reasons, this is inlined from V8Element::wrap and mus
t remain in sync. | |
| 66 if (impl->isHTMLElement()) | |
| 67 return wrap(toHTMLElement(impl), creationContext, isolate); | |
| 68 if (impl->isSVGElement()) | |
| 69 return wrap(toSVGElement(impl), creationContext, isolate); | |
| 70 return V8Element::createWrapper(toElement(impl), creationContext, isolat
e); | |
| 71 case Node::ATTRIBUTE_NODE: | |
| 72 return wrap(toAttr(impl), creationContext, isolate); | |
| 73 case Node::TEXT_NODE: | |
| 74 return wrap(toText(impl), creationContext, isolate); | |
| 75 case Node::CDATA_SECTION_NODE: | |
| 76 return wrap(toCDATASection(impl), creationContext, isolate); | |
| 77 case Node::PROCESSING_INSTRUCTION_NODE: | |
| 78 return wrap(toProcessingInstruction(impl), creationContext, isolate); | |
| 79 case Node::COMMENT_NODE: | |
| 80 return wrap(toComment(impl), creationContext, isolate); | |
| 81 case Node::DOCUMENT_NODE: | |
| 82 return wrap(toDocument(impl), creationContext, isolate); | |
| 83 case Node::DOCUMENT_TYPE_NODE: | |
| 84 return wrap(toDocumentType(impl), creationContext, isolate); | |
| 85 case Node::DOCUMENT_FRAGMENT_NODE: | |
| 86 if (impl->isShadowRoot()) | |
| 87 return wrap(toShadowRoot(impl), creationContext, isolate); | |
| 88 return wrap(toDocumentFragment(impl), creationContext, isolate); | |
| 89 } | |
| 90 ASSERT_NOT_REACHED(); | |
| 91 return V8Node::createWrapper(impl, creationContext, isolate); | |
| 92 } | |
| 93 } // namespace blink | |
| OLD | NEW |