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/shadow/ShadowRoot.h" | |
52 #include "core/events/EventListener.h" | |
53 #include "wtf/RefPtr.h" | |
54 | |
55 namespace blink { | |
56 | |
57 // These functions are custom to prevent a wrapper lookup of the return value wh
ich is always | |
58 // part of the arguments. | |
59 v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate) | |
60 { | |
61 ASSERT(impl); | |
62 switch (impl->nodeType()) { | |
63 case Node::ELEMENT_NODE: | |
64 // For performance reasons, this is inlined from V8Element::wrap and mus
t remain in sync. | |
65 if (impl->isHTMLElement()) | |
66 return wrap(toHTMLElement(impl), creationContext, isolate); | |
67 if (impl->isSVGElement()) | |
68 return wrap(toSVGElement(impl), creationContext, isolate); | |
69 return V8Element::createWrapper(toElement(impl), creationContext, isolat
e); | |
70 case Node::ATTRIBUTE_NODE: | |
71 return wrap(toAttr(impl), creationContext, isolate); | |
72 case Node::TEXT_NODE: | |
73 return wrap(toText(impl), creationContext, isolate); | |
74 case Node::CDATA_SECTION_NODE: | |
75 return wrap(toCDATASection(impl), creationContext, isolate); | |
76 case Node::PROCESSING_INSTRUCTION_NODE: | |
77 return wrap(toProcessingInstruction(impl), creationContext, isolate); | |
78 case Node::COMMENT_NODE: | |
79 return wrap(toComment(impl), creationContext, isolate); | |
80 case Node::DOCUMENT_NODE: | |
81 return wrap(toDocument(impl), creationContext, isolate); | |
82 case Node::DOCUMENT_TYPE_NODE: | |
83 return wrap(toDocumentType(impl), creationContext, isolate); | |
84 case Node::DOCUMENT_FRAGMENT_NODE: | |
85 if (impl->isShadowRoot()) | |
86 return wrap(toShadowRoot(impl), creationContext, isolate); | |
87 return wrap(toDocumentFragment(impl), creationContext, isolate); | |
88 } | |
89 ASSERT_NOT_REACHED(); | |
90 return V8Node::createWrapper(impl, creationContext, isolate); | |
91 } | |
92 } // namespace blink | |
OLD | NEW |