This source file includes following definitions.
- insertBeforeMethodCustom
- replaceChildMethodCustom
- removeChildMethodCustom
- appendChildMethodCustom
- wrap
#include "config.h"
#include "V8Node.h"
#include "V8Attr.h"
#include "V8CDATASection.h"
#include "V8Comment.h"
#include "V8Document.h"
#include "V8DocumentFragment.h"
#include "V8DocumentType.h"
#include "V8Element.h"
#include "V8HTMLElement.h"
#include "V8Notation.h"
#include "V8ProcessingInstruction.h"
#include "V8SVGElement.h"
#include "V8ShadowRoot.h"
#include "V8Text.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8AbstractEventListener.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8EventListener.h"
#include "core/dom/Document.h"
#include "core/dom/custom/CustomElementCallbackDispatcher.h"
#include "core/events/EventListener.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "wtf/RefPtr.h"
namespace WebCore {
void V8Node::insertBeforeMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
Node* impl = V8Node::toNative(holder);
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "insertBefore", "Node", info.Holder(), info.GetIsolate());
Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
Node* refChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]);
impl->insertBefore(newChild, refChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValue(info, info[0]);
}
void V8Node::replaceChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
Node* impl = V8Node::toNative(holder);
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceChild", "Node", info.Holder(), info.GetIsolate());
Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]);
impl->replaceChild(newChild, oldChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValue(info, info[1]);
}
void V8Node::removeChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
Node* impl = V8Node::toNative(holder);
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeChild", "Node", info.Holder(), info.GetIsolate());
Node* oldChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
impl->removeChild(oldChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValue(info, info[0]);
}
void V8Node::appendChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
Node* impl = V8Node::toNative(holder);
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
ExceptionState exceptionState(ExceptionState::ExecutionContext, "appendChild", "Node", info.Holder(), info.GetIsolate());
Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
impl->appendChild(newChild, exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValue(info, info[0]);
}
v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
ASSERT(impl);
switch (impl->nodeType()) {
case Node::ELEMENT_NODE:
if (impl->isHTMLElement())
return wrap(toHTMLElement(impl), creationContext, isolate);
if (impl->isSVGElement())
return wrap(toSVGElement(impl), creationContext, isolate);
return V8Element::createWrapper(toElement(impl), creationContext, isolate);
case Node::ATTRIBUTE_NODE:
return wrap(toAttr(impl), creationContext, isolate);
case Node::TEXT_NODE:
return wrap(toText(impl), creationContext, isolate);
case Node::CDATA_SECTION_NODE:
return wrap(toCDATASection(impl), creationContext, isolate);
case Node::PROCESSING_INSTRUCTION_NODE:
return wrap(toProcessingInstruction(impl), creationContext, isolate);
case Node::COMMENT_NODE:
return wrap(toComment(impl), creationContext, isolate);
case Node::DOCUMENT_NODE:
return wrap(toDocument(impl), creationContext, isolate);
case Node::DOCUMENT_TYPE_NODE:
return wrap(toDocumentType(impl), creationContext, isolate);
case Node::DOCUMENT_FRAGMENT_NODE:
if (impl->isShadowRoot())
return wrap(toShadowRoot(impl), creationContext, isolate);
return wrap(toDocumentFragment(impl), creationContext, isolate);
}
ASSERT_NOT_REACHED();
return V8Node::createWrapper(impl, creationContext, isolate);
}
}